Again, at wits end. This involves a previously mentioned pair of scripts that I've been working on. I tied ACP's weapon styles into feats that the player can activate at will, each style granting different bonuses and disadvantages. The code works like a charm, that is, when there are no other effects from anything else applied to the character when they try and change styles.
Here is the include with the functions:
"nc_wep_mstrcntrl"
//Resets to original phenotype
void ResetOriginalPhenoType(object oPC);
void ResetOriginalPhenoType(object oPC)
{
//If we are at phenotype 50-60 we want to reset it to neutral.
if (GetLocalInt(oPC, "iOriginalPhenoType") == 0)
{
SetPhenoType(0, oPC);
SendMessageToPC(oPC, "You are now using the Basic Form.");
}
//If we are at phenotype 61 - 71 we reset it to neutral.
else if (GetLocalInt(oPC, "iOriginalPhenoType") == 2)
{
SetPhenoType(2, oPC);
SendMessageToPC(oPC, "You are now using the Basic Form.");
}
}
void SetWeaponStyle(int iStyle);
void SetWeaponStyle(int iStyle)
{
if (GetPhenoType(OBJECT_SELF) == iStyle)
SendMessageToPC(OBJECT_SELF, "You're already using this fighting style!");
else SetPhenoType(iStyle);
}
//Library of Weapon Style Effects
//Defender Weapon Style Effect, 3/+20 DR, 2% chance to miss
void EffectDefenderStyle();
void EffectDefenderStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectMissChance(5, MISS_CHANCE_TYPE_NORMAL), oPC); //2% Miss Chance
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageReduction(5, DAMAGE_POWER_PLUS_TWENTY), oPC); //Defender Damage Reduction, 5/+20
}
//Fencer Weapon Style Effect, +1d4 Piercing Damage, +2 Dodge Bonus, -5 Discipline
void EffectFencerStyle();
void EffectFencerStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectACIncrease(2, AC_DODGE_BONUS), oPC); //Fencer AC increase
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d4(1), DAMAGE_TYPE_PIERCING), oPC); //+1d4 Piercing Damage
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSkillDecrease(SKILL_DISCIPLINE, 5), oPC); //-5 Discipline Penalty
}
//Powerful Swings Style Effect, +1d6 Bludgeoning Damage, -2 Tumble, -1 Dodge AC
void EffectPowerfulStyle();
void EffectPowerfulStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectACDecrease(1, AC_DODGE_BONUS), oPC); //AC Decrease
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d6(1), DAMAGE_TYPE_BLUDGEONING), oPC); //+1d6 bludgeoning bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSkillDecrease(SKILL_TUMBLE, 2), oPC); //-2 Tumble
}
//Twin Blades Style Effect, +2 to off-hand attack bonus, -3 AC
void EffectTwinBladesStyle();
void EffectTwinBladesStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectACDecrease(3, AC_DODGE_BONUS), oPC);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectAttackIncrease(2, ATTACK_BONUS_OFFHAND), oPC);
}
//Sun Fist unarmed style, +1d4 Bludgeoning
void EffectSunFistStyle();
void EffectSunFistStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d4(1), DAMAGE_TYPE_BLUDGEONING), oPC); //+1d4 Bludgeoning bonus
}
//Tiger Fang unarmed style, +1d6 slashing
void EffectTigerFangStyle();
void EffectTigerFangStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d6(1), DAMAGE_TYPE_SLASHING), oPC); //+1d6 slashing bonus
}
//Dragon Palm unarmed style, +1d6 magical bonus (aka chi)
void EffectDragonPalmStyle();
void EffectDragonPalmStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d6(1), DAMAGE_TYPE_MAGICAL), oPC); //+1d6 magical "chi" bonus
}
//Ken-Seijin style, +2 Attack Bonus, +1d8 Slashing Bonus
void EffectKenSeijinStyle();
void EffectKenSeijinStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d8(1), DAMAGE_TYPE_SLASHING), oPC); //+1d8 slashing damange bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectAttackIncrease(2, ATTACK_BONUS_MISC), oPC); //+2 Attack Bonus
}
//Singing Sword style, +2 Attack Bonus, +1d6 Magical Bonus
void EffectSingingSwordStyle();
void EffectSingingSwordStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d6(1), DAMAGE_TYPE_MAGICAL), oPC); //+1d6 Magical Bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectAttackIncrease(2, ATTACK_BONUS_MISC), oPC); //+2 Attack Bonus
}
//Ars Magna style, +3 Dodge Bonus, +1 Attack Bonus
void EffectArsMagnaStyle();
void EffectArsMagnaStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectAttackIncrease(1, ATTACK_BONUS_MISC), oPC); //Attack Bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectACIncrease(3, AC_DODGE_BONUS), oPC); //AC Bonus
}
//Bear Claw style, +1d6 Magical Bonus, +1d6 Slashing Bonus
void EffectBearClawStyle();
void EffectBearClawStyle()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d6(1), DAMAGE_TYPE_MAGICAL), oPC); //+1d6 Magical Bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(d6(1), DAMAGE_TYPE_SLASHING), oPC); //+1d6 Slashing Bonus
}
//Lagora-cû style, +1 Attack Per Round, 5% Chance of Missing
void EffectBow1Style();
void EffectBow1Style()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectModifyAttacks(1), oPC); //Extra Attack bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectMissChance(5, MISS_CHANCE_TYPE_NORMAL), oPC); //Miss Chance application
}
//Delos-cû style, +2 Attack Bonus, +1 Dodge Bonus
void EffectBow2Style();
void EffectBow2Style()
{
object oPC = OBJECT_SELF;
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectAttackIncrease(2, ATTACK_BONUS_MISC), oPC); //+2 Attack Bonus
ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectACIncrease(1, AC_DODGE_BONUS), oPC); //+1 Dodge Bonus
}
// Removes any previous weapon style effects that may be on the player so
// they can't stack 'em up and knock 'em down
// Removes any previous weapon style effects that may be on the player so
// they can't stack 'em up and knock 'em down
void RemoveStyleEffects()
{
object oPC = OBJECT_SELF;
effect eEffect = GetFirstEffect(oPC);
while (GetIsEffectValid(eEffect))
{
switch (GetEffectSpellId(eEffect))
{
case 2307: // Defender Style
case 2308: // Fencer Style
case 2309: // Powerful Swings Style
case 2310: // Twin Blades Style
case 2311: // Sun Fist Style
case 2312: // Tiger Fang Style
case 2313: // Dragon Palm Style
case 2314: // Ken-Seijin Style
case 2315: // Singing Sword Style
case 2316: // Ars Magna Style
case 2317: // Bear Claw Style
case 2318: // Lagora-cû style
case 2319: // Delos-cû style
RemoveEffect(oPC, eEffect);
break;
}
eEffect = GetNextEffect(oPC);
}
}[/code]
And here's the script that performs the actual switching. All of the feats are tied to this script.
"nc_wep_styswitch"
#include "nc_wep_mstrcntrl"
void main()
{
//Declare Major Variables
int nStyle = GetSpellId(); //Gets the weapon style that called this script
object oPC = OBJECT_SELF; //Defines the Player Character
int iOrigPheno = GetLocalInt(oPC, "iOriginalPhenoType");//Gets the original phenotype from the variable set on the player OnClientEnter (first entering the game)
switch (nStyle)
{
//Basic Form style (aka default mode)
case 2306:
RemoveStyleEffects();
ResetOriginalPhenoType(oPC);
break;
//Defender style
case 2307:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(56);
EffectDefenderStyle();
SendMessageToPC(oPC, "You are now using the Defender combat style");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(67);
EffectDefenderStyle();
SendMessageToPC(oPC, "You are now using the Defender combat style");
break;
}
break;
//Fencer style
case 2308:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(53);
EffectFencerStyle();
SendMessageToPC(oPC, "You are now using the Fencer combat style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(64);
EffectFencerStyle();
SendMessageToPC(oPC, "You are now using the Fencer combat style.");
break;
}
break;
//Powerful Swings style
case 2309:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(52);
EffectPowerfulStyle();
SendMessageToPC(oPC, "You are now using the Powerful Swings combat style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(63);
EffectPowerfulStyle();
SendMessageToPC(oPC, "You are now using the Powerful Swings combat style.");
break;
}
break;
//Twin Blades style
case 2310:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(51);
EffectTwinBladesStyle();
SendMessageToPC(oPC, "You are now using the Twin Blades combat style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(62);
EffectTwinBladesStyle();
SendMessageToPC(oPC, "You are now using the Twin Blades combat style.");
break;
}
break;
//Sun Fist style
case 2311:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(58);
EffectSunFistStyle();
SendMessageToPC(oPC, "You are now using the Sun Fist unarmed style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(69);
EffectSunFistStyle();
SendMessageToPC(oPC, "You are now using the Sun Fist unarmed style.");
break;
}
break;
//Tiger Fang style
case 2312:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(57);
EffectTigerFangStyle();
SendMessageToPC(oPC, "You are now using the Tiger Fang unarmed style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(68);
EffectTigerFangStyle();
SendMessageToPC(oPC, "You are now using the Tiger Fang unarmed style.");
break;
}
break;
//Dragon Palm style
case 2313:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(59);
EffectDragonPalmStyle();
SendMessageToPC(oPC, "You are now using the Dragon Palm unarmed style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(70);
EffectDragonPalmStyle();
SendMessageToPC(oPC, "You are now using the Dragon Palm unarmed style.");
break;
}
break;
//Ken-Seijin style
case 2314:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(50);
EffectKenSeijinStyle();
SendMessageToPC(oPC, "You are now using the Ken-Seijin combat style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(61);
EffectKenSeijinStyle();
SendMessageToPC(oPC, "You are now using the Ken-Seijin combat style.");
break;
}
break;
//Singing Sword style
case 2315:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(55);
EffectSingingSwordStyle();
SendMessageToPC(oPC, "You are now using the Singing Sword combat style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(66);
EffectSingingSwordStyle();
SendMessageToPC(oPC, "You are now using the Singing Sword combat style.");
break;
}
break;
//Ars Magna style
case 2316:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(54);
EffectArsMagnaStyle();
SendMessageToPC(oPC, "You are now using the Ars Magna combat style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(65);
EffectArsMagnaStyle();
SendMessageToPC(oPC, "You are now using the Ars Magna combat style.");
break;
}
break;
//Bear Claw style
case 2317:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(60);
EffectBearClawStyle();
SendMessageToPC(oPC, "You are now using the Bear's Claw unarmed style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(71);
EffectBearClawStyle();
SendMessageToPC(oPC, "You are now using the Bear's Claw unarmed style.");
break;
}
break;
//Langora-cû Style
case 2318:
switch (iOrigPheno) //Check for the phenotypes
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(51);
EffectBow2Style();
SendMessageToPC(oPC, "You are now using the Langora-cû ranged style.");
break;
//Large Phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(62);
EffectBow2Style();
SendMessageToPC(oPC, "You are now using the Langora-cû ranged style.");
break;
}
//Delos-cû Style
case 2319:
switch(iOrigPheno)
{
//Thin phenotype
case 0:
RemoveStyleEffects();
SetWeaponStyle(51);
EffectBow2Style();
SendMessageToPC(oPC, "You are now using the Delos-cû ranged style.");
break;
//Large phenotype
case 2:
RemoveStyleEffects();
SetWeaponStyle(62);
EffectBow2Style();
SendMessageToPC(oPC, "You are now using the Delos-cû ranged style.");
break;
}
}
}
Currently, everytime you switch, the script checks to see if one of the associated spellid's is active on the player then wipe's the style's effects from them before applying the new ones. This prevents players from stacking effects. Unfortunately, if I try to switch a style while something like Mage Armor is active, it causes a stack overflow and nothing happens. I'm at wits end here, I have no experience with these kinds of errors. Please help!
-NineCoronas