]> vgcfreebox.myrthtech.pt Git - alentejosemlei.git/blob - nwn-asl-ai/asl_npc_on_damaged
1st version paper
[alentejosemlei.git] / nwn-asl-ai / asl_npc_on_damaged
1 // ============================================================================
2 // File Name: bpc_on_damaged
3 // Emergency LLM interruption for combat events
4 // ============================================================================
5 #include "nwnx_redis"
6 void main()
7 {
8 object oNPC = OBJECT_SELF;
9 object oAttacker = GetLastDamager();
10 if (!GetIsObjectValid(oAttacker)) oAttacker = GetLastAttacker();
11
12 if (!GetIsObjectValid(oAttacker)) return;
13
14 int nStrategy = GetLocalInt(oNPC, "LLM_STRATEGY");
15 if (nStrategy == 3) return; // Maestros don't think in combat
16
17 if (GetLocalInt(oNPC, "LLM_PAIN_THROTTLE") == TRUE) return;
18 SetLocalInt(oNPC, "LLM_PAIN_THROTTLE", TRUE);
19 DelayCommand(12.0f, DeleteLocalInt(oNPC, "LLM_PAIN_THROTTLE"));
20
21 json jData = JsonObject();
22 jData = JsonObjectSet(jData, "npc_tag", JsonString(GetTag(oNPC)));
23 jData = JsonObjectSet(jData, "llm_strategy", JsonInt(nStrategy));
24 jData = JsonObjectSet(jData, "target_player", JsonString(GetName(oAttacker)));
25
26 string sPainMsg = "[SYSTEM CRITICAL] You were just physically attacked and damaged by " + GetName(oAttacker) + "!! Make a tactical decision immediately!";
27 jData = JsonObjectSet(jData, "message", JsonString(sPainMsg));
28 jData = JsonObjectSet(jData, "persona", JsonString(GetLocalString(oNPC, "LLM_PERSONA")));
29
30 NWNX_Redis_RPush("nwn_to_llm", JsonDump(jData));
31 }