Healing spell

OK, then:

First create a object for the player spawn in a freespecial:

In the object set

candamage player

EX:
Code:
name	jball
health	1
shadow	0
speed   14
candamage player
alpha 1


anim idle
	loop	1
	delay	6
	offset	118 104
        hitfx   data/sounds/hitfire.wav
        hitflash    mhit
        blockfx   data/sounds/hitfire.wav
        blockflash flamy
        forcedirection -1
	attack10  96 86 42 38 15 1 0 0 0
	frame	data/chars/jago/jball01.png
	frame	data/chars/jago/jball02.png
	frame	data/chars/jago/jball03.png
	frame	data/chars/jago/jball04.png
	frame	data/chars/jago/jball05.png

In this example the object has ATTACK10.

So in the other player, set in the header txt this:

Defense normal10 -0.5 1000 0 1000 1000 -1 0 #Absorb 50% of attack10 damage as healing (or 100% if blocked), and be effectively immune to fall/pain.
 
Yeah.. that's probably not the way to do it. It's not stable.

What happens if it hits an enemy? If you don't set up every enemy to deal with your heal spell, they'll take the healing as damage like it was an attack. Wouldn't that be kind of silly?

What if you don't have player vs. player damage enabled? Then the s[ell passes right through them. So to make this work, you are stuck with PvP forever.

These are just a couple of the problems you'll run into; there are plenty more.

Why not script it instead? There are at least a dozen examples around the forum of healing with script. It's far simpler to implement than this technique and much more stable.

 
dantedevil said:
The object cant hit a enemy DC, because has set "candamage player".

You missed the point though... that's still an unstable shoehorning. Just script the thing and be done with it. You know how to and it would be so much less work in the long run.

DC
 
If you want recreate Okina's (Last Blade 2) healing turtle ability, the method suggested by dantedevil is usable. In that game, it's possible for the turtle to accidentally hit opponent instead. That's part of game design so it's stable

However, if you want to directly heal other player, script does it better. Here's an example (from utunnels):

anim follow5 # Heal
@script
int iHP;
int i;
void e;
void ip;
int rng;
int ix;
int iy;
int iz;
void self = getlocalvar("self");
int castx = getentityproperty(self, "x");

if(frame == 5){
  for(i=0; i<=3;i++){
    ip = getplayerproperty(i, "entity");
    ix = getentityproperty(ip, "x");
    iy = getentityproperty(ip, "a");
    iz = getentityproperty(ip, "z");
    rng = ix - castx;

            clearspawnentry();
    if( rng > -160 && rng < 160 ){
              setspawnentry("name", "HealFX");
              e = spawn();

      iHP = getentityproperty(ip, "health");
      changeentityproperty(ip, "health", iHP + 50);
      changeentityproperty(e, "position", ix, iz + 2, iy);
    }
  }
}
@end_script
delay 8
offset 215 166
frame data/chars/priest/frsp100.gif
frame data/chars/priest/frsp101.gif
sound data/chars/priest/sounds/csw.wav
frame data/chars/priest/frsp102.gif
frame data/chars/priest/frsp103.gif
frame data/chars/priest/frsp104.gif
delay 180
@cmd mpcostX 20
sound data/chars/priest/sounds/csw2.wav
frame data/chars/priest/frsp104.gif
delay 8
frame data/chars/priest/frsp103.gif
frame data/chars/priest/frsp101.gif
frame data/chars/priest/frsp100.gif

When 6th frame of this animation is reached, all players (from 1st to 4th player if available) standing within 160 pixels range (160 to left and 160 to right) of spellcaster will gain HP addition of 50. Don't worry if the addition goes beyond maximum HP, OpenBoR will simply cut the excess :)

This is decent healing spell but if you need specific cases such as caster is excluded OR healing only heals one character, we will need to modify this script :)
 
Eh, although my answer is technically correct, when it comes to healing, enemies and NPCs need to check if they need to heal first before performing healing. That's why in Rise of Warduke, Iuz Priest (enemy healer) runs script in his IDLE to check if he needs healing or not.
He also checks other enemies' HP before deciding to heal any of them or not.

I'll share reduced script for self healing later.

[Later]

Here's the reduced script declared on IDLE and WALK:
C:
@script
    if(frame >= 1){
      void self = getlocalvar("self");
      int MHP = getentityproperty(self, "maxhealth");
      int HP = getentityproperty(self, "health");
      int MP = getentityproperty(self,"mp");

      if(HP < MHP/3 && MP > 20){
        changeentityproperty(self, "velocity", 0, 0, 0);
        performattack(self,openborconstant("ANI_FOLLOW4"));
      }
    }
@end_script
...

This script means the enemy will stop and perform FOLLOW4 (the self healing animation) if their HP falls below 1/3 of maxHP and has MP more than 20.
This is the FOLLOW4:
C:
anim    follow4
@script
    if(frame == 13){ // 14th frame
      void self = getlocalvar("self");
      int HP = getentityproperty(self, "health");
      int MP = getentityproperty(self,"mp");

      changeentityproperty(self, "health", HP + 40);
      changeentityproperty(self, "mp", MP-20);
    }
@end_script
...

Iuz Priest does the healing at 14th frame so if your enemy has less frames or heals at different frame, please adjust the frame.

HTH
 
Last edited:
Eh, although my answer is technically correct, when it comes to healing, enemies and NPCs need to check if they need to heal first before performing healing. That's why in Rise of Warduke, Iuz Priest (enemy healer) runs script in his IDLE to check if he needs healing or not.
He also checks other enemies' HP before deciding to heal any of them or not.

I'll share reduced script for self healing later.

[Later]

Here's the reduced script declared on IDLE and WALK:
C:
@script
    if(frame >= 1){
      void self = getlocalvar("self");
      int MHP = getentityproperty(self, "maxhealth");
      int HP = getentityproperty(self, "health");
      int MP = getentityproperty(self,"mp");

      if(HP < MHP/3 && MP > 20){
        changeentityproperty(self, "velocity", 0, 0, 0);
        performattack(self,openborconstant("ANI_FOLLOW4"));
      }
    }
@end_script
...

This script means the enemy will stop and perform FOLLOW4 (the self healing animation) if their HP falls below 1/3 of maxHP and has MP more than 20.
This is the FOLLOW4:
C:
anim    follow4
@script
    if(frame == 13){ // 14th frame
      void self = getlocalvar("self");
      int HP = getentityproperty(self, "health");
      int MP = getentityproperty(self,"mp");

      changeentityproperty(self, "health", HP + 40);
      changeentityproperty(self, "mp", MP-20);
    }
@end_script
...

Iuz Priest does the healing at 14th frame so if your enemy has less frames or heals at different frame, please adjust the frame.

HTH
Oh man this code is a lifesaver. I just so happened to be looking for a self healing action. Thank you so much.

I wasn't even aware inline scripting was possible in the char.txt files, almost went down the scripting file route.

I noticed OpenBOR also dumps out a script.c file under logs showing proper coding?
 
Back
Top Bottom