Skip to content

Commit

Permalink
heartbeat script now resets personal reputation if no enemy PCs seen …
Browse files Browse the repository at this point in the history
…for a while, aggro NPC script now sets a combat int and fast buffs immediately
  • Loading branch information
b5635 committed Sep 12, 2023
1 parent b6d2b78 commit 6e33107
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/nss/ai_onheartb.nss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
#include "inc_ai_combat"
#include "x0_i0_walkway"

void ClearPersonalReputationsWithAllPCs()
{
object oPC = GetFirstPC();

while (GetIsObjectValid(oPC))
{
ClearPersonalReputation(oPC, OBJECT_SELF);
oPC = GetNextPC();
}
}

void main()
{
if (GetIsDead(OBJECT_SELF)) return;
Expand Down Expand Up @@ -46,6 +57,40 @@ void main()

int nCombat = GetIsInCombat(OBJECT_SELF);

object oPC = GetFirstPC();

int bEnemyPCSeen = FALSE;

while (GetIsObjectValid(oPC))
{
if (GetIsEnemy(oPC) && (GetObjectSeen(oPC) || GetObjectHeard(oPC)))
{
bEnemyPCSeen = TRUE;
break;
}

oPC = GetNextPC();
}

int nCountBeforeClearReputation = GetLocalInt(OBJECT_SELF, "count_before_clearing_pc_reputation");

// clear reputation with all PCs if no enemy PCs have been seen for a while
// don't check for combat, what could happen is that the creature is in combat with a non-PC
// like a combat dummy and never clears reputation
if (bEnemyPCSeen)
{
SetLocalInt(OBJECT_SELF, "count_before_clearing_pc_reputation", 5);
}
else if (nCountBeforeClearReputation <= 0)
{
DeleteLocalInt(OBJECT_SELF, "count_before_clearing_pc_reputation");
ClearPersonalReputationsWithAllPCs();
}
else
{
SetLocalInt(OBJECT_SELF, "count_before_clearing_pc_reputation", nCountBeforeClearReputation - 1);
}

// torch stuff
object oArea = GetArea(OBJECT_SELF);
object oTorch = GetItemPossessedBy(OBJECT_SELF, "NW_IT_TORCH001");
Expand Down
7 changes: 7 additions & 0 deletions src/nss/dlg_aggro_all.nss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ void main()
if(GetFactionEqual(oTarget, OBJECT_SELF))
{
SetIsTemporaryEnemy(oPC, oTarget, TRUE);
SetLocalInt(oTarget, "combat", 1);

if (!GetIsInCombat(oTarget))
{
AssignCommand(oTarget, FastBuff());
}

AssignCommand(oTarget, gsCBDetermineCombatRound(oPC));
}
//Get next target in area
Expand Down

0 comments on commit 6e33107

Please sign in to comment.