#define DT_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION
float DT_COUNT;
-#define DT_MATCH(a,b) if(min(DT_MAX, a) == b)
+entity deathtypes[DT_MAX];
+.entity death_msgself;
+.entity death_msgmurder;
#define DEATHTYPE(name,msg_death,msg_death_by,position) \
float name; \
SET_FIRST_OR_LAST(position, DT_FIRST, DT_COUNT) \
SET_FIELD_COUNT(name, DT_FIRST, DT_COUNT) \
CHECK_MAX_COUNT(name, DT_MAX, DT_COUNT, "deathtypes") \
+ \
+ entity deathent = spawn(); \
+ deathtypes[name - 1] = deathent; \
+ #if (msg_death != NO_MSG) \
+ deathent.death_msgself = msg_multi_notifs[msg_death - 1]; \
+ #endif \
+ #if (msg_death_by != NO_MSG) \
+ deathent.death_msgmurder = msg_multi_notifs[msg_death_by - 1]; \
+ #endif \
} \
ACCUMULATE_FUNCTION(RegisterDeathtypes, RegisterDeathtype_##name)
GameLogEcho(s);
}
-#define INFO_NO_MSG 0 // so that compilation works with the INFO_##msg_death stuff
void Obituary_SpecialDeath(entity notif_target, float murder, float deathtype, string s1, string s2, string s3, float f1, float f2, float f3)
{
- float handled = 0, hits = 0;
if(DEATH_ISSPECIAL(deathtype))
{
- #define DEATHTYPE(name,msg_death,msg_death_by,position) \
- { if(deathtype == max(0, name)) \
- { \
- #if msg_death != NO_MSG \
- if not(murder) \
- { \
- Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, msg_death, s1, s2, s3, "", f1, f2, f3, 0); \
- Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, INFO_##msg_death, s1, s2, s3, "", f1, f2, f3, 0); \
- ++handled; \
- } \
- #endif \
- #if msg_death_by != NO_MSG \
- if(murder) \
- { \
- Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, msg_death_by, s1, s2, s3, "", f1, f2, f3, 0); \
- Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, INFO_##msg_death_by, s1, s2, s3, "", f1, f2, f3, 0); \
- ++handled; \
- } \
- #endif \
- ++hits; \
- } }
-
- DEATHTYPES
- #undef DEATHTYPE
-
- if not(hits)
+ entity deathent = deathtypes[deathtype - 1];
+ if not(deathent) { backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n"); return; }
+
+ if(murder)
{
- backtrace("Obituary_SpecialDeath(): Unhandled deathtype- Please notify Samual!\n");
+ if(deathent.death_msgmurder)
+ {
+ Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, deathent.death_msgmurder.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+ Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, deathent.death_msgmurder.nent_msginfo.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+ }
}
- if not(handled)
+ else
{
- dprint(sprintf(
- "Obituary_SpecialDeath(): ^1Deathtype ^7(%s-%d)^1 has no notification!\n",
- Deathtype_Name(deathtype),
- deathtype
- ));
- return;
+ if(deathent.death_msgself)
+ {
+ Send_Notification_WOVA(NOTIF_ONE, notif_target, MSG_MULTI, deathent.death_msgself.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+ Send_Notification_WOVA(NOTIF_ALL_EXCEPT, notif_target, MSG_INFO, deathent.death_msgself.nent_msginfo.nent_id, s1, s2, s3, "", f1, f2, f3, 0);
+ }
}
}
+ else { backtrace("Obituary_SpecialDeath called without a special deathtype?\n"); return; }
}
float w_deathtype;