• 🏆 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!

[Trigger] Buying stats through triggers

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2018
Messages
383
Hello how can i make a trigger that does as follow.


-agi XX
-str XX
-int XX

i made a starting trigger but i don't know what to do next.

  • LevelingSystem
    • Events
      • Player - Player 1 (Red) types a chat message containing -agi as A substring
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) Current lumber) Greater than 0
        • Then - Actions
          • Game - Display to (All players) the text: WORKING
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
            • Loop - Actions
              • Hero - Modify Agility of (Picked unit): Add (Length of (Entered chat string))
        • Else - Actions
 
Level 8
Joined
Jul 10, 2018
Messages
383
cast substring to integer
  • LevelingSystem
    • Events
      • Player - Player 1 (Red) types a chat message containing -agi as A substring
    • Conditions
      • ((Triggering player) Current lumber) Greater than 0
    • Actions
      • Set Agi = (Substring(Agi, 1, 99))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Hero - Modify Agility of (Picked unit): Add (Integer(Agi))
like this?
 
Level 8
Joined
Jul 10, 2018
Messages
383
  • Hero - Modify Agility of (Picked unit): Add (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
Why did you use 6?

  • Hero - Modify Agility of (Picked unit): Add (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
And also i want to remove that amount that the player put into AGI is that possible? from lets say Gold or lumber

Very close! but you should read how substring works: Substring - Wikipedia

The issue you have now is that "agi 3" is not an integer
nvm figured it out by myself THANKS!

  • Hero - Modify Agility of (Picked unit): Add (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
Hey man i've got a problem this only sets the current lumber to the number you entered

  • LevelingSystem
    • Events
      • Player - Player 1 (Red) types a chat message containing -agi as A substring
    • Conditions
      • ((Triggering player) Current lumber) Greater than 0
    • Actions
      • Set Agi = (Substring(Agi, 1, 99))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Items\AIam\AIamTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Player - Add ((Integer((Substring((Entered chat string), 6, (Length of (Entered chat string)))))) - ((Triggering player) Current lumber)) to (Triggering player) Current lumber
          • Hero - Modify Agility of (Picked unit): Add (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
it doesn't take away the number.
 
Last edited by a moderator:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,512
You're doing Agility - Lumber.

If you have 100 lumber, and type -agi 10, it will do 10 - 100, which is equal to -90.

So don't do "Agility - Triggering player current lumber", instead multiply the Agility value by -1 so it subtracts it.

It should look like: "Add (Agility * -1) to triggering players current lumber".

You also want to make sure that a player has enough Lumber to afford how much agility they typed. An If Then Else can handle this:

If Triggering Player current lumber >= Agility THEN run the actions

You could make the Else add Agility equal to your current lumber, so if you have 10 lumber, and type -agi 11, it will add up to the maximum instead (10).

I recommend setting the Agility Substring value as an Integer variable so it's easier to work with. It's a pain in the ass having to go through that substring process multiple times.

Your Agi variable should be equal to this: (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))

Then you can reference Agi throughout the trigger.
 
Last edited:
Level 8
Joined
Jul 10, 2018
Messages
383
You're doing Agility - Lumber.

If you have 100 lumber, and type -agi 10, it will do 10 - 100, which is equal to -90.

So don't do "Agility - Triggering player current lumber", instead multiply the Agility value by -1 so it subtracts it.

It should look like: "Add (Agility * -1) to triggering players current lumber".

You also want to make sure that a player has enough Lumber to afford how much agility they typed. An If Then Else can handle this:

If Triggering Player current lumber >= Agility THEN run the actions

You could make the Else add Agility equal to your current lumber, so if you have 10 lumber, and type -agi 11, it will add up to the maximum instead (10).

I recommend setting the Agility Substring value as an Integer variable so it's easier to work with. It's a pain in the ass having to go through that substring process multiple times.

Your Agi variable should be equal to this: (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))

Then you can reference Agi throughout the trigger.


ok i did as you said and it seems its working.

  • AGI
    • Events
      • Player - Player 1 (Red) types a chat message containing -agi as A substring
    • Conditions
      • ((Triggering player) Current lumber) Greater than 0
    • Actions
      • Set Agi = (Substring(Agi, 1, 99))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Items\AIam\AIamTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Player - Add ((Integer((Substring((Entered chat string), 6, (Length of (Entered chat string)))))) x -1) to (Triggering player) Current lumber
          • Hero - Modify Agility of (Picked unit): Add (Integer((Substring((Entered chat string), 6, (Length of (Entered chat string))))))
All works now anything else to watch out for?
 
Status
Not open for further replies.
Top