Hello everybody,
It's my very first post here, and my bad it's for asking help.
I managed to make Ryan's breakable doors plugin work on DoD.
link for Ryan's Plugin:
https://forums.alliedmods.net/showth...reakable+doors
Well in fact all func_door_rotating entities will blow-up while you shot at it.
I want to add health feature to those entities.
By searching into whole forum i saw that Brad made a Plugin that have this feature, but i'm unable to find it
And because im very noob at making/editing a plugin my tries don't seem to do anything:
So what i've made so far is to take parts of Ryans plugins
1: to find func_door_rotating entities
2: the effects
3: the restore entities at new round
then i've tried to add health to those entities and i tried to add a takedamage function.
Here is the full code :
[PHP]#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#define MAX_DOORS 32
#define AXIS_X 0
#define AXIS_Y 1
#define AXIS_Z 2
#define DOOR_ENT 0
#define DOOR_TYPE 1
#define FUNC_DOOR_ROTATING 0
#define FUNC_DOOR 1
new DOOR_GIBS; // Model Index
new g_iTotalDoors;
new g_Doors[MAX_DOORS][2];
//new const gDoorClassname[ ]= "func_door_rotating"
new Float:g_vDoorOrigins[MAX_DOORS][3];
new bool:g_bDoorBroken[MAX_DOORS];
//new bool:g_bBreakHint[33];
public plugin_init()
{
register_plugin( "dod_breakable_doors", "1.0", "Ryan modified by anna" );
register_event( "RoundState", "_door_restore", "a", "1=1" );
RegisterHam(Ham_TakeDamage, "info_target", "door_TakeDamage");
register_cvar( "mp_breakabledoors", "1" );
set_task( 1.0, "_door_find" );
}
public _door_find()
{
if ( !get_cvar_num( "mp_breakabledoors" ) )
return PLUGIN_CONTINUE;
new DoorEnt = find_ent( -1, "func_door_rotating" );
while ( DoorEnt > 0 )
{
new iDoorNum = g_iTotalDoors;
entity_get_vector( DoorEnt, EV_VEC_origin, g_vDoorOrigins[iDoorNum] );
g_Doors[iDoorNum][DOOR_ENT] = DoorEnt;
g_Doors[iDoorNum][DOOR_TYPE] = FUNC_DOOR_ROTATING;
DoorEnt = find_ent( DoorEnt, "func_door_rotating" );
entity_set_float(DoorEnt, EV_FL_health, Float:500);
g_iTotalDoors++;
}
if ( g_iTotalDoors == 0 )
set_cvar_num( "mp_breakabledoors", 0 );
return PLUGIN_HANDLED;
}
public _door_restore() {
if ( !get_cvar_num( "mp_breakabledoors" ) )
return PLUGIN_CONTINUE;
for ( new i = 0; i < g_iTotalDoors; i++ )
{
new DoorEnt = g_Doors[i][DOOR_ENT];
if ( g_bDoorBroken[i] && g_Doors[i][DOOR_TYPE] == FUNC_DOOR_ROTATING )
{
// Make visible
set_entity_visibility( DoorEnt, 1 );
// Reset position
entity_set_origin( DoorEnt, g_vDoorOrigins[i] );
entity_set_float(DoorEnt, EV_FL_health,Float: 500);
g_bDoorBroken[i] = false;
}
}
return PLUGIN_CONTINUE;
}
public door_TakeDamage(DoorEnt, inflictor, attacker, Float:damage)
{
if ( !get_cvar_num( "mp_breakabledoors" ) )
for ( new i = 0; i < g_iTotalDoors; i++ )
if( entity_get_float( DoorEnt, EV_FL_health ) <= 0.0 )
{
new Float:vNewOrigin[3];
vNewOrigin[0] = g_vDoorOrigins[i][0];
vNewOrigin[1] = g_vDoorOrigins[i][1];
vNewOrigin[2] = g_vDoorOrigins[i][2] + 2000;
while ( PointContents( vNewOrigin ) == CONTENTS_SOLID && vNewOrigin[AXIS_Z] != g_vDoorOrigins[i][AXIS_Z] )
vNewOrigin[AXIS_Z] -= 25.0;
vNewOrigin[AXIS_Z] += 300.0;
entity_set_origin( DoorEnt, vNewOrigin );
set_entity_visibility( DoorEnt, 0 );
door_effect( g_vDoorOrigins[i] );
g_bDoorBroken[i] = true;
}
}
public door_effect( Float:vDoor[3] ) {
new vEffect[3];
vEffect[0] = floatround( vDoor[0] );
vEffect[1] = floatround( vDoor[1] );
vEffect[2] = floatround( vDoor[2] );
// Door Parts
message_begin( MSG_BROADCAST, SVC_TEMPENTITY, vEffect );
write_byte( 108 ); // TE_BREAKMODEL (10
write_coord( vEffect[0] );
write_coord( vEffect[1] );
write_coord( vEffect[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();
return PLUGIN_HANDLED;
}
public plugin_precache() {
if ( !get_cvar_num( "mp_breakabledoors" ) )
return PLUGIN_CONTINUE;
DOOR_GIBS = precache_model( "models/woodgibs.mdl" );
return PLUGIN_CONTINUE;
}[/PH
So it compile whithout any warnings but nothing happens in game (no error in logs).
so if someone can help me to make it working, ive thought about trace attack and killed function for those entities...
I don't know.
thanks.