Some takedamagescripts to share

Bloodbane

Well-known member
  I've made some takedamagescripts for my mods. I'm sharing them here, starting from basic ones:

1. blink.c

Code:
void main()
{// Blink effect script
    void self = getlocalvar("self"); //Get calling entity.
    int Health = getentityproperty(self,"health");

    if(Health > 0){
	changeentityproperty(self, "colourmap", 1);
	changeentityproperty(self, "maptime", 14 + openborvariant("elapsed_time"));
    }
}

This takedamagescript changes entity's palette to 1st alternate palette or 1st remap in an instant (blink of an eye) before reverts to current palette or remap
Usually used by enemies and bosses in platformers to show that they have taken damage from player

2. invis.c

Code:
void main()
{// Temporary invincibility script
    void self = getlocalvar("self"); //Get calling entity.
    int Health = getentityproperty(self,"health");
    int eTime = openborvariant("elapsed_time");

    if(Health > 0){
      changeentityproperty(self, "invincible", 1);
      changeentityproperty(self, "invinctime", eTime + 400);
      changeentityproperty(self, "blink", 1);
    }
}

This takedamagescript sets temporary invincibility (2 seconds) when entity is hit by any attack
Usually used by players in platformers to protect player from getting another attack after first attack. Can be used by enemies too ;)

3. nostun.c

Code:
void main()
{// Anti stun script
    void self = getlocalvar("self"); //Get calling entity.

    changeentityproperty(self, "freezetime", 1);
}

This takedamagescript cancels frozen or stun effect from attacks entity received. Technically it cuts freezetime to 1 tick making it as if freeze or stun effect is never taken
Used by entities which can't be frozen nor stunned

4. endure.c

Code:
void main()
{// Endure script (to prevent entity from death)
    void self = getlocalvar("self"); //Get calling entity.
    int HP = getentityproperty(self, "health");
    int Damage = getlocalvar("damage"); //Get received damage

    if(HP <= Damage && HP <= 5){
      changeentityproperty(self, "health", 1);
    }
}

As name implies, this takedamagescript prevents entities from killing blow resulting in endure effect
Great to be used by enemies or bosses which runs away after player 'finished' them (combined with desperation script)


The next ones are combined or modifed ones for special purposes

1. blinkS.c

Code:
void main()
{// Blink effect + anti stun script
    void self = getlocalvar("self"); //Get calling entity.
    int Health = getentityproperty(self,"health");

    if (Health > 0){
      changeentityproperty(self, "colourmap", 1);
      changeentityproperty(self, "maptime", 20 + openborvariant("elapsed_time"));

      changeentityproperty(self, "freezetime", 1);
    }
}

This takedamagescript is combination of original blink.c above with nostun.c. The flaw of original blink.c is that when entity is hit by freeze attack, entity will be frozen using blink palette/remap. This combined script solves that flaw

2. Cendure.c

Code:
void main()
{// Endure script (to prevent entity from death)
// Endure all attacktypes except attack2
    void self = getlocalvar("self"); //Get calling entity.
    int HP = getentityproperty(self, "health");
    int Damage = getlocalvar("damage"); //Get received damage

    if(HP <= Damage && HP <= 5 && Type != openborconstant("ATK_NORMAL2")){
      changeentityproperty(self, "health", 1);
    }
}

This is modified endure.c which allows entities to be finished with attack2 attacktype
If you have rapid attacks special or supers and you want enemies to receive all attacks without getting killed before finishing blow, this is the script you need :). Of course, this means you must set all finisher attacks (attacks which are allowed to finish enemy) to attack2 attacktype

To use this takedamagescript, simply copy desired one such as blink.c then declare it like this in entity's header:

takedamagescript data/scripts/blink.c
 
This is nice, i was trying to set no stun on some enemies.

Didn´t know that "freezetime" command exits.

Thanks!
 
Thanks BB. I am using those scripts since long time :)
About the freeze, I managed to solve the issue by putting this code:

Code:
if(Type != openborconstant("ATK_FREEZE")){
		if (Health > 0){
		changeentityproperty(self, "colourmap", 6);
		changeentityproperty(self, "maptime", 20 + openborvariant("elapsed_time"));
			
}
 
So I'm using blink script and it works great, but I wanted to know if I can tweak it further. So far I modified it so it only works when enemy is not playing either IDLE or WALK, in which case it would play its PAIN animation as usual.

Now, I would like to know if the script can be changed so that the char flashes in more than one color. As it is, it flashes to remap 1. Can it be set to that it flashes as remap 1, then remap 2, then remap 1, then remap 2 again?

This is the script so far:
void main()
{// Blink effect script
    void self = getlocalvar("self"); //Get calling entity.
    int Health = getentityproperty(self,"health");
int iSnd = loadsample("data/sounds/(tmnt2/hit02.wav");
int anim = getentityproperty(self, "animationid");

    if((Health > 0) && (anim != openborconstant("ANI_IDLE")) && (anim != openborconstant("ANI_WALK"))){
changeentityproperty(self, "colourmap", 1);
changeentityproperty(self, "maptime", 7 + openborvariant("elapsed_time"));
playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 120, 0);
    }

else {
performattack(self, openborconstant("ANI_PAIN"));
    }
}
 
1. blink.c are not working on new build, seem like "colourmap" property has change or has been removed, someone has the same problem or kow how to solve it?
 
2. Cendure.c

I can't get this Cendure.c script to work :(

Code:
Script compile error in 'takedamagescript': Type line 8, column 34

********** An Error Occurred **********
*            Shutting Down            *

Can't compile script 'takedamagescript' data/chars/punk/punkE.txt
 
Oh sorry, I forgot to add this line:
Code:
  void Type = getlocalvar("attacktype"); // Get received attacktype
 
I tried to replace colourmap with drawmethod so i dotn have to make remap if i want blink effect but it didnt work cause theres no maptime alternative for drawmethod.
 
Back
Top Bottom