HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spinning Shurikens

02-13-2006, 06:45 AM#1
TGhost
Hi everyone

Im trying to make a trigger enchanced spell, wich would create a shuriken to circle around the caster. And because i want the caster to be able to create more than one, im trying to use Vexorians local variable trick.
The trigger looks like this:
Shuriken Shield
Trigger:
Shuriken Shield
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Shuriken Shield
Collapse Actions
Custom script: local unit udg_shuriken
Custom script: local unit udg_caster
Set caster = (Triggering unit)
Unit - Create 1 Shuriken for (Owner of caster) at ((Position of caster) offset by 200.00 towards 0.00 degrees) facing Default building facing degrees
Set shuriken = (Last created unit)
Unit - Set level of Premanent Immolation (Shuriken) for shuriken to (Level of Shuriken Shield for caster)
Collapse For each (Integer A) from 1 to 300, do (Actions)
Collapse Loop - Actions
Wait 0.05 seconds
Unit - Move shuriken instantly to ((Position of caster) offset by 200.00 towards (5.00 x (Real((Integer A)))) degrees)
Unit - Explode shuriken
Someone please tell me whats wrong?

note: if i make the trigger without the use of the local variables it works, but i have to use them, since i want this spell to be multiinstanceable.

Next time you post a trigger that was copied using the Copy As text feature, use the [trigger] tag instead of [code]
02-13-2006, 06:50 AM#2
Jacek
You won't get smooth movement by 0.10 wait probably :) hmm

Quote:
(10.00 x (Real((Integer A))))
I am not sure how W3 works with angles greater than 360*. In your trigger it will go until 1500 degrees.
And you should nullify unit variables too.

And are you sure you gave Premanent Immolation to shuriken unit?
02-13-2006, 07:06 AM#3
TGhost
ok, first, im not sure how to nullify variables, could you give me the costum script for that? And yes i did give the Premanent Immolation (Shuriken) to the shuriken. But how come if the degress is over 360, then you say it might not work, but it does with the non local variables?
I changed the code to this now:
Trigger:
Shuriken Shield
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Shuriken Shield
Collapse Actions
Custom script: local unit udg_shuriken
Custom script: local unit udg_caster
Custom script: local real udg_angle
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units owned by (Owner of (Triggering unit)) of type Shuriken)) Greater than or equal to 4
Collapse Then - Actions
Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + 50.00)
Skip remaining actions
Else - Actions
Set caster = (Triggering unit)
Unit - Create 1 Shuriken for (Owner of caster) at ((Position of caster) offset by 200.00 towards 0.00 degrees) facing Default building facing degrees
Set shuriken = (Last created unit)
Unit - Set level of Permanent Immolation (Shuriken) for shuriken to (Level of Shuriken Shield for caster)
Collapse For each (Integer A) from 1 to 300, do (Actions)
Collapse Loop - Actions
Wait 0.05 seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
angle Greater than or equal to 360.00
Collapse Then - Actions
Set angle = 0.00
Set angle = (angle + 5.00)
Collapse Else - Actions
Set angle = (angle + 5.00)
Unit - Move shuriken instantly to ((Position of caster) offset by 200.00 towards angle degrees)
Unit - Explode shuriken
now it chrashes the game?!

NOTE: the spell still works just perfect if i remove my costum scripts, so i think they are the problem.

EDIT: After reading Vexorians post again, i found out the problem myself. The problem is that loops dont support local variables!
But what else could i do to make his ability work? And be multi instanceable
02-13-2006, 08:02 AM#4
Anitarf
Loops should support local variables, since they don't create a seperate function for the loop actions, like the if-then-else does for conditions. However, you have other problems, you wait inside an Integer A loop, which is bad because Integer a is global and can be altered by other triggers during the wait. Also, warcraft is incapable of waiting for such a short time, the wait action is inaccurate, for such small wait, you must use timers or triggers with periodic events. That's how I would do this spell, I would just put all the shuriken into a unit group and then, in a periodic trigger, move all the shuriken around the hero.
02-13-2006, 08:06 AM#5
TGhost
thanks alot Anitarf, i might do that. Was thinking something like that aswell. But one problem. How can i move the units around the caster, in another trigger, without assigning the caster to a variable. Because if i do that, it wouldnt be multi instanceable?
02-13-2006, 08:15 AM#6
Anitarf
Have a unit array and a unit group array. Into the unit array go the heroes, and into the unit groups go the shuriken groups. When creating the shuriken, you just need to figure out into which group it goes (the one that has the array index under which the hero is stored in the unit array).

For determining array indexes, it depends on what degree of multi-instanceability you want to have; if it's one hero per player, you can easily use player numbers as the array indexes when storing the hero or the shuriken he creates. For full multi-instanceablility, you have to loop through the array until you find an empty index to store the hero, and afterwards loop through it every time a shuriken is cast until you find the index under which the casting hero is stored.
02-13-2006, 08:26 AM#7
TGhost
i only think im gonna need one hero per player, so i guess that would work. Thanks again.
02-13-2006, 11:57 AM#8
Vexorian
the local variable trick only works for one local vaiable at a time for some odd reasons.

locals work well in loops. Not in Unit Group - Pick every unit in group / also pick every item/destructable/player thise use another function
02-13-2006, 12:16 PM#9
Jacek
I forgot that blizzard tells in triggers that Waits shouldn't be used within loops.
02-13-2006, 12:39 PM#10
Chuckle_Brother
Quote:
Originally Posted by Jacek
You won't get smooth movement by 0.10 wait probably :) hmm


I am not sure how W3 works with angles greater than 360*. In your trigger it will go until 1500 degrees.

The gamr already handles shit like that, if you offset it by 390 for example, it will go 390 degrees from the static point of 0 degrees, so on that front he needs not worry.
02-13-2006, 12:43 PM#11
Vexorian
Quote:
Originally Posted by Vexorian
the local variable trick only works for one local vaiable at a time for some odd reasons.

locals work well in loops. Not in Unit Group - Pick every unit in group / also pick every item/destructable/player thise use another function
When using that trick for 2 or more locals it causes undefined code apparentally and many weird things occur
02-13-2006, 06:07 PM#12
TGhost
Oh, well, thanks alot for the replies everyone. I made it work now.