Page 1 of 2
If Distance/If Target Script
Posted: Wed May 17, 2006 8:08 pm
by Broadus
I'm a very, very bad scripter, so I was wandering if maybe someone could give me the basis of a script like...
I've got some tanks that are on the same team as the player. When they get a certain distance away from the player, I want them to stop (self.driving = 0) so the player can catch up, or so the player can back up so that the friendlies can catch up with him.
I also want them to stop when they have a target (like real tanks had to stop when they wanted to shoot at something), but keep moving when they don't have a target.
Would these conflict with eachother?
Thanks for any help!
Posted: Wed May 17, 2006 10:49 pm
by jv_map
That should be possible... note that tanks by themselves don't have any target finding, so that'd have to be fully scripted.
Posted: Thu May 18, 2006 12:56 am
by Broadus
Well, I've already got a tank-targeting script that I just pulled out of t2l4.
So, any idea what the script would look like that makes the tank stop when it gets a certain distance from the player?
Posted: Thu May 18, 2006 2:34 pm
by Green Beret
local.tank.origin = $AI.origin + ( xxx )
Just a guess, Im no awsome scripter niether.
Kinda like how the avatar floats above your head on Freeze Tag?
Posted: Thu May 18, 2006 10:57 pm
by Broadus
... Yeah, I have a feeling that making the origin of the tank the same as the origin of something else won't solve much of anything in this case.
Posted: Thu May 18, 2006 11:46 pm
by lizardkid
i believe a sighttrace would be the best. basically it's like drawing a straight line from point to point, and it returns false if it's out of range or somehting's in the way.
i dont have the g_dumpallclasses file anymore, but it should be in there.
Posted: Fri May 19, 2006 4:35 am
by Rookie One.pl
Sighttrace traces using a bounding box, m8.

Posted: Fri May 19, 2006 4:47 am
by Broadus
So how do I make a sighttrace?
Posted: Fri May 19, 2006 5:18 am
by lizardkid
there's a bunch of traces... i think theres a "trace" too... i dunno.
Posted: Fri May 19, 2006 6:10 am
by Broadus
Then how do I just make it so that it stops at a certain distance?
Posted: Fri May 19, 2006 8:24 am
by jv_map
Depends. What is your current drive code?
Posted: Sat May 20, 2006 1:40 am
by Broadus
Well, it's... Not very complicated at the moment.
Basically:
$FFtank1 thread FFt1drive
. . .
FFt1drive:
self.driving = 1 (just in case?)
self drive $FFtank1path 5 10 100 256 //speed, accel/decel, closeness to nodes, looking ahead
self waittill drive
self stop
end
Posted: Sun May 21, 2006 4:21 am
by Green Beret
Broadus wrote:... Yeah, I have a feeling that making the origin of the tank the same as the origin of something else won't solve much of anything in this case.
I didnt say make it the same origin, The + adds onto the origin
+ ( xxx xxx xxx )
But the sighttrace is the way to go, Have fun scripting that

Posted: Sun May 21, 2006 5:07 am
by lizardkid
Code: Select all
local.tank.origin = $AI.origin + ( xyz )
sets the entity that local.tank refers to to the origin of $AI incremented by the amount in hte parens, so yes you'd be setting the tank right next to whatever AI is named that.
i asked about traces before and got a copy/paste code of it from bdb.
Code: Select all
local.player = $player
local.range = 1024
local.fwd_vec = angles_toforward local.player.viewangles
local.start = local.player gettagposition "Bip01 Head"
local.target.origin = trace (local.start + local.fwd_vec * 64) (local.start + local.fwd_vec * local.range ) 0
in this case it draws a line straight from the player to either 1024 units ahead or until it hits a brush, in which case it returns coords to where the trace terminated.
but the tank would sort of be wallhacking, because it would need to look at the player it's entire existance to know when it can actually see the player.
makes you wish they just made tank AI built-in doesnt it?
Posted: Mon May 22, 2006 3:13 am
by Green Beret
Makes you wonder why they didnt, Itd be nice to have a tank go on a search and destroy mission, Then come in after the tank and clean up what is left
