Author Topic: Adding ip damage immunity % other than 5,10,25,50,...  (Read 338 times)

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Adding ip damage immunity % other than 5,10,25,50,...
« on: April 24, 2013, 04:23:12 am »


               I have a script that populates several stores with randomly enchanted items when the module loads.  Those items are then available thru Silicon Scout's loot system as some of the stuff you might find in a loot cache or a powerful monster's treasure heap.

I can add any percent immunity I want in the toolset using CEP, but how would I do that for the non-standard percentages in a script?

I am using:
ItemPropertyDamageImmunity()
IP_CONST_DAMAGEIMMUNITY_X_PERCENT

Since IP_CONST_DAMAGEIMMUNITY_15/20/30_PERCENT does not exist, I'm finding myself falling short of doing exactly what I want.

Help is appreciated.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Adding ip damage immunity % other than 5,10,25,50,...
« Reply #1 on: April 24, 2013, 05:02:12 am »


               Keep in mind that the Constatnts "IP_CONST_DAMAGEIMMUNITY_X_PERCENT"  are only lables that are given to the compiler that represent a number.  

In this case the number is an indice into a 2da.   all you need to do is find the 2da and use the line number instead of the constant. Or you can define your own constants
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Adding ip damage immunity % other than 5,10,25,50,...
« Reply #2 on: April 24, 2013, 05:24:39 am »


               Finding the correct 2da.  

In itempropdef.2da the CostTableResRef collumn is a indice into iprp_costtable.2da  it will give the the file name 2da that is the cost table.    

For example

line 20 in itempropdef.2da is has the lable DamageImmunity.  
it has 5 listed in the CostTableResRef collumn
line number 5 in iprp_costtable.2da has IPRP_IMMUNCOST in the name collumn.  
Meaning that iprp_immuncost.2da has the data you are looking for.

If you have trouble finding the one currently being used by your module.   Go to the screen where you add haks at and check for conflicts.   A list of all overriden resources will be generated with where they are located.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Adding ip damage immunity % other than 5,10,25,50,...
« Reply #3 on: April 24, 2013, 07:29:45 am »


               It's really easy.


int GetPercentImmuneFromCostTableValue(int nValue) {
    if (nValue > 50 && nValue < 151)
        return nValue-50;

    switch (nValue) {
        case 1: return 5;
        case 2: return 10;
        case 3: return 25;
        case 4: return 50;
        case 5: return 75;
        case 6: return 90;
        case 7: return 100;
    }

    return -1;
}

int GetCostValueFromPercentImmune (int nImmune) {
    return nImmune + 50;
}

Basically, you can stop using the old costtable consts (1-7). Just take the percent immunity you want, and add 50 to it, and use that in place of the IP_CONST_DAMAGEIMMUNITY_ const.

For example, to do 63% immunity to fire:

itemproperty ip = ItemPropertyDamageImmunity(IP_CONST_DAMAGETYPE_FIRE, 113);

Funky
               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Adding ip damage immunity % other than 5,10,25,50,...
« Reply #4 on: April 24, 2013, 03:51:33 pm »


               I just exported and looked at iprp_immune cost from cep2_top_v24. I see that 1% starts at line 51 and 100% is at line 150, and was  coming here to clarify that putting in the line# in place of the constant was what I needed to do - the function above confirms it.

Thank you so much.