Stop a thread
Posted: Wed Dec 03, 2003 7:43 am
Is it possible to stop a thread while it is running? Here's part of my script.
If I set the gards alertness to normal settings the second I shoot Hitler (while all three are walking) they attack me. When I set their alertness to 1 and I shoot Hitler the gards will keep walking even when Hitler is dead, so when they get to the waypoint they spin around and around. (because their .destination is Hitler's destination) How could I get them to stop or go idle or attack etc. the second Hitler is killed.
If I set the gards alertness to normal settings the second I shoot Hitler (while all three are walking) they attack me. When I set their alertness to 1 and I shoot Hitler the gards will keep walking even when Hitler is dead, so when they get to the waypoint they spin around and around. (because their .destination is Hitler's destination) How could I get them to stop or go idle or attack etc. the second Hitler is killed.
Code: Select all
$gard1.smokinginitialized = "no"
$gard2.smokinginitialized = "no"
$hitler.smokinginitialized = "no"
$gard1 turnto $g1wp1
$gard2 turnto $g2wp1
$gard1 anim atease
$gard2 anim atease
wait .5
$gard1 animscript "anim/continue_last_anim.scr"
$gard2 animscript "anim/continue_last_anim.scr"
wait 10
$gard1 thread gard_follow $hitler
$gard2 thread gard_follow $hitler
$hitler turnto $wp1
while(vector_length ($hitler.origin - $wp1.origin) > 64)
{
$hitler anim "unarmed_walk_forward"
$hitler waittill flaggedanimdone
}
$hitler anim idle
$hitler.smokinginitialized = "no"
wait 2
$gard1 turnto NULL
$gard2 turnto NULL
$gard1 anim atease
$gard2 anim atease
wait .5
$gard1 animscript "anim/continue_last_anim.scr"
$gard2 animscript "anim/continue_last_anim.scr"
wait 20
$gard1 walkto $g1wp1a
$gard1 waittill movedone
$gard1 turnto $g1wp2
$gard1 anim atease
$gard2 walkto $g2wp1a
$gard2 waittill movedone
$gard2 turnto $g2wp2
wait .5
$gard1 turnto NULL
$gard2 turnto NULL
$gard1 thread gard_follow $hitler
$gard2 thread gard_follow $hitler
$hitler turnto $wp2
while(vector_length ($hitler.origin - $wp2.origin) > 64)
{
$hitler anim "unarmed_walk_forward"
$hitler waittill flaggedanimdone
}
$hitler anim idle
$hitler.smokinginitialized = "no"
wait 2
$gard1 anim atease
$gard2 anim atease
wait .5
$gard1 animscript "anim/continue_last_anim.scr"
$gard2 animscript "anim/continue_last_anim.scr"
$gard1 turnto $east
$gard2 turnto $east
wait 10
if(isalive $hitler)
{
$gard1 aimat $hitler
wait 2
$gard1 fire
wait .1
$gard1 fire
wait .1
$gard1 fire
wait .1
$gard1 fire
wait .1
$gard1 fire
$hitler killed
wait 3
$gard1 aimat NULL
$gard1 turnto $wp2
$gard1 walkto $wp2
$gard1 waittill movedone
$gard1 anim grenade_kick
}
else
{
$gard1 anim specialmove
}
end
gard_follow local.hitler:
println "hitler thread active "
self.destination = local.hitler
self.distance = 3
self.waittime=1
self.friendrange = 3
self.runanimrate=1.28
if(isalive local.hitler)
{
self thread follow_player local.hitler
}
end
follow_player local.followed:
self.destination = local.followed
self.movedoneradius = self.distance
if (vector_length (self.destination.origin - self.origin) > self.distance + self.friendrange)
{
self animscript "anim/walk.scr" self.destination.origin
}
end