Alangara_PRC8/_module/nss/mn_i_pcskin.nss
Jaysyn904 86feb9ca6f Initial commit
Initial commit.
2024-06-05 21:21:06 -04:00

302 lines
9.5 KiB
Plaintext

#include "prc_inc_skin"
// Gets the character skin, creates it if not present, equips if not equipped.
object getSkin(object oPC);
// Remove all properties on skin, and recalculate properties
// from classes and race.
void updateSkin(object oPC);
// Removes all effects from character
void removeEffects(object oPC);
// Removes all effects from character, and recalculates effects
// from classes and race.
void setupSpecialEffects(object oPC);
void equipSkin(object oSkin,int nCount=0)
{
object oThere=GetItemInSlot(INVENTORY_SLOT_CARMOUR,OBJECT_SELF);
if (nCount>0&&GetCurrentAction()==ACTION_REST)
{
DelayCommand(0.2,equipSkin(oSkin,nCount));
return;
}
if (oSkin!=oThere&&!GetIsObjectValid(oThere))
{ // equip
AssignCommand(OBJECT_SELF,ActionEquipItem(oSkin,INVENTORY_SLOT_CARMOUR));
if (nCount<29) DelayCommand(0.2,equipSkin(oSkin,nCount+1));
} // equip
else if (GetIsObjectValid(oThere)&&oSkin!=oThere)
{ // skin already present
DestroyObject(oSkin);
} // skin already present
} // SKIN_SupportEquipSkin()
object getSkin(object oPC)
{
object oSkin=GetItemPossessedBy(oPC,"MN_PCSKIN");
if (GetIsObjectValid(oSkin))
{
SetPlotFlag(oSkin, FALSE);
DestroyObject(oSkin);
DeleteLocalObject(oPC, "skinObj");
}
oSkin=GetItemPossessedBy(oPC,"MN_PCSKIN2");
if (GetIsObjectValid(oSkin))
{
SetPlotFlag(oSkin, FALSE);
DestroyObject(oSkin);
DeleteLocalObject(oPC, "skinObj");
}
oSkin=GetItemPossessedBy(oPC,"MN_PCSKIN3");
if (GetIsObjectValid(oSkin))
{
SetPlotFlag(oSkin, FALSE);
DestroyObject(oSkin);
DeleteLocalObject(oPC, "skinObj");
}
oSkin=GetLocalObject(oPC,"skinObj");
// If resting, there's no point in re-assigning the "equip" action.
if (!GetIsPC(oPC)) return oPC;
if (!GetIsObjectValid(oSkin))
{ // find skin
oSkin=GetItemInSlot(INVENTORY_SLOT_CARMOUR,oPC);
if (GetIsObjectValid(oSkin))
{
SetLocalObject(oPC,"skinObj",oSkin);
}
} // find skin
if (!GetIsObjectValid(oSkin))
{ // create it
oSkin=GetItemPossessedBy(oPC,"MN_PCSKIN4");
if (GetIsObjectValid(oSkin))
{ // equip it already
DelayCommand(1.0,AssignCommand(oPC,equipSkin(oSkin)));
SetLocalObject(oPC,"skinObj",oSkin);
SetDroppableFlag(oSkin,FALSE);
return oSkin;
} // equip it already
else
{ // don't have one
oSkin=CreateItemOnObject("mn_pcskin",oPC);
DelayCommand(1.0,AssignCommand(oPC,equipSkin(oSkin)));
SetLocalObject(oPC,"skinObj",oSkin);
SetDroppableFlag(oSkin,FALSE);
} // don't have one
} // create it
return oSkin;
}
void updateSkin(object oPC)
{
object skin = GetPCSkin(oPC);
// Remove all properties from skin
itemproperty property = GetFirstItemProperty(skin);
while (GetIsItemPropertyValid(property))
{
RemoveItemProperty(skin, property);
property = GetNextItemProperty(skin);
}
// Add Minion Control feat
property = ItemPropertyBonusFeat( IP_CONST_FEAT_PLAYER_TOOL_01 );
DelayCommand(0.01f, AddItemProperty(DURATION_TYPE_PERMANENT, property, skin));
// Add bard abilities
int bardLevels = GetLevelByClass(CLASS_TYPE_BARD , oPC);
if (bardLevels>=10)
{
property = ItemPropertyBonusFeat( IP_CONST_FEAT_PLAYER_TOOL_10 );
DelayCommand(0.01f, AddItemProperty( DURATION_TYPE_PERMANENT, property, skin));
}
// Add weapon master abilities
// NB - maybe we can do this permanently instead using the char editor, at least for the ability calculations.
// This would make the changes "natural", as to not count against the cap of +12
int WMlevels = GetLevelByClass(CLASS_TYPE_WEAPON_MASTER, oPC);
if (WMlevels > 0)
{
// Ability modifiers are now given through DM, so only AC penalty remains on skin.
// property = ItemPropertyAbilityBonus(IP_CONST_ABILITY_STR, 4);
// AddItemProperty( DURATION_TYPE_PERMANENT, property, skin);
// property = ItemPropertyAbilityBonus(IP_CONST_ABILITY_DEX, 4);
// AddItemProperty( DURATION_TYPE_PERMANENT, property, skin);
// property = ItemPropertyDecreaseAbility(IP_CONST_ABILITY_CON, 4);
// AddItemProperty( DURATION_TYPE_PERMANENT, property, skin);
// BELOW REMOVED TEMPORARILY.
// itemproperty property = ItemPropertyDecreaseAC(IP_CONST_ACMODIFIERTYPE_DODGE, 4); // DODGE so that it will hopefully stack with all other modifiers.
// AddItemProperty( DURATION_TYPE_PERMANENT, property, skin);
}
}
void removeEffects(object oPC)
{
// TODO implement in JVM
effect ef = GetFirstEffect(oPC);
while (GetIsEffectValid(ef))
{
RemoveEffect(oPC, ef);
ef = GetNextEffect(oPC);
}
}
void monkEffects(object oPC)
{
// Check for monk status
int monk = GetLevelByClass(CLASS_TYPE_MONK, oPC );
if ( monk > 0 )
{
// Get total of levels
monk += GetLevelByClass(CLASS_TYPE_ASSASSIN, oPC );
monk += GetLevelByClass(CLASS_TYPE_HARPER, oPC );
monk += GetLevelByClass(CLASS_TYPE_SHADOWDANCER, oPC );
monk += GetLevelByClass(CLASS_TYPE_ROGUE, oPC );
int dmgBoost = 0;
int attackBonus = 0;
if ( monk < 41 )
{
dmgBoost = DAMAGE_BONUS_20;
attackBonus = 20;
}
if ( monk < 31 )
{
dmgBoost = DAMAGE_BONUS_15;
attackBonus = 15;
}
if ( monk < 21 )
{
dmgBoost = DAMAGE_BONUS_10;
attackBonus = 10;
}
if ( monk < 11 )
{
dmgBoost = DAMAGE_BONUS_5;
attackBonus = 5;
}
// Create effects
effect eDmgBoost = SupernaturalEffect(EffectDamageIncrease( dmgBoost, DAMAGE_TYPE_MAGICAL ));
effect eAttackIncrease = SupernaturalEffect(EffectAttackIncrease (attackBonus, ATTACK_BONUS_MISC));
// Den version nedenunder goer at vaaben bonusser ikke taeller med.
// men har fusket selv som du kan se ovenfor og det virker.....
// hilsen tarashon, hehe
// effect eAttackIncrease = EffectAttackIncrease ( attackBonus, ATTACK_BONUS_ONHAND );
// Always call monkEffects through setupSpecialEffects, so effects are already removed - no stacking removal necessary
// Apply effect to player
DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDmgBoost, oPC));
DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eAttackIncrease, oPC));
}
}
void rogueEffects(object oPC)
{
int rogue = GetLevelByClass(CLASS_TYPE_ROGUE, oPC );
if ( rogue > 0 )
{
// Get total of levels
rogue += GetLevelByClass(CLASS_TYPE_ASSASSIN, oPC );
rogue += GetLevelByClass(CLASS_TYPE_HARPER, oPC );
rogue += GetLevelByClass(CLASS_TYPE_SHADOWDANCER, oPC );
// rogue += GetLevelByClass(CLASS_TYPE_WEAPON_MASTER, oPC );
int dmgBoost = 0;
int attackBonus = 0;
if ( rogue < 41 )
{
dmgBoost = DAMAGE_BONUS_20;
attackBonus = 20;
}
if ( rogue < 31 )
{
dmgBoost = DAMAGE_BONUS_15;
attackBonus = 15;
}
if ( rogue < 21 )
{
dmgBoost = DAMAGE_BONUS_10;
attackBonus = 10;
}
if ( rogue < 11 )
{
dmgBoost = DAMAGE_BONUS_5;
attackBonus = 5;
}
// Create effects
effect eDmgBoost = SupernaturalEffect(EffectDamageIncrease( dmgBoost, DAMAGE_TYPE_MAGICAL ));
effect eAttackIncrease = SupernaturalEffect(EffectAttackIncrease ( attackBonus, ATTACK_BONUS_MISC ));
/** Always call rogueEffects through setupSpecialEffects, so effects are already removed
// Prohibit stacking
effect eLoop=GetFirstEffect(oPC);
while (GetIsEffectValid(eLoop))
{
if (GetEffectType(eLoop)==EFFECT_TYPE_DAMAGE_INCREASE)
{
RemoveEffect(oPC, eLoop);
}
else if (GetEffectType(eLoop)== EFFECT_TYPE_ATTACK_INCREASE)
{
RemoveEffect(oPC, eLoop);
}
eLoop=GetNextEffect(oPC);
}
**/
// Apply effect to player - due to NWScript-bug, use delayCommand (duration_type_permanent cannot be removed and added in same script...)
DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDmgBoost, oPC));
DelayCommand(0.1f, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eAttackIncrease, oPC));
}
}
void setupSpecialEffects(object oPC)
{
removeEffects(oPC);
// Rogue/monk boost power
int rogue = GetLevelByClass(CLASS_TYPE_ROGUE, oPC );
if ( rogue > 0 )
{
// Get total of levels
rogue += GetLevelByClass(CLASS_TYPE_ASSASSIN, oPC );
rogue += GetLevelByClass(CLASS_TYPE_HARPER, oPC );
rogue += GetLevelByClass(CLASS_TYPE_SHADOWDANCER, oPC );
}
int monk = GetLevelByClass(CLASS_TYPE_MONK, oPC );
if ( monk > 0 )
{
// Get total of levels
monk += GetLevelByClass(CLASS_TYPE_ASSASSIN, oPC );
monk += GetLevelByClass(CLASS_TYPE_HARPER, oPC );
monk += GetLevelByClass(CLASS_TYPE_SHADOWDANCER, oPC );
monk += GetLevelByClass(CLASS_TYPE_ROGUE, oPC );
}
if (monk >= rogue && monk > 0)
{
monkEffects(oPC);
}
else if (rogue > monk && rogue > 0)
{
rogueEffects(oPC);
}
}
//::void main(){}