Conversation
|
okay, this doesn't work somehow, i'll rework it. |
|
Turns out this needs to be done with a delay. |
|
Hey I don't think that implementing snark aggression against players is a good idea as it would be easier to grief (spawn, throw snarks, suicide, repeat). In fact, it may be better for snarks to ignore players/friendly npcs regardless of |
|
Yeah, mp_friendlyfire makes sense here. |
good idea. |
Done in the way as described here. Guard and scientists still aren't happy to see player's snarks, but I guess it's fine ? |
|
I have working filter for ally NPCs now, the only issue is that they still can ask for help. |
but security still asks for help due to how it's done in the code, i tried using SetReletationship input on snarks, but i still have to idea why it says that the syntax is incorrect
|
No ally agro on snarks now, but security still asks for help due to how it's done in the code, i tried using SetReletationship input on snarks, but i still have to idea why it says that the syntax is incorrect. |
ampreeT
left a comment
There was a problem hiding this comment.
Tested on Linux Dedicated server. Implementation is working as described and looks good to me. Did you test on a Windows server?
Fix up the syntax/styling issues and we can get this merged in. Thanks!
| CAI_BaseNPC pEnemy = CAI_BaseNPC(DHookGetParam(hParams, 1)); | ||
|
|
||
| //not valid target | ||
| if (!pEnemy.IsValid()) |
There was a problem hiding this comment.
Change this line to if (pEnemy == NULL_CBASEENTITY)
|
|
||
| if (strcmp(szClassname, "npc_snark") == 0) | ||
| { | ||
| CBasePlayer pOwner = CBasePlayer(CNpc_Snark(pEnemy.entindex).GetSnarkOwner()); |
There was a problem hiding this comment.
Methodmap function GetSnarkOwner currently returns int. It should return CBaseEntity. When that is fixed, change this line to:
CNpc_Snark pSnark = view_as<CNpc_Snark>(pEnemy);
CBaseEntity pOwner = pSnark.GetSnarkOwner();
... // cast to player if it is still needed after checking entity is valid player| //------------------------------------------------------ | ||
| public void Hook_Snark_OnCreated(const int iEntIndex) | ||
| { | ||
| if (CBaseEntity(iEntIndex).GetHammerID() != 0) //don't for map-placed |
There was a problem hiding this comment.
Change to:
CNpc_Snark pSnark = CNpc_Snark(iEntIndex);
if (pSnark.GetHammerID() != 0) //don't for map-placed| if (CBaseEntity(iEntIndex).GetHammerID() != 0) //don't for map-placed | ||
| return; | ||
|
|
||
| CBasePlayer pPlayer = CBasePlayer(CNpc_Snark(iEntIndex).GetSnarkOwner()); |
There was a problem hiding this comment.
Change to:
CBaseEntity pOwner = pSnark.GetSnarkOwner();
if (pOwner == NULL_CBASEENTITY || !pOwner.IsPlayer())
return;
CBasePlayer pPlayer = view_as<CBasePlayer>(pOwner);| return; | ||
|
|
||
| int iTeam = (mp_friendlyfire.BoolValue) ? TEAM_ANY : pPlayer.GetTeam(); | ||
| SetEntProp(iEntIndex, Prop_Data, "m_iInitialTeamNum", iTeam); |
There was a problem hiding this comment.
Change to:
pSnark.SetInitialTeam(iTeam);
pSnark.SetTeam(iTeam);| return MRES_Ignored; | ||
|
|
||
| CAI_BaseNPC pEnemy = CAI_BaseNPC(DHookGetParam(hParams, 1)); | ||
| if (!pEnemy.IsValid()) |
There was a problem hiding this comment.
Change to:
if (pEnemy == NULL_CBASEENTITY)| return MRES_Ignored; | ||
|
|
||
| //guard is PROVOKED | ||
| if (HasEntProp(pEnemy.entindex, Prop_Data, "m_afMemory") && pEnemy.m_afMemory & bits_MEMORY_PROVOKED) |
There was a problem hiding this comment.
Not familar with this implementation. What is the point of checking if the entity has the netprop m_afMemory?
| SetEntPropFloat(this.entindex, Prop_Data, "m_fLifeTime", flLifeTime); | ||
| } | ||
|
|
||
| public int GetSnarkOwner() |
There was a problem hiding this comment.
Change this so it returns CBaseEntity:
public CBaseEntity GetSnarkOwner()
{
return CBaseEntity(GetEntPropEnt(this.entindex, Prop_Data, "m_hOwner"));
}| return GetEntPropEnt(this.entindex, Prop_Data, "m_hOwner"); | ||
| } | ||
|
|
||
| public void SetSnarkOwner(int iEntIndex) |
There was a problem hiding this comment.
Change this:
public void SetSnarkOwner(const CBaseEntity pOwner)
{
SetEntPropEnt(this.entindex, Prop_Data, "m_hOwner", pOwner.entindex);
}| #if defined ENTPATCH_BM_SNARK | ||
| if (strcmp(szClassname, "npc_snark") == 0 && CoopManager.IsCoopModeEnabled()) | ||
| { | ||
| RequestFrame(Hook_Snark_OnCreated, iEntIndex); |
There was a problem hiding this comment.
Instead of using RequestFrame, try using a post spawn hook here using SDKhooks
I gonna try to fix sec guard issue first once I can dedicate the time again, i have an idea. It was tested with listening servers on Windows. |
|
Found few issues. |
Fixes #300
Replaces teamnum value to make IsValidEnemy() pass players even if mp_teamplay is enabled to make snarks aggressive to all players, just like in sp/dm. Filtered map-placed snarks for certain reasons.
Includes ENTPATCH_BM_SNARK macro.