dm.projectile for tanks
Posted: Mon Mar 31, 2008 2:48 am
I have a problem. I made a tank from the script and spawned it into a dm map. I made the sounds work, made the turret follow the $player, and shoot. Germans will leave the tank when destroyed as well.
Now the problem: The cannon fires blanks. No damage is delivered to the player.
If I could get a "scripting God" or lucky layman to help me out, I would be greatful. The error says I need a model for a projectile attack. Here's the script:
This script may also have problems attacking more than one $player in multiplayer.
Now the problem: The cannon fires blanks. No damage is delivered to the player.
If I could get a "scripting God" or lucky layman to help me out, I would be greatful. The error says I need a model for a projectile attack. Here's the script:
Code: Select all
//****************
// Installs a Tiger Tank
//****************
spawn_thing:
local.temp = spawn models/vehicles/tigertank.tik "targetname" "tank1"
$tank1.dmprojectile= "models/projectiles/tigercannonshell.tik"
local.temp.origin = $spawn_origin.origin
self remove
thread tank
end
tank:
$tank1 waitthread tank1_initialize //setup tank properties
$tank1 thread tank1_feedback //monitor for damage taken and gives feedback effects
//$tank1 waitthread tank1_move $tank1_path //setup tank movement parameters and make tank move
$tank1 thread tank1_targeting //targeting systems
$tank1 thread tank1_death //monitor for death
end
tank1_initialize:
//*** Setup the tank properties
local.gun = self QueryTurretSlotEntity 0 //local.gun is the tank turret itself local.gun.dmprojectile= "models/projectiles/tigercannonshell.tik"
local.gun.turret1= "vehicles/tigercannon.tik"
local.gun2 = self QueryTurretSlotEntity 1 //local.gun2 is the machine gun if it ever worked
self.health = 1000 //health - damage per player's panzerschreck shell is 200
self removeondeath 0 //prevent it from vanishing when destroyed
self lock //prevent it from being usable by the player
local.gun TurnSpeed 8 //set the turret traversing speed original value 4
self immune bullet
self immune fast_bullet
self immune grenade
self immune bash
end
tank1_feedback:
local.originalhealth = self.health
local.previoushealth = self.health //initialize
while (isAlive $tank1)
{
waitframe
if !(isAlive $tank1)
end
if (self.health < local.previoushealth)
{
local.tankfraction = (self.health / local.originalhealth) * 100
local.tankfractioninteger = int local.tankfraction
iprintlnbold_noloc (loc_convert_string "TIGER TANK: ") local.tankfractioninteger (loc_convert_string " percent")//(loc_convert_string "\%")
local.previoushealth = self.health
}
}
end
tank1_death:
self waittill death
iprintlnbold "Tiger Tank destroyed."
local.gun = self QueryTurretSlotEntity 0 //local.gun is the tank turret itself
local.gun2 = self QueryTurretSlotEntity 1 //local.gun2 is the machine gun if it ever worked
self show
self playsound explode_tank
self stop
local.gun stopfiring
//*** If a main gun and/or mounted machine gun exists on the tank, remove it
if (local.gun)
{
self DetachTurretSlot 0
local.gun remove
}
if (local.gun2)
{
self DetachTurretSlot 1
local.gun2 remove
}
//*** Activate the explosion visual effect
local.temp = spawn script_model
local.temp.origin = self.origin
local.temp model "fx/fx_tank_explosion.tik"
local.temp anim start
//*** Shake the player's view hard
exec global/earthquake.scr .23 4 0 0
//*** Issue some damage in a radius around the destroyed vehicle
radiusdamage self.origin 200 200
//Kill the player if there's a chance they might be stuck in the barrel...don't be close when the tank explodes.
radiusdamage ( ($tank1_radiusdamage_source.origin) + (0 0 16) ) 2000 325 1
//*** Turn on the tank barrel collision
// $tank1_barrel_collision solid
//*** Replace the model with the destroyed version and give it a collision mask
local.brushmodel = self.target.brushmodel
local.collision = spawn script_object model local.brushmodel
local.collision.angles = self.angles
local.collision.origin = self.origin
local.collision disconnect_paths
local.damaged = spawn script_model model models/vehicles/tigertank_d.tik
// local.damaged.targetname = self.targetname
local.damaged.origin = self.origin
local.damaged.angles = self.angles
self remove
//*** Initialize the 'guys getting out of the tank' animation
local.anims[0] = tank_exit_1
local.anims[1] = tank_exit_2
local.anims[2] = tank_exit_3
local.anims[3] = tank_exit_4
local.damaged thread global/vehicles_thinkers.scr::tank_guys_get_out local.anims
end
tank1_targeting:
if (isAlive self)
{
self fullstop
local.gun = self QueryTurretSlotEntity 0
local.gun setAimTarget $player
local.gun waittill ontarget
goto fire
}
end
fire:
if (isAlive self)
{
local.trace = trace (self.origin + (0 0 120)) ($player[local.i].origin + (0 0 48)) 1
if ! ((local.trace[0] == $player[local.i].origin[0]) || (local.trace[1] == $player[local.i].origin[1]) || (local.trace[2] == $player[local.i].origin[2] + 48))
{
println "DENIED BY NO LINE OF SIGHT"
wait 1
goto fire
}
local.gun startfiring
wait 1
local.gun stopfiring
wait 5
local.gun waittill ontarget
goto fire
}
endThis script may also have problems attacking more than one $player in multiplayer.