| 05-16-2005, 03:53 AM | #1 |
Ok, so in my rpg, there is a fearie unit that can cast some spells and can hold extra items for the player. I have a trigger that basically says every 3 seconds move the fearie to the position of the hero. This works fine and all, but it is kind of annoying if you tell the fearie to pick up an item, then b4 he gets there he gets moved due to the trigger. HOW can I set it up so it will have a condition that is something like: IF unit is not doing something or unit not being issued an order or something along these lines. Basically, just a trigger that will move the fearie to the position of the players hero IF the fearie is inactive. Anyone know, I know anitarf knowz probably ^_^ |
| 05-16-2005, 10:46 AM | #2 | |
Quote:
I'm unsure about this but it should work, at least it worked for me. I was also usnure if u wanted the Faerie thing to "Move" or to "Instantly Move" so this script is using the "Instant" one. Here's the trigger: Event: Time - Every 3.00 seconds of game time Conditions: (Current order of Faerie Thing 0000 <gen>) Equal to (Order(move,cast,attack)) Action: Unit - Move Faerie Thing 0000 <gen> instantly to (Position of Hero 0001 <gen>) Very simple |
| 05-16-2005, 11:15 AM | #3 |
If you are using instant-move, you should increase the frequency of the trigger considerably to make it look smooth, it's just wierd if the unit jumps from one point to the next every three seconds. Using the period 0.04 seconds makes it only semi-smooth, the period 0.02 is almost ok. Here's an example of the trigger: Code:
Periodic move
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of Flying Machine 0001 <gen>) Equal to (Order(idle))
Then - Actions
Set tempPoint = (Position of Paladin 0000 <gen>)
Unit - Move Flying Machine 0001 <gen> instantly to (Position of Paladin 0000 <gen>), facing (Facing of Paladin 0000 <gen>) degrees
Custom script: call RemoveLocation( udg_tempPoint )
Else - Actions |
| 05-16-2005, 10:28 PM | #4 | |
Quote:
After messing around with these for a bit, I just came up with something similair that works how I want it. I forgot to mention, that if the unit leaves area around hero then also move, so, I did this trigger: Code:
Fearie Helper
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - 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) is A Hero) Equal to True
(Owner of (Picked unit)) Equal to Players[(Integer A)]
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Rect centered at (Position of (Picked unit)) with size (1500.00, 1500.00)) contains Player_Fearies[(Integer A)]) Equal to True
Then - Actions
Do nothing
Else - Actions
Unit - Move Player_Fearies[(Integer A)] instantly to (Position of (Picked unit))
Else - Actions
Do nothingWorks fine :) |
| 05-16-2005, 11:32 PM | #5 |
Wouldn't it be better if you used another unit array for the player'sheroes the same way you do for faeries? That way, you wouldn't need to do all that pick units in unit group stuff that leaks... 300 unit group objects per second. That's pretty bad. You also leak a point object (position of (picked unit)) and a rect whenever the trigger runs, that's 600 more handle objects per second. If you are not attempting to make smooth movement, then you should decrease the trigger frequency, no need for it to run 50 times per second if it moves the unit only when it gets out of range, unless you might consider adding the order comparison as well so the unit is moved if it's outside range or if it doesn't have an order. And to prevent the memory leaks, I would suggest using a unit array for the heroes so you can avoid the "pick units in a unit group" function which generates an unit group object, also dump the "unit in rect" boolean comparison and use "distance between 2 points" real comparison, and for the two points (positions of the hero and the fairy), you can solve that the same way I did in my trigger, with two temp point variables (or just a single point variable array) where you store the positions of the two units, and after you compare the distance/move the fairy, destroy the points. |
| 05-17-2005, 03:45 AM | #6 |
Wow, that sounds like a whole lot of NEW stuff to make :\ Can you show me what the trigger would look like? Pretty plz >:) Also, I had no idea unit group did memeory leaks, sigh, that means THIS WHOLE new system I just made where you can enchant items, I will have to redo O_o |
| 05-17-2005, 06:43 AM | #7 |
btw, "fairies" is spelt like that Code:
Periodic move
Events
Time - Every 0.25 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Set tempPoint1 = (Position of Player_Heroes[(Integer A)])
Set tempPoint2 = (Position of Player_Fearies[(Integer A)])
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of Player_Fearies[(Integer A)]) Equal to (Order(idle))
OR
(Distance between (tempPoint1) and (tempPoint2)) is greater than 512.00
Then - Actions
Unit - Move Player_Fearies[(Integer A)] instantly to (tempPoint1), facing 270 degrees
Else - Actions
Custom script: call RemoveLocation( udg_tempPoint1 )
Custom script: call RemoveLocation( udg_tempPoint2 )modified anitarfs trigger to do what you wanted (btw ani, is "idle" really an order? you may have to check if the order ID integer = 0 for it to be doing nothing) |
| 05-17-2005, 08:26 AM | #8 |
Well, I've read about "idle" before, and when I tested it, it seemed to work as it should, so yeah, "idle" is an order. BTW, a small typo, you should have said "Set tempPoint1 = (position of (Player_Heroes[(Integer A)]))" :) Yeah, Raptor--'s trigger is what I was proposing, except for the 0.25 second period, that's so un-smooth, try it with a 0.2 and see how cool it looks. Also, try using "move unit and face angle" instead of just "move unit", and as the angle, use the facing of the hero, so the fairy will face the same direction as the hero when moving, it looks really neat. |
| 05-17-2005, 07:33 PM | #9 | |
Quote:
there i fixed it, i'm better at conveying the idea, not the actual syntax and i assumed his fairy was a wisp so it wouldn't actually matter which way it faced actually what would look cool is Code:
Periodic move
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Set FairyAngle[Integer A] = (FairyAngle[Integer A] + 1) mod 360
Set tempPoint1 = (Position of Player_Heroes[(Integer A)])
Set tempPoint2 = (Position of Player_Fearies[(Integer A)])
Set tempPoint3 = (tempPoint1 offset by 128.00 towards Real(FairyAngle[Integer A]) degrees)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of Player_Fearies[(Integer A)]) Equal to (Order(idle))
OR
(Distance between (tempPoint1) and (tempPoint2)) is greater than 512.00
Then - Actions
Unit - Move Player_Fearies[(Integer A)] instantly to (tempPoint3), facing (FairyAngle[Integer A] + 90) degrees
Else - Actions
Custom script: call RemoveLocation( udg_tempPoint1 )
Custom script: call RemoveLocation( udg_tempPoint2 )
Custom script: call RemoveLocation( udg_tempPoint3 )
so i just arbitrarily added in another temppoint but oh well, then your fairy circles around you when its not doing anything, facing the direction its going... Angle + 180 would always face the player as it circled |
| 05-17-2005, 09:48 PM | #10 |
This is turning out to be something really really neat. With all that eyecandy, it would be wierd if the fairie just instantly teleported to the hero whenever it went out of range or became idle. So, I'll just upgrade the trigger some more. Since we are using more and more temp points, I'll just make them an array. Code:
Periodic move
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Set FairyAngle[Integer A] = (FairyAngle[Integer A] + 3) mod 360
Set tempPoint[1] = (Position of Player_Heroes[(Integer A)])
Set tempPoint[2] = (Position of Player_Fearies[(Integer A)])
Set tempPoint[3] = (tempPoint[1] offset by 128.00 towards Real(FairyAngle[Integer A]) degrees)
Set tempPoint[4] = (tempPoint[2] offset by 12 towards (angle between (tempPoint[2]) and (tempPoint[3])))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of Player_Fearies[(Integer A)]) Equal to (Order(idle))
OR
(Distance between (tempPoint[1]) and (tempPoint[2])) is greater than 512.00
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between (tempPoint[2]) and (tempPoint[3])) is greater than 12.00
Then - Actions
Set FairyAngle[Integer A] = (angle between (tempPoint[3]) and (tempPoint[2])) + 90
Unit - Move Player_Fearies[(Integer A)] instantly to (tempPoint[4]), facing (FairyAngle[Integer A] + 90) degrees
Else - Actions
Unit - Move Player_Fearies[(Integer A)] instantly to (tempPoint[3]), facing (FairyAngle[Integer A] + 90) degrees
Else - Actions
For each (Integer B) from 1 to 4, do (Actions)
Loop - Actions
Custom script: call RemoveLocation( udg_tempPoint[GetForLoopIndexB()] )I also thought about unit speed a bit, as you see, I set it to move 3 degrees whenever the trigger runs (which is 50 times per second, meaning the fairie would travel 150 degrees in a second, thus taking between 2 and 3 seconds to complete a circle). This gives the apparent movement speed (if the hero is standing still and with the circling radius of 128) of about 335 units per second, which is roughly equal to the movement speed of a fast war3 hero (demon hunter for example). When returning to a hero, I set it to move 12 units per trigger run (defined that when I defined tempPoint[4]), that's 600 units per second, which is slightly faster than the maximum normal unit movement speed in warcraft, so it's slightly faster than a blademaster with a level 3 wind walk. You can easily change these speeds if you want to. When returning from afar, the trigger also adjust the fairie's angle so if my calculations were correct, it should come to it's circling path under the same angle as it will then continiue to circle. |
| 05-18-2005, 01:20 AM | #11 |
meh, just add the blink effect when its out of range and ur gold :p actually something even more interesting would be to use a sine function so it also bobs up and down as it circles around, simple, and hopefully visible Code:
PRE: real MAX_BOB = maximum vertical displacement = 45.00
Periodic move
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Set FairyAngle[Integer A] = (FairyAngle[Integer A] + 3) mod 360
//2 Bobs per full rotation, max height at 135, min height at 45 (could be shifted with arithmetic easily)
Unit - Set flying height of Player_Fearies[Integer A] to (Sin(Real(FairyAngle[Integer A]) ) * MAX_BOB + 90) at speed 5000.00
Set tempPoint[1] = (Position of Player_Heroes[(Integer A)])
Set tempPoint[2] = (Position of Player_Fearies[(Integer A)])
Set tempPoint[3] = (tempPoint[1] offset by 128.00 towards Real(FairyAngle[Integer A]) degrees)
Set tempPoint[4] = (tempPoint[2] offset by 12 towards (angle between (tempPoint[2]) and (tempPoint[3])))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of Player_Fearies[(Integer A)]) Equal to (Order(idle))
OR
(Distance between (tempPoint[1]) and (tempPoint[2])) is greater than 512.00
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Distance between (tempPoint[2]) and (tempPoint[3])) is greater than 12.00
Then - Actions
Set FairyAngle[Integer A] = (angle between (tempPoint[3]) and (tempPoint[2])) + 90
Unit - Move Player_Fearies[(Integer A)] instantly to (tempPoint[4]), facing (FairyAngle[Integer A] + 90) degrees
Else - Actions
Unit - Move Player_Fearies[(Integer A)] instantly to (tempPoint[3]), facing (FairyAngle[Integer A] + 90) degrees
Else - Actions
For each (Integer B) from 1 to 4, do (Actions)
Loop - Actions
Custom script: call RemoveLocation( udg_tempPoint[GetForLoopIndexB()] )either way, i think we went too complex for zero |
| 05-19-2005, 04:45 AM | #12 | |
Quote:
Hey! I havn't even had time to look at any of these! MY FREAKING internet crashed about 2 days ago and am I am at a firends house. It turns out my mom's lamo bf decided he just didn't want to pay the bill....... I will copy this stuff in a text file and HOPEFULLY get it all :p See ya when I get the damn net back........ |
