Triggering an event when the player loses health

Status
Not open for further replies.

Traumlos

Villager
Member
Joined
Dec 9, 2013
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Hello again. I've got another quick question.

I want to trigger an event the first time the player falls below a certain amount of HP- in this case, let's say 25%.

This would be to teach the player how to use the healing item in the game. So I imagine it going as follows:

- Player enters battle

- Player drops to 25% HP

- Mid-battle, a text prompt shows up telling the player to use a specific item

- If the player uses the item, they are healed, and the battle continues. This event will never trigger again.

- If the player does not use the item, the event will trigger again the next time they drop to 25% HP, and will continue to do so until they use the item.

I've been having some trouble wrapping my head around switches/variables in RPG Maker. The engines I'm used to using allow me to specify whether a switch/variable is false or below a certain number, rather than always being positive.

Any help would be greatly appreciated. :)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You can probably use Troop events for this, assuming you're gonna use a specialized troop for a "battle orientation"


if not, well you can still use troop events that run every turn I guess that checks an actor's HP...


You can always use the else clause when checking switches to determine if the switch is false... for variables, you can check either less than, less than or equal to, equal to, greater than, greater than or equal to, when using conditional branches
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You might be able to do it via troop events - an event page that has Span = Battle, Condition Actor's HP is 25% or below.


However, you'd have to have that on every troop you think the player might encounter before they definitely receive the message, and I'm not sure how you'd turn it off. You could certainly use a switch to indicate you've displayed the message, but the troop conditions are only for a switch being ON, rather than OFF.


So maybe, turn on the switch at the beginning of the game (ON = Player needs tutorial) and condition the troop pages by Actor's HP AND the switch. Then in the event turn the switch OFF so it'll never trigger again.
 

Traumlos

Villager
Member
Joined
Dec 9, 2013
Messages
9
Reaction score
0
First Language
English
Primarily Uses
I'm a bit stuck at the moment, so I'll walk you through what I'm doing.

I decided to go with a Troop event. I divided the first map into three regions. The only troop that can appear in every region is the Tutorial group, and other troops only appear in the second and third regions, so the player is only attacked by the Tutorial troop in region 1, with a high percentage of being attacked by the Tutorial group throughout the map. 

Here is a screenshot of the Conditional I set up in the Troop event: http://img38.imageshack.us/img38/3840/mct4.png

The logic is supposed to go as follows:

Once the player falls below 40% HP

IF NeedsTutorial is on:

- Run through the text sequence

ELSE:

- Pass

And then, beneath it, I have another conditional that reads as follows:

IF AmuletUsage is greater than or equal to 1, turn off NeedsTutorial. 

Otherwise, pass. 

In addition to this, I have:

- An event in the starting village level:

If AmuletUsage <= 0, NeedsTutorial is on.

Otherwise, NeedsTutorial is off.

And, just in case, an event in the dungeon level that reads:

If AmuletUsage >= 1, NeedsTutorial is off.

This doesn't behave the way that I was hoping. The first time through works just as I wanted it to, but the event continues to run through, even though the amulet usage has been incremented ($game_variables[1] += 1, as was suggested in an earlier thread).
 

Berylstone

Veteran
Veteran
Joined
Jun 3, 2013
Messages
642
Reaction score
62
First Language
English
Primarily Uses
I'm a bit stuck at the moment, so I'll walk you through what I'm doing.

I decided to go with a Troop event. I divided the first map into three regions. The only troop that can appear in every region is the Tutorial group, and other troops only appear in the second and third regions, so the player is only attacked by the Tutorial troop in region 1, with a high percentage of being attacked by the Tutorial group throughout the map. 

Here is a screenshot of the Conditional I set up in the Troop event: http://img38.imageshack.us/img38/3840/mct4.png

The logic is supposed to go as follows:

Once the player falls below 40% HP

IF NeedsTutorial is on:

- Run through the text sequence

ELSE:

- Pass

And then, beneath it, I have another conditional that reads as follows:

IF AmuletUsage is greater than or equal to 1, turn off NeedsTutorial. 

Otherwise, pass. 

In addition to this, I have:

- An event in the starting village level:

If AmuletUsage <= 0, NeedsTutorial is on.

Otherwise, NeedsTutorial is off.

And, just in case, an event in the dungeon level that reads:

If AmuletUsage >= 1, NeedsTutorial is off.

This doesn't behave the way that I was hoping. The first time through works just as I wanted it to, but the event continues to run through, even though the amulet usage has been incremented ($game_variables[1] += 1, as was suggested in an earlier thread).
If I am reading this correctly (which I may not be) it sounds like you are just wanting to run a tutorial event once during your battle event if the player is at 40% or less Hp and variable:[AmuleteUsage] is 0.  So the method Shaz described should work for you if I am understanding you correctly.

So you might want to try adding a page to your battle event that looks similar to this (see screenshot1).  And just make sure you turn the switch ON previous to the battle event as was indicated.  Note that in my example Test.Variable1 would be where you insert your AmuletUsage variable.

Screenshot1.png
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Should the tutorial repeat until the player DOES use the amulet? After all, TELLING them to use it isn't going to MAKE them use it.


If you just want to know if they've used it ONCE, but you don't really care how many times they've used it, you can just use a switch. In fact, if you don't want the tutorial to come up at all if they use it in the very first battle without being told to, you could use the same switch for the amulet usage and the troop page condition:


at start of game, turn switch ON.


in amulet damage formula, add $game_switches[id] = false; before the actual damage/heal formula


in troop event, set condition to Actor HP < 40% and switch[id] is ON (same switch)


Then in the events, show the tutorial. If you don't want the message to repeat, even if they've used the amulet, turn the switch off. If you omit this, the message will keep repeating until they do use the amulet.
 

Traumlos

Villager
Member
Joined
Dec 9, 2013
Messages
9
Reaction score
0
First Language
English
Primarily Uses
Sorry for the late response! Your suggestions worked perfectly, thanks. :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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 Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
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:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top