Aller au contenu

Photo

Adding ip damage immunity % other than 5,10,25,50,...


  • Veuillez vous connecter pour répondre
4 réponses à ce sujet

#1
Terrorble

Terrorble
  • Members
  • 194 messages
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.

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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

#3
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#4
FunkySwerve

FunkySwerve
  • Members
  • 1 308 messages
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

#5
Terrorble

Terrorble
  • Members
  • 194 messages
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.