Mover Class

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Killerdude
Sergeant Major
Posts: 110
Joined: Fri May 11, 2007 12:16 am

Mover Class

Post 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?
[Rome wasn't mapped in a day!]
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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
Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post 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.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Killerdude
Sergeant Major
Posts: 110
Joined: Fri May 11, 2007 12:16 am

Post 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?
[Rome wasn't mapped in a day!]
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post 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.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Killerdude
Sergeant Major
Posts: 110
Joined: Fri May 11, 2007 12:16 am

Post by Killerdude »

Thanks again. Now I know :D
[Rome wasn't mapped in a day!]
Post Reply