Page 1 of 1
Mover Class
Posted: Tue Mar 11, 2008 11:08 pm
by Killerdude
Found this in g_allclasses ....
Code: Select all
Mover (mover) -> Trigger -> Animate -> Entity -> SimpleEntity -> Listener -> Class
movedone( Entity finishedEntity )
Sent to commanding thread when done with move .
Was hoping someone could explain this a little or better yet point me to an example script. Is this something that I can use to tell when a script_object has finished a moveto without having to use waitmove?
Posted: Wed Mar 12, 2008 12:36 pm
by bdbodger
I used it in my rescue map . For an entity like an ai where you won't be using waitmove you can use it .
follow_player local.followed:
self.destination = local.followed
local.movethread = -1
self.movedoneradius = self.distance
if (vector_length (self.destination.origin - self.origin) > self.distance + self.friendrange)
{
self runto self.destination.origin
local.stand = 0
self waittill movedone
if !(self.destination)
self.destination = null
if (vector_length (self.destination.origin - self.origin) < self.distance + self.friendrange)
{
self exec global/stand.scr
}
}
else
{
if (local.stand == 0)
{
self exec global/stand.scr
local.stand = 1
}
wait 1
}
if (vector_length (self.destination.origin - self.origin) > self.distance + self.friendrange)
{
self runto self.destination.origin
local.stand = 0
thread movedone
local.movethread = parm.previousthread
}
if ((local.movethread != -1) && (local.movethread != NIL))
local.movethread delete
local.dest = self.destination.origin
local.runnertime = level.time + 2
while (((self.movedone == 0) && (vector_length (local.dest - self.origin) > (self.distance + self.friendrange))) && (local.runnertime > level.time))
{
if (self.waittime == -1)
waitframe
else
wait self.waittime
}
end
or this from the global/movecrate.scr ( notice animdone as well )
self holster
self type_attack "alarm"
self type_disguise "none"
local.o = local.cratetomove gettagposition "pickup"
self exec global/walkto.scr local.o
self waittill movedone
local.o = local.cratetomove gettagposition "box"
self exec global/turnto.scr local.o
local.distance = vector_length (self.origin - local.o)
println "distance to pickup crate '" local.o "' is " local.distance
if(local.distance > 45 )
{
println "crate guy " self.targetname " failed to get to " local.o
if(self.thinkstate == "curious")
println "cause of failure: curious"
self waitthread dropthecrate
end
}
self anim crate_pickup1
self waittill animdone
self.hasthecrate = 1
local.cratetomove hide
self anim crate_pickup2
Posted: Wed Mar 12, 2008 6:04 pm
by Rookie One.pl
Bodger, your code applies for the Actor class, not for Movers. However, since the event is listed... Hm. It could work. Try it like Bodger suggested ($object waittill movedone), if it doesn't work, you can just spawn another thread that will wait for the object to move and watch that thread's execution.
Posted: Wed Mar 12, 2008 6:30 pm
by Killerdude
Thanks for the replies guys. Two questions do come to mind as I read the posts. They are ...
1. Can I derive my own class from the mover class? What might the syntax look like?
2. Can you poll for the movedone or do you have to "wait" for the event?
My ultimate goal is to spawn an array of scrip_objects, set them in motion and poll each one for the movedone. Whatcha think? Possible?
Posted: Wed Mar 12, 2008 7:13 pm
by Rookie One.pl
1. You can't derive your own classes.
2. Nope, you can only wait for this event. You can achieve the polling functionality, however. Make a thread for each object that sets some level-wide boolean variable to false, does a waitmove and toggles the aforementioned variable afterwards. The variable can be polled from anywhere.
Posted: Wed Mar 12, 2008 7:39 pm
by Killerdude
Thanks again. Now I know
