Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Outside of SV battle, a character can take damage and die. What is a GOOD way to do that for NPCs and monster events while in a map scene?
NOTE: I've made my character swing his sword in the right direction when you hit the appropriate key, and I can get the event data of the monster that would be hit, so those parts are working. The 'damage' that would be dealt is calculated properly, as is the max HP of the target (based on monster type and level). I just need some way to track the current hp of an event with reasonable and forward-facing code.
 

Iron_Brew

Veteran
Veteran
Joined
Nov 19, 2021
Messages
333
Reaction score
972
First Language
English
Primarily Uses
RMMV
Define a variable to have it increment, have it trigger a self-switch when variable is hits a certain number, then reset the variable if you wanna reuse it.
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Makes sense. So, I would probably need an invisible event that finds the monster events and sets their HP dynamically. I was kinda hoping there was a more dynamic way to do it, but this should be sufficient for now. ty!
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Ideally, I'd love to listen for a `player_transferred` event and run a method checking for monsters on the map he/she just moved to, and making those monster events a new property. Right now I just have an invisible event that runs once after the player arrives in the map.
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
194
Reaction score
173
First Language
English
Primarily Uses
RMMZ
Is there a reason why you don't want to just give the event a "hp" property? Or are you trying to do this without script calls or something?
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
I want to have the plugin give it that 'hp' or 'hp_current' property automatically when the player enters the map. I would rather not have lots of events with script calls, as that would confuse future users of the plugin.
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
194
Reaction score
173
First Language
English
Primarily Uses
RMMZ
Oh, you're making a plugin? Sorry, your initial post didn't really make it clear exactly what you're doing. It's a really simple matter in that case, so I thought maybe you were trying to do this all through eventing or something. If you're making a plugin, then just hook into one of the methods that deals with the creation of the events, and then assign the property there. For example:

JavaScript:
(function(alias) {
    Game_Map.prototype.setupEvents = function() {
        alias.call(this);

        for (const event of this._events.filter(event => !!event)) {
            event.hp = 500;
        }
    };
})(Game_Map.prototype.setupEvents);

That will make it so that when you enter a map, it will iterate through all events on the map and give them a hp property with an initial value of 500. Of course, you're probably going to want to pull the hp value from a note tag, or from some calculation or something, rather than assigning a flat value like I did in the example.

*edit* I should mention that I wrote that based on MZ's code base, because I already had it open in VS Code and didn't feel like switching. Pretty sure it won't matter in this case, but in the event that it doesn't work, that's probably why.
 
Last edited:

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Ah, this answers so many questions. Ty!
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Sorry for the double-post, but this actually spat out an error the moment I clicked "New Game". I must have an outdated plugin or something:
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
194
Reaction score
173
First Language
English
Primarily Uses
RMMZ
That shouldn't have anything to do with my code. When the error occurs, can you press F8 to open up the console, and post a picture of it? The stack trace might help us figure out what's going on.
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Here's the stack trace
EDIT: I found the issue. It was this:
JavaScript:
// Game_Player.prototype.performTransfer = function() {
// };
I thought I had commented it out, but I just found that I hadn't...
 
Last edited:

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
194
Reaction score
173
First Language
English
Primarily Uses
RMMZ
Glad you got it figured out.
 

Latest Threads

Latest Profile Posts

Have a new game, want to enjoy?
Genres: Action, Survival Horror, Gun, Sci-fi.
Engine: RGSS3 a.k.a rmk VXAce
Historically, "honor" isn't what has won fights. Being as brutally dishonorable and malicious as possible has done that. This is a tactic that works for any fight. Honor doesn't matter when you're the loser.
Mcniner wrote on Umbriel's profile.
Hello! It seems the Zelda sprites you sent me were removed by a moderator. Could you gmail them to me here: steinjaltman@gmail.com? Thanks!
Remember to do your 0,01% progress on your game today!
Went to see Jujutsu Kaisen 0 yesterday, it was cool. The movie wasnt really a masterpiece, it had some pacing and characterization problems, but overall I enjoyed it, maybe because it was the first anime film I have ever been to in the cinema lol. The battle animation & music were top-notch. I havent seen much of the anime so people who watched the entire season would probably like it more.

Forum statistics

Threads
121,998
Messages
1,145,782
Members
160,265
Latest member
Greysis1
Top