[Solved] Enemies use healing spells only if there's something to heal

Status
Not open for further replies.

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
I'm surprised this hasn't been asked before. But I can't find it in the Master List.


See this?
 

trhythy.png



"Experimento uses Revive." It's great to have someone reviving you. The problem is there is no dead enemy to revive. This enemy is basicly wasting a turn and losing mana for no reason. This happens with non-reviving spells too:

t45ty5.png



"Experimento used Heal." But everyone's HP is full already. It's the same as before.


Another problem is that the target of the spell is randomized, meaning that even if there is someone to heal, the spell might get used on someone that has full HP.


It would be very nice if someone could make a script that solves this. Having enemies use healing spells only if there is someone missing HP. You could, for example, make it so that if you write <healing> in the notetag, enemies only use it if there is someone to heal and only on enemies that are missing HP. I don't know. You're the genious mind here, I'm just a casul' who can't even script.


Thank you for reading. I hope someone will make my little wish come true *_*


Have a great day ^^


Solved: Use https://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/skill-restrictions/,


https://yanflychannel.wordpress.com/rmvxa/battle-scripts/lunatic-targets/


and https://yanflychannel.wordpress.com/rmvxa/battle-scripts/lunatic-targets/ltp-conditions/


Put this in the notetags of reviving spells:

<restrict eval>
gtdm = $game_troop.dead_members.size;
return false if gtdm > 0;
return true;
</restrict eval>



And this into the notetags of healing spells:

<custom target: allies HP below 99%>
<restrict eval>
am = $game_troop.alive_members;
p = 0.99;
mh = am.select{|m| m.hp <= (m.mhp * p)};
return false if mh.size > 0;
return true;
</restrict eval>


'p' is the percentage of health the enemy needs to be at or below before the skill is enabled.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
check for enemy AI scripts instead - iirc some of them have additional targeting options as well as the usual skill use conditions.


You won't find such scripts as a separate function, it's usually more general for all enemy skill uses.
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
check for enemy AI scripts instead - iirc some of them have additional targeting options as well as the usual skill use conditions.


You won't find such scripts as a separate function, it's usually more general for all enemy skill uses.
Thanks! I'll have a look, I'll see what I find.
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
I haven't found anything that works. Anyone willing to help me? :DD
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
Should I bump this? Guess I should.
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
I used Yanfly Skill Restrictions and Lunatic Targets. Then I created healing and reviving skills for enemy use only, so the restrictions would not carry over to the player. To restrict healing to allies with HP lower than a certain percentage of health, you can put the following into the 'note' box of the skill.


<custom target: allies HP below 65%>


For restricting a revive skill (raising a dead member)

Code:
<restrict eval>
gtdm = $game_troop.dead_members.size;
return false if gtdm > 0;
return true;
</restrict eval>
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
I used Yanfly Skill Restrictions and Lunatic Targets. Then I created healing and reviving skills for enemy use only, so the restrictions would not carry over to the player. To restrict healing to allies with HP lower than a certain percentage of health, you can put the following into the 'note' box of the skill.



<custom target: allies HP below 65%>


For restricting a revive skill (raising a dead member)



<restrict eval>
gtdm = $game_troop.dead_members.size;
return false if gtdm > 0;
return true;
</restrict eval>
Thank you! The second one works perfectly. The first one doesn't thought.
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
I used Yanfly Skill Restrictions and Lunatic Targets. Then I created healing and reviving skills for enemy use only, so the restrictions would not carry over to the player. To restrict healing to allies with HP lower than a certain percentage of health, you can put the following into the 'note' box of the skill.
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
I used Yanfly Skill Restrictions and Lunatic Targets. Then I created healing and reviving skills for enemy use only, so the restrictions would not carry over to the player. To restrict healing to allies with HP lower than a certain percentage of health, you can put the following into the 'note' box of the skill.



<custom target: allies HP below 65%>


For restricting a revive skill (raising a dead member)



<restrict eval>
gtdm = $game_troop.dead_members.size;
return false if gtdm > 0;
return true;
</restrict eval>


Thank you! The second one works perfectly. The first one doesn't thought.
 
Last edited by a moderator:

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
@xdan Oops, you'll need this script as well to make the first one work. LTP Conditions
Almost there. At first they don't use the skill, but once someone loses hp, they keep using it for the rest of the battle even if everyone is already healed.
 
Last edited by a moderator:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
@xdan Hmm, well, add the following into the heal skill along with the custom target. This should detect when an alive enemy in the party is below a certain percentage of health. If an enemy is, then the custom target will kick in and only heal that person ... in theory.


'p' is the percentage of health the enemy needs to be at or below before the skill is enabled. I have not tested this code, so it might blow up.

Code:
<restrict eval>
am = $game_troop.alive_members;
p = 0.65;
mh = am.select(|m| m.hp <= (m.mhp * p));
return false if mh.size > 0;
return true;
</restrict eval>
<custom target: allies HP below 65%>
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
@xdan Hmm, well, add the following into the heal skill along with the custom target. This should detect when an alive enemy in the party is below a certain percentage of health. If an enemy is, then the custom target will kick in and only heal that person ... in theory.


'p' is the percentage of health the enemy needs to be at or below before the skill is enabled. I have not tested this code, so it might blow up.



<restrict eval>
am = $game_troop.alive_members;
p = 0.65;
mh = am.select(|m| m.hp <= (m.mhp * p));
return false if mh.size > 0;
return true;
</restrict eval>
<custom target: allies HP below 65%>


Apparently your syntax is wrong (?)


fewt4.png


It keeps resisting. He wants to use heal and we're not going te forbide it XD


By the way, thanks a lot ^^
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
@xdan Oh, whoops ... I used parenthesis where I should have used brackets. Here, this should work.

Code:
<restrict eval>
am = $game_troop.alive_members;
p = 0.65;
mh = am.select{|m| m.hp <= (m.mhp * p)};
return false if mh.size > 0;
return true;
</restrict eval>
<custom target: allies HP below 65%>
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
@xdan Oh, whoops ... I used parenthesis where I should have used brackets. Here, this should work.



<restrict eval>
am = $game_troop.alive_members;
p = 0.65;
mh = am.select{|m| m.hp <= (m.mhp * p)};
return false if mh.size > 0;
return true;
</restrict eval>
<custom target: allies HP below 65%>


I hate RPG Maker.


ythyth.png
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
@xdan Hmm ... ok, put the custom target part before the restrict eval part.

Code:
<custom target: allies HP below 65%>
<restrict eval>
am = $game_troop.alive_members;
p = 0.65;
mh = am.select{|m| m.hp <= (m.mhp * p)};
return false if mh.size > 0;
return true;
</restrict eval>
 

xdan

Veteran
Veteran
Joined
Aug 21, 2016
Messages
158
Reaction score
59
First Language
Spanish
Primarily Uses
@xdan Hmm ... ok, put the custom target part before the restrict eval part.



<custom target: allies HP below 65%>
<restrict eval>
am = $game_troop.alive_members;
p = 0.65;
mh = am.select{|m| m.hp <= (m.mhp * p)};
return false if mh.size > 0;
return true;
</restrict eval>


It worked perfectly. Thanks a lot, seriously ^^
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,977
Members
137,563
Latest member
cexojow
Top