Scipted substitute for targeting and damage formula needed.

I stopped developping this game for one year so i have to make a new post now that i have time to continue. You can see the original post there but I will resume some interventions here too. 





Using Hime's "Tag Manager" makes this Big bird's ability to damage only "insects" but doesn't prevent it from attaking itself (even if it do zero damage.)

Andar said: 


you'll either need to abandoning the attack pattern and use a scripted substitute for targeting, or you'll have to think a bit "out of the box". (using troop events and an "allies alive" switch).


So i would like a targeting script. It will be useful for other battles dynamics too.


MeowFace said:
instead of stopping it to target self, why not add a damage formula in your skill to check if target is self, do heal instead of damage?


eg


if attacker's id = target's id, heal 100 hp and play animation 40, else play animation 1 and do 500 damage.


b.id == a.id ? a.hp += 100; a.animation_id = 40; 0 : b.animation_id = 1; 500


If you leave the animation blank in the default skill setting, you can easily set the damage formula to play 2 types of animations based on conditions. 

Probleme i encounter with MeowFace's damage formula: error message: (unexpected ';' expecting ':')


Is the formula too long to place in one line or is there an error?


If i use this formula instead: b.id == a.id ? a.hp += 100 : 500


There is no error message but.. the BigBird does zero damage to its allies and to itself. I even tried with 9999 damage in formula.. stil zero damage when testing. 


[IMG]https://snag.gy/u3yQEp.jpg[/IMG]


Thanks for your precious help!
That's because it's not a correctly formatted formula for a single line.

Code:
b.id == a.id ? (a.hp += 100; a.animation_id = 40; 0) : (b.animation_id = 1; 500)



However, if the enemy is attacking the characters, b.id could be a.id and he will heal rather than attack.  I think the comparison you need to use is b == a, not b.id == a.id - you want to check if he's attacking himself, not some battler with the same id as his own (which could be one of your party members)
You are right for b == a! It is the correct form. Also, your equation do not encounter any errors 🙂

Only probleme: When attacking itself, it does not heal 100 hp. Il only trigers the heal animation and does 0 damage. 
How can i change your formula so it really heals 100hp?


Right now it heals 0:

Code:
a.hp += 100
Sorry! In in reallity, it was healing, but without specifiing it. So that the player has no way to figure out that it heals. I can put the damage type to "absorb HP" so that it does 0 to itself and vampirize it's allies. 

But is it possible to change:

Code:
b.id == a.id ? (a.hp += 100; a.animation_id = 40; 0) : (b.animation_id = 1; 500)

for something like:


b.id == a.id ? (a.animation_id = 40; +=100) : (b.animation_id = 1; 500)


so that the HP it heals are properly showed to the player? I tested the seccond formula and it crashes the game, but is there an other way to express it correctly?
I will try to ask the question elswhere cause it seems i'll get no more feedback here..


But i will keep checking out from time to time if i get feedback here. So don't refrain yourself from interracting again in this post.

Original thread: https://forums.rpgmakerweb.com/threads/scipted-substitute-for-targeting-and-damage-formula-needed.67596/