tanks looping forever

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
LtNeil
Sergeant
Posts: 54
Joined: Sun Nov 14, 2004 8:46 pm
Location: southend on sea
Contact:

tanks looping forever

Post by LtNeil »

I have two enemy tanks which i would like to see going round and round forever(well until i shoot them with my tank).

I have put down my info_vehiclepoint (tank1_path) which links to t1 info_vehiclepoint t2 ...etc etc but when it reaches the start again(tank1_path) my tanks stop.How do i get them to keep on going round and round?

heres my tank script

thread go_tanks

level waitTill prespawn

level.fastspeed = 300
level.slowspeed = 160

$playertank waitthread global/vehicles_thinkers.scr::players_tank
$playertank vehiclespeed level.slowspeed
level.currently_fast = 0

exec global/ambient.scr m5l2a

level waitTill spawn

speedup:
if (level.currently_fast == 1)
end

for (local.speed = level.slowspeed; local.speed <= level.fastspeed; local.speed += 1)
{
$playertank vehiclespeed local.speed
waitframe
}

level.currently_fast = 1
end

slowdown:
if (level.currently_fast != 1)
end

for (local.speed = level.fastspeed; local.speed >= level.slowspeed; local.speed -= 1)
{
$playertank vehiclespeed local.speed
waitframe
}

level.currently_fast = 0
end

drive_path local.path local.speed local.remove:
self.driving = 1
self drive local.path local.speed 30 200 level.lookahead
self waitTill drive
if (self)
{
self stop
self.driving = 0
if (local.remove == "remove")
self remove
}
end

cant_go_that_way:
//called by the BSP
if( level.drive == NIL || level.drive.size == 0)
{
level.drive[0] = dfr_drive_01h_2
level.drive[1] = dfr_drive_02h_1
level.drive[2] = dfr_drive_04h_1
level.drive[3] = dfr_drive_05h_1
level.drive[4] = dfr_drive_07h_2
level.drive[5] = dfr_drive_08h_1
level.drive[6] = dfr_drive_09h_1
level.drive[7] = dfr_drive_10h_2

if (level.prev_drive != NIL)
{
for (local.i = 0; local.i < level.drive.size; local.i++)
{
if (level.drive[local.i] == level.prev_drive)
{
println "before1: " level.drive.size
level.drive[local.i] = NIL
println "after1: " level.drive.size
break
}
}
}
}

level.prev_drive = thread get_random_entry level.drive
//level.playertank playsound level.prev_drive
$player playsound level.prev_drive
end

get_random_entry local.entries:
local.n = randomint (local.entries.size)
//println "XXX:" local.n
local.entry = 0
get_random_entry_loop:
local.result = local.entries[local.entry]
if (local.result == NIL)
{
local.entry++
goto get_random_entry_loop
}
if (local.n)
{
local.n--
local.entry++
goto get_random_entry_loop
}

println "result: " local.result

local.entries[local.entry] = NIL
end local.result

go_tanks:
level.lookahead = 256
level.enemytankspeed = 200
level.sightdistance = 2048
level.playertank=playertank

$tank1 thread TankGo $tank1_path level.enemytankspeed empty_panzer_desert
$tank2 thread TankGo $tank2_path level.enemytankspeed empty_panzer_desert

TankGo local.path local.speed local.type:
self immune aagun
self thread global/vehicles_thinkers.scr::enemy_tank_think 0 local.type
self thread drive_path local.path local.speed

(ps.) ive copied most of it from a breathrough script and chopped and changed bits but it all works ok(for me that is,lol)
My candle burns at both ends it will not last the night but oh my foes and oh my friends it gives a lovely light.
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 »

Make sure the last node of the path targets the first one.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

once you get this part done properly with a thread name for example for the thread then you can loop it as long as the tank has not been destroyed
after the self waittill drive line
level.currently_fast = 0
end

drive_path local.path local.speed local.remove:
self.driving = 1
self drive local.path local.speed 30 200 level.lookahead
self waitTill drive
if (self)
{
self stop
self.driving = 0
if (local.remove == "remove")
self remove
}
end
Image
Post Reply