• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

hp trigger?

Status
Not open for further replies.
Level 5
Joined
May 10, 2009
Messages
88
Ok I have this, I want the trigger to make the HP of a unit what is specified

  • hp
    • Events
      • Player - Player 1 (Red) types a chat message containing -hp as A substring
    • Conditions
      • (Integer((Substring((Entered chat string), 6, 12)))) Less than or equal to (Integer((Life of (Targeted unit))))
    • Actions
      • Set HP_Variable = (Integer((Substring((Entered chat string), 6, 12))))
      • Unit - Set life of (Targeted unit) to (Real(HP_Variable))
How do I make this work? By the way,

  • hp
    • Conditions
      • (Integer((Substring((Entered chat string), 6, 12)))) Less than or equal to (Integer((Life of (Targeted unit))))
What are the numbers after substring equal to? What do they mean and how do you use them?

---

This is what I want:
Player 1: -hp #

(sets hp of targeted unit to # specified, integer must be < / = current life of targeted unit
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • Untitled Trigger 007
    • Events
      • Player - Player 1 (Red) types a chat message containing -hp as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 4)) Equal to -hp
    • Actions
      • Set Temp_Real_1 = (Real((Substring((Entered chat string), 5, 12))))
      • Set Temp_Group_1 = (Units currently selected by (Triggering player))
      • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real_1 Less than or equal to (Life of (Picked unit))
            • Then - Actions
              • Unit - Set life of (Picked unit) to Temp_Real_1
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Temp_Group_1)
 
Level 5
Joined
May 10, 2009
Messages
88
Thanks works perfect +rep...

Can you explain

  • Conditions
  • (Substring((Entered chat string), 1, 4)) Equal to -hp
  • Actions
  • Set Temp_Real_1 = (Real((Substring((Entered chat string), 5, 12))))
Why did you use 1, 4 and 5, 12? How do you know which numbers to use, and what do they mean?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
And to be more specific about this trigger:

Let's say you type

-hp 500

The event register that there is -hp somewhere in the entered chat string. But it could be "I rule -hp" or "Typing-hpsomething" and it would still register.

So the condition checks the four first characters to verify that the entered chat string begins with -hp . Note that there must be a space in there before the number.

- = first character
h = second
p = third
= fourth

Then that 5,12 part checks the entered number. You could use just about any number instead of 12. If you put 5,5 then it will only check the first number. Setting it to 5,6 makes it to support two digit nubers. 5,12 makes it support 8 digit numnbers, health upto 999999999, which should be enough :)
 
Level 5
Joined
May 10, 2009
Messages
88
Oh ok, so if you wanted

-lumber

you would do

  • Conditions
  • (Substring((Entered chat string), 1, 8)) Equal to -lumber
  • Actions
  • Set Temp_Real_1 = (Real((Substring((Entered chat string), 9, 16))))
this makes total sense, thanks so much, +rep again maker, and +rep to you marcelo^^
 
Status
Not open for further replies.
Top