Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <sdkhooks>
- #define TRACE_START 1.0
- #define TRACE_LENGTH 80.0
- #define LASER_COLOR_D "38 251 42"
- #define LASER_WIDTH 0.6
- #define MODEL_MINE "models/w_models/weapons/w_eq_pipebomb.mdl"
- #define MODEL_BEAM "materials/sprites/laserbeam.vmt"
- public OnPluginStart()
- {
- HookEvent("grenade_bounce", EventGrenadeB);
- }
- public OnMapStart()
- {
- PrecacheModel("materials/sprites/laserbeam.vmt");
- }
- public EventGrenadeB(Event event, const char[] name, bool dontBroadcast)
- {
- new client = GetClientOfUserId(event.GetInt("userid"));
- new grenade = GetGrenade(client);
- PlaceMine(client);
- AcceptEntityInput(grenade, "Kill" );
- }
- GetGrenade(iClient)
- {
- decl String:sClass[32] = {"pipe_bomb_projectile"};
- for(new i = 0, iGrenade = -1; i < sizeof(sClass); i++)
- {
- while((iGrenade = FindEntityByClassname(iGrenade, sClass[i])) != -1)
- {
- if(GetEntPropEnt(iGrenade, Prop_Send, "m_hThrower") == iClient)
- return iGrenade;
- }
- }
- return 0;
- }
- public PlaceMine(client)
- {
- new grenade_main = GetGrenade(client);
- decl Float:trace_start[3], Float:trace_angle[3], Float:trace_end[3], Float:trace_normal[3];
- GetClientEyeAngles( client, trace_angle );
- GetAngleVectors( trace_angle, trace_end, NULL_VECTOR, NULL_VECTOR );
- NormalizeVector( trace_end, trace_end );
- GetEntPropVector(grenade_main, Prop_Send, "m_vecOrigin", trace_start);
- // offset start by near point
- for( new i = 0; i < 3; i++ )
- trace_start[i] += trace_end[i] * TRACE_START;
- for( new i = 0; i < 3; i++ )
- trace_end[i] = trace_start[i] + trace_end[i] * TRACE_LENGTH;
- TR_TraceRayFilter( trace_start, trace_end, CONTENTS_SOLID|CONTENTS_WINDOW, RayType_EndPoint, TraceFilter_All, 0 );
- if( TR_DidHit( INVALID_HANDLE ) )
- {
- TR_GetEndPosition( trace_end, INVALID_HANDLE );
- TR_GetPlaneNormal(INVALID_HANDLE, trace_normal);
- }
- new Float:position[3];
- TR_TraceRayFilter(position, trace_angle, CONTENTS_SOLID, RayType_Infinite, TraceFilter_All, 0);
- CreateLaser(trace_start, trace_end)
- }
- public CreateLaser(Float:start[3], Float:end[3])
- {
- new ent = CreateEntityByName("env_beam");
- if (ent != -1)
- {
- decl String:color[16];
- color = LASER_COLOR_D;
- TeleportEntity(ent, start, NULL_VECTOR, NULL_VECTOR);
- SetEntityModel(ent, MODEL_BEAM);
- SetEntPropVector(ent, Prop_Data, "m_vecEndPos", end);
- DispatchKeyValue(ent, "rendercolor", color );
- DispatchKeyValue(ent, "renderamt", "80");
- DispatchKeyValue(ent, "decalname", "Bigshot");
- DispatchKeyValue(ent, "life", "0");
- DispatchKeyValue(ent, "TouchType", "0");
- DispatchSpawn(ent);
- SetEntPropFloat(ent, Prop_Data, "m_fWidth", LASER_WIDTH);
- SetEntPropFloat(ent, Prop_Data, "m_fEndWidth", LASER_WIDTH);
- ActivateEntity(ent);
- AcceptEntityInput(ent, "TurnOn");
- }
- return ent;
- }
- public bool:TraceFilter_All( entity, contentsMask )
- {
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment