View Single Post
VJScope
Senior Member
Join Date: Jul 2012
Location: Finland
Old 04-19-2016 , 06:57   Re: [CSGO]rxg_mine plugin needs small fixes...
Reply With Quote #4

I'm pretty sure that the problem lies somewhere in this part of the code:
Code:
public SetupMine( client, Float:position[3], Float:normal[3] ) {
	decl String:mine_name[64];
	decl String:beam_name[64];
	decl String:str[128];

	Format( mine_name, 64, "rxgtripmine%d", mine_counter );
	
	
	new Float:angles[3];
	GetVectorAngles( normal, angles );
	
	
	new ent = CreateEntityByName( "prop_physics_override" );

	Format( beam_name, 64, "rxgtripmine%d_%d", mine_counter, ent );

	DispatchKeyValue( ent, "model", MODEL_MINE );
	DispatchKeyValue( ent, "physdamagescale", "0.0");	// enable this to destroy via physics?
	DispatchKeyValue( ent, "health", "1" ); // use the set entity health function instead ?
	DispatchKeyValue( ent, "targetname", mine_name);
	DispatchKeyValue( ent, "spawnflags", "256"); // set "usable" flag
	DispatchSpawn( ent );

	SetEntityMoveType(ent, MOVETYPE_NONE);
	SetEntProp(ent, Prop_Data, "m_takedamage", 2);
	SetEntPropEnt(ent, Prop_Data, "m_hLastAttacker", client); // use this to identify the owner (see below)
	//SetEntPropEnt(ent, Prop_Data, "m_hOwnerEntity",client); //Set the owner of the mine (cant, it stops the owner from destroying it)
	SetEntityRenderColor( ent, 255, 255, 255, 255 );
	SetEntProp( ent, Prop_Send, "m_CollisionGroup", 2); // set non-collidable

	// when the mine is broken, delete the laser beam
	Format( str, sizeof(str), "%s,Kill,,0,-1", beam_name );
	DispatchKeyValue( ent, "OnBreak", str );

	// hook to explosion function
	HookSingleEntityOutput( ent, "OnBreak", MineBreak, true );

	HookSingleEntityOutput( ent, "OnPlayerUse", MineUsed, false );

	// offset placement slightly so it is on the wall's surface
	for( new i =0 ; i < 3; i++ ) {
		position[i] += normal[i] * 0.5;
	}
	TeleportEntity(ent, position, angles, NULL_VECTOR );//angles, NULL_VECTOR );

	// trace ray for laser (allow passage through windows)
	TR_TraceRayFilter(position, angles, CONTENTS_SOLID, RayType_Infinite, TraceFilter_All, 0);

	new Float:beamend[3];
	TR_GetEndPosition( beamend, INVALID_HANDLE );

	// create beam
	new ent_laser = CreateLaser( beamend, position, beam_name, GetClientTeam(client) );
	
	// when touched, activate/break the mine

	if( minefilter == 1 || minefilter == 2 ) {
		HookSingleEntityOutput( ent_laser, "OnTouchedByEntity", MineLaser_OnTouch );
	} else {

		// detonate against anything
		Format( str, sizeof(str), "%s,Break,,0,-1", mine_name );
		DispatchKeyValue( ent_laser, "OnTouchedByEntity", str );
	}

	SetEntPropEnt(ent_laser, Prop_Data, "m_hOwnerEntity",client); //Set the owner of the mine's beam
	
	// timer for activating
	new Handle:data;
	CreateDataTimer( 1.0, ActivateTimer, data, TIMER_REPEAT );  
	ResetPack(data);
	WritePackCell(data, 0);
	WritePackCell(data, ent);
	WritePackCell(data, ent_laser);

	PlayMineSound( ent, SOUND_PLACE );
	
	mine_counter++;
}
Edit: I did some testing and SetEntProp(ent, Prop_Data, "m_takedamage", 2); basically 2 was the same as 3: Grenades and molotovs destroyed the mine. 0 and 1 made the mine indestructable (as expected). Maybe m_takedamage 2 is broken? Or maybe the mine positioning has been fucked up?
__________________
Strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses, not from some farcical aquatic ceremony.

Last edited by VJScope; 04-19-2016 at 07:29.
VJScope is offline