Status
Not open for further replies.

D4RK_G4ND4LF

Level 19
I just made a spell which I wanted to submit here later but it does not seem to work properly

There is a unit group which contains all units which were hit already (these units should not be hit again so I added them to a group that I can ask if there are still units in it) but it only works for the first cast for some reason and after that the enemy are killed nearly instantly

what did I forgot? (and any other things to improve)

• Rhino Loop
• Events
• Time - Every 0.03 seconds of game time
• Conditions
• Actions
• -------- Resets the counter variable which is used to shut down the trigger if there is no rhino to be moved --------
• Set instances = 0
• For each (Integer int) from 0 to rhino_max, do (Actions)
• Loop - Actions
• -------- If there still is a unit --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• rhino[int] Not equal to No unit
• Then - Actions
• -------- If the distance is not moved yet and and the caster is not dead and still there --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• rhino_distance[int] Less than rhino_distance_max[int]
• rhino_caster[int] Not equal to No unit
• (rhino_caster[int] is alive) Equal to True
• Then - Actions
• -------- Increases distance moved --------
• Set rhino_distance[int] = (rhino_distance[int] + rhino_speed[int])
• -------- Sets new coordinates --------
• Set rhino_x[int] = (rhino_x[int] + (rhino_speed[int] x (Cos((Facing of rhino_caster[int])))))
• Set rhino_y[int] = (rhino_y[int] + (rhino_speed[int] x (Sin((Facing of rhino_caster[int])))))
• -------- If the units run out of the playable map area they will be stopped --------
• Custom script: if RectContainsCoords(GetPlayableMapRect(), udg_rhino_x[udg_int], udg_rhino_y[udg_int]) then
• -------- Increases counter --------
• Set instances = (instances + 1)
• -------- Makes the rhinos fade out after 50% of distance traveled --------
• Animation - Change rhino[int]'s vertex coloring to (100.00%, 100.00%, 100.00%) with (-50.00 + (100.00 x (rhino_distance[int] / rhino_distance_max[int])))% transparency
• -------- Destroys trees if enabled --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• rhino_kill_trees[int] Equal to True
• Then - Actions
• Custom script: call KillTreesInRect( udg_rhino_aoe[udg_int], udg_rhino_x[udg_int], udg_rhino_y[udg_int] )
• Else - Actions
• -------- Damages units around --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• rhino_aoe[int] Greater than 0.00
• Then - Actions
• Set temppoint = (Point(rhino_x[int], rhino_y[int]))
• Set tempgroup = (Units within rhino_aoe[int] of temppoint matching ((((Owner of (Matching unit)) is an enemy of (Owner of rhino_caster[int])) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in rhino_hit_units[int]) Equal to False))))
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (tempgroup is empty) Equal to False
• Then - Actions
• Unit Group - Pick every unit in tempgroup and do (Actions)
• Loop - Actions
• Unit - Cause rhino_caster[int] to damage (Picked unit), dealing rhino_dmg[int] damage of attack type Spells and damage type Normal
• Unit Group - Add all units of tempgroup to rhino_hit_units[int]
• Else - Actions
• Custom script: call DestroyGroup( udg_tempgroup )
• Custom script: call RemoveLocation( udg_temppoint )
• Else - Actions
• -------- Moves the rhino to its coordinates --------
• Custom script: call SetUnitX(udg_rhino[udg_int],udg_rhino_x[udg_int])
• Custom script: call SetUnitY(udg_rhino[udg_int],udg_rhino_y[udg_int])
• -------- makes the unit face something --------
• Unit - Make rhino[int] face (Facing of rhino_caster[int]) over 0.00 seconds
• Custom script: else
• -------- Resetseverything --------
• Set rhino_hit_units[int] = (Random 0 units from rhino_hit_units[int])
• Unit - Remove rhino[int] from the game
• Set rhino[int] = No unit
• Set rhino_distance[int] = 0.00
• Custom script: endif
• Else - Actions
• -------- Resetseverything --------
• Set rhino_hit_units[int] = (Random 0 units from rhino_hit_units[int])
• Unit - Remove rhino[int] from the game
• Set rhino[int] = No unit
• Set rhino_distance[int] = 0.00
• Else - Actions
• -------- Disabels trigger if there are no instances running --------
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• instances Equal to 0
• Then - Actions
• Trigger - Turn off (This trigger)
• Else - Actions
I changed the spell and redid some stuff so that it works now but I still would like to know why this try didn't work (if anyone will read this )

Last edited:

Bomi

Level 4
Custom script: call DestroyGroup( udg_tempgroup )
sounds very suspicious... I've never used it myself, and i have no idea what it does but it sounds like it removes the variable.

Marcelo Hossomi

Level 7
Custom script: call DestroyGroup( udg_tempgroup )
sounds very suspicious... I've never used it myself, and i have no idea what it does but it sounds like it removes the variable.

His solution will probably work, but the theory is wrong ^^

DestroyGroup( ) indeed destroys the group to prevent leaks, but since you're using a global variable it's not needed - actually, you must not do it. If you do, you have to create it again, while it's much better just to clear the group.

Once you destroy the variable and you don't recreate it, it won't work anymore

D4RK_G4ND4LF

Level 19
His solution will probably work, but the theory is wrong ^^

DestroyGroup( ) indeed destroys the group to prevent leaks, but since you're using a global variable it's not needed - actually, you must not do it. If you do, you have to create it again, while it's much better just to clear the group.

Once you destroy the variable and you don't recreate it, it won't work anymore

good to know....always thought it would be like RemoveLocation()
but right now I'm so f***ed up about wc3 and needing twice the time to remove leaks and fix bugs caused by leak fixing then I would need to make the trigger itself...

however thanks + rep

GhostWolf

Level 29
good to know....always thought it would be like RemoveLocation()

It is exactly the same, just for a unit group.

Status
Not open for further replies.

Replies
18
Views
796
Replies
6
Views
2K
Replies
13
Views
732
Replies
12
Views
818
Replies
8
Views
893