WeaponSelection.Script.txt

You can talk about ManiaScript for ManiaPlanet here

Moderator: English Moderator

User avatar
alividerci
Posts: 363
Joined: 11 Feb 2012, 07:03

WeaponSelection.Script.txt

Post by alividerci »

how to use WeaponSelection.Script.txt?
User avatar
steeffeen
Translator
Translator
Posts: 2463
Joined: 14 Oct 2012, 16:22
Location: Germany

Re: WeaponSelection.Script.txt

Post by steeffeen »

just look at the script file itself, it's not that complicated
i didn't use it yet but i see these main functions here:

Code: Select all

Void Load();
Void Unload();

Code: Select all

Void StartAll();
Void StopAll();
(you can start the selection for specific players, too)

Code: Select all

CSmMode::EWeapon GetWeapon(CSmPlayer _Player);
but don't mix this script up with the weapon changing in combo, i'm pretty sure they used an CUILayer ManialinkPage to listen for KeyPressed events
the WeaponSelection script is probably used in elite with the corresponding script setting enabled
    Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

    ManiaControl, FancyManiaLinks
    User avatar
    alividerci
    Posts: 363
    Joined: 11 Feb 2012, 07:03

    Re: WeaponSelection.Script.txt

    Post by alividerci »

    i dont know how it use
    User avatar
    Eole
    Nadeo
    Nadeo
    Posts: 1265
    Joined: 26 Apr 2011, 21:08

    Re: WeaponSelection.Script.txt

    Post by Eole »

    Steeffeen asked the right question, what are you trying to do?

    If you want to display a weapon selection screen as in Siege before the players are spawn, then this library is the right one. If you want to use weapon switching as in Combo, then you'll have to proceed differently. What's your goal?
    steeffeen wrote:but don't mix this script up with the weapon changing in combo, i'm pretty sure they used an CUILayer ManialinkPage to listen for KeyPressed events
    Nice try, but that's not it. ^^
    We use a new feature based on the Action system to avoid lag caused by a netread/netwrite in UI.

    Code: Select all

    foreach (Event in PendingEvents) {
      if (Event.Type == CSmModeEvent::EType::OnActionEvent) {
        switch (Event.ActionSlot) {
          case CSmModeEvent::EActionSlots::Weapon: DoSomething();   ///< Default: left mouse click
          case CSmModeEvent::EActionSlots::Movement: DoSomething(); ///< Default: right mouse click
          case CSmModeEvent::EActionSlots::Activable1: DoSomething(); ///< Default: 1
          case CSmModeEvent::EActionSlots::Activable2: DoSomething(); ///< Default: 2
          case CSmModeEvent::EActionSlots::Activable3: DoSomething(); ///< Default: 3
          case CSmModeEvent::EActionSlots::Activable4: DoSomething(); ///< Default: 4
        }
      }		
    }
    
    Contribute to the ManiaPlanet documentation on GitHub
    A question about ManiaScript? Ask it here!
    User avatar
    steeffeen
    Translator
    Translator
    Posts: 2463
    Joined: 14 Oct 2012, 16:22
    Location: Germany

    Re: WeaponSelection.Script.txt

    Post by steeffeen »

    Image

    :lol:

    is it possible to discard these events preventing that a shot is being fired or a jump is being performed? ^.^
      Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

      ManiaControl, FancyManiaLinks
      User avatar
      Eole
      Nadeo
      Nadeo
      Posts: 1265
      Joined: 26 Apr 2011, 21:08

      Re: WeaponSelection.Script.txt

      Post by Eole »

      Once the Action system will be complete and released, yes.
      Contribute to the ManiaPlanet documentation on GitHub
      A question about ManiaScript? Ask it here!
      User avatar
      steeffeen
      Translator
      Translator
      Posts: 2463
      Joined: 14 Oct 2012, 16:22
      Location: Germany

      Re: WeaponSelection.Script.txt

      Post by steeffeen »

      Eole wrote:Once the Action system will be complete and released, yes.
      sweet :yes:
        Game Mode and Title Pack Creator, Developer, ShootMania-Player & more

        ManiaControl, FancyManiaLinks
        User avatar
        alividerci
        Posts: 363
        Joined: 11 Feb 2012, 07:03

        Re: WeaponSelection.Script.txt

        Post by alividerci »

        Eole wrote:Steeffeen asked the right question, what are you trying to do?

        If you want to display a weapon selection screen as in Siege before the players are spawn, then this library is the right one. If you want to use weapon switching as in Combo, then you'll have to proceed differently. What's your goal?
        steeffeen wrote:but don't mix this script up with the weapon changing in combo, i'm pretty sure they used an CUILayer ManialinkPage to listen for KeyPressed events
        Nice try, but that's not it. ^^
        We use a new feature based on the Action system to avoid lag caused by a netread/netwrite in UI.

        Code: Select all

        foreach (Event in PendingEvents) {
          if (Event.Type == CSmModeEvent::EType::OnActionEvent) {
            switch (Event.ActionSlot) {
              case CSmModeEvent::EActionSlots::Weapon: DoSomething();   ///< Default: left mouse click
              case CSmModeEvent::EActionSlots::Movement: DoSomething(); ///< Default: right mouse click
              case CSmModeEvent::EActionSlots::Activable1: DoSomething(); ///< Default: 1
              case CSmModeEvent::EActionSlots::Activable2: DoSomething(); ///< Default: 2
              case CSmModeEvent::EActionSlots::Activable3: DoSomething(); ///< Default: 3
              case CSmModeEvent::EActionSlots::Activable4: DoSomething(); ///< Default: 4
            }
          }		
        }
        
        i think my goal second!(such as in a combo mode) I want to switch weapon when i running and shooting(and why in pack server we havent royal script)besides i want to use UI in game mode.... where tutorial? thx
        p.s tutorial by gugli i have seen
        User avatar
        Eole
        Nadeo
        Nadeo
        Posts: 1265
        Joined: 26 Apr 2011, 21:08

        Re: WeaponSelection.Script.txt

        Post by Eole »

        For a combo style weapon switching your mode will have to be in a TitlePack. Once it's done it's easy to do what you want.

        Code: Select all

        foreach (Event in PendingEvents) {
        	if (Event.Type == CSmModeEvent::EType::OnActionEvent) {
        		switch (Event.ActionSlot) {
        			case CSmModeEvent::EActionSlots::Activable1: {
        				SetPlayerWeapon(Player, CSmMode::EWeapon::Laser, False);
        			}
        			case CSmModeEvent::EActionSlots::Activable2: {
        				SetPlayerWeapon(Player, CSmMode::EWeapon::Nucleus, False);
        			}
        			case CSmModeEvent::EActionSlots::Activable3: {
        				SetPlayerWeapon(Player, CSmMode::EWeapon::Arrow, False);
        			}
        			case CSmModeEvent::EActionSlots::Activable4: {
        				SetPlayerWeapon(Player, CSmMode::EWeapon::Rocket, False);
        			}
        		}
        	}
        }
        
        With this you 'll be able to switch weapons while playing. The SetPlayerWeapon uses three parameters:
        - The player who want to change of weapon
        - The new weapon to use
        - Enable/Disable the automatic weapon switch when a player go underground or on a laser pad
        Contribute to the ManiaPlanet documentation on GitHub
        A question about ManiaScript? Ask it here!
        User avatar
        alividerci
        Posts: 363
        Joined: 11 Feb 2012, 07:03

        Re: WeaponSelection.Script.txt

        Post by alividerci »

        hmm, I have always plagued this questions! How for example can not change weapons underground or on the laser platform (optional)
        And is it possible to change the rate of recharge for each weapon separately .... speed of regeneration health on a platforms? thx and pls give me answer for my before post question(where royal script in server pack?)
        Last edited by alividerci on 16 Apr 2013, 15:20, edited 2 times in total.
        Post Reply

        Return to “ManiaScript”

        Who is online

        Users browsing this forum: No registered users and 1 guest