Skip to content

Commit 93f686d

Browse files
committed
add touch function
1 parent e538944 commit 93f686d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

api_custom_entities.sma

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,11 @@ bool:@Entity_IsCustom(this) {
615615
@Entity_Touch(this, pToucher) {
616616
new Trie:itPData = @Entity_GetPData(this);
617617
new iId = GetPDataMember(itPData, CE_MEMBER_ID);
618+
619+
if (ExecuteHookFunction(CEFunction_Touch, iId, this, pToucher)) {
620+
return;
621+
}
622+
618623
new CEPreset:iPreset = ArrayGetCell(g_rgCEData[CEData_Preset], iId);
619624

620625
switch (iPreset) {
@@ -937,6 +942,10 @@ ExecuteHookFunction(CEFunction:iFunction, iId, pEntity, any:...) {
937942
callfunc_push_int(pEntity);
938943

939944
switch (iFunction) {
945+
case CEFunction_Touch: {
946+
new pToucher = getarg(3);
947+
callfunc_push_int(pToucher);
948+
}
940949
case CEFunction_Kill, CEFunction_Killed: {
941950
new pKiller = getarg(3);
942951
new bool:bPicked = bool:getarg(4);

include/api_custom_entities.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ enum CEFunction {
4242
CEFunction_Activate, // Calls every trigger activation check
4343
CEFunction_Activated, // Calls when player activates trigger
4444
CEFunction_Init, // Calls when entity is initialized (on first spawn)
45-
CEFunction_Think // Calls when entity thinking
45+
CEFunction_Think, // Calls when entity thinking
46+
CEFunction_Touch // Calls when entity touched
4647
};
4748

4849
/*

0 commit comments

Comments
 (0)