How to properly get or change "Defense" value?

Crimsondeath

Active member
Hi again,
I'm using this script as onmodelcopyscript when enemies pick up a weapon or I give the weapon to them by special events:

C++:
void main()
{
    void self           = getlocalvar("self");
    void old            = getlocalvar("old");

    int  iSpeed     = getentityproperty(old,"speed");
    int  iAggre     = getentityproperty(old,"aggression");
    int  iMaxJuggle    = getentityproperty(old,"maxjugglepoints");
    int  iJuggle    = getentityproperty(old,"jugglepoints");
    int  iBounce    = getentityproperty(old,"bounce");
    int  iMprate     = getentityproperty(old,"mprate");
    int  iRunS        = getentityproperty(old,"running","speed");
    int  iRunY        = getentityproperty(old,"running","jumpy");
    int  iRunX        = getentityproperty(old,"running","jumpx");
    int  iRunL        = getentityproperty(old,"running","land");
    int  iRunM        = getentityproperty(old,"running","movez");
    float  iJumpS     = getentityproperty(old,"jumpspeed");
    float  iJumpH     = getentityproperty(old,"jumpheight");
    int  iStealth    = getentityproperty(old,"stealth");
    int  iDetect    = getentityproperty(old,"detect");
    int  iGrabForce = getentityproperty(old,"grabforce");
    int  iFalldie = getentityproperty(old,"falldie");
    int  iHostile    = getentityproperty(old,"hostile");
    int  iCandamage    = getentityproperty(old,"candamage");
    int  iProjectile = getentityproperty(old,"projectilehit");
    int  iOffScreenkill = getentityproperty(old,"offscreenkill");
    int  iBlockOdds = getentityproperty(old,"blockodds");
    int  iNodieblink = getentityproperty(old,"nodieblink");
    int  itHold = getentityproperty(old,"thold");
    char iBlockpain  = getentityproperty(old,"blockpain");
    int  iHostile   = getentityproperty(old,"hostile");
    int  iCandamage = getentityproperty(old,"candamage");
    int  iProjectile = getentityproperty(old,"projectilehit");

    int  iDefense     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL"));
    int  iDefense2     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL2"));
    int  iDefense3     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL3"));
    int  iDefense4     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL4"));
    int  iDefense5     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL5"));
    int  iDefense6     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL6"));
    int  iDefense7     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL7"));
    int  iDefense8     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL8"));
    int  iDefense9     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL9"));
    int  iDefense10     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL10"));
    int  iDefense23     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL23"));
    int  iDefense24    = getentityproperty(old,"defense", openborconstant("ATK_NORMAL24"));
    int  iDefense26    = getentityproperty(old,"defense", openborconstant("ATK_NORMAL26"));
    int  iDefense27     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL27"));
    int  iDefense28    = getentityproperty(old,"defense", openborconstant("ATK_NORMAL28"));
    int  iDefense29     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL29"));
    int  iDefense30    = getentityproperty(old,"defense", openborconstant("ATK_NORMAL30"));
    int  iDefense31     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL31"));
    int  iDefense50    = getentityproperty(old,"defense", openborconstant("ATK_NORMAL50"));
    int  iDefense51     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL51"));
    int  iDefense52     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL52"));
    int  iDefense53     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL53"));
    int  iDefense54     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL54"));
    int  iDefBurn     = getentityproperty(old,"defense", openborconstant("ATK_BURN"));
    int  iDefShock     = getentityproperty(old,"defense", openborconstant("ATK_SHOCK"));


    changeentityproperty(self, "speed", iSpeed);
    changeentityproperty(self, "aggression", iAggre);
    changeentityproperty(self, "maxjugglepoints", iMaxJuggle);
    changeentityproperty(self, "jugglepoints", iJuggle);
    changeentityproperty(self, "bounce", iBounce);
    changeentityproperty(self, "mpset", NULL(), NULL(), NULL(), iMprate, NULL(), NULL()); //SET MP RECOVERY RATE.
    changeentityproperty(self, "running", iRunS, iRunY, iRunX, iRunL, iRunM);
    changeentityproperty(self, "jumpspeed", iJumpS);
    changeentityproperty(self, "jumpheight", iJumpH);
    changeentityproperty(self, "stealth", iStealth);
    changeentityproperty(self, "detect", iDetect);
    changeentityproperty(self, "grabforce", iGrabForce);
    changeentityproperty(self, "falldie", iFalldie);
    changeentityproperty(self, "hostile", iHostile);
    changeentityproperty(self, "candamage", iCandamage);
    changeentityproperty(self, "projectilehit", iProjectile);
    changeentityproperty(self, "offscreenkill", iOffScreenkill);
    changeentityproperty(self, "blockodds", iBlockOdds);
    changeentityproperty(self, "nodieblink", iNodieblink);
    changeentityproperty(self, "thold", itHold);
    changeentityproperty(self, "blockpain", iBlockpain);
    changeentityproperty(self, "hostile", iHostile);
    changeentityproperty(self, "candamage", iCandamage);
    changeentityproperty(self, "projectilehit", iProjectile);

    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL"), iDefense);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL2"), iDefense2);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL3"), iDefense3);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL4"), iDefense4);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL5"), iDefense5);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL6"), iDefense6);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL7"), iDefense7);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL8"), iDefense8);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL9"), iDefense9);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL10"), iDefense10);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL23"), iDefense23);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL24"), iDefense24);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL26"), iDefense26);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL27"), iDefense27);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL28"), iDefense28);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL29"), iDefense29);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL30"), iDefense30);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL31"), iDefense31);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL50"), iDefense50);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL51"), iDefense51);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL52"), iDefense52);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL53"), iDefense53);
    changeentityproperty(self, "defense", openborconstant("ATK_NORMAL54"), iDefense54);
    changeentityproperty(self, "defense", openborconstant("ATK_BURN"), iDefBurn);
    changeentityproperty(self, "defense", openborconstant("ATK_SHOCK"), iDefShock);
}

The problem is that some "defense" values aren't changed properly (and don't know why).

For example:

I make an enemy inmune to ATK_NORMAL and very resistant to ATK_NORMAL54 like this:

Code:
defense normal 0 0 1 0 21 0 0
defense normal54 0.10 0 1 0 0 0 0

Works fine until he pick up a weapon or I use weaponframe on him (or changeentityproperty(self, "weapon", 1); ), he keeps his ATK_NORMAL inmunity but ATK_NORMAL54 is completely vulnerable. I thought it was because the decimal value of ATK_NORMAL54 so I change the variable to float:

C++:
float  iDefense54     = getentityproperty(old,"defense", openborconstant("ATK_NORMAL54"));

But don't work either.
 
Which version are you using? I remember I had some issues working with this on 3.0
For example, I wanted to have Gold War Machine as an alternate model (palette based), where I would make him with highter defense and higher knockdowncount.
But it never worked and I had to split it into a different character.
 
According to my tests in the v4, apparently the same issue persists in the engine when we try to apply a new defense factor above ATK_NORMAL10 with scripts via "changeentityproperty". From 1 to 10 it works fine.

@DCurrent It seems that this issue has some connection with the attack types declared in the openbor.h file, which is declared only from ATK_NORMAL to ATK_NORMAL10. There's some comments about adding it to the script access, is there any tip about how to do it?

1734583511803.png

EDIT: Currently the issue can be bypassed by repeating the defense declaration in all weapon model headers.
 
Last edited:
@O Ilusionista : IOpenBoR v3.0 Build, Compile Date: May 12 2023.

Maybe I have to do the same as you, but I'm using this for changing the computer AI entities behavior.

For example:

"BossPunk" can use 3 of 4 of his Freespecials. The 4th Freespecial is locked (with and energycost 999 xd).

When the health of "BossPunk" is below 30% his model will change to the "Weapon model" ("BossPunk1") which has the same entity properties but his 4th Freespecial unlocked (with an energycost of 10 xd) so he'll able to use it.

@Kratus: Ok, it's an OpenBOR Issue xd. I think I'll aply the defense values to all weapons model manually just at the end of development x.x.

Thanks to both of you (y).
 
According to my tests in the v4, apparently the same issue persists in the engine when we try to apply a new defense factor above ATK_NORMAL10 with scripts via "changeentityproperty". From 1 to 10 it works fine.

@DCurrent It seems that this issue has some connection with the attack types declared in the openbor.h file, which is declared only from ATK_NORMAL to ATK_NORMAL10. There's some comments about adding it to the script access, is there any tip about how to do it?

View attachment 9880

EDIT: Currently the issue can be bypassed by repeating the defense declaration in all weapon model headers.

That note is for something else.

Constants beyond ATKMORMAL10 are auto generated on startup, and so are the various references. The note is for static constants below 10, in case someone decides to add one.

The engine is intentionally designed so that weapon models override defense setting of base models. This is so you can add strengths or weaknesses to the weapon models by design.

DC
 
The engine is intentionally designed so that weapon models override defense setting of base models. This is so you can add strengths or weaknesses to the weapon models by design.
Yeah, indeed almost everything works fine with new attack type addition. But for some reason even in the default model, if you applies a new defense value using changeentityproperty(self, "defense", openborconstant("ATK_NORMAL11"), new_value) it only works fine from attacks 1 to 10.

As soon as I change ATK_NORMAL10 to ATK_NORMAL11 (or any value above) it does not work anymore. I'm doing different tests to confirm if I'm missing something, but so far all the results are the same.
 
Back
Top Bottom