Battledale_PRC8/_module/nss/sc_hero_hb.nss
Jaysyn904 7b9e44ebbb Initial upload
Initial upload.  PRC8 has been added.  Module compiles, PRC's default AI & treasure scripts have been integrated.  Started work on top hak for SLA / Ability / Scripting modifications.
2024-03-11 23:44:08 -04:00

251 lines
10 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Name sc_hero_hb
//:: sc_hero_hb.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Modified henchman heartbeat script
*/
//:://////////////////////////////////////////////
//:: Created By: Pad O'Lion
//:: Created On: 06/29/2002
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"
#include "nw_i0_plot"
#include "rpo_inc"
// * Applies an XP and GP penalty
// * to the player respawning
void ApplyPenalty(object oDead)
{
int nXP = GetXP(oDead);
int nPenalty = 100 * GetHitDice(oDead);
int nHD = GetHitDice(oDead);
// * You can not lose a level with this respawning
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
int nNewXP = nXP - nPenalty;
if (nNewXP < nMin)
{
nNewXP = nMin;
}
if (nNewXP < 1)
{
nNewXP = 1;
}
if (nNewXP < (nXP/2))
{
nNewXP = (nXP/2);
}
SetXP(oDead, nNewXP);
int nGoldToTake = FloatToInt(0.10 * GetGold(oDead));
// * a cap of 10 000gp taken from you
if (nGoldToTake > 10000)
{
nGoldToTake = 10000;
}
AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));
}
void Ressurect(object oRespawner)
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oRespawner);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
RemoveEffects(oRespawner);
UnequipPlayer (oRespawner, TRUE);
SendMessageToPC(oRespawner, "You awake with blurred vision, as your sight begins to clear you can make out your surroundings.");
SetLocalInt(oRespawner, "PlayerState",PWS_PLAYER_STATE_ALIVE);
}
void main()
{
float fDistance;
object oMaster = GetMaster();
int nRandom;
if (GetIsObjectValid(oMaster))
{
int iPlayerState = GetLocalInt(oMaster, "PlayerState");
if (iPlayerState == PWS_PLAYER_STATE_RESCUED)
{
fDistance = GetDistanceBetween(oMaster, OBJECT_SELF);
if (fDistance <= 3.0)
{
object oSpawnPoint = GetObjectByTag("WP_RessPoint");
SpeakString("I shall bring ya to the nearby temple. Fare thee well and may the spirits of the woods watch over ya.");
RemoveDeathAmulet(oMaster);
ApplyPenalty(oMaster);
Ressurect(oMaster);
AssignCommand(oMaster, JumpToLocation(GetLocation(oSpawnPoint)));
SendMessageToPC(oMaster, "You find yourself at in " + GetName(GetArea(oSpawnPoint)));
DestroyObject(OBJECT_SELF);
}
else
{
nRandom = d3();
if (nRandom == 1)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY1);
SpeakString("Hold out friend, I shall be right there!", TALKVOLUME_SHOUT);
}
else if (nRandom == 2)
{
PlayVoiceChat(VOICE_CHAT_BATTLECRY2);
SpeakString("Uragshaaaaa!", TALKVOLUME_SHOUT);
}
else
{
PlayVoiceChat(VOICE_CHAT_ENEMIES);
SpeakString("There are enemies near!", TALKVOLUME_SHOUT);
}
ActionMoveToObject(oMaster, TRUE);
}
}
else if (iPlayerState == PWS_PLAYER_STATE_ALIVE)
{
}
}
if(!GetAssociateState(NW_ASC_IS_BUSY))
{
//Seek out and disable undisabled traps
object oTrap = GetNearestTrapToObject();
if(GetIsObjectValid(oTrap) && GetDistanceToObject(oTrap) < 15.0 && GetDistanceToObject(oTrap) > 0.0)
{
object oTrapSaved = GetLocalObject(OBJECT_SELF, "NW_ASSOCIATES_LAST_TRAP");
int nTrapDC = GetTrapDisarmDC(oTrap);
int nSkill = GetSkillRank(SKILL_DISABLE_TRAP);
nSkill = nSkill + 20 - nTrapDC;
if(nSkill > 0 && GetSkillRank(SKILL_DISABLE_TRAP) > 0)
{
if( GetIsObjectValid(oMaster)
&& nSkill > 0
&& !IsInConversation(OBJECT_SELF)
&& !GetIsInCombat()
&& GetCurrentAction(OBJECT_SELF) != ACTION_REST
&& GetCurrentAction(OBJECT_SELF) != ACTION_DISABLETRAP)
{
ClearAllActions();
ActionUseSkill(SKILL_DISABLE_TRAP, oTrap);
ActionDoCommand(SetCommandable(TRUE));
ActionDoCommand(PlayVoiceChat(VOICE_CHAT_TASKCOMPLETE));
SetCommandable(FALSE);
return;
}
}
else if(oTrap != oTrapSaved && GetSkillRank(SKILL_DISABLE_TRAP) > 0)
{
PlayVoiceChat(VOICE_CHAT_CANTDO);
SetLocalObject(OBJECT_SELF, "NW_ASSOCIATES_LAST_TRAP", oTrap);
}
}
if(GetIsObjectValid(oMaster) &&
GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOW &&
GetCurrentAction(OBJECT_SELF) != ACTION_DISABLETRAP &&
GetCurrentAction(OBJECT_SELF) != ACTION_OPENLOCK &&
GetCurrentAction(OBJECT_SELF) != ACTION_REST &&
GetCurrentAction(OBJECT_SELF) != ACTION_ATTACKOBJECT)
{
if(
!GetIsObjectValid(GetAttackTarget()) &&
!GetIsObjectValid(GetAttemptedSpellTarget()) &&
!GetIsObjectValid(GetAttemptedAttackTarget()) &&
!GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN))
)
{
if(GetDistanceToObject(GetMaster()) > 6.0)
{
if(GetAssociateState(NW_ASC_HAVE_MASTER))
{
if(!GetIsFighting(OBJECT_SELF))
{
if(!GetAssociateState(NW_ASC_MODE_STAND_GROUND))
{
if(GetDistanceToObject(GetMaster()) > GetFollowDistance())
{
ClearAllActions();
if(GetAssociateState(NW_ASC_AGGRESSIVE_STEALTH) || GetAssociateState(NW_ASC_AGGRESSIVE_SEARCH))
{
if(GetAssociateState(NW_ASC_AGGRESSIVE_STEALTH))
{
//ActionUseSkill(SKILL_HIDE, OBJECT_SELF);
//ActionUseSkill(SKILL_MOVE_SILENTLY,OBJECT_SELF);
}
if(GetAssociateState(NW_ASC_AGGRESSIVE_SEARCH))
{
ActionUseSkill(SKILL_SEARCH, OBJECT_SELF);
}
MyPrintString("GENERIC SCRIPT DEBUG STRING ********** " + "Assigning Force Follow Command with Search and/or Stealth");
ActionForceFollowObject(oMaster, GetFollowDistance());
}
else
{
MyPrintString("GENERIC SCRIPT DEBUG STRING ********** " + "Assigning Force Follow Normal");
ActionForceFollowObject(oMaster, GetFollowDistance());
//ActionForceMoveToObject(GetMaster(), TRUE, GetFollowDistance(), 5.0);
}
}
}
}
}
}
else if(!GetAssociateState(NW_ASC_MODE_STAND_GROUND))
{
if(GetIsObjectValid(oMaster))
{
if(GetCurrentAction(oMaster) != ACTION_REST)
{
ClearAllActions();
if(GetAssociateState(NW_ASC_AGGRESSIVE_STEALTH) || GetAssociateState(NW_ASC_AGGRESSIVE_SEARCH))
{
if(GetAssociateState(NW_ASC_AGGRESSIVE_STEALTH))
{
//ActionUseSkill(SKILL_HIDE, OBJECT_SELF);
//ActionUseSkill(SKILL_MOVE_SILENTLY,OBJECT_SELF);
}
if(GetAssociateState(NW_ASC_AGGRESSIVE_SEARCH))
{
ActionUseSkill(SKILL_SEARCH, OBJECT_SELF);
}
MyPrintString("GENERIC SCRIPT DEBUG STRING ********** " + "Assigning Force Follow Command with Search and/or Stealth");
ActionForceFollowObject(oMaster, GetFollowDistance());
}
else
{
MyPrintString("GENERIC SCRIPT DEBUG STRING ********** " + "Assigning Force Follow Normal");
ActionForceFollowObject(oMaster, GetFollowDistance());
}
}
}
}
}
else if(!GetIsObjectValid(GetAttackTarget()) &&
!GetIsObjectValid(GetAttemptedSpellTarget()) &&
!GetIsObjectValid(GetAttemptedAttackTarget()) &&
!GetAssociateState(NW_ASC_MODE_STAND_GROUND))
{
//DetermineCombatRound();
}
}
if(GetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}
}
}