Each item set will have different bonuses. I don't want to lock the team into making sets that only add a specific number of bonuses per items equipped, so one set may give 3, 4, then 5 bonuses, and another may give 2, then 5 bonuses.
A loop is a quick (though expensive) solution. I could also execute code directly inside the case switch.
/*************************************************************Evezial's Set Item ScriptThis script allows set items to apply a bonus based onthe number of set items currently equipped. It worksby running through each equpment slot whenever a setitem is equipped. For each additional item found, itapplies the bonus effect/s.
When items are unequipped, the effects will be removed.This requires each set to be entered onto the ez_setitem_geartable, along with the bonus it applies.
Each set will need its own script for unique bonusesthat will be applied. This script simply applies thebonuses related to the sets. Also, each item will needto have the proper local variables set.
Evezial Hall03132011**************************************************************/#include "ez_setitem_gear"
void main(){object oPC = GetPCItemLastEquippedBy(); //PC who equipped the item.object oItem = GetPCItemLastEquipped(); //Item being equipped.object oInvItem; //Item currently being checked in player's inventory.
string sItemLocString = GetLocalString(oInvItem); //Local string variable of item being checked. string sKitLocString = GetLocalString(oItem, sKitID); //Local string variable of the set.
int iSlot; //Inventory slots (all 17 of them!).int iSetNum; //Number of set items currently equipped.
//Compares the local string var of each item and adds up the matches.for(iSlot=0; iSlot < 18; iSlot++) { GetItemInSlot(iSlot, oPC); if(sKitLocString == sItemLocString) iSetNum++; } //Make certain that the if (iSetNum < 2)return;
//Applies bonus to PCeffect iBonus = eItemSetBonus(sKitLocString, iSetNum, oPC);
}
And this is where the set items are defined:
/********************************************************************This script is the collection of all the set items on the server.As additional items are created, they must be added and programmedhere.*********************************************************************/
void eItemSetBonus(string sKitID, int iSetNum, object oPC){int iBonus = iSetNum - 2; //Switch Case has to start at 0, so we subtract 2 from the iSetNum result, giving us a range from 0 to 4 for all items.
//These store up to 6 seperate effects that can be granted by the set items. More can be added if necessary.effect Effect1;effect Effect2;effect Effect3;effect Effect4;effect Effect5;effect Effect6;effect eLinked;
if(sKitID == "BigCleaver") { switch(iBonus) { case 0 : Effect1 = EffectAbilityIncrease(ABILITY_CHARISMA, 1); break; case 1 : Effect1 = EffectAbilityIncrease(ABILITY_CHARISMA, 2); break; case 2 : Effect1 = EffectAbilityIncrease(ABILITY_CHARISMA, 2); Effect2 = EffectAbilityIncrease(ABILITY_STRENGTH, 1); eLinked = EffectLinkEffects(Effect1, Effect2); break; case 3 : Effect1 = EffectAbilityIncrease(ABILITY_CHARISMA, 2); Effect2 = EffectAbilityIncrease(ABILITY_STRENGTH, 2); eLinked = EffectLinkEffects(Effect1, Effect2); break; case 4 : Effect1 = EffectAbilityIncrease(ABILITY_CHARISMA, 2); Effect2 = EffectAbilityIncrease(ABILITY_STRENGTH, 2); Effect3 = EffectHaste(); eLinked = EffectLinkEffects(Effect1, Effect2, Effect3); break; } } //Next IF goes here.
//Link and apply effectseLinked = EffectLinkEffects(eLinked);eLinked = SupernaturalEffect(eLinked);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLinked, oPC);;
}
I think I like the idea of just linking and applying the effect directly in the switch case, so I don't have to worry about making a variable number of ApplyEffect functions in a loop.
My second, larger problem, is removing the effects if a set item is unequpped. My first though would be to remove all status effects, then reapply them as if there were one fewer of the set equipped. This could easily be exploited to get rid of curses and such.
My second thought was to only remove effects that are both permanent and supernatural (required so the abilities don't disappear on rest or disenchant). I'm not familiar enough with DnD to know if there are any castable spells that match this. On top of that, it's REALLY expensive to run that loop. My very powerful machine running a local game paused for almost a second while the loop ran.
Any ideas how to make it less intrusive and more reliable?
void main(){object oPC = GetLastOpenedBy();
effect eEffect = GetFirstEffect(oPC);
while (GetIsEffectValid(eEffect)) { if (GetEffectDurationType(eEffect) == DURATION_TYPE_PERMANENT && GetEffectSubType(eEffect) == SUBTYPE_SUPERNATURAL) { RemoveEffect(oPC, eEffect); } } eEffect = GetNextEffect(oPC); }





Retour en haut






