That script is in the free section in the store.
The script is made to trigger a animation.
So if you shoot at a door, that the anim plays, when the doors health reaches zero.
And then the door opens.
So its not a real explosion script
I used this for my animations that explode. so these are seperate animations.
But here is the script.
-- shoot_door.lua
--
-- open and close door/trunk/case
-- can be used on multiple doors
--
-- author :- J_C
--
-- mods to original script by Harry Wever
-- thanks Harry for the idea..
--
-- Free to all
--
--//////////////////////////////////////////////////////////////////////////////////////
-- These variable will have different values for each door at different points in play
-- so they are made into arrays - each door entity will use (e) like this ent_state[e]
--//////////////////////////////////////////////////////////////////////////////////////
-- this is how you declare the array with = {}
--
-- 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
Harry