EntityPostHook Condition not working

Please post any questions about developing your plugin here. Please use the search function before posting!
12jdlovins
Junior Member
Posts: 17
Joined: Mon Apr 16, 2018 5:11 am

EntityPostHook Condition not working

Postby 12jdlovins » Sat Apr 21, 2018 3:00 am

So i'm trying to create an entity and hook them, creating them is working so-so i think.. just need to figure out coordinates however for the PostHook it's hooking things that arent met in the condition.

Syntax: Select all

@EntityPostHook(EntityCondition.equals_entity_classname("trigger_multiple"), 'start_touch')
def Entity_StartTouch(args, ret):
entity = make_object(Entity, args[0])
print(f"entity index: {entity.index}")
print(f"class name: {entity.classname} - target_name: {entity.target_name}")


In theory this should ONLY pass if the triggers classname is "trigger_multiple", however it is hitting on other triggers as well.

Code: Select all

entity index: 44
class name: trigger_teleport - target_name:
entity index: 119
class name: trigger_push - target_name:


This trigger_teleport and trigger_push are getting passed through for some reason. Any ideas on why that would be happening?
Last edited by Ayuto on Sat Apr 21, 2018 10:22 am, edited 1 time in total.
Reason: code -> python
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: EntityPostHook Condition not working

Postby Ayuto » Sat Apr 21, 2018 10:31 am

This is expected behaviour. The entity condition only determines the entity that is used to hook the function. Now, look at the virtual function table of CTriggerMultiple:

Code: Select all

Inheritance Tree:
 CTriggerMultiple
  CBaseTrigger
   CBaseToggle
    CBaseEntity
     IServerEntity
      IServerUnknown
       IHandleEntity

VTable for CTriggerMultiple: (0, 0)
 Lin  Win Function
   0    0 CTriggerMultiple::~CTriggerMultiple()
   1    0 CTriggerMultiple::~CTriggerMultiple()
   2    1 CBaseEntity::SetRefEHandle(CBaseHandle  const&)
   3    2 CBaseEntity::GetRefEHandle(void)const
   4    3 CBaseEntity::GetCollideable(void)
   5    4 CBaseEntity::GetNetworkable(void)
   6    5 CBaseEntity::GetBaseEntity(void)
   7    6 CBaseEntity::GetModelIndex(void)const
   8    7 CBaseEntity::GetModelName(void)const
   9    8 CBaseEntity::SetModelIndex(int)
  10    9 CBaseEntity::GetServerClass(void)
  11   10 CBaseEntity::YouForgotToImplementOrDeclareServerClass(void)
  12   11 CTriggerMultiple::GetDataDescMap(void)
  13   12 CBaseEntity::SetModelIndexOverride(int, int)
  14   13 CBaseEntity::TestCollision(Ray_t  const&, unsigned int, CGameTrace &)
  15   14 CBaseEntity::TestHitboxes(Ray_t  const&, unsigned int, CGameTrace &)
  16   15 CBaseEntity::ComputeWorldSpaceSurroundingBox(Vector *, Vector *)
  17   16 CBaseEntity::ShouldCollide(int, int)const
  18   17 CBaseEntity::SetOwnerEntity(CBaseEntity*)
  19   18 CBaseEntity::ShouldTransmit(CCheckTransmitInfo  const*)
  20   19 CBaseEntity::UpdateTransmitState(void)
  21   20 CBaseEntity::SetTransmit(CCheckTransmitInfo *, bool)
  22   21 CBaseEntity::GetTracerType(void)
  23   22 CTriggerMultiple::Spawn(void)
  24   23 CBaseEntity::Precache(void)
  25   24 CBaseEntity::SetModel(char  const*)
  26   25 CBaseEntity::OnNewModel(void)
  27   26 CBaseEntity::PostConstructor(char  const*)
  28   27 CBaseTrigger::PostClientActive(void)
  29   28 CBaseEntity::ParseMapData(CEntityMapData *)
  30   30 CBaseToggle::KeyValue(char  const*, char  const*)
  31   29 CBaseToggle::KeyValue(char  const*, float)
  32   31 CBaseEntity::KeyValue(char  const*, Vector  const&)
  33   32 CBaseEntity::GetKeyValue(char  const*, char *, int)
  34   33 CBaseTrigger::Activate(void)
  35   34 CBaseEntity::SetParent(CBaseEntity*, int)
  36   35 CBaseEntity::ObjectCaps(void)
  37   36 CBaseEntity::AcceptInput(char  const*, CBaseEntity*, CBaseEntity*, variant_t, int)
  38   37 CBaseEntity::GetInputDispatchEffectPosition(char  const*, Vector &, QAngle &)
  39   38 CBaseEntity::DrawDebugGeometryOverlays(void)
  40   39 CBaseTrigger::DrawDebugTextOverlays(void)
  41   40 CBaseEntity::Save(ISave &)
  42   41 CBaseEntity::Restore(IRestore &)
  43   42 CBaseEntity::ShouldSavePhysics(void)
  44   43 CBaseEntity::OnSave(IEntitySaveUtils *)
  45   44 CBaseEntity::OnRestore(void)
  46   45 CBaseEntity::RequiredEdictIndex(void)
  47   46 CBaseToggle::MoveDone(void)
  48   47 CBaseEntity::Think(void)
  49   49 CBaseEntity::NetworkStateChanged_m_nNextThinkTick(void)
  50   48 CBaseEntity::NetworkStateChanged_m_nNextThinkTick(void *)
  51   50 CBaseEntity::GetBaseAnimating(void)
  52   51 CBaseEntity::GetResponseSystem(void)
  53   52 CBaseEntity::DispatchResponse(char  const*)
  54   53 CBaseEntity::Classify(void)
  55   54 CBaseEntity::DeathNotice(CBaseEntity*)
  56   55 CBaseEntity::ShouldAttractAutoAim(CBaseEntity*)
  57   56 CBaseEntity::GetAutoAimRadius(void)
  58   57 CBaseEntity::GetAutoAimCenter(void)
  59   58 CBaseEntity::GetBeamTraceFilter(void)
  60   59 CBaseEntity::PassesDamageFilter(CTakeDamageInfo  const&)
  61   60 CBaseEntity::TraceAttack(CTakeDamageInfo  const&, Vector  const&, CGameTrace *, CDmgAccumulator *)
  62   61 CBaseEntity::CanBeHitByMeleeAttack(CBaseEntity*)
  63   62 CBaseEntity::OnTakeDamage(CTakeDamageInfo  const&)
  64   63 CBaseEntity::AdjustDamageDirection(CTakeDamageInfo  const&, Vector &, CBaseEntity*)
  65   64 CBaseEntity::TakeHealth(float, int)
  66   65 CBaseEntity::IsAlive(void)
  67   66 CBaseEntity::Event_Killed(CTakeDamageInfo  const&)
  68   67 CBaseEntity::Event_KilledOther(CBaseEntity*, CTakeDamageInfo  const&)
  69   68 CBaseEntity::BloodColor(void)
  70   69 CBaseEntity::IsTriggered(CBaseEntity*)
  71   70 CBaseEntity::IsNPC(void)const
  72   71 CBaseEntity::MyCombatCharacterPointer(void)
  73   72 CBaseEntity::MyNextBotPointer(void)
  74   73 CBaseToggle::GetDelay(void)
  75   74 CBaseEntity::IsMoving(void)
  76   75 CBaseEntity::DamageDecal(int, int)
  77   76 CBaseEntity::DecalTrace(CGameTrace *, char  const*)
  78   77 CBaseEntity::ImpactTrace(CGameTrace *, int, char  const*)
  79   78 CBaseEntity::OnControls(CBaseEntity*)
  80   79 CBaseEntity::HasTarget(string_t)
  81   80 CBaseEntity::IsPlayer(void)const
  82   81 CBaseEntity::IsNetClient(void)const
  83   82 CBaseEntity::IsTemplate(void)
  84   83 CBaseEntity::IsBaseObject(void)const
  85   84 CBaseEntity::IsBaseTrain(void)const
  86   85 CBaseEntity::IsCombatItem(void)const
  87   86 CBaseEntity::IsBaseCombatWeapon(void)const
  88   87 CBaseEntity::IsWearable(void)const
  89   88 CBaseEntity::MyCombatWeaponPointer(void)
  90   89 CBaseEntity::GetServerVehicle(void)
  91   90 CBaseEntity::IsViewable(void)
  92   91 CBaseEntity::ChangeTeam(int)
  93   92 CBaseEntity::OnEntityEvent(EntityEvent_t, void *)
  94   94 CBaseEntity::CanStandOn(CBaseEntity*)const
  95   93 CBaseEntity::CanStandOn(edict_t *)const
  96   96 CBaseEntity::GetEnemy(void)
  97   95 CBaseEntity::GetEnemy(void)const
  98   97 CBaseEntity::Use(CBaseEntity*, CBaseEntity*, USE_TYPE, float)
  99   98 CBaseTrigger::StartTouch(CBaseEntity *)
 100   99 CBaseEntity::Touch(CBaseEntity*)
 101  100 CBaseTrigger::EndTouch(CBaseEntity *)
 102  101 CBaseEntity::StartBlocked(CBaseEntity*)
 103  102 CBaseEntity::Blocked(CBaseEntity*)
 104  103 CBaseEntity::EndBlocked(void)
 105  104 CBaseEntity::PhysicsSimulate(void)
 106  105 CBaseTrigger::UpdateOnRemove(void)
 107  106 CBaseEntity::StopLoopingSounds(void)
 108  107 CBaseEntity::SUB_AllowedToFade(void)
 109  108 CBaseEntity::Teleport(Vector  const*, QAngle  const*, Vector  const*)
 110  109 CBaseEntity::NotifySystemEvent(CBaseEntity*, notify_system_event_t, notify_system_event_params_t  const&)
 111  110 CBaseEntity::MakeTracer(Vector  const&, CGameTrace  const&, int)
 112  111 CBaseEntity::GetTracerAttachment(void)
 113  112 CBaseEntity::FireBullets(FireBulletsInfo_t  const&)
 114  113 CBaseEntity::DoImpactEffect(CGameTrace &, int)
 115  114 CBaseEntity::ModifyFireBulletsDamage(CTakeDamageInfo *)
 116  115 CBaseEntity::Respawn(void)
 117  116 CBaseToggle::IsLockedByMaster(void)
 118  117 CBaseEntity::GetMaxHealth(void)const
 119  118 CBaseEntity::ModifyOrAppendCriteria(AI_CriteriaSet &)
 120  120 CBaseEntity::NetworkStateChanged_m_iMaxHealth(void)
 121  119 CBaseEntity::NetworkStateChanged_m_iMaxHealth(void *)
 122  122 CBaseEntity::NetworkStateChanged_m_iHealth(void)
 123  121 CBaseEntity::NetworkStateChanged_m_iHealth(void *)
 124  124 CBaseEntity::NetworkStateChanged_m_lifeState(void)
 125  123 CBaseEntity::NetworkStateChanged_m_lifeState(void *)
 126  126 CBaseEntity::NetworkStateChanged_m_takedamage(void)
 127  125 CBaseEntity::NetworkStateChanged_m_takedamage(void *)
 128  127 CBaseEntity::GetDamageType(void)const
 129  128 CBaseEntity::GetDamage(void)
 130  129 CBaseEntity::SetDamage(float)
 131  130 CBaseEntity::EyePosition(void)
 132  131 CBaseEntity::EyeAngles(void)
 133  132 CBaseEntity::LocalEyeAngles(void)
 134  133 CBaseEntity::EarPosition(void)
 135  134 CBaseEntity::BodyTarget(Vector  const&, bool)
 136  135 CBaseEntity::HeadTarget(Vector  const&)
 137  136 CBaseEntity::GetVectors(Vector *, Vector *, Vector *)const
 138  137 CBaseEntity::GetViewOffset(void)const
 139  138 CBaseEntity::SetViewOffset(Vector  const&)
 140  139 CBaseEntity::GetSmoothedVelocity(void)
 141  140 CBaseEntity::GetVelocity(Vector *, Vector *)
 142  142 CBaseEntity::FVisible(CBaseEntity*, int, CBaseEntity**)
 143  141 CBaseEntity::FVisible(Vector  const&, int, CBaseEntity**)
 144  143 CBaseEntity::CanBeSeenBy(CAI_BaseNPC *)
 145  144 CBaseEntity::GetAttackDamageScale(CBaseEntity*)
 146  145 CBaseEntity::GetReceivedDamageScale(CBaseEntity*)
 147  146 CBaseEntity::GetGroundVelocityToApply(Vector &)
 148  147 CBaseEntity::PhysicsSplash(Vector  const&, Vector  const&, float, float)
 149  148 CBaseEntity::Splash(void)
 150  149 CBaseEntity::WorldSpaceCenter(void)const
 151  150 CBaseEntity::GetSoundEmissionOrigin(void)const
 152  151 CBaseEntity::ModifyEmitSoundParams(EmitSound_t &)
 153  152 CBaseEntity::IsDeflectable(void)
 154  153 CBaseEntity::Deflected(CBaseEntity*, Vector &)
 155  154 CBaseEntity::CreateVPhysics(void)
 156  155 CBaseEntity::ForceVPhysicsCollide(CBaseEntity*)
 157  156 CBaseEntity::VPhysicsDestroyObject(void)
 158  157 CBaseEntity::VPhysicsUpdate(IPhysicsObject *)
 159  158 CBaseEntity::VPhysicsTakeDamage(CTakeDamageInfo  const&)
 160  159 CBaseEntity::VPhysicsShadowCollision(int, gamevcollisionevent_t *)
 161  160 CBaseEntity::VPhysicsShadowUpdate(IPhysicsObject *)
 162  161 CBaseEntity::VPhysicsCollision(int, gamevcollisionevent_t *)
 163  162 CBaseEntity::VPhysicsFriction(IPhysicsObject *, float, int, int)
 164  163 CBaseEntity::UpdatePhysicsShadowToCurrentPosition(float)
 165  164 CBaseEntity::VPhysicsGetObjectList(IPhysicsObject **, int)
 166  165 CBaseEntity::VPhysicsIsFlesh(void)
 167  166 CBaseEntity::HasPhysicsAttacker(float)
 168  167 CBaseEntity::PhysicsSolidMaskForEntity(void)const
 169  168 CBaseEntity::ResolveFlyCollisionCustom(CGameTrace &, Vector &)
 170  169 CBaseEntity::PerformCustomPhysics(Vector *, Vector *, QAngle *, QAngle *)
 171  170 CBaseEntity::GetStepOrigin(void)const
 172  171 CBaseEntity::GetStepAngles(void)const
 173  172 CBaseEntity::ShouldDrawWaterImpacts(void)
 174  174 CBaseEntity::NetworkStateChanged_m_fFlags(void)
 175  173 CBaseEntity::NetworkStateChanged_m_fFlags(void *)
 176  176 CBaseEntity::NetworkStateChanged_m_nWaterLevel(void)
 177  175 CBaseEntity::NetworkStateChanged_m_nWaterLevel(void *)
 178  178 CBaseEntity::NetworkStateChanged_m_hGroundEntity(void)
 179  177 CBaseEntity::NetworkStateChanged_m_hGroundEntity(void *)
 180  180 CBaseEntity::NetworkStateChanged_m_vecBaseVelocity(void)
 181  179 CBaseEntity::NetworkStateChanged_m_vecBaseVelocity(void *)
 182  182 CBaseEntity::NetworkStateChanged_m_flFriction(void)
 183  181 CBaseEntity::NetworkStateChanged_m_flFriction(void *)
 184  184 CBaseEntity::NetworkStateChanged_m_vecVelocity(void)
 185  183 CBaseEntity::NetworkStateChanged_m_vecVelocity(void *)
 186  186 CBaseEntity::NetworkStateChanged_m_vecViewOffset(void)
 187  185 CBaseEntity::NetworkStateChanged_m_vecViewOffset(void *)
 188  187 CBaseEntity::ShouldBlockNav(void)const
 189  188 CBaseToggle::KeyValue(char  const*, Vector)
 190  189 CBaseTrigger::InputEnable(inputdata_t &)
 191  190 CBaseTrigger::InputDisable(inputdata_t &)
 192  191 CBaseTrigger::InputToggle(inputdata_t &)
 193  192 CBaseTrigger::InputTouchTest(inputdata_t &)
 194  193 CBaseTrigger::InputStartTouch(inputdata_t &)
 195  194 CBaseTrigger::InputEndTouch(inputdata_t &)
 196  195 CBaseTrigger::UsesFilter(void)
 197  196 CBaseTrigger::PassesTriggerFilters(CBaseEntity *)
 198  197 CBaseTrigger::StartTouchAll(void)
 199  198 CBaseTrigger::EndTouchAll(void)
As you can see CTriggerMultiple has no own implementation of StartTouch, but uses the implementation of CBaseTrigger, which is the base class for all triggers. Thus, your hook is called for other trigger types as well.

If you wish to filter the calls, you need to do that on your own.

Syntax: Select all

@EntityPostHook(EntityCondition.equals_entity_classname("trigger_multiple"), 'start_touch')
def Entity_StartTouch(args, ret):
entity = make_object(Entity, args[0])
if entity.classname != 'trigger_multiple':
return

# Your code here
12jdlovins
Junior Member
Posts: 17
Joined: Mon Apr 16, 2018 5:11 am

Re: EntityPostHook Condition not working

Postby 12jdlovins » Sat Apr 21, 2018 3:36 pm

Ayuto wrote:This is expected behaviour. The entity condition only determines the entity that is used to hook the function. Now, look at the virtual function table of CTriggerMultiple:

Code: Select all

Inheritance Tree:
 CTriggerMultiple
  CBaseTrigger
   CBaseToggle
    CBaseEntity
     IServerEntity
      IServerUnknown
       IHandleEntity

VTable for CTriggerMultiple: (0, 0)
 Lin  Win Function
   0    0 CTriggerMultiple::~CTriggerMultiple()
   1    0 CTriggerMultiple::~CTriggerMultiple()
   2    1 CBaseEntity::SetRefEHandle(CBaseHandle  const&)
   3    2 CBaseEntity::GetRefEHandle(void)const
   4    3 CBaseEntity::GetCollideable(void)
   5    4 CBaseEntity::GetNetworkable(void)
   6    5 CBaseEntity::GetBaseEntity(void)
   7    6 CBaseEntity::GetModelIndex(void)const
   8    7 CBaseEntity::GetModelName(void)const
   9    8 CBaseEntity::SetModelIndex(int)
  10    9 CBaseEntity::GetServerClass(void)
  11   10 CBaseEntity::YouForgotToImplementOrDeclareServerClass(void)
  12   11 CTriggerMultiple::GetDataDescMap(void)
  13   12 CBaseEntity::SetModelIndexOverride(int, int)
  14   13 CBaseEntity::TestCollision(Ray_t  const&, unsigned int, CGameTrace &)
  15   14 CBaseEntity::TestHitboxes(Ray_t  const&, unsigned int, CGameTrace &)
  16   15 CBaseEntity::ComputeWorldSpaceSurroundingBox(Vector *, Vector *)
  17   16 CBaseEntity::ShouldCollide(int, int)const
  18   17 CBaseEntity::SetOwnerEntity(CBaseEntity*)
  19   18 CBaseEntity::ShouldTransmit(CCheckTransmitInfo  const*)
  20   19 CBaseEntity::UpdateTransmitState(void)
  21   20 CBaseEntity::SetTransmit(CCheckTransmitInfo *, bool)
  22   21 CBaseEntity::GetTracerType(void)
  23   22 CTriggerMultiple::Spawn(void)
  24   23 CBaseEntity::Precache(void)
  25   24 CBaseEntity::SetModel(char  const*)
  26   25 CBaseEntity::OnNewModel(void)
  27   26 CBaseEntity::PostConstructor(char  const*)
  28   27 CBaseTrigger::PostClientActive(void)
  29   28 CBaseEntity::ParseMapData(CEntityMapData *)
  30   30 CBaseToggle::KeyValue(char  const*, char  const*)
  31   29 CBaseToggle::KeyValue(char  const*, float)
  32   31 CBaseEntity::KeyValue(char  const*, Vector  const&)
  33   32 CBaseEntity::GetKeyValue(char  const*, char *, int)
  34   33 CBaseTrigger::Activate(void)
  35   34 CBaseEntity::SetParent(CBaseEntity*, int)
  36   35 CBaseEntity::ObjectCaps(void)
  37   36 CBaseEntity::AcceptInput(char  const*, CBaseEntity*, CBaseEntity*, variant_t, int)
  38   37 CBaseEntity::GetInputDispatchEffectPosition(char  const*, Vector &, QAngle &)
  39   38 CBaseEntity::DrawDebugGeometryOverlays(void)
  40   39 CBaseTrigger::DrawDebugTextOverlays(void)
  41   40 CBaseEntity::Save(ISave &)
  42   41 CBaseEntity::Restore(IRestore &)
  43   42 CBaseEntity::ShouldSavePhysics(void)
  44   43 CBaseEntity::OnSave(IEntitySaveUtils *)
  45   44 CBaseEntity::OnRestore(void)
  46   45 CBaseEntity::RequiredEdictIndex(void)
  47   46 CBaseToggle::MoveDone(void)
  48   47 CBaseEntity::Think(void)
  49   49 CBaseEntity::NetworkStateChanged_m_nNextThinkTick(void)
  50   48 CBaseEntity::NetworkStateChanged_m_nNextThinkTick(void *)
  51   50 CBaseEntity::GetBaseAnimating(void)
  52   51 CBaseEntity::GetResponseSystem(void)
  53   52 CBaseEntity::DispatchResponse(char  const*)
  54   53 CBaseEntity::Classify(void)
  55   54 CBaseEntity::DeathNotice(CBaseEntity*)
  56   55 CBaseEntity::ShouldAttractAutoAim(CBaseEntity*)
  57   56 CBaseEntity::GetAutoAimRadius(void)
  58   57 CBaseEntity::GetAutoAimCenter(void)
  59   58 CBaseEntity::GetBeamTraceFilter(void)
  60   59 CBaseEntity::PassesDamageFilter(CTakeDamageInfo  const&)
  61   60 CBaseEntity::TraceAttack(CTakeDamageInfo  const&, Vector  const&, CGameTrace *, CDmgAccumulator *)
  62   61 CBaseEntity::CanBeHitByMeleeAttack(CBaseEntity*)
  63   62 CBaseEntity::OnTakeDamage(CTakeDamageInfo  const&)
  64   63 CBaseEntity::AdjustDamageDirection(CTakeDamageInfo  const&, Vector &, CBaseEntity*)
  65   64 CBaseEntity::TakeHealth(float, int)
  66   65 CBaseEntity::IsAlive(void)
  67   66 CBaseEntity::Event_Killed(CTakeDamageInfo  const&)
  68   67 CBaseEntity::Event_KilledOther(CBaseEntity*, CTakeDamageInfo  const&)
  69   68 CBaseEntity::BloodColor(void)
  70   69 CBaseEntity::IsTriggered(CBaseEntity*)
  71   70 CBaseEntity::IsNPC(void)const
  72   71 CBaseEntity::MyCombatCharacterPointer(void)
  73   72 CBaseEntity::MyNextBotPointer(void)
  74   73 CBaseToggle::GetDelay(void)
  75   74 CBaseEntity::IsMoving(void)
  76   75 CBaseEntity::DamageDecal(int, int)
  77   76 CBaseEntity::DecalTrace(CGameTrace *, char  const*)
  78   77 CBaseEntity::ImpactTrace(CGameTrace *, int, char  const*)
  79   78 CBaseEntity::OnControls(CBaseEntity*)
  80   79 CBaseEntity::HasTarget(string_t)
  81   80 CBaseEntity::IsPlayer(void)const
  82   81 CBaseEntity::IsNetClient(void)const
  83   82 CBaseEntity::IsTemplate(void)
  84   83 CBaseEntity::IsBaseObject(void)const
  85   84 CBaseEntity::IsBaseTrain(void)const
  86   85 CBaseEntity::IsCombatItem(void)const
  87   86 CBaseEntity::IsBaseCombatWeapon(void)const
  88   87 CBaseEntity::IsWearable(void)const
  89   88 CBaseEntity::MyCombatWeaponPointer(void)
  90   89 CBaseEntity::GetServerVehicle(void)
  91   90 CBaseEntity::IsViewable(void)
  92   91 CBaseEntity::ChangeTeam(int)
  93   92 CBaseEntity::OnEntityEvent(EntityEvent_t, void *)
  94   94 CBaseEntity::CanStandOn(CBaseEntity*)const
  95   93 CBaseEntity::CanStandOn(edict_t *)const
  96   96 CBaseEntity::GetEnemy(void)
  97   95 CBaseEntity::GetEnemy(void)const
  98   97 CBaseEntity::Use(CBaseEntity*, CBaseEntity*, USE_TYPE, float)
  99   98 CBaseTrigger::StartTouch(CBaseEntity *)
 100   99 CBaseEntity::Touch(CBaseEntity*)
 101  100 CBaseTrigger::EndTouch(CBaseEntity *)
 102  101 CBaseEntity::StartBlocked(CBaseEntity*)
 103  102 CBaseEntity::Blocked(CBaseEntity*)
 104  103 CBaseEntity::EndBlocked(void)
 105  104 CBaseEntity::PhysicsSimulate(void)
 106  105 CBaseTrigger::UpdateOnRemove(void)
 107  106 CBaseEntity::StopLoopingSounds(void)
 108  107 CBaseEntity::SUB_AllowedToFade(void)
 109  108 CBaseEntity::Teleport(Vector  const*, QAngle  const*, Vector  const*)
 110  109 CBaseEntity::NotifySystemEvent(CBaseEntity*, notify_system_event_t, notify_system_event_params_t  const&)
 111  110 CBaseEntity::MakeTracer(Vector  const&, CGameTrace  const&, int)
 112  111 CBaseEntity::GetTracerAttachment(void)
 113  112 CBaseEntity::FireBullets(FireBulletsInfo_t  const&)
 114  113 CBaseEntity::DoImpactEffect(CGameTrace &, int)
 115  114 CBaseEntity::ModifyFireBulletsDamage(CTakeDamageInfo *)
 116  115 CBaseEntity::Respawn(void)
 117  116 CBaseToggle::IsLockedByMaster(void)
 118  117 CBaseEntity::GetMaxHealth(void)const
 119  118 CBaseEntity::ModifyOrAppendCriteria(AI_CriteriaSet &)
 120  120 CBaseEntity::NetworkStateChanged_m_iMaxHealth(void)
 121  119 CBaseEntity::NetworkStateChanged_m_iMaxHealth(void *)
 122  122 CBaseEntity::NetworkStateChanged_m_iHealth(void)
 123  121 CBaseEntity::NetworkStateChanged_m_iHealth(void *)
 124  124 CBaseEntity::NetworkStateChanged_m_lifeState(void)
 125  123 CBaseEntity::NetworkStateChanged_m_lifeState(void *)
 126  126 CBaseEntity::NetworkStateChanged_m_takedamage(void)
 127  125 CBaseEntity::NetworkStateChanged_m_takedamage(void *)
 128  127 CBaseEntity::GetDamageType(void)const
 129  128 CBaseEntity::GetDamage(void)
 130  129 CBaseEntity::SetDamage(float)
 131  130 CBaseEntity::EyePosition(void)
 132  131 CBaseEntity::EyeAngles(void)
 133  132 CBaseEntity::LocalEyeAngles(void)
 134  133 CBaseEntity::EarPosition(void)
 135  134 CBaseEntity::BodyTarget(Vector  const&, bool)
 136  135 CBaseEntity::HeadTarget(Vector  const&)
 137  136 CBaseEntity::GetVectors(Vector *, Vector *, Vector *)const
 138  137 CBaseEntity::GetViewOffset(void)const
 139  138 CBaseEntity::SetViewOffset(Vector  const&)
 140  139 CBaseEntity::GetSmoothedVelocity(void)
 141  140 CBaseEntity::GetVelocity(Vector *, Vector *)
 142  142 CBaseEntity::FVisible(CBaseEntity*, int, CBaseEntity**)
 143  141 CBaseEntity::FVisible(Vector  const&, int, CBaseEntity**)
 144  143 CBaseEntity::CanBeSeenBy(CAI_BaseNPC *)
 145  144 CBaseEntity::GetAttackDamageScale(CBaseEntity*)
 146  145 CBaseEntity::GetReceivedDamageScale(CBaseEntity*)
 147  146 CBaseEntity::GetGroundVelocityToApply(Vector &)
 148  147 CBaseEntity::PhysicsSplash(Vector  const&, Vector  const&, float, float)
 149  148 CBaseEntity::Splash(void)
 150  149 CBaseEntity::WorldSpaceCenter(void)const
 151  150 CBaseEntity::GetSoundEmissionOrigin(void)const
 152  151 CBaseEntity::ModifyEmitSoundParams(EmitSound_t &)
 153  152 CBaseEntity::IsDeflectable(void)
 154  153 CBaseEntity::Deflected(CBaseEntity*, Vector &)
 155  154 CBaseEntity::CreateVPhysics(void)
 156  155 CBaseEntity::ForceVPhysicsCollide(CBaseEntity*)
 157  156 CBaseEntity::VPhysicsDestroyObject(void)
 158  157 CBaseEntity::VPhysicsUpdate(IPhysicsObject *)
 159  158 CBaseEntity::VPhysicsTakeDamage(CTakeDamageInfo  const&)
 160  159 CBaseEntity::VPhysicsShadowCollision(int, gamevcollisionevent_t *)
 161  160 CBaseEntity::VPhysicsShadowUpdate(IPhysicsObject *)
 162  161 CBaseEntity::VPhysicsCollision(int, gamevcollisionevent_t *)
 163  162 CBaseEntity::VPhysicsFriction(IPhysicsObject *, float, int, int)
 164  163 CBaseEntity::UpdatePhysicsShadowToCurrentPosition(float)
 165  164 CBaseEntity::VPhysicsGetObjectList(IPhysicsObject **, int)
 166  165 CBaseEntity::VPhysicsIsFlesh(void)
 167  166 CBaseEntity::HasPhysicsAttacker(float)
 168  167 CBaseEntity::PhysicsSolidMaskForEntity(void)const
 169  168 CBaseEntity::ResolveFlyCollisionCustom(CGameTrace &, Vector &)
 170  169 CBaseEntity::PerformCustomPhysics(Vector *, Vector *, QAngle *, QAngle *)
 171  170 CBaseEntity::GetStepOrigin(void)const
 172  171 CBaseEntity::GetStepAngles(void)const
 173  172 CBaseEntity::ShouldDrawWaterImpacts(void)
 174  174 CBaseEntity::NetworkStateChanged_m_fFlags(void)
 175  173 CBaseEntity::NetworkStateChanged_m_fFlags(void *)
 176  176 CBaseEntity::NetworkStateChanged_m_nWaterLevel(void)
 177  175 CBaseEntity::NetworkStateChanged_m_nWaterLevel(void *)
 178  178 CBaseEntity::NetworkStateChanged_m_hGroundEntity(void)
 179  177 CBaseEntity::NetworkStateChanged_m_hGroundEntity(void *)
 180  180 CBaseEntity::NetworkStateChanged_m_vecBaseVelocity(void)
 181  179 CBaseEntity::NetworkStateChanged_m_vecBaseVelocity(void *)
 182  182 CBaseEntity::NetworkStateChanged_m_flFriction(void)
 183  181 CBaseEntity::NetworkStateChanged_m_flFriction(void *)
 184  184 CBaseEntity::NetworkStateChanged_m_vecVelocity(void)
 185  183 CBaseEntity::NetworkStateChanged_m_vecVelocity(void *)
 186  186 CBaseEntity::NetworkStateChanged_m_vecViewOffset(void)
 187  185 CBaseEntity::NetworkStateChanged_m_vecViewOffset(void *)
 188  187 CBaseEntity::ShouldBlockNav(void)const
 189  188 CBaseToggle::KeyValue(char  const*, Vector)
 190  189 CBaseTrigger::InputEnable(inputdata_t &)
 191  190 CBaseTrigger::InputDisable(inputdata_t &)
 192  191 CBaseTrigger::InputToggle(inputdata_t &)
 193  192 CBaseTrigger::InputTouchTest(inputdata_t &)
 194  193 CBaseTrigger::InputStartTouch(inputdata_t &)
 195  194 CBaseTrigger::InputEndTouch(inputdata_t &)
 196  195 CBaseTrigger::UsesFilter(void)
 197  196 CBaseTrigger::PassesTriggerFilters(CBaseEntity *)
 198  197 CBaseTrigger::StartTouchAll(void)
 199  198 CBaseTrigger::EndTouchAll(void)
As you can see CTriggerMultiple has no own implementation of StartTouch, but uses the implementation of CBaseTrigger, which is the base class for all triggers. Thus, your hook is called for other trigger types as well.

If you wish to filter the calls, you need to do that on your own.

Syntax: Select all

@EntityPostHook(EntityCondition.equals_entity_classname("trigger_multiple"), 'start_touch')
def Entity_StartTouch(args, ret):
entity = make_object(Entity, args[0])
if entity.classname != 'trigger_multiple':
return

# Your code here



Hmm that does make sense but I wish it didn't haha. I was going to resort to checking the classname again if there was no other solutions.

I noticed that in the equals_entity_classname it has

Syntax: Select all

@staticmethod
def equals_entity_classname(*classnames):
"""Return a function that requires an :class:`entities.entity.Entity``
instace. The returned function returns ``True`` if the entity's
classname equals one of the passed classnames.
:rtype: lambda
"""
return lambda entity: entity.classname in classnames


Wouldn't that already do the proper check or is the entity its being passed different than the one that is being made from make_object?

To me it seems like having it check in the lambda and then checking again in the method would yield the same results but this is also a giant black box im slowly trying to understand :)

edit:
Digging deeper into this https://github.com/Source-Python-Dev-Te ... ks.py#L156

That calls the filter lambda with the entity and the lambda function is only returning True if the classname is "trigger_multiple". So how is a "trigger_push" or "trigger_teleport" passing that lambda check? Thats like saying "a" = "b" from what i can tell.


edit 2:

I updated the code to be

Syntax: Select all

def my_filter(*classnames):
def my_test_filter(entity):
print(f"We received: {entity.classname} ({entity.index}) and the list is {classnames}")
if entity.classname in classnames:
print("we are returning true on this")
return True
else:
print("we are returning false")
return False
return my_test_filter


@EntityPostHook(my_filter("trigger_multiple"), 'start_touch')
def Entity_StartTouch(args, ret):
entity = make_object(Entity, args[0])
print(f"entity index: {entity.index}")
print(f"class name: {entity.classname} - target_name: {entity.target_name}")


so that it will print out every filter condition so i can see whats going on.

Code: Select all

We received: worldspawn (0) and the list is ('trigger_multiple',)
we are returning false
We received: cs_team_manager (33) and the list is ('trigger_multiple',)
we are returning false
We received: cs_team_manager (34) and the list is ('trigger_multiple',)
we are returning false
We received: cs_team_manager (35) and the list is ('trigger_multiple',)
we are returning false
We received: cs_team_manager (36) and the list is ('trigger_multiple',)
we are returning false
We received: soundent (37) and the list is ('trigger_multiple',)
we are returning false
We received: cs_player_manager (38) and the list is ('trigger_multiple',)
we are returning false
We received: cs_gamerules (39) and the list is ('trigger_multiple',)
we are returning false
We received: ai_network (40) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (48) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (49) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (50) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (51) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (57) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (58) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (59) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (60) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (61) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (62) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (63) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (64) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (65) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (66) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (67) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (68) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (69) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (70) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (71) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (72) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (73) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (74) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (75) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (76) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (77) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (78) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (79) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (80) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (81) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (82) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (83) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_terrorist (84) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (85) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (86) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (87) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (88) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (89) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (90) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (91) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (92) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (93) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (94) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (95) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (96) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (97) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (98) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (99) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (100) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (101) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (102) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (103) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (104) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (105) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (106) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (107) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (108) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (109) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (110) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (111) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (112) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (113) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (114) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (115) and the list is ('trigger_multiple',)
we are returning false
We received: info_player_counterterrorist (116) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (166) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (167) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (168) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (169) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (170) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (187) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (188) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (189) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (190) and the list is ('trigger_multiple',)
we are returning false
We received: func_illusionary (197) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_teleport (41) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_teleport (42) and the list is ('trigger_multiple',)
we are returning false
We received: info_teleport_destination (43) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_teleport (44) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_teleport (45) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_teleport (46) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_teleport (47) and the list is ('trigger_multiple',)
we are returning false
We received: trigger_multiple (52) and the list is ('trigger_multiple',)
we are returning true on this


are all the results, however it is missing some.

Code: Select all

class name: trigger_teleport - target_name:
entity index: 198


That index 198 is getting passed through due to not being tested against the filter condition is what im thinking... That seems like a bug and certainly not intended?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: EntityPostHook Condition not working

Postby satoon101 » Sat Apr 21, 2018 5:45 pm

12jdlovins wrote:Hmm that does make sense but I wish it didn't haha. I was going to resort to checking the classname again if there was no other solutions.

I noticed that in the equals_entity_classname it has

Syntax: Select all

@staticmethod
def equals_entity_classname(*classnames):
"""Return a function that requires an :class:`entities.entity.Entity``
instace. The returned function returns ``True`` if the entity's
classname equals one of the passed classnames.
:rtype: lambda
"""
return lambda entity: entity.classname in classnames


Wouldn't that already do the proper check or is the entity its being passed different than the one that is being made from make_object?

No, the EntityCondition you provide is only called to validate the entity in order to hook it's StartTouch function in memory. Once the hook is created, SP does not validate every single time against the EntityCondition. In fact, once the EntityCondition has been found, and the hook created, that specific EntityCondition will never be ran again. Due to the fact that other entity types share the same StartTouch, your function will be called for any/all of them. You'll just have to filter out the ones you don't want, just as Ayuto has demonstrated.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 24 guests