generated from Jaysyn/ModuleTemplate
84 lines
2.9 KiB
Plaintext
84 lines
2.9 KiB
Plaintext
// Racial and Armor speed routines
|
|
#include "prc_x2_itemprop"
|
|
// Declare int values for movement rates
|
|
const int SML_CREATURE_MOVEPEN = 33;
|
|
const float SML_CREATURE_ARMORPEN = 25.0;
|
|
const float MDM_CREATURE_ARMORPEN = 33.0;
|
|
//Sets movement rates to more closely match the 3.5 D&D rules.
|
|
void SetRacialMovementRate(object oCreature)
|
|
{
|
|
if(GetLocalInt(oCreature, "RACIAL_MOVEMENT") == 1)
|
|
return;
|
|
|
|
int nType = GetRacialType(oCreature);
|
|
if(nType == RACIAL_TYPE_ANIMAL || nType == RACIAL_TYPE_BEAST ||
|
|
nType == RACIAL_TYPE_DRAGON || nType == RACIAL_TYPE_MAGICAL_BEAST ||
|
|
nType == RACIAL_TYPE_VERMIN) return;
|
|
|
|
if(GetCreatureSize(oCreature) == CREATURE_SIZE_SMALL || nType == RACIAL_TYPE_DWARF
|
|
|| nType == RACIAL_TYPE_GNOME || nType == RACIAL_TYPE_HALFLING)
|
|
{
|
|
SendMessageToPC(oCreature, "Setting Racial Movement Rate");
|
|
effect eRate = SupernaturalEffect(EffectMovementSpeedDecrease(SML_CREATURE_MOVEPEN));
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eRate, oCreature);
|
|
SetLocalInt(oCreature, "RACIAL_MOVEMENT", 1);
|
|
return;
|
|
}
|
|
}
|
|
//Apply armor encumbrance penalties to oObject
|
|
void EffectArmorEncumbrance(object oCreature, object oArmor)
|
|
{
|
|
int nType = GetRacialType(oCreature);
|
|
int nNetAC = GetItemACValue(oArmor);
|
|
int nBonus = IPGetWeaponEnhancementBonus(oArmor, ITEM_PROPERTY_AC_BONUS);
|
|
int nBaseAC = nNetAC - nBonus;
|
|
float fMod;
|
|
|
|
switch(nBaseAC)
|
|
{
|
|
case 0: case 1: case 2: case 3: return;
|
|
case 4: case 5: fMod = 1.0f; break;
|
|
default: fMod = 1.0f;
|
|
}
|
|
effect ePenalty;
|
|
int nRate;
|
|
if(GetCreatureSize(oCreature) == CREATURE_SIZE_SMALL|| nType == RACIAL_TYPE_DWARF
|
|
|| nType == RACIAL_TYPE_GNOME || nType == RACIAL_TYPE_HALFLING)
|
|
{
|
|
nRate = FloatToInt(SML_CREATURE_ARMORPEN / fMod);
|
|
ePenalty = SupernaturalEffect(EffectMovementSpeedDecrease(nRate));
|
|
}
|
|
else
|
|
{
|
|
nRate = FloatToInt(MDM_CREATURE_ARMORPEN / fMod);
|
|
ePenalty = SupernaturalEffect(EffectMovementSpeedDecrease(nRate));
|
|
}
|
|
ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePenalty, oCreature);
|
|
SendMessageToPC(oCreature, "Movement Speed Decreased By " + IntToString(nRate) + " % Due To Armor Encumbrance");
|
|
}
|
|
//Remove armor encumbrance penalties from oObject
|
|
void RemoveArmorEncumbrance(object oCreature, object oArmor)
|
|
{
|
|
int nType;
|
|
effect ePenalty = GetFirstEffect(oCreature);
|
|
while(GetIsEffectValid(ePenalty))
|
|
{
|
|
nType = GetEffectType(ePenalty);
|
|
SendMessageToPC(OBJECT_SELF, IntToString(nType));
|
|
if(GetEffectCreator(ePenalty) == OBJECT_SELF &&
|
|
nType == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE &&
|
|
GetEffectSubType(ePenalty) == SUBTYPE_SUPERNATURAL)
|
|
{
|
|
RemoveEffect(oCreature, ePenalty);
|
|
}
|
|
ePenalty = GetNextEffect(oCreature);
|
|
}
|
|
SendMessageToPC(oCreature, "Movement Speed Set To Normal");
|
|
SetLocalInt(oCreature, "RACIAL_MOVEMENT", 0);
|
|
DelayCommand(0.5, SetRacialMovementRate(oCreature));
|
|
}
|
|
// Uncomment to test compiling
|
|
//void main ()
|
|
//{
|
|
//}
|