Well thanks to info from The Mighty JV_Map and Parts I am now able to have a German Tiger Tank shoot at allied players.
Some Notes:
-All orgins for aiming and driving were placed in map file
-The tiger Tank was spawned into game, placing it in map file did not work
-Turret does not fire at axis players but will take aim at them.
thread the_tank
the_tank:
spawn vehicles/tigertankdsrt.tik "targetname" "tiger1"
$tiger1.origin = ( -1314 -3692 0)
$tiger1.angle = 0
$tiger1.scale = .9
$tiger1.gun = $tiger1 QueryTurretSlotEntity 0
$tiger1.gun2 = $tiger1 QueryTurretSlotEntity 1
thread tankgo
$tiger1 thread TankDead
end
tankgo:
wait 15
$p1.target = NULL
$tiger1 drive $p1
$tiger1 waittill drive
$tiger1 stop
$tiger1.gun setAimTarget $aim1
$tiger1.gun waittill ontarget
$tiger1.gun anim fire
wait 3
$p2.target = NULL
$tiger1 drive $p2
$tiger1 waittill drive
$tiger1 stop
$tiger1.gun setAimTarget $aim2
$tiger1.gun waittill ontarget
$tiger1.gun anim fire
wait 3
$p3.target = NULL
$tiger1 drive $p3
$tiger1 waittill drive
$tiger1 stop
$tiger1.gun setAimTarget $aim1
$tiger1.gun waittill ontarget
$tiger1.gun anim fire
wait 3
$p4.target = NULL
$tiger1 drive $p4
$tiger1 waittill drive
$tiger1 stop
$tiger1.gun setAimTarget $aim3
$tiger1.gun waittill ontarget
$tiger1.gun anim fire
wait 2
$tiger1 thread Target
end
TankDead:
self waittill death
spawn script_model "targetname" "deadtiger"
$deadtiger.origin = self.origin
$deadtiger.angles = self.angles
$deadtiger model "vehicles/tigertank_d.tik"
exec global/model.scr self.origin "models/fx/fx_tank_explosion"
exec global/earthquake.scr .2 4 0 0
radiusdamage (self.origin + (0 0 200)) 800 400
wait 1.3
thread DoExplosion $deadtiger "models/emitters/explosion_tank.tik"
wait .5
thread DoExplosion $deadtiger "models/animate/fx_explosiom_tank.tik"
iprintlnbold "Tiger Tank has been destroyed!"
end
DoExplosion local.org local.model local.scale:
if (local.model == NIL)
local.model = models/animate/fx_explosion_tank
local.ent = spawn script_model
local.ent model local.model
if (local.scale != NIL)
local.ent scale local.scale
local.ent.origin = local.org
local.ent anim start
local.ent notsolid
wait 3
local.ent anim stop
local.ent delete
end
//*** find an allied player near by to shoot at!
Target:
println ("looking for target")
//look for first player in range and shoot at them!
for (self.i = 1; self.i <= 32; self.i++)
{
if ($player[self.i])
{
if ($player[self.i].dmteam == allies)
{
if (vector_length (self.origin - $player[self.i].origin) > 200)
{
if (vector_length (self.origin - $player[self.i].origin) < 3000)
{
if (self cansee $player[self.i])
{
println ("targeting player #" + self.i)
self.gun setAimTarget $player[self.i]
self.gun waittill ontarget
self.gun anim fire
goto breakloop
}
else
{
println "can't see him!"
}
}
}
}
}
}
println "no target found"
breakloop:
wait 3
goto Target
end
Hope this will help someone
[FS] Desert Eagle
Axis Tanks Firing at Allied Players in Multiplayer, works!!
Moderator: Moderators
-
Desert Eagle
- Captain
- Posts: 237
- Joined: Mon Jan 13, 2003 1:05 am
- Location: Mapping Bunker
- Contact:
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
it'd be best to use && instead of so many if's just to increase scripting and reading time
replace this
for (self.i = 1; self.i <= 32; self.i++)
{
if ($player[self.i])
{
if ($player[self.i].dmteam == allies)
{
if (vector_length (self.origin - $player[self.i].origin) > 200)
{
if (vector_length (self.origin - $player[self.i].origin) < 3000)
{
if (self cansee $player[self.i])
{
println ("targeting player #" + self.i)
self.gun setAimTarget $player[self.i]
self.gun waittill ontarget
self.gun anim fire
goto breakloop
}
else
{
println "can't see him!"
}
}
}
}
}
}
with
for (self.i = 1; self.i <= 32; self.i++)
{
if ($player[self.i]) && ($player[self.i].dmteam == allies) && (vector_length (self.origin - $player[self.i].origin) > 200) &&(vector_length (self.origin - $player[self.i].origin) < 3000) && (self cansee $player[self.i])
{
println ("targeting player #" + self.i)
self.gun setAimTarget $player[self.i]
self.gun waittill ontarget
self.gun anim fire
goto breakloop
}
else
{
println "can't see him!"
}
or unless you were doing it this way to pick up on debuggin you should have more
println "can't see him!"
}
println "!"
}
println "!!"
}
println "!!!"
}
println "!!!!"
}
println "!!!!!"
}
to show where each error is occurring
not saying u've done it wrong though
well done m8!!!!
replace this
for (self.i = 1; self.i <= 32; self.i++)
{
if ($player[self.i])
{
if ($player[self.i].dmteam == allies)
{
if (vector_length (self.origin - $player[self.i].origin) > 200)
{
if (vector_length (self.origin - $player[self.i].origin) < 3000)
{
if (self cansee $player[self.i])
{
println ("targeting player #" + self.i)
self.gun setAimTarget $player[self.i]
self.gun waittill ontarget
self.gun anim fire
goto breakloop
}
else
{
println "can't see him!"
}
}
}
}
}
}
with
for (self.i = 1; self.i <= 32; self.i++)
{
if ($player[self.i]) && ($player[self.i].dmteam == allies) && (vector_length (self.origin - $player[self.i].origin) > 200) &&(vector_length (self.origin - $player[self.i].origin) < 3000) && (self cansee $player[self.i])
{
println ("targeting player #" + self.i)
self.gun setAimTarget $player[self.i]
self.gun waittill ontarget
self.gun anim fire
goto breakloop
}
else
{
println "can't see him!"
}
or unless you were doing it this way to pick up on debuggin you should have more
println "can't see him!"
}
println "!"
}
println "!!"
}
println "!!!"
}
println "!!!!"
}
println "!!!!!"
}
to show where each error is occurring
hope this helps, prob not cos it's all foreign 2 me :-/
-
Desert Eagle
- Captain
- Posts: 237
- Joined: Mon Jan 13, 2003 1:05 am
- Location: Mapping Bunker
- Contact:
thanks nuggets and jv for even more informaion. I am by no means any good at scripting, more of a try it and see if it works.
Jv said:
were would I put it?
Jv said:
Also now working on if tiger stuck thread. In my map allies can stop tank from advancing by blowing up a line of trees and blocking its path. Which works and looks good but if player gets to close to tank, they are killed, becuase tank thinks it is still driving.
Jv said:
Probably you will need an isAlive check also.
were would I put it?
Jv said:
You do not have to scale it to .9 to work, I did because of street restrictions on my map.Why do you use scale 0.9 for the tank?
Also now working on if tiger stuck thread. In my map allies can stop tank from advancing by blowing up a line of trees and blocking its path. Which works and looks good but if player gets to close to tank, they are killed, becuase tank thinks it is still driving.
The if(isAlive $player[self.i]) can go instead of if($player[self.i]), since if(isAlive x) actually means if(x != NULL && x.health > 0).
You could e.g. paste it right here:
if ((isAlive $player[self.i]) && ($player[self.i].dmteam == allies) && (vector_length (self.origin - $player[self.i].origin) > 200) &&(vector_length (self.origin - $player[self.i].origin) < 3000) && (self cansee $player[self.i]) )
You may also want to use local.i in the future, just in case you want more threads later
You could e.g. paste it right here:
if ((isAlive $player[self.i]) && ($player[self.i].dmteam == allies) && (vector_length (self.origin - $player[self.i].origin) > 200) &&(vector_length (self.origin - $player[self.i].origin) < 3000) && (self cansee $player[self.i]) )
You may also want to use local.i in the future, just in case you want more threads later
-
Desert Eagle
- Captain
- Posts: 237
- Joined: Mon Jan 13, 2003 1:05 am
- Location: Mapping Bunker
- Contact:
