tanks
Moderator: Moderators
-
brendank310
- Corporal
- Posts: 27
- Joined: Mon Apr 07, 2003 11:02 am
- Contact:
tanks
hey mohaa rox... tanks please...
K, here's a brief guide for ya ppl:
make a tank, any tank from vehicles_german_xxx. Give it a targetname of let's say "tank". Give it a "target" of "tank_mask". Then construct a collision mask with the Metal Tank texture from "common" folder. Make it a script object, and give it a targetname of "tank_mask". You should see an arrow linking these 2 entities. Put the mask anywhere, in the air, under the terrain. Make a trigger multiple with targetname "tank_trigger".
In your script add:
$tank thread global/vehicles_thinkers.scr::player_tanks
$tank.collisionent = $tank.target
$tank vehiclespeed 200
That's it for now! Enjoy!
make a tank, any tank from vehicles_german_xxx. Give it a targetname of let's say "tank". Give it a "target" of "tank_mask". Then construct a collision mask with the Metal Tank texture from "common" folder. Make it a script object, and give it a targetname of "tank_mask". You should see an arrow linking these 2 entities. Put the mask anywhere, in the air, under the terrain. Make a trigger multiple with targetname "tank_trigger".
In your script add:
$tank thread global/vehicles_thinkers.scr::player_tanks
$tank.collisionent = $tank.target
$tank vehiclespeed 200
That's it for now! Enjoy!
Live to map, not map to live.
-mohaa_rox, .map
moderator
-mohaa_rox, .map
moderator
I Nearly have the tank working multiplayer. Two problems I can't seem to get to work and no idea why.
1. First pirson getting in the tank can't get out of it. Once the first person kills themself subsequent people can jump in and out at will
2. None of the command which should return if there is a player in the driver slot return anything. This means I can't tell when a player has left the tank. Anyone know?
Here's the script I have so far.
This is the tank setup:
spawn vehicles/tigertank.tik "targetname" "tiger1"
$tiger1.origin = ( -1032 -1390 -38)
$tiger1.angle = 0
$tiger1.gun = $tiger1 QueryTurretSlotEntity 0
$tiger1.gun2 = $tiger1 QueryTurretSlotEntity 1
//$tiger1.canjump false
//$tiger1 nodamage
//thread tankstuck
$tiger1 thread TankDestroyed
// collision entity
spawn script_object "targetname" "TigerCollisionEnt" "classname" "collisionent"
//spawn VehicleCollisionEntity "targetname" "TigerCollisionEnt"
$TigerCollisionEnt.origin = $tiger1.origin + ( 0 0 -3000)
//dd$TigerCollisionEnt.origin = $tiger1.origin
$TigerCollisionEnt.angles = $tiger1.angles
$TigerCollisionEnt.model = "static/vehicle_tigertank.tik"
//link collision entity to tank itself
$tiger1.target = "TigerCollisionEnt"
spawn trigger_use "targetname" "TankTrigger"
$TankTrigger.origin = $tiger1.origin
$TankTrigger.angles = $tiger1.angles
$TankTrigger.model = "static/vehicle_tigertank.tik"
$TankTrigger triggerable
$TankTrigger setthread "GetInTank"
$TankTrigger notsolid
$TankTrigger glue $tiger1
level.InTank = 0
level.FirstTime = 1
Here's the trigger script:
GetInTank:
if (level.InTank == 0)
{
iprintlnbold "You have control of the tank"
$tiger1.collisionent = $tiger1.target
$tiger1 vehiclespeed 200
$tiger1 waitthread global/VehicleDrive.scr::EnterTank parm.other
if (level.FirstTime == 1)
{
//for some reason First time you get in the tank the player is not aligned properly
wait 0.2
$tiger1 detachdriverslot 0
//iprintlnbold "detached"
$tiger1 thread global/VehicleDrive.scr::EnterTank parm.other
//iprintlnbold "reattached"
level.FirstTime = 0
}
level.InTank = 1
}
else
{
iprintlnbold "Tank already occupied"
}
end
and here is the vehicle setp script (basicall a hacked version of vehicle thinker):
EnterTank local.player:
// self vehiclespeed 300
self rendereffects "-shadow"
local.parent = spawn script_origin
local.parent.origin = self.origin
level.playertanktarget = spawn script_origin
level.playertanktarget.origin = (self.origin + (0 0 80))
level.playertanktarget bind local.parent
local.parent glue self
self removeondeath 1
if (self.target)
{
self.collisionent = self.target
// self.collisionent hide
}
local.gun = self QueryTurretSlotEntity 0
local.gun2 = self QueryTurretSlotEntity 1
if (local.gun)
local.gun nodamage
if (local.gun2)
local.gun2 nodamage
thread SetupTankHealth local.player
end
SetupTankHealth local.player:
//local.player notsolid
local.player nodamage
local.player hide
self attachdriverslot 0 local.player
local.player perferredweapon "88mm Tank Gun"
self.health = 200
//self.health = 3000
//self.health = 5000
// if ( (int (getcvar developer)) )
//thread tank_health_hud
thread tanktake_pain
//self waittill death
//self LockMovement
//self playsound explode_tank
//iprintlnbold "The King Tiger Tank has been lost, you have failed."
end
tanktake_pain:
local.original_health = self.health
local.previoushealth = self.health
local.paintime = level.time
while(isAlive self)
{
wait .1
if (self.health < local.previoushealth)
{
self playsound damage_tank
exec global/earthquake.scr .2 4 0 0
if ( (self.health < (local.previoushealth - 150)) && (level.time > (local.paintime + 5) ) )
{
local.paintime = level.time
local.health_fraction = (self.health / local.original_health)
println "z: local.health_fraction: " local.health_fraction
if (local.health_fraction >= 0.7)
{
local.player playsound tank_hurt1
}
else if (local.health_fraction >= 0.4)
{
local.player playsound tank_hurt2
}
else
{
local.player playsound tank_hurt3
}
}
local.previoushealth = self.health
}
}
end
1. First pirson getting in the tank can't get out of it. Once the first person kills themself subsequent people can jump in and out at will
2. None of the command which should return if there is a player in the driver slot return anything. This means I can't tell when a player has left the tank. Anyone know?
Here's the script I have so far.
This is the tank setup:
spawn vehicles/tigertank.tik "targetname" "tiger1"
$tiger1.origin = ( -1032 -1390 -38)
$tiger1.angle = 0
$tiger1.gun = $tiger1 QueryTurretSlotEntity 0
$tiger1.gun2 = $tiger1 QueryTurretSlotEntity 1
//$tiger1.canjump false
//$tiger1 nodamage
//thread tankstuck
$tiger1 thread TankDestroyed
// collision entity
spawn script_object "targetname" "TigerCollisionEnt" "classname" "collisionent"
//spawn VehicleCollisionEntity "targetname" "TigerCollisionEnt"
$TigerCollisionEnt.origin = $tiger1.origin + ( 0 0 -3000)
//dd$TigerCollisionEnt.origin = $tiger1.origin
$TigerCollisionEnt.angles = $tiger1.angles
$TigerCollisionEnt.model = "static/vehicle_tigertank.tik"
//link collision entity to tank itself
$tiger1.target = "TigerCollisionEnt"
spawn trigger_use "targetname" "TankTrigger"
$TankTrigger.origin = $tiger1.origin
$TankTrigger.angles = $tiger1.angles
$TankTrigger.model = "static/vehicle_tigertank.tik"
$TankTrigger triggerable
$TankTrigger setthread "GetInTank"
$TankTrigger notsolid
$TankTrigger glue $tiger1
level.InTank = 0
level.FirstTime = 1
Here's the trigger script:
GetInTank:
if (level.InTank == 0)
{
iprintlnbold "You have control of the tank"
$tiger1.collisionent = $tiger1.target
$tiger1 vehiclespeed 200
$tiger1 waitthread global/VehicleDrive.scr::EnterTank parm.other
if (level.FirstTime == 1)
{
//for some reason First time you get in the tank the player is not aligned properly
wait 0.2
$tiger1 detachdriverslot 0
//iprintlnbold "detached"
$tiger1 thread global/VehicleDrive.scr::EnterTank parm.other
//iprintlnbold "reattached"
level.FirstTime = 0
}
level.InTank = 1
}
else
{
iprintlnbold "Tank already occupied"
}
end
and here is the vehicle setp script (basicall a hacked version of vehicle thinker):
EnterTank local.player:
// self vehiclespeed 300
self rendereffects "-shadow"
local.parent = spawn script_origin
local.parent.origin = self.origin
level.playertanktarget = spawn script_origin
level.playertanktarget.origin = (self.origin + (0 0 80))
level.playertanktarget bind local.parent
local.parent glue self
self removeondeath 1
if (self.target)
{
self.collisionent = self.target
// self.collisionent hide
}
local.gun = self QueryTurretSlotEntity 0
local.gun2 = self QueryTurretSlotEntity 1
if (local.gun)
local.gun nodamage
if (local.gun2)
local.gun2 nodamage
thread SetupTankHealth local.player
end
SetupTankHealth local.player:
//local.player notsolid
local.player nodamage
local.player hide
self attachdriverslot 0 local.player
local.player perferredweapon "88mm Tank Gun"
self.health = 200
//self.health = 3000
//self.health = 5000
// if ( (int (getcvar developer)) )
//thread tank_health_hud
thread tanktake_pain
//self waittill death
//self LockMovement
//self playsound explode_tank
//iprintlnbold "The King Tiger Tank has been lost, you have failed."
end
tanktake_pain:
local.original_health = self.health
local.previoushealth = self.health
local.paintime = level.time
while(isAlive self)
{
wait .1
if (self.health < local.previoushealth)
{
self playsound damage_tank
exec global/earthquake.scr .2 4 0 0
if ( (self.health < (local.previoushealth - 150)) && (level.time > (local.paintime + 5) ) )
{
local.paintime = level.time
local.health_fraction = (self.health / local.original_health)
println "z: local.health_fraction: " local.health_fraction
if (local.health_fraction >= 0.7)
{
local.player playsound tank_hurt1
}
else if (local.health_fraction >= 0.4)
{
local.player playsound tank_hurt2
}
else
{
local.player playsound tank_hurt3
}
}
local.previoushealth = self.health
}
}
end
[VS-UK]Capt.Parts[BnHQ]
Like all these things so near and yet so far!
I have the tank almost working MP but I have one major problem. Once the player gets itno the tank it becomes non solid so they can't get shot! i.e. Rockets go straight through the tank.
Is this defined by the collision entity? I think this may be where my problem is. I have added the tank to an existing map so I'm spawning the new object in the script. So the script to spawn the collision entity looks as shown below:
//spawn script_model "targetname" "TigerCollisionEnt" "classname" "collisionent"
spawn script_model "targetname" "TigerCollisionEnt"
//spawn VehicleCollisionEntity "targetname" "TigerCollisionEnt"
$TigerCollisionEnt.origin = $tiger1.origin + ( 0 0 -3000)
//dd$TigerCollisionEnt.origin = $tiger1.origin
$TigerCollisionEnt.angles = $tiger1.angles
$TigerCollisionEnt.model = "static/vehicle_tigertank.tik"
$tiger1.target = "TigerCollisionEnt"
WhenI look at the log file I see the following error later in the scrpt:
self.collisionent = self.target (global/vehicledrive.scr, 16)
self^
^~^~^ Script Error: Model for Entity not of a valid type. Must be B-Model.
Cas someone tell me what this means? How can I create a "B-Model" in a script?
Thanks in advance.
I have the tank almost working MP but I have one major problem. Once the player gets itno the tank it becomes non solid so they can't get shot! i.e. Rockets go straight through the tank.
Is this defined by the collision entity? I think this may be where my problem is. I have added the tank to an existing map so I'm spawning the new object in the script. So the script to spawn the collision entity looks as shown below:
//spawn script_model "targetname" "TigerCollisionEnt" "classname" "collisionent"
spawn script_model "targetname" "TigerCollisionEnt"
//spawn VehicleCollisionEntity "targetname" "TigerCollisionEnt"
$TigerCollisionEnt.origin = $tiger1.origin + ( 0 0 -3000)
//dd$TigerCollisionEnt.origin = $tiger1.origin
$TigerCollisionEnt.angles = $tiger1.angles
$TigerCollisionEnt.model = "static/vehicle_tigertank.tik"
$tiger1.target = "TigerCollisionEnt"
WhenI look at the log file I see the following error later in the scrpt:
self.collisionent = self.target (global/vehicledrive.scr, 16)
self^
^~^~^ Script Error: Model for Entity not of a valid type. Must be B-Model.
Cas someone tell me what this means? How can I create a "B-Model" in a script?
Thanks in advance.
[VS-UK]Capt.Parts[BnHQ]
