FANDOM


What It Does Edit

A large script of added and included functions to make a scripter's life easier.

Farenheit's awesome include file in a response to Red Warlock's great idea, I added a few functions of my own, and felt that this should be continued as a collection of useful tools. Thanks to Cheiron the Centaur who originally created the jump to point routine (included) and an altered version as a Move Forward function. A list of commands that can be seen at a glance is posted below. Nothing longer than about a page should be added to this include file. This is for simple functions. So take what you need, add a few functions, let us know what was added, then re-post this! (Who knows, it could be the answer to something somebody has been working on for a week to figure out)?

About credit: Farenheit never claimed credit for any of these functions. The name added to the function is just the person who submitted it. The idea here, is to make available as many tools to the scripter as possible. If you see something in here you feel is exclusively yours and it bugs you, then by all means, change the credits and repost this article. (Just be sure to add a function, when you do it).


The function List Edit

void main()
{
/*
// FUNCTION LIST:

// Some useful existing commands.
GetHasEffect(int nEffectType, object oTarget = OBJECT_SELF); ....  NW_i0_GENERIC.
GetIsPostOrWalking(object oWalker = OBJECT_SELF); ................ NW_i0_GENERIC
RemoveAmbientSleep(); ............................................ NW_i0_GENERIC
GetPercentageHPLoss(object oWounded); ............................ NW_i0_GENERIC
HasItem(object oCreature, string s); ............................. NW_i0_TOOL
TakeGold(int nAmount, object oGoldHolder, int bDestroy=TRUE); ...  NW_i0_TOOL
AutoDC(int DC, int nSkill, object oTarget); ...................... NW_i0_TOOL
HasGold(int nAmount, object oGoldHolder); ........................ NW_i0_TOOL
NW_i0_TOOL
DoGiveXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL);

// Added functions
DoEquip(object oTarget);
GetBetweenHours(int nFirstHour, int nSecondHour);
DebugSpeak(string s);
DimensionHop(object oTarget);
CanSeePlayer();
EscapeArea(int bRun = TRUE, string sTag="NW_EXIT");
RewardXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL, int bAllParty=TRUE);
RewardGP(int GP, object oTarget,int bAllParty=TRUE);
CheckCharismaLow(object oTarget);
CheckCharismaNormal(object oTarget);
CheckCharismaHigh(object oTarget);
CheckIntelligenceLow(object oTarget);
CheckIntelligenceNormal(object oTarget);
CheckIntelligenceHigh(object oTarget);
CheckWisdomLow(object oTarget);
CheckWisdomNormal(object oTarget);
CheckWisdomHigh(object oTarget);
GetWisdom(object oTarget);
GetIntelligence(object oTarget);
GetCharisma(object oTarget);
GetNumItems(object oTarget,string sItem);
GiveNumItems(object oTarget,string sItem,int nNumItems);
TakeNumItems(object oTarget,string sItem,int nNumItems);
RemoveEffects(object oDead);
GetReactionAdjustment(object oTarget);
EscapeViaTeleport(object oFleeing);
MoveForward(object oMove, float fDistance);
Turn(object oTurn, int TURN_LEFT, TURN_RIGHT);
JumpToPoint(object oTarget, int JUMP_INFRONT, JUMP_BEHIND, float fDistance);
getWeaponSize(int iBaseType);
getCurrentTime();
*/
}


The Include file: SIMPLE_FUNCTION Edit

#include "NW_I0_GENERIC"
#include "NW_I0_TOOL"
//To use any of the functions listed, just add: #include "SIMPLE_FUNCTION"
/* to the top of your script.
If you see something that is from an existing "include" file, strip the function
and note up here, where it can be found.
(In an attempt to reduce any kind of "include" conflict).

// Some useful existing commands.
GetHasEffect(int nEffectType, object oTarget = OBJECT_SELF); ....  NW_i0_GENERIC.
GetIsPostOrWalking(object oWalker = OBJECT_SELF); ................ NW_i0_GENERIC
RemoveAmbientSleep(); ............................................ NW_i0_GENERIC
GetPercentageHPLoss(object oWounded); ............................ NW_i0_GENERIC
HasItem(object oCreature, string s); ............................. NW_i0_TOOL
TakeGold(int nAmount, object oGoldHolder, int bDestroy=TRUE); ...  NW_i0_TOOL
AutoDC(int DC, int nSkill, object oTarget); ...................... NW_i0_TOOL
HasGold(int nAmount, object oGoldHolder); ........................ NW_i0_TOOL
NW_i0_TOOL
DoGiveXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL);

// Added functions
DoEquip(object oTarget);
GetBetweenHours(int nFirstHour, int nSecondHour);
DebugSpeak(string s);
DimensionHop(object oTarget);
CanSeePlayer();
EscapeArea(int bRun = TRUE, string sTag="NW_EXIT");
RewardXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL, int bAllParty=TRUE);
RewardGP(int GP, object oTarget,int bAllParty=TRUE);
CheckCharismaLow(object oTarget);
CheckCharismaNormal(object oTarget);
CheckCharismaHigh(object oTarget);
CheckIntelligenceLow(object oTarget);
CheckIntelligenceNormal(object oTarget);
CheckIntelligenceHigh(object oTarget);
CheckWisdomLow(object oTarget);
CheckWisdomNormal(object oTarget);
CheckWisdomHigh(object oTarget);
GetWisdom(object oTarget);
GetIntelligence(object oTarget);
GetCharisma(object oTarget);
GetNumItems(object oTarget,string sItem);
GiveNumItems(object oTarget,string sItem,int nNumItems);
TakeNumItems(object oTarget,string sItem,int nNumItems);
RemoveEffects(object oDead);
GetReactionAdjustment(object oTarget);
EscapeViaTeleport(object oFleeing);
MoveForward(object oMove, float fDistance);
Turn(object oTurn, int TURN_LEFT, TURN_RIGHT);
JumpToPoint(object oTarget, int JUMP_INFRONT, JUMP_BEHIND, float fDistance);
getWeaponSize(int iBaseType);
getCurrentTime();

(remove the type, void, int etc and list it up here. Be sure to include the description
under the "declarations" line).

*/

// Variable Declarations
int nHour = GetTimeHour();
string sNPCName = GetName(OBJECT_SELF);
int TURN_LEFT = 0; // NPC 90 Degrees
int TURN_RIGHT = 1; //
int JUMP_INFRONT = 0;
int JUMP_BEHIND = 1;
//  Function description under the declararations line. (leave the space).
//  Function Declarations

// A wrapper to simplify checking for an item.
int HasItem(object oCreature, string s);
//  Takes nAmount of gold from the object speaking.
//  By default, the gold is destroyed.
void TakeGold(int nAmount, object oGoldHolder, int bDestroy=TRUE);
//  Returns a pass value based on the object's level and the suggested DC
//  December 20 2001: Changed so that the difficulty is determined by the
//  NPC's Hit Dice
int AutoDC(int DC, int nSkill, object oTarget);
//  Checks to see if the player has nAmount of gold
int HasGold(int nAmount, object oGoldHolder);
//  Farenheit, Makes the user get his best weapons and armor.
void DoEquip(object oTarget);
//  Farenheit, Check to see if nHour is after nFirstHour
//  and before nSecondHour. Midnight=0
int GetBetweenHours(int nFirstHour, int nSecondHour);
//  Farenheit,
//  Used for Debugging, speaks sString
void DebugSpeak(string s);
//  Farenheit, Will move the character from one point to oTarget
//  with a flashy graphic.
//  Original Use: Dryads in M3Q3, SnowGlobe
void DimensionHop(object oTarget);
//  Farenheit,
//  Returns true if OBJECT_SELF can see the player
int CanSeePlayer();
//  Farenheit, Runs object to nearest waypoint with tag
//  "NW_EXIT".  This tag can be overridden.
//  You can also specify whether to run or not.
void EscapeArea(int bRun = TRUE, string sTag="NW_EXIT");
//  Farenheit, Gives each player the reward, scaled 1.25 times if of the correct alignment
//  and 0.75 times if of the wrong alignment.  Neutral always get the
//  1.0 times reward.
void RewardXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL, int bAllParty=TRUE);
//  Farenheit, Gives the GP to (if bAllParty = TRUE) all party members.
//  Each players gets the GP value amount.
void RewardGP(int GP, object oTarget,int bAllParty=TRUE);
//  Farenheit, Returns TRUE if charisma of oTarget is in the low range.
int CheckCharismaLow(object oTarget);
//  Farenheit, Returns TRUE if charisma of oTarget is in the normal range.
int CheckCharismaNormal(object oTarget);
//  Farenheit, Returns TRUE if charisma of oTarget is in the high range.
int CheckCharismaHigh(object oTarget);
//  Farenheit, Returns TRUE if Intelligence of oTarget is in the low range.
int CheckIntelligenceLow(object oTarget);
//  Farenheit, Returns TRUE if Intelligence of oTarget is in the normal range.
int CheckIntelligenceNormal(object oTarget);
//  Farenheit, Returns TRUE if Intelligence of oTarget is in the high range.
int CheckIntelligenceHigh(object oTarget);
//  Returns TRUE if Wisdom of oTarget is in the low range.
int CheckWisdomLow(object oTarget);
//  Farenheit, Returns TRUE if Wisdom of oTarget is in the normal range.
int CheckWisdomNormal(object oTarget);
//  Farenheit, Returns TRUE if Wisdom of oTarget is in the high range.
int CheckWisdomHigh(object oTarget);
//  Farenheit, Return Wisdom of oTarget
int GetWisdom(object oTarget);
//  Farenheit, Return Intelligence of oTarget
int GetIntelligence(object oTarget);
//  Farenheit, Return charisma of oTarget
int GetCharisma(object oTarget);
//  Farenheit, Returns the number of specified item in the
//  target's inventory.
int GetNumItems(object oTarget,string sItem);
//  Farenheit, Gives the target the number of items specified.
void GiveNumItems(object oTarget,string sItem,int nNumItems);
//  Farenheit, Takes the number of items specified from the target.
void TakeNumItems(object oTarget,string sItem,int nNumItems);
//  Farenheit, removes all negative effects
void RemoveEffects(object oDead);
//  Farenheit, Returns the adjusted Reaction for the purposes of store pricing.
float GetReactionAdjustment(object oTarget);
//  Farenheit, Makes the person teleport away and look like
//  they are casting a spell.
void EscapeViaTeleport(object oFleeing);
//  Long, Simply moves an NPC forward, based on Centaur's Jump routine
//  float fDistance .
void MoveForward(object oMove, float fDistance);
//  Long, Turn NPC 90 degrees.
//  int TURN_LEFT, TURN_RIGHT
void Turn(object oTurn, int TURN);
//  Cheiron the Centaur's Jump routine.(jump an object to oTarget).
//  JUMP_INFRONT, JUMP_BEHIND, float Distance away.
void JumpToPoint(object oTarget, int JUMP, float fDistance);
//  Cheiron, This function can be used to determine what kind of weapon
//  it is, but also to determine if an item is a weapon at all!
//  It will return: 0 => not a (valid) weapon,
//  1 => TINY weapon, 2 => SMALL weapon
//  3 => MEDIUM weapon 4 => LARGE weapon
int getWeaponSize(int iBaseType);
//  Cheiron, Convert current YY-MM-DD HH:MM:SS to one float value
//  Useful in GetLocalFloat/SetLocalFloat context to wait a specified number of hours.
//  Example: if(GetLocalFloat(OBJECT_SELF, "LASTTIME") + HoursToSeconds(hoursToWait) > getCurrentTime())
//  { // do something and SetLocalFloat; }
float getCurrentTime();

//::///////////////////////////////////////////////
//:: Equip Appropriate Weapons and armor
//:://////////////////////////////////////////////
/**/
// Makes the user get his best weapons and armor.
void DoEquip(object oTarget)
{
  if(GetDistanceToObject(oTarget) > 5.0)
  {
    ActionEquipMostDamagingRanged(oTarget);
  }
  else
  {
    if (GetHasFeat(FEAT_TWO_WEAPON_FIGHTING,OBJECT_SELF))
      ActionEquipMostDamagingMelee(oTarget,TRUE);
    else
      ActionEquipMostDamagingMelee(oTarget);
  }
  ActionEquipMostEffectiveArmor();
}
//::///////////////////////////////////////////////
//:: GetBetweenHours
//:://////////////////////////////////////////////
/**/
// Check to see if nHour is after nFirstHour
// and before nSecondHour. Midnight=0
int GetBetweenHours(int nFirstHour, int nSecondHour)
{
  if ((nSecondHour-nFirstHour)<0)
  {
    nSecondHour += 24;
    nHour += 12;
  }
  if (nHour >= nFirstHour && nHour < nSecondHour)
    return TRUE;
  return FALSE;
}
//::///////////////////////////////////////////////
//:: DebugSpeak
//:://////////////////////////////////////////////
/**/
// Used for Debugging, speaks sString
void DebugSpeak(string sString)
{
    SpeakString(sString);
}
//::///////////////////////////////////////////////
//:: DimensionHop
//:://////////////////////////////////////////////
/**/
// Will move the character from one point to oTarget
// with a flashy graphic.
// Original Use: Dryads in M3Q3, SnowGlobe
void DimensionHop(object oTarget)
{
    if (GetDistanceToObject(oTarget) > 2.5)
    {
        effect eVis = EffectVisualEffect(VFX_IMP_UNSUMMON);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, OBJECT_SELF);
        ActionJumpToObject(oTarget);
    }
}
//::///////////////////////////////////////////////
//:: CanSeePlayer
//:://////////////////////////////////////////////
/**/
// Returns true if OBJECT_SELF can see the player
int CanSeePlayer()
{
    return GetIsObjectValid(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF, 1, CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN));
}
//::///////////////////////////////////////////////
//:: EscapeArea()
//:://////////////////////////////////////////////
/**/
// Runs object to nearest waypoint with tag
// "NW_EXIT".  This tag can be overridden.
// You can also specify whether to run or not.
void EscapeArea(int bRun = TRUE, string sTag="NW_EXIT")
{
    object oWay = GetNearestObjectByTag(sTag);
    if (GetIsObjectValid(oWay))
    {
        ActionMoveToObject(oWay, bRun);
        ActionDoCommand(DestroyObject(OBJECT_SELF));
        SetCommandable(FALSE); // * this prevents them from being interrupted
    }
    else
    SpeakString("invalid exit waypoint");
}
///////////////////////////////////////////////////////////////////////////////
//  RewardXP
///////////////////////////////////////////////////////////////////////////////
/**/
//  Gives each player the reward, scaled 1.25 times if of the correct alignment
//  and 0.75 times if of the wrong alignment.  Neutral always get the
//  1.0 times reward.
void RewardXP(string sJournalTag, int nPercentage, object oTarget, int QuestAlignment=ALIGNMENT_NEUTRAL, int bAllParty=TRUE)
{
//   AssignCommand(oTarget, SpeakString("in rewardxp function"));
    if (bAllParty == TRUE)
    {
        object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            DoGiveXP(sJournalTag, nPercentage, oPartyMember, QuestAlignment);
            oPartyMember = GetNextFactionMember(oTarget, TRUE);
//            AssignCommand(oTarget,SpeakString("here your xp sir"));
        }
    }
    else
    {
     DoGiveXP(sJournalTag, nPercentage, oTarget, QuestAlignment);
    }
}
///////////////////////////////////////////////////////////////////////////////
//  RewardGP
///////////////////////////////////////////////////////////////////////////////
/**/
//  Gives the GP to (if bAllParty = TRUE) all party members.
//  Each players gets the GP value amount.
void RewardGP(int GP, object oTarget,int bAllParty=TRUE)
{
    // * for each party member
    // * cycle through them and
    // * and give them the appropriate reward
    // * HACK FOR NOW
    if (bAllParty == TRUE)
    {
        object oPartyMember = GetFirstFactionMember(oTarget, TRUE);
        while (GetIsObjectValid(oPartyMember) == TRUE)
        {
            //AssignCommand(oPartyMember, SpeakString("MY GP reward is: " + IntToString(GP)));
            GiveGoldToCreature(oPartyMember, GP);
            oPartyMember = GetNextFactionMember(oTarget, TRUE);
        }
    }
    else
    {
     GiveGoldToCreature(oTarget, GP);
    }
}
///////////////////////////////////////////////////////////////////////////////
//  CheckCharismaLow
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if charisma is in the low range.
int CheckCharismaLow(object oTarget)
{
 if (GetAbilityScore(oTarget,ABILITY_CHARISMA) < 10)
 {
  return TRUE;
 }
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckCharismaNormal
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if charisma is in the normal range.
int CheckCharismaNormal(object oTarget)
{
 if ((GetAbilityScore(oTarget,ABILITY_CHARISMA) >= 10)&&(GetAbilityScore(oTarget,ABILITY_CHARISMA) < 15))
 {
   return TRUE;
 }
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckCharismaHigh
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if charisma is in the high range.
int CheckCharismaHigh(object oTarget)
{
 if (GetAbilityScore(oTarget,ABILITY_CHARISMA) >= 15)
 {
  return TRUE;
 }
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckIntelligenceLow
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if intelligence is in the low range
int CheckIntelligenceLow(object oTarget)
{
 if (GetAbilityScore(oTarget,ABILITY_INTELLIGENCE) < 9)
   return TRUE;
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckIntelligenceNormal
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if intelligence is normal
int CheckIntelligenceNormal(object oTarget)
{
 if ((GetAbilityScore(oTarget,ABILITY_INTELLIGENCE) >= 9)&&(GetAbilityScore(oTarget,ABILITY_INTELLIGENCE) < 15))
   return TRUE;
 return FALSE;
}
//::///////////////////////////////////////////////
//:: CheckIntelligenceHigh
//:://////////////////////////////////////////////
/**/
//  Returns TRUE if intelligence is in the high range
int CheckIntelligenceHigh(object oTarget)
{
 if (GetAbilityScore(oTarget,ABILITY_INTELLIGENCE) >= 15)
   return TRUE;
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckWisdomLow
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if wisdom is in the Low range
int CheckWisdomLow(object oTarget)
{
 if (GetAbilityScore(oTarget,ABILITY_WISDOM) == 8)     
   return TRUE;
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckWisdomNormal
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if wisdom is in the Normal range
int CheckWisdomNormal(object oTarget)
{
 if ((GetAbilityScore(oTarget,ABILITY_WISDOM) >= 9) &&(GetAbilityScore(oTarget,ABILITY_WISDOM) < 14))
   return TRUE;
 return FALSE;
}
///////////////////////////////////////////////////////////////////////////////
//  CheckWisdomHigh
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns TRUE if wisdom is in the High range
int CheckWisdomHigh(object oTarget)
{
 if (GetAbilityScore(oTarget,ABILITY_WISDOM) >= 14)
   return TRUE;
 return FALSE;
}
int GetWisdom(object oTarget)
{
    return GetAbilityScore(oTarget, ABILITY_WISDOM);
}
int GetIntelligence(object oTarget)
{
    return GetAbilityScore(oTarget, ABILITY_WISDOM);
}
int GetCharisma(object oTarget)
{
    return GetAbilityScore(oTarget, ABILITY_CHARISMA);
}
//////////////////////////////////////////////////
//  GetNumItems
//////////////////////////////////////////////////
/**/
// Returns the number of specified item in the
// target's inventory.
int GetNumItems(object oTarget,string sItem)
{
    int nNumItems = 0;
    object oItem = GetFirstItemInInventory(oTarget);
    while (GetIsObjectValid(oItem) == TRUE)
    {
        if (GetTag(oItem) == sItem)
        {
            nNumItems = nNumItems + GetNumStackedItems(oItem);
        }
        oItem = GetNextItemInInventory(oTarget);
    }
   return nNumItems;
}
//////////////////////////////////////////////////
//  GiveNumItems
//////////////////////////////////////////////////
/**/
// Gives the target the number of items specified.
void GiveNumItems(object oTarget,string sItem,int nNumItems)
{
    int nCount = 0;
    object oItem = GetFirstItemInInventory(OBJECT_SELF);
    while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)
    {
        if (GetTag(oItem) == sItem)
        {
            ActionGiveItem(oItem,oTarget);
            nCount++;
        }
        oItem = GetNextItemInInventory(OBJECT_SELF);
    }
   return;
}
//////////////////////////////////////////////////
//  TakeNumItems
//////////////////////////////////////////////////
/**/
// Takes the number of items specified from the target.
void TakeNumItems(object oTarget,string sItem,int nNumItems)
{
    int nCount = 0;
    object oItem = GetFirstItemInInventory(oTarget);
    while (GetIsObjectValid(oItem) == TRUE && nCount < nNumItems)
    {
        if (GetTag(oItem) == sItem)
        {
            ActionTakeItem(oItem,oTarget);
            nCount++;
        }
        oItem = GetNextItemInInventory(oTarget);
    }
   return;
}
///////////////////////////////////////////////////////////////////////////////
//  GetReactionAdjustment
///////////////////////////////////////////////////////////////////////////////
/**/
//  Returns the adjusted Reaction for the purposes of store pricing.
 float GetReactionAdjustment(object oTarget)
{
    float nFactionAdjustment = 2.0;
    // (i)
    if (GetIsFriend(oTarget) == TRUE)
    {
        nFactionAdjustment = 1.0;
    }
    // (ii)
    int oTargetLawChaos = GetLawChaosValue(oTarget);
    int oTargetGoodEvil = GetGoodEvilValue(oTarget);
    int oSourceLawChaos = GetLawChaosValue(OBJECT_SELF);
    int oSourceGoodEvil = GetGoodEvilValue(OBJECT_SELF);
    int APB = abs(oSourceLawChaos - oTargetLawChaos)  + abs(oSourceGoodEvil - oTargetGoodEvil);
    int nTargetCharismaMod = GetAbilityModifier(ABILITY_CHARISMA, oTarget);
    return abs(10 + APB - (nTargetCharismaMod * 10)) * nFactionAdjustment;
}
//::///////////////////////////////////////////////
//:: Escape Via Teleport
//::///////////////////////////////////////////////
/**/
// Makes the person teleport away and look like
// they are casting a spell.
void EscapeViaTeleport(object oFleeing)
{
    effect eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
    ActionCastFakeSpellAtObject(SPELL_MINOR_GLOBE_OF_INVULNERABILITY, oFleeing);
    DelayCommand(1.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, GetLocation(oFleeing)));
    DestroyObject(oFleeing, 2.5);
}
//::///////////////////////////////////////////////
//:: RemoveEffects
//:://////////////////////////////////////////////
/**/
// removes all negative effects
void RemoveEffects(object oDead)
{
    //Declare major variables
    object oTarget = oDead;
    effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
    int bValid;
    effect eBad = GetFirstEffect(oTarget);
    //Search for negative effects
    while(GetIsEffectValid(eBad))
    {
        if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
            GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
            GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
            GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
            GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL ||
            GetEffectType(eBad) == EFFECT_TYPE_FRIGHTENED ||
            GetEffectType(eBad) == EFFECT_TYPE_DAZED ||
            GetEffectType(eBad) == EFFECT_TYPE_CONFUSED ||
            GetEffectType(eBad) == EFFECT_TYPE_POISON ||
            GetEffectType(eBad) == EFFECT_TYPE_DISEASE
                )
            {
                //Remove effect if it is negative.
                RemoveEffect(oTarget, eBad);
            }
        eBad = GetNextEffect(oTarget);
    }
    //Fire cast spell at event for the specified target
    SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);
    // * May 2002: Removed this because ActionRest is no longer an instant.
    // * rest the player
    //AssignCommand(oDead, ActionRest());
}
//::///////////////////////////////////////////////
//:: MoveForward
//:://////////////////////////////////////////////
/**/
// Altered, JumpTo routine. Move forward fDistance.
void MoveForward(object oMove, float fDistance)
{
   object oTarget = (oMove);
   object oArea = GetArea(oTarget);
   vector vPosition = GetPosition(oTarget);
   float fOrientation = GetFacing(oTarget);
   vector vNewPos = AngleToVector(fOrientation);
   float vZ = vPosition.z;
   float vX = vPosition.x + fDistance * vNewPos.x;
   float vY = vPosition.y + fDistance * vNewPos.y;

   fOrientation = GetFacing(oTarget);
   vX = vPosition.x + fDistance * vNewPos.x;
   vY = vPosition.y + fDistance * vNewPos.y;
   vNewPos = AngleToVector(fOrientation);
   vZ = vPosition.z;
   vNewPos = Vector(vX, vY, vZ);
   ActionForceMoveToLocation(Location(oArea,vNewPos,fOrientation),FALSE,10.0);
}
//::///////////////////////////////////////////////
//:: Turn
//:://////////////////////////////////////////////
/**/
// Turns NPC 90 degrees in that direction.
void Turn(object oTurn, int TURN)
{
float fFacing;
fFacing = GetFacing(oTurn);
    switch (TURN)
    {
        case 0:
        if(fFacing > 270.0)
        {
        fFacing = fFacing - 270.0;
        SetFacing(fFacing);
        }
        else if(fFacing <= 270.0)
        {
        fFacing = fFacing + 90.0;
        SetFacing(fFacing);
        }
        break;
        case 1:
        if(fFacing < 90.0)
        {
        fFacing = fFacing + 270.0;
        SetFacing(fFacing);
        }
        else if(fFacing >= 90.0)
        {
        fFacing = fFacing - 90.0;
        SetFacing(fFacing);
        }
        break;
    }
}
//::///////////////////////////////////////////////
//:: JumpToPoint
//:://////////////////////////////////////////////
/**/
// Cheiron the Centaur's Jump routine.
void JumpToPoint(object oTarget, int JUMP, float fDistance)
{
   object oJump = (oTarget);
   object oArea = GetArea(oJump);
   vector vPosition = GetPosition(oJump);
   float fOrientation = GetFacing(oJump);
   vector vNewPos = AngleToVector(fOrientation);
   float fDist = (fDistance);
   float vX;
   float vY;
   float vZ;
   switch (JUMP)
    {
        case 0:
        vX = vPosition.x + fDist * vNewPos.x;
        vY = vPosition.y + fDist * vNewPos.y;
        vZ = vPosition.z;
        vNewPos = Vector(vX, vY, vZ);
        ActionJumpToLocation(Location(oArea, vNewPos, fOrientation) );
        ActionDoCommand(SetFacing(fOrientation));
        break;
        case 1:
        vX = vPosition.x - fDist * vNewPos.x;
        vY = vPosition.y - fDist * vNewPos.y;
        vZ = vPosition.z;
        vNewPos = Vector(vX, vY, vZ);
        ActionJumpToLocation( Location( oArea, vNewPos, fOrientation) );
        ActionDoCommand(SetFacing(fOrientation));
        break;
    }
}
// ***************************************
// This function can be used to determine what kind of weapon it is,
// but also to determine if an item is a weapon at all!
// It will return:
//   0 => not a (valid) weapon
//   1 => TINY weapon
//   2 => SMALL weapon
//   3 => MEDIUM weapon
//   4 => LARGE weapon
// ***************************************
int getWeaponSize(int iBaseType)
{
   switch(iBaseType)
   {
      case BASE_ITEM_DAGGER: // simple, melee
      case BASE_ITEM_KAMA:   // exotic, melee
      case BASE_ITEM_KUKRI:  // exotic, melee
      case BASE_ITEM_SHURIKEN: // exotic, ranged
      {
         return(1); // weapon size: Tiny
      }
      case BASE_ITEM_LIGHTMACE: // simple, melee
      case BASE_ITEM_SICKLE:  // simple, melee
      case BASE_ITEM_THROWINGAXE: // martial, melee
      case BASE_ITEM_LIGHTHAMMER: // martial, melee
      case BASE_ITEM_HANDAXE: // martial, melee
      case BASE_ITEM_SHORTSWORD: // martial, melee
      case BASE_ITEM_DART: // simple, ranged
      case BASE_ITEM_LIGHTCROSSBOW: // simple, ranged
      case BASE_ITEM_SLING: // simple, ranged
      {
         return(2); // weapon size: Small
      }
      case BASE_ITEM_CLUB: // simple, melee
      case BASE_ITEM_MORNINGSTAR: // simple, melee
      case BASE_ITEM_BATTLEAXE: // martial, melee
      case BASE_ITEM_LIGHTFLAIL: // martial, melee
      case BASE_ITEM_LONGSWORD: // martial, melee
      case BASE_ITEM_RAPIER: // martial, melee
      case BASE_ITEM_SCIMITAR: // martial, melee
      case BASE_ITEM_WARHAMMER: // martial, melee
      case BASE_ITEM_KATANA: // exotic, melee
      case BASE_ITEM_BASTARDSWORD: // exotic, melee
      case BASE_ITEM_HEAVYCROSSBOW: // simple, ranged
      case BASE_ITEM_SHORTBOW: // martial, ranged
      {
         return(3);   // weapon size: Medium
      }
      case BASE_ITEM_QUARTERSTAFF: // simple, melee
      case BASE_ITEM_SHORTSPEAR: // simple, melee
      case BASE_ITEM_GREATSWORD: // martial, melee
      case BASE_ITEM_GREATAXE: // martial, melee
      case BASE_ITEM_HALBERD: // martial, melee
      case BASE_ITEM_HEAVYFLAIL: // martial, melee
      case BASE_ITEM_SCYTHE: // martial, melee
      case BASE_ITEM_TWOBLADEDSWORD: // exotic, melee
      case BASE_ITEM_DIREMACE: // exotic, melee (?)
      case BASE_ITEM_DOUBLEAXE: // exotic, melee
      case BASE_ITEM_LONGBOW: // martial, ranged
      {
         return(4); // weapon size: Large
      }
   }
   return 0; // it's not a weapon!
}
// ***************************************
// Convert current YY-MM-DD HH:MM:SS to one float value
// Useful in GetLocalFloat/SetLocalFloat context to wait a specified number of hours.
// Example:
// if(GetLocalFloat(OBJECT_SELF, "LASTTIME") + HoursToSeconds(hoursToWait) > getCurrentTime())
// { // do something and SetLocalFloat; }
// ***************************************
float getCurrentTime()
{
   float fTime  = 0.0; // use floats, because the maximum might be > maxInt (2147483647)
   float year   = IntToFloat(GetCalendarYear() - 1300); // 1300..1400 => 0..100
   float month  = IntToFloat(GetCalendarMonth());       // 1..12
   float day    = IntToFloat(GetCalendarDay());         // 1..28
   float hour   = IntToFloat(GetTimeHour());            // 1..24
   float minute = IntToFloat(GetTimeMinute());          // 1..60
   float second = IntToFloat(GetTimeSecond());          // 1..60
   float factor = HoursToSeconds(1) / 60.0; // how many minutes are there in 1 hour?
   fTime = (((((((((year * 12.0) + month) * 28.0) + day) * 24.0) + hour) * factor) + minute) * 60.0) + second;
   return fTime;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.