Hi I cannot manage to use the shot_explosion script by Dagorde that can be downlaod for free from the store
here the code
-- variable to keep door states open/closed
local ent_state = {};
-- variable to tell main we are just starting up
local mySetup = {};
-- //========================================================================
--////////////////////////////////////////////////////////////////////////////////////////////////
-- All doors will use the same values for these variables below - so they don't need to be arrays
--////////////////////////////////////////////////////////////////////////////////////////////////
-- all entities will start with this health
local startHealth = 500;
-- the action health value - if we go below this do our action
local actHealth = 200;
-- used when the door is open - to enable door to be shot when open
local doorOpen_shoot_range = 200;
-- animations for door from FPE file animation section - see double-door entity
local open_door_anim = 0;
local close_door_anim = 1;
-- door states
local closed_state = 0;
local opened_state = 1;
local PlayerDist = 0 -- Check distance and animation and then destroy(e) at a distance
local AnimRun = 0 -- Check distance and animation and then destroy(e) at a distance
-- //===================================================================================================
-- initialize function called only once at start up by GG
function shot_explosion_init(e)
-- initialize mySetup for this entity [e]
mySetup[e] = nil;
-- initialize ent_state for this entity
ent_state[e] = nil;
end
-- this function is called every FPS by GG
-- GG passes in the (e) number of the entity
-- so if we have 3 doors attached to this script
-- then this will be called 3 times
-- with each door's [e] number
function shot_explosion_main(e)
-- check if this door [e] number is just starting up
if mySetup[e] == nil then
-- just starting so set the entity [e] health to startHealth
SetEntityHealth(e,startHealth)
-- this entity [e] is closed at start
ent_state[e] = closed_state;
-- setup done - so set mySetup for this entity [e] to 1
-- we will not do this again for this entity
mySetup[e] = 1;
else
-- the door is closed
if ent_state[e] == closed_state then
-- make sure collision is on
CollisionOn(e);
-- if the entity health has gone below the action health value
-- we can open the door
if g_Entity[e]['health'] < actHealth then
AnimRun = 1
SetAnimationSpeed(e,200)
SetAnimationFrames(15,100)
-- set animation 0,1,2 the anims setup in the FPE file for this entity
SetAnimation(open_door_anim)
PlayAnimation(e)
-- turn off collision for the door opening...
-- or we will not be able to go through doorway
CollisionOff(e);
-- set our flag to tell script the door is open
-- so we will not come down into this code again
-- ( until we set ent_state[e] = closed_state again when we close door)
ent_state[e] = opened_state;
-- set the health back up to the start value
-- so we can keep playing with the door
SetEntityHealth(e,startHealth)
end
else
-- Check distance and animation and then destroy(e) at a distance
if AnimRun == 1 and PlayerDist > 1800 then
Destroy(e)
end
-- the door is open
-- get player distance from door [e]
PlayerDist = GetPlayerDistance(e)
-- we need to be (doorOpen_shoot_range) away from the door so we can
-- turn collision ON for the door.. so the gun can shoot the door again..(to close it)
-- if the collision is off.. then the gun can't shoot the door because..
-- there will be no collision detection for GG to use
if PlayerDist > doorOpen_shoot_range then
-- turn on collision so GG can detect gun shots again
CollisionOn(e);
-- if health is below action health value
-- close the door
if g_Entity[e]['health'] < actHealth then
-- do close animation
SetAnimation(close_door_anim)
PlayAnimation(e)
-- door closing
-- so turn collision back on
-- so we can't walk through door
CollisionOn(e);
-- tell our flag the door is closed
ent_state[e] = closed_state;
-- set entity health back to start value
SetEntityHealth(e,startHealth)
end
else
-- we are getting close to the door
-- we must want to go through it
-- so make sure the collision is off
CollisionOff(e);
end
end
end
-- entity tell me your health
--PromptLocal(e, " health "..g_Entity[e]['health'])
end
I apply this code to a dynamc entity like a crate or a barrel but when I shot to them nothing happen and after the entity helth reach zero the entity dont exlplode, remain on the level but become crossable
where I wrong??
PC Specs:
Q9550@3,8GHZ - 8GB RAM - SVGA R9 280 3GB GDDR5 - HDD WD 1500TB