Senior Member
Join Date: Dec 2009
Location: Sydney, Australia
|
06-15-2013
, 05:52
Re: Help creating a "mine"
|
#5
|
Quote:
Originally Posted by Chaosxk
Whatever your using to trigger the mines off, use GetClientTeam(client) before it is triggered.
Then just make sure that only the opposite team of client can trigger it.
|
TBH, I don't really understand what's going on well enough to know where to do that...
Here's a fuller section of the code:
Code:
SetMine(client)
{
// setup unique target names for entities to be created with
new String:beam[64];
new String:beammdl[64];
new String:tmp[128];
Format(beam, sizeof(beam), "tmbeam%d", gCount);
Format(beammdl, sizeof(beammdl), "tmbeammdl%d", gCount);
gCount++;
if (gCount>10000)
{
gCount = 1;
}
// trace client view to get position and angles for tripmine
decl Float:start[3], Float:angle[3], Float:end[3], Float:normal[3], Float:beamend[3];
GetClientEyePosition( client, start );
GetClientEyeAngles( client, angle );
GetAngleVectors(angle, end, NULL_VECTOR, NULL_VECTOR);
NormalizeVector(end, end);
start[0]=start[0]+end[0]*TRACE_START;
start[1]=start[1]+end[1]*TRACE_START;
start[2]=start[2]+end[2]*TRACE_START;
end[0]=start[0]+end[0]*TRACE_END;
end[1]=start[1]+end[1]*TRACE_END;
end[2]=start[2]+end[2]*TRACE_END;
TR_TraceRayFilter(start, end, CONTENTS_SOLID, RayType_EndPoint, FilterAll, 0);
if (TR_DidHit(INVALID_HANDLE))
{
// update client's inventory
gRemaining[client]-=1;
// find angles for tripmine
TR_GetEndPosition(end, INVALID_HANDLE);
TR_GetPlaneNormal(INVALID_HANDLE, normal);
GetVectorAngles(normal, normal);
// trace laser beam
TR_TraceRayFilter(end, normal, CONTENTS_SOLID, RayType_Infinite, FilterAll, 0);
TR_GetEndPosition(beamend, INVALID_HANDLE);
// create tripmine model
new ent = CreateEntityByName("prop_physics_override");
SetEntityModel(ent,mdlMine);
DispatchKeyValue(ent, "StartDisabled", "false");
DispatchSpawn(ent);
TeleportEntity(ent, end, normal, NULL_VECTOR);
SetEntProp(ent, Prop_Send, "m_usSolidFlags", 152);
SetEntProp(ent, Prop_Send, "m_CollisionGroup", 1);
SetEntityMoveType(ent, MOVETYPE_NONE);
// SetEntProp(ent, Prop_Send, "m_MoveCollide", 0);
SetEntProp(ent, Prop_Send, "m_nSolidType", 6);
SetEntPropEnt(ent, Prop_Data, "m_hLastAttacker", client);
DispatchKeyValue(ent, "targetname", beammdl);
DispatchKeyValue(ent, "ExplodeRadius", "256");
DispatchKeyValue(ent, "ExplodeDamage", "400");
Format(tmp, sizeof(tmp), "%s,Break,,0,-1", beammdl);
DispatchKeyValue(ent, "OnHealthChanged", tmp);
Format(tmp, sizeof(tmp), "%s,Kill,,0,-1", beam);
DispatchKeyValue(ent, "OnBreak", tmp);
SetEntProp(ent, Prop_Data, "m_takedamage", 2);
AcceptEntityInput(ent, "Enable");
HookSingleEntityOutput(ent, "OnBreak", mineBreak, true);
// create laser beam
ent = CreateEntityByName("env_beam");
TeleportEntity(ent, beamend, NULL_VECTOR, NULL_VECTOR);
SetEntityModel(ent, MDL_LASER);
DispatchKeyValue(ent, "texture", MDL_LASER);
DispatchKeyValue(ent, "targetname", beam);
DispatchKeyValue(ent, "TouchType", "4");
DispatchKeyValue(ent, "LightningStart", beam);
DispatchKeyValue(ent, "BoltWidth", "4.0");
DispatchKeyValue(ent, "life", "0");
DispatchKeyValue(ent, "rendercolor", "0 0 0");
DispatchKeyValue(ent, "renderamt", "0");
DispatchKeyValue(ent, "HDRColorScale", "0.3");
DispatchKeyValue(ent, "decalname", "Bigshot");
DispatchKeyValue(ent, "StrikeTime", "0");
DispatchKeyValue(ent, "TextureScroll", "35");
Format(tmp, sizeof(tmp), "%s,Break,,0,-1", beammdl);
DispatchKeyValue(ent, "OnTouchedByEntity", tmp);
SetEntPropVector(ent, Prop_Send, "m_vecEndPos", end);
SetEntPropFloat(ent, Prop_Send, "m_fWidth", 4.0);
AcceptEntityInput(ent, "TurnOff");
new Handle:data = CreateDataPack();
CreateTimer(GetConVarFloat(cvActTime), TurnBeamOn, data);
WritePackCell(data, client);
WritePackCell(data, ent);
WritePackFloat(data, end[0]);
WritePackFloat(data, end[1]);
WritePackFloat(data, end[2]);
// play sound
EmitSoundToAll(SND_MINEPUT, ent, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, 100, ent, end, NULL_VECTOR, true, 0.0);
// send message
PrintHintText(client, "Tripmines remaining: %d", gRemaining[client]);
}
else
{
PrintHintText(client, "Invalid location for Tripmine");
}
}
public Action:TurnBeamOn(Handle:timer, Handle:data)
{
decl String:color[26];
ResetPack(data);
new client = ReadPackCell(data);
new ent = ReadPackCell(data);
if (IsValidEntity(ent))
{
new team = GetClientTeam(client);
if(team == TEAM_T) color = COLOR_T;
else if(team == TEAM_CT) color = COLOR_CT;
else color = COLOR_DEF;
DispatchKeyValue(ent, "rendercolor", color);
AcceptEntityInput(ent, "TurnOn");
new Float:end[3];
end[0] = ReadPackFloat(data);
end[1] = ReadPackFloat(data);
end[2] = ReadPackFloat(data);
EmitSoundToAll(SND_MINEACT, ent, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, 100, ent, end, NULL_VECTOR, true, 0.0);
}
CloseHandle(data);
}
public mineBreak (const String:output[], caller, activator, Float:delay)
{
UnhookSingleEntityOutput(caller, "OnBreak", mineBreak);
AcceptEntityInput(caller,"kill");
}
public bool:FilterAll (entity, contentsMask)
{
return false;
}
Is it in the minebreak function that I check?
Last edited by Remy Lebeau; 06-15-2013 at 05:53.
|
|