1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Zoom command

Discussion in 'World Editor Help Zone' started by DaneTheBeast, Jan 10, 2015.

  1. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I want to add a zoom command to my map.
    When a player types -zoom 0 the camera will be zoomed in to the ground (more than warcraft allows with scroll on the mouse) and the max would be -zoom 1000 where you pretty much won't be able to see the map how far you would be. Also, any number in between would also work.This command can be seen in Legion TD. How to make it?
     
  2. MojObi-Dos

    MojObi-Dos

    Joined:
    Dec 31, 2014
    Messages:
    67
    Resources:
    0
    Resources:
    0
    You'll have to experient with values but..
    • Events
      • Player - Player 1 (Red) types a chat message containing -Zoom1 as An exact match
    • Conditions
    • Actions
      • Camera - Set (Triggering player)'s camera Field of view to 1500.00 over 0.00 seconds


    For both Zooms make a trigger but change the 1500 value.

    If your map is Multiplayer you'd have to make seperate triggers for all players that will be playing.
     
  3. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,549
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    You can add more events to one trigger. Only one trigger is needed, as you can refer to the correct player with using "TriggeringPlayer" response.

    It can be done with static commands as shown above.
    It can be done in a more dynamic way if you work with "Types <-zoom >" as substring. Then you need to convert the latter subtring into a real and do further operations.
     
  4. Shoto

    Shoto

    Joined:
    May 11, 2010
    Messages:
    276
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I made an example for you.

    Triggers

    • Setup
      • Events
        • Time - Elapsed game time is 0.00 seconds
      • Conditions
      • Actions
        • For each (Integer TempInt) from 1 to 12, do (Actions)
          • Loop - Actions
            • Trigger - Add to Zoom <gen> the event (Player - (Player(TempInt)) types a chat message containing -zoom as A substring)

    • Zoom
      • Events
      • Conditions
      • Actions
        • Set TempReal = (Real((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
        • Camera - Set (Triggering player)'s camera Field of view to TempReal over 0.00 seconds


    In the setup trigger, it adds all players to the other trigger so they can trigger it by writing "-zoom"
    The Zoom trigger runs when a player writes -zoom and checks what they've written after zoom, and sets the camera bounds to that number.
    For example, writing "-zoom 50" would set the camera field of view to 50.

    Test map attached
     

    Attached Files:

    Last edited: Jan 11, 2015
  5. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,549
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    ^It's good. But I would use "LengthOf(EnteredChatstring)" instead of the hardcoded "11".
     
  6. Shoto

    Shoto

    Joined:
    May 11, 2010
    Messages:
    276
    Resources:
    1
    Spells:
    1
    Resources:
    1
    A good point, but in this case it doesn't really matter as WC3 has hardcoded limits to field of view which is much lower than the 99999 you can type in here :p (as far as I know at least, I might be wrong here)
    Changed it anyway
     
  7. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Kinda works, it's not exactly what I wanted but thank you guys :)
     
  8. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,190
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I would recommend adding conditions to check if the entered chat string is a valid zoom command. This includes checking if it is prefixed with the appropriate "-zoom " (case insensitive, space included) string and that it has exactly 1 argument which is a valid integer.

    This is to stop it firing accidently when people are instructing the command to other players.

    For example, Shoto's implementation shown above (did not check map) would incorrectly fire if someone typed the below message.
    With the above the player would have had their zoom level set as if they typed "-zoom 257" even though they clearly did not type the command. If the string conversion has poor robustness it could result in a value of 0 zoom, which would inconvenience the player. This would correctly fail the prefix check I described above as "NARUTO" is not case insensitive equal to "-zoom ".
     
  9. Faith

    Faith

    Joined:
    Dec 29, 2009
    Messages:
    883
    Resources:
    3
    Spells:
    1
    Tutorials:
    2
    Resources:
    3
    • Zoom
      • Events
      • Conditions
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Substring((Entered chat string), 1, 5)) Equal to -zoom
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Not equal to <Empty String>
              • Then - Actions
                • Set tempReal = (Real((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • tempReal Less than 500.00
                  • Then - Actions
                    • Camera - Set (Triggering player)'s camera Distance to target to 500.00 over 1.00 seconds
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • tempReal Greater than 3000.00
                      • Then - Actions
                        • Camera - Set (Triggering player)'s camera Distance to target to 3000.00 over 1.00 seconds
                      • Else - Actions
                        • Camera - Set (Triggering player)'s camera Distance to target to tempReal over 1.00 seconds
              • Else - Actions
                • Camera - Reset camera for (Triggering player) to standard game-view over 1.00 seconds
          • Else - Actions


    Try this, I believe this should work.
    It will also reset the camera to the default zoom if you type "-zoom" without entering any additional information.
     
  10. fladdermasken

    fladdermasken

    Off-Topic Vaktmästare

    Joined:
    Dec 27, 2006
    Messages:
    2,454
    Resources:
    3
    Tutorials:
    3
    Resources:
    3
    Opened on request.
     
  11. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Thanks fladdermasken.
    After some time (long time) I tested the trigger and it works perfectly except one thing.
    When a player types "-zoom " (There is a space after zoom) the camera goes to the minimum (500).
    I tried putting another condition where it's
    • (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Not equal to " "
    (So just 1 space) instead of <Empty String>, and it works. But now if you type "-zoom " (2 spaces) it acts like before where it sets the camera to the minimum.

    Any ways to avoid this?
     
  12. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,638
    Resources:
    3
    Spells:
    3
    Resources:
    3
    You should use a String library.
    One that supports splitting words, then you can do:

    Code (vJASS):
    call String_SplitWords(GetEnteredChatString())
    if String_StartsWith(word[0], "/") then
        if word[0] == "/zoom" and S2I(word[1]) > 0 then
            call SetCameraDistanceStuffICantRememberTheName(S2I(word[1]))
        endif
    endif


    Both String_SplitWords() and String_StartsWith() would be functions from the string library.
    (I am aware that SplitWords would be Trim on regex to replace multispaces with single spaces and a Split that would split the string with " " as argument of the split, but that is of no concern at this moment, I assume String libraries will work differently depending on who made it.)

    In GUI, there is not much you can do... you will still require custom scripts that run the String libraries functions.
     
  13. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I don't know any Jass sadly so it seems I can't do anything about the problem. Thanks for the help anyway, maybe one day it will be useful, if not to me, to someone else.
     
  14. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,549
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    Why do you need this?
    What you want happens if someone types "zoom "with one or more spaces?
     
  15. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    If someone types "-zoom" the camera is set to the default game camera, but when they type "-zoom " (with a space) the camera goes to the minimum value (500).

    It's nothing important really, just wanted to know if there was a way to make it always behave the same way, regardless of how many spaces.
     
  16. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,638
    Resources:
    3
    Spells:
    3
    Resources:
    3
    You can do a substring check.
    Technically, check if the substring of 1 to 5 of the entered chat string is equal to "-zoom" or "/zoom"
    Then it wont care what you wrote after it.
    If you also want the feature to have it zoom to a parameter that you can fill in, then you have to reset the camera if the integer of the substring of the remainder of the string is equal to 0.

    EDIT:
    Just took a look at the actual script and:
    After "Set tempReal = (Real((Substring((Entered chat string), 7, (Length of (Entered chat string))))))"
    You have to do a check if the tempReal is equal to 0.
    If so, it is not a proper number (probably) and you then should also return it to the standard game camera.
     
  17. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Isn't that already in the trigger?

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Substring((Entered chat string), 1, 5)) Equal to -zoom
      • Then - Actions


    If it's equal to zero (-zoom 0) then this part of the trigger puts it to 500

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • tempReal Less than 500.00
      • Then - Actions
        • Camera - Set (Triggering player)'s camera Distance to target to 500.00 over 1.00 seconds


    But WE sees <Empty string> and a space (" ") differently

    0 is a number that the player would put in(Which is a number less than 500), and then again the above trigger would put it to 500.

    Edit: I might have a solution
    Edit2: The solution isn't working because 1 space and 2 spaces are 2 different things. And it sees nothing as 0
     
  18. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,549
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    Make a comparison if "Entered Chat String Equals "-zoom".
    If it does then set the cam to default values.

    If not, that does mean the string is longer then just "-zoom".
    In this case you convert the rest of the string to an "real" and put it
    as the cam value. If it is a valid value it will be set correct, but if it
    is emptry spaces, or random characters, it will return 0, and so become 500 in your system.
     
  19. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Doesn't that mean that whatever the player types in will make it go to the default value, since it isn't "-zoom"
    Edit: I am looking for a way for when it returns 0 ,that it doesn't set it to 500. But 1 space and 2 spaces (etc) are treated differently
    Edit2: Is there a way to see if it contains a thing within itself? Like check if: 6 to (leng of chatstring) has 2 or more spaces?
    Yay 200th post
     
  20. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,549
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    I don't understand your question. Make sure to read my post again.