If I understand the OP's proposal correctly, He was only going to equip the items at random. Unless I miss my guess, that would cause less lag than script-looping through all effects, removing the unwanted ones and adding wanted ones.
So, as I understand it, there are 12 amulets held by the creature. Each amulet bestows 100% immunity to 11 types of damage and 100% vulnerability to the remaining damage type. The vulnerablility is different for each amulet. After a few rounds of combat, the creature equips a new (randomly selected) amulet, thus unequipping the previous one and thus becoming vulnerable to a different damage type, which forces the PCs to switch weapons until they find the new vulnerability.
I can see that the difficulty could be set by how often the creature switches vulnerability.
Switching vulnerability every combat round would make the creature almost impossible to defeat as the players would have finished their combat round by the time they could finish switching weapons. Switching it only every 12 rounds would allow the players to discover the new vulnerability and get in some worthwhile damage before the next change. Anything less than 12 rounds would make it possible for the players to not discover the vulnerability before the next change.
Add the following to the start of the OnCombatRoundEnd script event on the creature, just after the opening curly brace following void main()
int iRounds=GetLocalInt(OBJECT_SELF,"Rounds");
iRounds++;
if (iRounds>11)// change the number here to one less than the number of rounds between changes.
{
iRounds=0;// Reset iRounds so we don't start switching weapons every round.
int iAmmy=Random(12)+1;// change 0-11 to 1-12 by adding one
// In the following line, change the part in quotes to the actual tag for the amulets.
ActionEquipItem("AmuletTag"+IntToString(iAmmy), INVENTORY_SLOT_NECK);
}
SetLocalInt(OBJECT_SELF,"Rounds",iRounds);
That should do what you want. Tag the amulets "AmuletTag1" through "AmuletTag12", make sure they're in the creature's inventory and identified and you should be good to go.
Ask questions if anything is unclear and I'll try to help.
Modifié par Melkior_King, 13 mai 2012 - 04:55 .