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

Unit Group - Pick Problem

Status
Not open for further replies.
Level 4
Joined
Aug 15, 2010
Messages
53
Hi!
I am trying to pick specific units. Trigger works every step but Unit Group Pick does not.
I use game text messages for bug check.
I checked the conditions. They all work. But I could not understand the problem here.

[Ability]: I try to create 1 ward for 20 sec. Ward gives every friendly heroes STR, AGI, INT in 900 range for 20 sec.

  • Kutsama Kontrol
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KutsamaKontrol Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Kutsama for KutsamaCaster) Equal to 1
            • Then - Actions
              • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) has buff Kutsama ) Equal to True) and (((Matching unit) is in KutsamaUngroup) Equal to True))) and do (Actions)
                • Loop - Actions
                  • Hero - Modify Strength of (Picked unit): Add (10 + (KCStatSTR / 2))
                  • Hero - Modify Agility of (Picked unit): Add (10 + (KCStatAGI / 2))
                  • Hero - Modify Intelligence of (Picked unit): Add (10 + (KCStatINT / 2))
                  • Game - Display to (Player group((Owner of (Picked unit)))) the text: STAT Pick Successful...
                  • Unit Group - Remove (Picked unit) from KutsamaUngroup
                  • Unit Group - Add (Picked unit) to KutsamaGroup
              • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) has buff Kutsama ) Not equal to True) and (((Matching unit) is in KutsamaGroup) Equal to True))) and do (Actions)
                • Loop - Actions
                  • Hero - Modify Strength of (Picked unit): Subtract (10 + (KCStatSTR / 2))
                  • Hero - Modify Agility of (Picked unit): Subtract (10 + (KCStatAGI / 2))
                  • Hero - Modify Intelligence of (Picked unit): Subtract (10 + (KCStatINT / 2))
                  • Game - Display to (Player group((Owner of (Picked unit)))) the text: STAT Remove Pick Suc...
                  • Unit Group - Remove (Picked unit) from KutsamaGroup
                  • Unit Group - Add (Picked unit) to KutsamaUngroup
            • Else - Actions
 

Attachments

  • Ability TESTER.w3x
    19.3 KB · Views: 31
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Can you elaborate?
Do the group happen at all, incorrect stat adding? etc

Also, I think you should change the group

Pick every unit in (Units in (Playable map area) matching ((((Matching unit) has buff Kutsama ) Equal to True) and (((Matching unit) is in KutsamaUngroup) Equal to True))) and do (Actions)
>
Pick every unit in KutsamaUngroup matching ((((Matching unit) has buff Kutsama ) Equal to True)))) and do (Actions)

same for the other group

I do not think it fixes the problem but it should be a bit more readable
 
Level 4
Joined
Aug 15, 2010
Messages
53
I apologize, my mistake. I want to create a ward and increase the attribute points of the heroes around it. Heroes with Buff will be strengthened. (STR, AGI, INT)
I try to pick all friendly heroes to do this, but it does not.

(EDİT: I am editing the post now.)
 
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
I think the approach in general is flawed.

This is an incomplete trigger, but I think the approach is much cleaner:
  • Kutsama
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kutsama
    • Actions
      • Set KutsamaCaster = (Casting unit)
      • Set KutsamaCastPoint = (Target point of ability being cast)
      • Set KutsamaUnitType = Kutsanmıs Totem
      • Unit - Create 1 KutsamaUnitType for (Owner of KutsamaCaster) at KutsamaCastPoint facing Default building facing degrees
      • Unit - Add Kutsama to (Last created unit)
      • Unit - Add a 20.00 second Generic expiration timer to (Last created unit)
  • Kutsama Kontrol
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Kutsama ) Equal to True
            • Then - Actions
              • Hero - Modify Strength of (Picked unit): Add 10
              • Hero - Modify Agility of (Picked unit): Add 10
              • Hero - Modify Intelligence of (Picked unit): Add 10
            • Else - Actions
              • Hero - Modify Strength of (Picked unit): Subtract 10
              • Hero - Modify Agility of (Picked unit): Subtract 10
              • Hero - Modify Intelligence of (Picked unit): Subtract 10
edit: on second thought that'd be buggy. There needs to be a check to see if a unit has a bonus before removing, but my point was that your approach was a mess.

Something you should specify, do you want it to be MUI?
 
Here are some good tutorials, also for hashtable: Elemental Coder Guide

But it's maybe not easiest spell then, with it, so I attached an example. It seems to work, but I wrote it from scratch, because I was confused a bit how to interpret some of the code.
You can also add some more configuration if you want, like dynamic range/stats bonus, and making them dependant on hero level.

There are new triggers that you could modify to more needs (if you maybe want create an effect):
  • Katsuna onEffect (this happens when a friendly hero is in range, so the stats are only added at the moment)
  • Katsuna onEffectRemoval (this happens when time is over, or out of range, so at the moment only stats are removed again)


  • Kutsana Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Kutsama_Table = (Last created hashtable)
      • Set Kutsama_WardType = Kutsanmıs Totem
      • Set Kutsana_Ability = Kutsama
  • Kutsama Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kutsana_Ability
    • Actions
      • Set Kutsama_Unit = (Triggering unit)
      • Set Kutsama_Point = (Target point of ability being cast)
      • -------- -------- --------
      • Set Kutsama_Str = ((Strength of Kutsama_Unit (Exclude bonuses)) + 1)
      • Set Kutsama_Agi = ((Agility of Kutsama_Unit (Exclude bonuses)) + 1)
      • Set Kutsama_Int = ((Intelligence of Kutsama_Unit (Exclude bonuses)) + 1)
      • Set Katsuma_Range = 900.00
      • -------- -------- --------
      • Unit - Create 1 Kutsama_WardType for (Triggering player) at Kutsama_Point facing 0.00 degrees
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Kutsama_WardGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn on Kutsama Periodic <gen>
        • Else - Actions
      • Set Kutsama_Unit = (Last created unit)
      • Set Katsuma_HandleId = (Key (Last created unit))
      • Unit Group - Add Kutsama_Unit to Kutsama_WardGroup
      • Unit - Add a 20.00 second Generic expiration timer to Kutsama_Unit
      • -------- -------- --------
      • Hashtable - Save Kutsama_Str as 0 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Kutsama_Agi as 1 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Kutsama_Int as 2 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Katsuma_Range as 3 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Handle Of(Units within 0.00 of Kutsama_Point) as 4 of Katsuma_HandleId in Kutsama_Table
      • -------- -------- --------
      • Custom script: call RemoveLocation(udg_Kutsama_Point)
  • Kutsama Periodic
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Kutsama_WardGroup and do (Actions)
        • Loop - Actions
          • Set Kutsama_Unit = (Picked unit)
          • Set Kutsama_Point = (Position of Kutsama_Unit)
          • Set Katsuma_HandleId = (Key (Picked unit))
          • Set Kutsama_Str = (Load 0 of Katsuma_HandleId from Kutsama_Table)
          • Set Kutsama_Agi = (Load 1 of Katsuma_HandleId from Kutsama_Table)
          • Set Kutsama_Int = (Load 2 of Katsuma_HandleId from Kutsama_Table)
          • Set Katsuma_Range = (Load 3 of Katsuma_HandleId from Kutsama_Table)
          • Set Kutsama_HeroGroup = (Load 4 of Katsuma_HandleId in Kutsama_Table)
          • -------- -------- --------
          • -------- Check if time has expired --------
          • -------- -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Kutsama_Unit is dead) Equal to True
            • Then - Actions
              • -------- -------- --------
              • -------- Remove ward, and effects for all heroes --------
              • -------- -------- --------
              • Unit Group - Remove Kutsama_Unit from Kutsama_WardGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in Kutsama_WardGroup) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in Kutsama_HeroGroup and do (Actions)
                • Loop - Actions
                  • Set Kutsama_Unit = (Picked unit)
                  • Trigger - Run Kutsama onEffect Removal <gen> (ignoring conditions)
              • Hashtable - Clear all child hashtables of child Katsuma_HandleId in Kutsama_Table
            • Else - Actions
              • -------- -------- --------
              • -------- Check if affected heroes are still in range --------
              • -------- -------- --------
              • Unit Group - Pick every unit in Kutsama_HeroGroup and do (Actions)
                • Loop - Actions
                  • Set Kutsama_Unit = (Picked unit)
                  • Set Kutsama_Point2 = (Position of Kutsama_Unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Kutsama_Point and Kutsama_Point2) Greater than Katsuma_Range
                    • Then - Actions
                      • Unit Group - Remove Kutsama_Unit from Kutsama_HeroGroup
                      • Trigger - Run Kutsama onEffect Removal <gen> (ignoring conditions)
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_Kutsama_Point2)
              • -------- -------- --------
              • -------- Check for new possible heroes in range --------
              • -------- -------- --------
              • Custom script: set bj_wantDestroyGroup = true
              • Set Katsuma_Player = (Owner of Kutsama_Unit)
              • Unit Group - Pick every unit in (Units within Katsuma_Range of Kutsama_Point) and do (Actions)
                • Loop - Actions
                  • Set Kutsama_Unit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Kutsama_Unit is in Kutsama_HeroGroup) Equal to False
                      • (Owner of Kutsama_Unit) Equal to Katsuma_Player
                      • (Kutsama_Unit is A Hero) Equal to True
                    • Then - Actions
                      • Unit Group - Add Kutsama_Unit to Kutsama_HeroGroup
                      • Trigger - Run Kutsama onEffect <gen> (ignoring conditions)
                    • Else - Actions
          • Custom script: call RemoveLocation(udg_Kutsama_Point)
  • Kutsama onEffect
    • Events
    • Conditions
    • Actions
      • -------- -------- --------
      • -------- Here you can use Katsuma-: Str, Agi, Int, Range, Unit --------
      • -------- -------- --------
      • Hero - Modify Strength of Kutsama_Unit: Add Kutsama_Str
      • Hero - Modify Agility of Kutsama_Unit: Add Kutsama_Agi
      • Hero - Modify Intelligence of Kutsama_Unit: Add Kutsama_Int
  • Kutsama onEffect Removal
    • Events
    • Conditions
    • Actions
      • -------- -------- --------
      • -------- Here you can use Katsuma-: Str, Agi, Int, Range, Unit --------
      • -------- -------- --------
      • Hero - Modify Strength of Kutsama_Unit: Subtract Kutsama_Str
      • Hero - Modify Agility of Kutsama_Unit: Subtract Kutsama_Agi
      • Hero - Modify Intelligence of Kutsama_Unit: Subtract Kutsama_Int
 

Attachments

  • Ability TESTER.w3x
    19.3 KB · Views: 34
Last edited:
Level 4
Joined
Aug 15, 2010
Messages
53
What is KCStatSTR?
Can the caster change it while the units around are under the effect of the ward?

for; "If caster lvl up after casting" :D

Here are some good tutorials, also for hashtable: Elemental Coder Guide

But it's maybe not easiest spell then, with it, so I attached an example. It seems to work, but I wrote it from scratch, because I was confused a bit how to interpret some of the code.
You can also add some more configuration if you want, like dynamic range/stats bonus, and making them dependant on hero level.

There are new triggers that you could modify to more needs (if you maybe want create an effect):
  • Katsuna onEffect (this happens when a friendly hero is in range, so the stats are only added at the moment)
  • Katsuna onEffectRemoval (this happens when time is over, or out of range, so at the moment only stats are removed again)


  • Kutsana Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Kutsama_Table = (Last created hashtable)
      • Set Kutsama_WardType = Kutsanmıs Totem
      • Set Kutsana_Ability = Kutsama
  • Kutsama Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kutsana_Ability
    • Actions
      • Set Kutsama_Unit = (Triggering unit)
      • Set Kutsama_Point = (Target point of ability being cast)
      • -------- -------- --------
      • Set Kutsama_Str = ((Strength of Kutsama_Unit (Exclude bonuses)) + 1)
      • Set Kutsama_Agi = ((Agility of Kutsama_Unit (Exclude bonuses)) + 1)
      • Set Kutsama_Int = ((Intelligence of Kutsama_Unit (Exclude bonuses)) + 1)
      • Set Katsuma_Range = 900.00
      • -------- -------- --------
      • Unit - Create 1 Kutsama_WardType for (Triggering player) at Kutsama_Point facing 0.00 degrees
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Kutsama_WardGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn on Kutsama Periodic <gen>
        • Else - Actions
      • Set Kutsama_Unit = (Last created unit)
      • Set Katsuma_HandleId = (Key (Last created unit))
      • Unit Group - Add Kutsama_Unit to Kutsama_WardGroup
      • Unit - Add a 20.00 second Generic expiration timer to Kutsama_Unit
      • -------- -------- --------
      • Hashtable - Save Kutsama_Str as 0 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Kutsama_Agi as 1 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Kutsama_Int as 2 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Katsuma_Range as 3 of Katsuma_HandleId in Kutsama_Table
      • Hashtable - Save Handle Of(Units within 0.00 of Kutsama_Point) as 4 of Katsuma_HandleId in Kutsama_Table
      • -------- -------- --------
      • Custom script: call RemoveLocation(udg_Kutsama_Point)
  • Kutsama Periodic
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Kutsama_WardGroup and do (Actions)
        • Loop - Actions
          • Set Kutsama_Unit = (Picked unit)
          • Set Kutsama_Point = (Position of Kutsama_Unit)
          • Set Katsuma_HandleId = (Key (Picked unit))
          • Set Kutsama_Str = (Load 0 of Katsuma_HandleId from Kutsama_Table)
          • Set Kutsama_Agi = (Load 1 of Katsuma_HandleId from Kutsama_Table)
          • Set Kutsama_Int = (Load 2 of Katsuma_HandleId from Kutsama_Table)
          • Set Katsuma_Range = (Load 3 of Katsuma_HandleId from Kutsama_Table)
          • Set Kutsama_HeroGroup = (Load 4 of Katsuma_HandleId in Kutsama_Table)
          • -------- -------- --------
          • -------- Check if time has expired --------
          • -------- -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Kutsama_Unit is dead) Equal to True
            • Then - Actions
              • -------- -------- --------
              • -------- Remove ward, and effects for all heroes --------
              • -------- -------- --------
              • Unit Group - Remove Kutsama_Unit from Kutsama_WardGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in Kutsama_WardGroup) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in Kutsama_HeroGroup and do (Actions)
                • Loop - Actions
                  • Set Kutsama_Unit = (Picked unit)
                  • Trigger - Run Kutsama onEffect Removal <gen> (ignoring conditions)
              • Hashtable - Clear all child hashtables of child Katsuma_HandleId in Kutsama_Table
            • Else - Actions
              • -------- -------- --------
              • -------- Check if affected heroes are still in range --------
              • -------- -------- --------
              • Unit Group - Pick every unit in Kutsama_HeroGroup and do (Actions)
                • Loop - Actions
                  • Set Kutsama_Unit = (Picked unit)
                  • Set Kutsama_Point2 = (Position of Kutsama_Unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Kutsama_Point and Kutsama_Point2) Greater than Katsuma_Range
                    • Then - Actions
                      • Unit Group - Remove Kutsama_Unit from Kutsama_HeroGroup
                      • Trigger - Run Kutsama onEffect Removal <gen> (ignoring conditions)
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_Kutsama_Point2)
              • -------- -------- --------
              • -------- Check for new possible heroes in range --------
              • -------- -------- --------
              • Custom script: set bj_wantDestroyGroup = true
              • Set Katsuma_Player = (Owner of Kutsama_Unit)
              • Unit Group - Pick every unit in (Units within Katsuma_Range of Kutsama_Point) and do (Actions)
                • Loop - Actions
                  • Set Kutsama_Unit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Kutsama_Unit is in Kutsama_HeroGroup) Equal to False
                      • (Owner of Kutsama_Unit) Equal to Katsuma_Player
                      • (Kutsama_Unit is A Hero) Equal to True
                    • Then - Actions
                      • Unit Group - Add Kutsama_Unit to Kutsama_HeroGroup
                      • Trigger - Run Kutsama onEffect <gen> (ignoring conditions)
                    • Else - Actions
          • Custom script: call RemoveLocation(udg_Kutsama_Point)
  • Kutsama onEffect
    • Events
    • Conditions
    • Actions
      • -------- -------- --------
      • -------- Here you can use Katsuma-: Str, Agi, Int, Range, Unit --------
      • -------- -------- --------
      • Hero - Modify Strength of Kutsama_Unit: Add Kutsama_Str
      • Hero - Modify Agility of Kutsama_Unit: Add Kutsama_Agi
      • Hero - Modify Intelligence of Kutsama_Unit: Add Kutsama_Int
  • Kutsama onEffect Removal
    • Events
    • Conditions
    • Actions
      • -------- -------- --------
      • -------- Here you can use Katsuma-: Str, Agi, Int, Range, Unit --------
      • -------- -------- --------
      • Hero - Modify Strength of Kutsama_Unit: Subtract Kutsama_Str
      • Hero - Modify Agility of Kutsama_Unit: Subtract Kutsama_Agi
      • Hero - Modify Intelligence of Kutsama_Unit: Subtract Kutsama_Int

Thx for help! I will check this tutorial.

and thx for help Chaosy :D
 
Status
Not open for further replies.
Top