Author Topic: Boss Concept: Randomly changing Damage Immunities  (Read 505 times)

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« on: May 10, 2012, 08:45:09 pm »


               OK. If any of you have played Median XL, you will know exactly what I am talking about. Basically this boss will be damned near Quov Tsin. Credits to Lazbro for the idea '<img'>

My idea was creating 12 amulets with 100% immune to all but one dmg type, and 100% vuln to a single damage type.   And have the boss randomly equip one from his inventory every few rounds.

I never got around to pursuing this encounter because on our server players had up to 180 unresistable dmg from EffectDamageIncrease at the time. This has recently been changed to temporary damage bonuses on weapons which has revived my motivation '<img'>

-----

I would like to get a little help from some of you more experienced scripters to try and get a smoothly running system for this boss. I honestly don't even know where to start for the most part. But as I said above I never even got past the concept on this so I never researched the inventory functions and whatnot. I guess I could figure it all out on my own, but it might not be as refined as someone elses.

I'm thinking just make these 12 amulets with linear resrefs/tags and use GetItemPossessedBy to loop through the 12 items and ActionEquipItem to equip one.

skip_dmgshld_01
skip_dmgshld_02
skip_dmgshld_03
... etc.

And then run this code OnCombatRoundEnd with like a 50% chance to change items.

-----
Second part of the encounter would be creating like 50 waypoints and run a random teleport + timestop OnDamaged in the boss's events.

What do you guys think? And suggestions welcome.

Thanx '<img'>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #1 on: May 10, 2012, 09:05:47 pm »


               wrong approach with the items, its simple, just make custom heartbeat where you:
- remove existing damage immunity effect
- add random damage immunity effect
effect will be permanent and supernatural

to do that you have to loop all effects on creature, then check if creator is OBJECT_SELF, subtype supernatural and type is damage immunity

alternatively you could use the creature skin/other item where you would loop itemproperties, remove the damge immunity one and add new but I don't see any benefit compared to the effects
               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #2 on: May 10, 2012, 09:13:10 pm »


               

wrong approach with the items, its simple, just make custom heartbeat where you:
- remove existing damage immunity effect
- add random damage immunity effect
effect will be permanent and supernatural

to
do that you have to loop all effects on creature, then check if creator
is OBJECT_SELF, subtype supernatural and type is damage immunity



Yah that was option # 2, wasn't sure which one would be faster and less laggy.

I wouldn't think there would be much performance difference between the two. Effects would definitely be a faster way to develop it. Only factor that matters to me is server performance.
               
               

               


                     Modifié par SKIPPNUTTZ, 10 mai 2012 - 08:17 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #3 on: May 10, 2012, 09:32:03 pm »


               from server performance, destroying and creating items itself makes much more hassle as the each itemproperty on item in fact applies invisible effects to pc, so when destroyed internal nwn code first deletes all effect from old item and then apply new effect from new item
               
               

               
            

Legacy_Melkior_King

  • Full Member
  • ***
  • Posts: 234
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #4 on: May 13, 2012, 05:34:55 pm »


               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 .
                     
                  


            

Legacy_Melkior_King

  • Full Member
  • ***
  • Posts: 234
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #5 on: May 13, 2012, 05:52:19 pm »


               I just realised I didn't read the OP's request correctly.  I'll leave my original code up because it may be useful to someone else. I also note that I didn't protect against the currently equipped amulet being selected.  I *think* that would do nothing.  I'll leave it as-is anyway.

Oh, and I forgot that you can use d12() instead of Random(12)+1 '<img'>  It's almost 3am.  Gimme a break! '-_-'

Here's some code which should do what the OP wants:

if (d2()==1)// Here's our 50% chance.
{
string sAmmy=GetTag(GetItemInSlot(INVENTORY_SLOT_NECK));
int iAmmy=d12();
// Keep looping until we select an unequipped amulet
while (sAmmy=="AmuletTag"+IntToString(iAmmy)) iAmmy=d12();
// Now equip the new amulet.
ActionEquipItem("AmuletTag"+IntToString(iAmmy)) ;
}

If you want the creature to have a random amulet equipped from the start, put this same script fragment at the start of the creature's OnSpawn script as well as at the start of the OnCombatRoundEnd script.

As before, either tag the amulets "AmuletTag1" through "AmuletTag12" or change the name in the appropriate parts of the script.
               
               

               


                     Modifié par Melkior_King, 13 mai 2012 - 04:54 .
                     
                  


            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #6 on: May 13, 2012, 05:56:32 pm »


               Yes that is exactly what I was proposing Melkior. It does seem to me that doing it using items would be a lot easier/smoother than looping through effects and adding/removing.

If you want the creature to have a random amulet equipped from the
start, put this same script fragment at the start of the creature's
OnSpawn script as well as at the start of the OnCombatRoundEnd script.


Very good point lol, I would have totally overlooked that.

-----
Now what would be the most efficient way to make the boss teleport to a random waypoint in his lair when damaged? I want something like 25% chance when damaged to teleport to one of 50 waypoints.
-----
int nChance = d4;
//Random waypoints labeled "boss_wp_1" through "boss_wp_50"
int nWP = Random (50) +1;
if(nChance == 1)
{JumpToObject(GetNearestWaypointByTag("boss_wp_" + IntToString(nWP), OBJECT_SELF);}
-----

Something along those lines in the OnDamaged event is what I was thinking.
               
               

               


                     Modifié par SKIPPNUTTZ, 13 mai 2012 - 05:01 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #7 on: May 13, 2012, 06:12:00 pm »


               

I wouldn't think there would be much performance difference between the two. Effects would definitely be a faster way to develop it. Only factor that matters to me is server performance.

You asked for what better performed by server. I believe its effects. Maybe it requires a bit more nwscripting than using items but in the end it involves much less instructions performed by game.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #8 on: May 13, 2012, 07:32:11 pm »


               Equipping an item is also an action command, whereas the effects are changed instantly, which is another thing to consider.
               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #9 on: May 13, 2012, 07:40:42 pm »


               That's true, it would require an action to equip it. Yah I never thought about that, thanks FB.

Anyone willing to help me with the coding end of this? To replicate the exact system i would have used with items?
               
               

               


                     Modifié par SKIPPNUTTZ, 13 mai 2012 - 06:42 .
                     
                  


            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #10 on: May 17, 2012, 09:36:04 pm »


               Incase you are still needing help with this.

object oTarget;
    effect eImm = EffectVisualEffect(VFX_NONE);
    int iN = Random(12)+1;
    if (iN != 1) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_ACID, 100), eImm);}
    if (iN != 2) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_BLUDGEONING, 100), eImm);}
    if (iN != 3) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_COLD, 100), eImm);}
    if (iN != 4) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_DIVINE, 100), eImm);}
    if (iN != 5) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_ELECTRICAL, 100), eImm);}
    if (iN != 6) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_FIRE, 100), eImm);}
    if (iN != 7) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_MAGICAL, 100), eImm);}
    if (iN != 8) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_NEGATIVE, 100), eImm);}
    if (iN != 9) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_PIERCING, 100), eImm);}
    if (iN != 10) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_POSITIVE, 100), eImm);}
    if (iN != 11) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_SLASHING, 100), eImm);}
    if (iN != 12) {eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_SONIC, 100), eImm);}
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(eImm), oTarget, 6.0);

(EDIT: The forum makes it look really ugly...)

This stirs a question: would it work properly if you link an effect that has not been initiated?
effect eImm;
eImm = EffectLinkEffects(EffectDamageImmunityIncrease(DAMAGE_TYPE_ACID, 100), eImm);

               
               

               


                     Modifié par Xardex, 17 mai 2012 - 08:36 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #11 on: May 17, 2012, 10:07:37 pm »


               yes it will work properly
               
               

               
            

Legacy_Leurnid

  • Sr. Member
  • ****
  • Posts: 473
  • Karma: +0/-0
Boss Concept: Randomly changing Damage Immunities
« Reply #12 on: May 17, 2012, 10:15:09 pm »


               For the teleporting, check out the Beholder way points and AI. Those were set up with the intent of having the Beholder teleport to the WPs based on range to target, as I recall.