88#include " stdafx.hpp"
99#include " modules/cbaseentity.hpp"
1010
11- #include " modules/cbaseplayer.hpp"
12-
1311#include " utils.hpp"
1412#include " globals.hpp"
15-
16- #include " vscript/ivscript.h"
17- #include " irecipientfilter.h"
13+ #include " signatures.hpp"
1814
1915/* *
2016 * @brief Remove a entity from the world.
21- * @param pEntity Pointer to entity.
17+ * @param entity Pointer to entity.
2218 */
23- void CBaseEntity::RemoveEntity (CBaseEntity* pEntity)
19+ using RemoveEntityT = void (__cdecl*)(CBaseEntity*);
20+ void CBaseEntity::RemoveEntity (CBaseEntity* entity)
2421{
25- if (!pEntity )
22+ if (!entity )
2623 return ;
2724
28- static auto removeEntity = reinterpret_cast < void (__cdecl*)( void *)>( Memory::Scan<void * >(MODULE_SERVER, " 55 8B EC 57 8B 7D 08 85 FF 74 72 " ) );
29- removeEntity (( reinterpret_cast <IServerEntity*>(pEntity)-> GetNetworkable ()) );
25+ static auto removeEntity = Memory::Scan<RemoveEntityT >(MODULE_SERVER, Signatures::RemoveEntity );
26+ removeEntity (entity );
3027}
3128
3229/* *
3330 * @brief Get the script scope of a entity.
34- * @param pEntity Pointer to entity.
31+ * @param entity Pointer to entity.
3532 * @return VScript handle to entity's script scope.
3633 */
37- HSCRIPT CBaseEntity::GetScriptScope (CBaseEntity* pEntity )
34+ HSCRIPT CBaseEntity::GetScriptScope (CBaseEntity* entity )
3835{
39- if (!pEntity )
36+ if (!entity )
4037 return nullptr ;
4138
42- return *reinterpret_cast <HSCRIPT*>(reinterpret_cast <uintptr_t >(pEntity ) + 0x33C );
39+ return *reinterpret_cast <HSCRIPT*>(reinterpret_cast <uintptr_t >(entity ) + 0x33C );
4340}
4441
4542/* *
4643 * @brief Get the script instance of a entity.
4744 * @param entity Pointer to entity.
4845 * @return VScript instance handle of the entity.
4946 */
47+ using GetScriptInstanceT = HSCRIPT (__thiscall*)(CBaseEntity*);
5048HSCRIPT CBaseEntity::GetScriptInstance (CBaseEntity* entity)
5149{
52- static auto getScriptInstance = reinterpret_cast <HSCRIPT (__thiscall*)(CBaseEntity*)>(Memory::Scan<void *>(MODULE_SERVER, " 55 8B EC 51 56 8B F1 83 BE 50" ));
50+ if (!entity)
51+ return nullptr ;
52+
53+ static auto getScriptInstance = Memory::Scan<GetScriptInstanceT>(MODULE_SERVER, Signatures::GetScriptInstance);
5354 if (!getScriptInstance)
5455 {
5556 Log (WARNING, false , " Could not get script instance for entity!" );
@@ -61,30 +62,50 @@ HSCRIPT CBaseEntity::GetScriptInstance(CBaseEntity* entity)
6162
6263/* *
6364 * @brief Make a entity emit a sound.
64- * @param pEntity Entity that will call to emit a sound.
65+ * @param entity Entity that will call to emit a sound.
6566 * @param entityIndex Entity that will emit the sound. Use -1 if you want to set a position in the world for it to play.
6667 * @param filter Filter of recipient entities that can hear this noise.
6768 * @param soundName Sound file path, or script name to play.
68- * @param pOrigin Position in the world the sound will play.
69+ * @param origin Position in the world the sound will play.
6970 * @param soundTime Time in seconds till sound is played. NOT HOW LONG SOUND WILL PLAY!
7071 * @return Return code for sound.
7172 */
72- int CBaseEntity::EmitSound (CBaseEntity* pEntity, int entityIndex, IRecipientFilter& filter, const char * soundName, const Vector* pOrigin, const float soundTime)
73+ using EmitSoundT = int (__thiscall*)(CBaseEntity*, IRecipientFilter&, int , const char *, const Vector*, float );
74+ int CBaseEntity::EmitSound (CBaseEntity* entity, const int entityIndex, IRecipientFilter& filter, const char * soundName, const Vector* origin, const float soundTime)
7375{
74- static auto emitSound = reinterpret_cast <int (__thiscall*)(CBaseEntity*, IRecipientFilter&, int , const char *, const Vector*, float )>(Memory::Scan<void *>(MODULE_SERVER, " 55 8B EC 83 EC 4C 8B 0D" ));
75- return emitSound (pEntity, filter, entityIndex, soundName, pOrigin, soundTime);
76- }
76+ if (!entity)
77+ return 0 ;
7778
78- void CBaseEntity::AddEffects (CBaseEntity* pEntity, int nEffects)
79- {
80- static auto addEffects = reinterpret_cast <void (__thiscall*)(CBaseEntity*, int )>(Memory::Scan<void *>(MODULE_SERVER, " 55 8B EC 53 8B D9 8B 83 A8" ));
81- addEffects (pEntity, nEffects);
79+ static auto emitSound = Memory::Scan<EmitSoundT>(MODULE_SERVER, Signatures::EmitSound);
80+ return emitSound (entity, filter, entityIndex, soundName, origin, soundTime);
8281}
8382
84- void CBaseEntity::RemoveEffects (CBaseEntity* pEntity, int nEffects)
83+ /* *
84+ * @brief Add effects to a entity.
85+ * @param entity Entity to add effects to.
86+ * @param effects Effects to apply on entity.
87+ */
88+ using AddEffectsT = void (__thiscall*)(CBaseEntity*, int );
89+ void CBaseEntity::AddEffects (CBaseEntity* entity, const EntityEffect effects)
8590{
86- static auto removeEffects = reinterpret_cast <void (__thiscall*)(CBaseEntity*, int )>(Memory::Scan<void *>(MODULE_SERVER, " 55 8B EC 53 56 8B 75 08 8B D9 8B 83" ));
87- removeEffects (pEntity, nEffects);
91+ if (!entity)
92+ return ;
93+
94+ static auto addEffects = Memory::Scan<AddEffectsT>(MODULE_SERVER, Signatures::AddEffects);
95+ addEffects (entity, effects);
8896}
8997
98+ /* *
99+ * @brief Remove effects from a entity.
100+ * @param entity Entity to remove effects from.
101+ * @param effects Effects to remove from entity.
102+ */
103+ using RemoveEffectsT = void (__thiscall*)(CBaseEntity*, int );
104+ void CBaseEntity::RemoveEffects (CBaseEntity* entity, const EntityEffect effects)
105+ {
106+ if (!entity)
107+ return ;
90108
109+ static auto removeEffects = Memory::Scan<RemoveEffectsT>(MODULE_SERVER, Signatures::RemoveEffects);
110+ removeEffects (entity, effects);
111+ }
0 commit comments