/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
/*
* Description:
* If the satellite dish on top of the CT truck is destroyed then the cams will
* give off sparks and will stop working for the remainder of the round.
* However, the cams will start working again next round.
*
* Also this plugin allows the players to blow up the back door by throwing nades at it.
* But this can be disabled by editing the specified #define bellow.
*/
#include
#include
#define PLUGIN "Assault: Cams Fix"
#define AUTHOR "hoboman313/Van"
#define VERSION "1.2"
new ENT_NUM_DOOR, door_is_destroyed, DOOR_GIBS, backdoorBlow
new ENT_NUM_CAM1, ENT_NUM_CAM2, ENT_NUM_CAM3, cams_are_destroyed
new CAM_SPARK_POS[3] = { 340, 312, 282 }
#define EXPLODE_FROM_DOOR_RANGE 120.0
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR)
new mapname[16]
get_mapname(mapname,15)
if(equali("cs_assault",mapname))
{
kill_evil_ent()
backdoorBlow = register_cvar("amx_breakable_backdoor", "1" )
register_event("23", "dish_kill","a","1=108","3<500","15=2")
register_event("HLTV", "reset", "a", "1=0", "2=0")
register_event("23", "explosion","a","1=3","6=25")
register_forward( FM_EmitSound, "EmitSound")
}
}
public kill_evil_ent()
{
ENT_NUM_DOOR = engfunc( EngFunc_FindEntityByString, 0, "classname","func_door_rotating")
ENT_NUM_CAM1 = engfunc( EngFunc_FindEntityByString, 0, "model","*51")
ENT_NUM_CAM2 = engfunc( EngFunc_FindEntityByString, 0, "model","*52")
ENT_NUM_CAM3 = engfunc( EngFunc_FindEntityByString, 0, "model","*53")
engfunc( EngFunc_RemoveEntity, engfunc( EngFunc_FindEntityByString, 0, "classname","trigger_relay"))
}
public dish_kill()
{
cams_are_destroyed = 1
set_pev ( ENT_NUM_CAM1, pev_target, "" )
set_pev ( ENT_NUM_CAM2, pev_target, "" )
set_pev ( ENT_NUM_CAM3, pev_target, "" )
set_task(6.0,"deadcam_sparks",119,"",0,"b")
}
public reset()
{
if(cams_are_destroyed)
{
cams_are_destroyed = 0
set_pev ( ENT_NUM_CAM1, pev_target, "cam1" )
set_pev ( ENT_NUM_CAM2, pev_target, "cam2" )
set_pev ( ENT_NUM_CAM3, pev_target, "cam3" )
remove_task(119)
}
if( door_is_destroyed )
{
engfunc( EngFunc_SetOrigin, ENT_NUM_DOOR, Float:{696.0, 2236.0, 48.0} )
door_is_destroyed = 0
}
}
public plugin_precache()
{
DOOR_GIBS = precache_model( "models/woodgibs.mdl" )
}
public EmitSound(entity, channel, const sound[])
{
if( door_is_destroyed && ( containi(sound,"doors/doormove9.wav") != -1 || containi(sound,"doors/doorstop4.wav") != -1 ) )
return FMRES_SUPERCEDE
return FMRES_IGNORED
}
public explosion()
{
if( !door_is_destroyed && get_pcvar_num(backdoorBlow) )
{
//the door position stay constant so may as well hardcode it
new Float:explosionCoords[3], Float:doorPosition[3]={696.000000,2236.000000,48.000000}
read_data(2, explosionCoords[0])
read_data(3, explosionCoords[1])
read_data(4, explosionCoords[2])
new Float:distance = get_distance_f( doorPosition, explosionCoords )
if( distance < EXPLODE_FROM_DOOR_RANGE )
{
door_is_destroyed = 1
door_effect()//make wood gibs where the door was
engfunc( EngFunc_SetOrigin, ENT_NUM_DOOR, Float:{696.0, 2236.0, -54.0} )//throw door out of the map
}
}
}
public door_effect()
{
new doorPosition[3]={696,2236,48}
message_begin( MSG_BROADCAST, SVC_TEMPENTITY, doorPosition )
write_byte( 108 )
write_coord( doorPosition[0] )
write_coord( doorPosition[1] )
write_coord( doorPosition[2] )
write_coord( 0 )
write_coord( 0 )
write_coord( 0 )
write_coord( 5 )
write_coord( 5 )
write_coord( 5 )
write_byte( 15 )
write_short( DOOR_GIBS )
write_byte( 50 )
write_byte( 50 )
write_byte( 0 )
message_end()
}
public deadcam_sparks()
{
new posnum = random_num(0,2)
message_begin( MSG_ALL, SVC_TEMPENTITY,{0,0,0})
write_byte(111)
write_coord( 340)
write_coord( CAM_SPARK_POS[posnum])
write_coord( 57)
write_byte(20)
message_end()
}