1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Gamespeed Keys

Discussion in 'Trigger (GUI) Editor Tutorials' started by Saitek009, Oct 4, 2007.

  1. Saitek009

    Saitek009

    Joined:
    Jun 26, 2007
    Messages:
    63
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    SpeedKeys


    Have you ever wanted to have more detectable keys without using a third-party program?
    Well here is a single-player solution that uses the game-speed increase and decrease keys, "+" and "-".
    Just put the trigger in your map, your preference GUI or JASS and then put your trigger actions after the marked point.
    With the Demo it adds gold with the "+" key and subtracts gold with the "-" key.


    GUI
    • SpeedKeys GUI
      • Events
        • Time - Every 0.30 seconds of game time
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Current game speed) Equal to Normal
          • Then - Actions
            • Game - Set game speed to Slow
            • -------- Put your actions for the "+" key after this point --------
            • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) + 1)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Current game speed) Equal to Slowest
              • Then - Actions
                • Game - Set game speed to Slow
                • -------- Put your actions for the "-" key after this point --------
                • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) - 1)
              • Else - Actions
                • Do nothing

    Add this to your initialization trigger
    • Game - Set game speed to Slow




    JASS
    Code (vJASS):

    function Trig_SpeedKeys_JASS_Actions takes nothing returns nothing      
        if GetGameSpeed() == MAP_SPEED_NORMAL then
            call SetGameSpeed(MAP_SPEED_SLOW)
            //Put your actions for the "+" key after this point
            call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)+1)  
        elseif GetGameSpeed() == MAP_SPEED_SLOWEST then  
            call SetGameSpeed(MAP_SPEED_SLOW)
            //Put your actions for the "-" key after this point
           call SetPlayerState(Player(0), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)-1)    
        endif              
    endfunction

    function InitTrig_SpeedKeys_JASS takes nothing returns nothing
        set gg_trg_SpeedKeys_JASS = CreateTrigger()
        call TriggerRegisterTimerEventPeriodic(gg_trg_SpeedKeys_JASS, 0.3)
        call TriggerAddAction(gg_trg_SpeedKeys_JASS, function Trig_SpeedKeys_JASS_Actions)
        call SetGameSpeed(MAP_SPEED_SLOW)
    endfunction
     


    NOTE: Game-speeds are a little strange in Wc3
    Fast In-game == Normal in WE
    Normal In-game == Slow in WE
    Slow In-game == Slowest in WE
    That is why the setting are as they are. :wink:


    Due to the unique nature of the game-speed change keys you can actually hold down the + or - key
    and it will keep on doing the triggered action over and over, unlike ability hot keys.
    But again, this is only usable in single player.

    Have fun,
    -Saitek
     

    Attached Files:

  2. ragingspeedhorn

    ragingspeedhorn

    Joined:
    Apr 30, 2005
    Messages:
    6,521
    Resources:
    14
    Icons:
    5
    Maps:
    7
    Tutorials:
    2
    Resources:
    14
    Only usable in single player and you cannot use gold (in your example) in the map, that is not very handy.
     
  3. Xarwin

    Xarwin

    Joined:
    Nov 16, 2006
    Messages:
    2,233
    Resources:
    3
    Icons:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    3
    Try using integers instead.
     
  4. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Raging, I think +/- 1 gold was his example effect.
     
  5. ragingspeedhorn

    ragingspeedhorn

    Joined:
    Apr 30, 2005
    Messages:
    6,521
    Resources:
    14
    Icons:
    5
    Maps:
    7
    Tutorials:
    2
    Resources:
    14
    Wasn't it supposed to increase/decrease gamespeed? What does that have to do with gold, I am confused.
     
  6. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    No, +/- increases/decreases gamespeed.

    He was showing how to manipulate that to detect when they're pressed.
     
  7. Saitek009

    Saitek009

    Joined:
    Jun 26, 2007
    Messages:
    63
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Sorry I haven't replied. All this does is make the + and - keys detectable.
    The adding gold thing is just an example.
    Try it out and it'll make sense.
     
  8. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    I'm wondering whether this is actually practical enough to be worthwile.

    Arrow Keys are fine in Single Player, as is Esc, so it's not that necessary.

    Meh, we'll see what others have to say.
     
  9. Saitek009

    Saitek009

    Joined:
    Jun 26, 2007
    Messages:
    63
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    I guess it's just if you need more than the arrows and Esc.
    That's why Wc3: WoW is going to use it.
     
  10. Wolverabid

    Wolverabid

    Joined:
    Oct 23, 2006
    Messages:
    8,302
    Resources:
    5
    Tutorials:
    5
    Resources:
    5
    Tutorial Approved!

    Creators of single player maps and campaigns should find this little trick to be both handy and useful. Extra hotkeys? Sign me up!

    » REP DUMP «

    ~ Thread moved to Trigger (GUI) Editor Tutorials.
     
  11. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Erm.

    ~Thread moved to Trigger (GUI) Editor Tutorials :p