Skip to content

Commit

Permalink
Cosmetic petrified creatures are not interactable
Browse files Browse the repository at this point in the history
closes #795
  • Loading branch information
b5635 committed Nov 3, 2024
1 parent fea0b94 commit fd6c222
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/nss/area_refresh_pet.nss
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include "inc_general"

void CleanAndSpawnPetrified(string sCreature)
{
string sResRef;
int nNumSpawns = GetLocalInt(OBJECT_SELF, "num_petrified_creatures_per_type");
if (nNumSpawns == 0) { nNumSpawns = 1; }

if (sCreature == "DireWolf") { sResRef = "wolf_dire"; }
else if (sCreature == "Bear") { sResRef = "bear_black"; }
else if (sCreature == "Deer") { sResRef = "deer"; }
else if (sCreature == "Smuggler") { sResRef = "smuggler_archer"; }
else if (sCreature == "Badger") { sResRef = "badger"; }

string sVar = "PetrifiedCreature_" + sCreature;
int nCount = GetLocalInt(OBJECT_SELF, sVar + "_count");
int i;
Expand All @@ -23,7 +25,7 @@ void CleanAndSpawnPetrified(string sCreature)
DeleteLocalObject(OBJECT_SELF, sVar + IntToString(i));
}
DeleteLocalInt(OBJECT_SELF, sVar + "_count");

int nNumSpawnPoints = GetLocalInt(OBJECT_SELF, "petrified_Petrified" + sCreature);
if (nNumSpawnPoints > 0)
{
Expand All @@ -38,9 +40,7 @@ void CleanAndSpawnPetrified(string sCreature)
object oNew = CreateObject(OBJECT_TYPE_CREATURE, sResRef, lLoc);
SetLocalObject(OBJECT_SELF, "PetrifiedCreature_" + sCreature + IntToString(nNumberSpawned), oNew);
nNumberSpawned++;
AssignCommand(oNew, SetFacing(IntToFloat(Random(360))));
DelayCommand(3.0, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectPetrify(), oNew));
SetLocalInt(oNew, "no_credit", 1);
SetDecorativePetrification(oNew);
}
}
}
Expand All @@ -53,4 +53,4 @@ void main()
CleanAndSpawnPetrified("Deer");
CleanAndSpawnPetrified("Smuggler");
CleanAndSpawnPetrified("Badger");
}
}
47 changes: 39 additions & 8 deletions src/nss/inc_general.nss
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ int GetIsMute(object oCreature)
GetHasEffect(EFFECT_TYPE_TURNED, oCreature) ||
GetHasEffect(EFFECT_TYPE_PETRIFY, oCreature))
{
return TRUE;
return TRUE;
}

return FALSE;
Expand All @@ -759,7 +759,7 @@ int GetIsControllable(object oCreature)
GetHasEffect(EFFECT_TYPE_TURNED, oCreature) ||
GetHasEffect(EFFECT_TYPE_PETRIFY, oCreature))
{
return FALSE;
return FALSE;
}

return TRUE;
Expand All @@ -769,12 +769,12 @@ int IncrementPlayerStatistic(object oPC, string sStat, int nIncrement = 1);
int IncrementPlayerStatistic(object oPC, string sStat, int nIncrement = 1)
{
if (!GetIsPC(oPC)) return 0;

string sVarName = STAT_PREFIX+sStat;

int nNewTotal = SQLocalsPlayer_GetInt(oPC, sVarName) + nIncrement;
SQLocalsPlayer_SetInt(oPC, sVarName, nNewTotal);

nNewTotal = GetCachedCdkeyInt(oPC, "playerstats", sVarName);
SetCachedCdkeyInt(oPC, "playerstats", sVarName, nNewTotal + nIncrement);
UpdatePlayerStatsUIBindIfOpen(oPC, sStat);
Expand Down Expand Up @@ -813,7 +813,7 @@ string GetPlayerStatisticString(object oPC, string sStat, int bCDKeyDB=0);
string GetPlayerStatisticString(object oPC, string sStat, int bCDKeyDB=0)
{
if (!GetIsPC(oPC)) return "";

string sVarName = STAT_PREFIX+sStat;
if (!bCDKeyDB)
{
Expand All @@ -826,7 +826,7 @@ int GetPlayerStatistic(object oPC, string sStat, int bCDKeyDB=0);
int GetPlayerStatistic(object oPC, string sStat, int bCDKeyDB=0)
{
if (!GetIsPC(oPC)) return 0;

string sVarName = STAT_PREFIX+sStat;
if (!bCDKeyDB)
{
Expand Down Expand Up @@ -857,7 +857,7 @@ int IsAmmo(object oItem);
int IsAmmo(object oItem)
{
int nBaseType = GetBaseItemType(oItem);

if (nBaseType == BASE_ITEM_THROWINGAXE || nBaseType == BASE_ITEM_DART || nBaseType == BASE_ITEM_SHURIKEN || nBaseType == BASE_ITEM_ARROW || nBaseType == BASE_ITEM_BULLET || nBaseType == BASE_ITEM_BOLT)
{
return TRUE;
Expand All @@ -875,7 +875,7 @@ int IsAmmoInfinite(object oItem)
{
return FALSE;
}

itemproperty ip = GetFirstItemProperty(oItem);

while (GetIsItemPropertyValid(ip))
Expand All @@ -890,4 +890,35 @@ int IsAmmoInfinite(object oItem)

return FALSE;
}

void SetDecorativePetrification(object oCreature);
void SetDecorativePetrification(object oCreature)
{
AssignCommand(oCreature, SetFacing(IntToFloat(Random(360))));
DelayCommand(3.0, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectPetrify(), oCreature));


// note: spawn scripts will have triggered at this point
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_BLOCKED_BY_DOOR, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_DAMAGED, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_DEATH, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_DIALOGUE, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_DISTURBED, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_END_COMBATROUND, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_HEARTBEAT, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_MELEE_ATTACKED, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_NOTICE, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_RESTED, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_SPELLCASTAT, "");
SetEventScript(oCreature, EVENT_SCRIPT_CREATURE_ON_USER_DEFINED_EVENT, "");

SetAILevel(oCreature, AI_LEVEL_VERY_LOW);

// supposedly unused
SetSoundset(oCreature, 315);

// possibly not needed when event scripts are cleared
SetLocalInt(oCreature, "no_credit", 1);
SetUseableFlag(oCreature, FALSE);
}
//void main(){}

0 comments on commit fd6c222

Please sign in to comment.