Is it possible to store information about the unit/event which triggered an event?

shadowllp

Warper
Member
Joined
Sep 27, 2020
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
A unit walks onto a square -- say a trap. It triggers an event, which then stores the data about the unit somewhere. How would I do something like this? Does such a place to store data exist? Variables are good for determining the coordinates of events, but not for the events themselves...

The end result would be EvilDude triggering an event, the event storing a reference to EvilDude, then being able to subtract 5 from EvilDude's number using that stored reference. Of course, if NiceNancy triggered the trap, it would subtract 5 from NiceNancy's number instead. End result being less clogged code & more dynamic events. But idk how to store references to events here..
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
238
Reaction score
49
First Language
English
Primarily Uses
RMMV
If statements, and then they can set a variable value, which would correspond to the character who triggered it.
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
698
Reaction score
3,446
First Language
English
Primarily Uses
N/A
If this trigger is literally when an event steps onto it, as in they would share the same tile, you could use the call
$gameMap.eventsXy(x, y), where x and y are the coords for the trap.
The result is an array, with all events on that x, y location, which would be the trap and whoever stepped on it.

If you loop through the array and check each item's ._eventId prop to make sure it isn't the trap's event Id, you'd wind up with the actual event that triggered the trap.
Does that makes sense?

EDIT: If you wanted this to work with $gamePlayer as well, it would be easiest just to check for that first, when the trap is triggered. Simply checking if the $gamePlayer's x and y are equal to the traps would suffice.

The longer (but cleaner) and slightly more complex route would be to add a function to Game_Character so that $gamePlayer and Events would have the function on them.
 

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

Latest Threads

Latest Profile Posts

Less than a week and I can move into my new apartment and out of this bad situation. I'm so excited! Then game making power will increase. :kaoluv:
Enter the password in letters. (English subtitles)
I really tried to pull off something for halloween, but I don't feel like going on. I feel like the plot I was building was too generic, and I couldn't connect to it as I do with other projects. On the bright side, I've been working on my cosmic-puzzle project, so far I think the core mechanics are working properly, so I'll be creating some large test maps to see how it works out.
People2_5 & SF_Monster1 added!

Ami
--- X Costume ---

M.Healer: I'm wearing M.Mage's Costume.
M.Mage: I'm wearing M.Healer's Costume.
M.Knight: Why not using the Scary Costume like me,The Scary Frankenstein?
M.Healer: Err…Because we have low of Budget.
M.Mage: Yeah,right.

Forum statistics

Threads
104,602
Messages
1,007,483
Members
136,084
Latest member
TikeTenGamesOffical
Top