How to find the code you need to edit

So this is a pretty simple question. I consider myself a fairly decent coder -- not an expert by any means, but I enjoy playing around and I have some experience -- but I have one main issue:

Java and its ilk are my mortal foes for time immoral and we shall one day fight upon the last mountaintop peak, upon which one of us shall be slain with the Forgotten Semicolen.

As such, when I opted to get into RPGMaker, I wanted to start with something simple, to get my toes wet. I wanted to make it so that a character or enemy would die if they went to go 0 HP OR 0 MP. I thought it wouldn't be too hard.

Apparently, I am much less competent than I thought, as I found many, many pieces of code that is related to death -- IE, 'is this person dead? How do I revive this person? Is this person dead, The Second Function?' -- but I couldn't find the code that actually stated ''this person is now dead'

I'm not even necessarily asking where that piece of code is -- though I certainly wouldn't mind being told -- it's more that I have a complete lack of understanding of how to even find what I want to muck with.

I looked a bit at Trihan's Jump into Javascript -- should I just start by reading that from start to end? Is my extreme enmity towards all things Java the problem? Or is there something else that I should focus on so I feel less like I'm looking through a massive forest where all of the trees call another tree which calls another tree which calls the first tree and nothing makes any sense?

(P.S. -- I'm pretty sure this is the forum to put this post, but please move it if it's not! )
The engine is written in Javascript btw, not in Java.

The engine itself is a framework different than usual javascipt framework. Even if you know javascript, it'll get time to get used to and to learn the framework. There's no secret, you just got to twinkle in it a lot to get to know it well over time.

Check out Game_BattlerBase.prototype.isDead.
One way to figure out this stuff is to start with the script calls list to get a fingernail into this



and then use the F12 console debugger and inspect different objects

for instance if you want to know the properties of an event, you just enter $gameMap.event(1) or whatever into the console, and it'll give a list of the event's current properties.

Or if you want to know stuff about different characters, you can enter in $gameActors and say, oh, there's a ._data attribute, navigate to $gameActors._data[1] and look at character one's properties.


I'd also recommend using agent ransack and notepad++ together as tools. Agent ransack lets you easily search within files, and notepad++ is a nice lightweight editor that does syntax highlighting. Combined, it makes it pretty easy to follow things between files (and you can also set breakpoints in the 'sources' tab of the chrome debugger and follow execution from there as well)
I personally use Sublime to search through all the files for a string that matches what I want. In your case that might be isDead. I then open up a test game and set breakpoints at all positions that seem to fit. Then I would do a test and in you case let someone die. Then the game should jump to the breakpoints.
Fun fact about isDead... it calls two functions, if something has appeared, and if something is death state affected. Checking if something is death state effected, calls 'is state affected' with 'death state ID'. ...Death state ID returns 1.

I did eventually find what I was looking for, though. Thanks, everybody!

( P.S. -- You're right that it's JavaScript and not Java; I just have difficulties with all high-level languages in general. I much prefer lower-level stuff personally. I tend to use Java as a catch-all for 'languages that are a high enough level that I instinctively hate it, because I am a biased and petty, petty coder'. )

Original thread: https://forums.rpgmakerweb.com/threads/how-to-find-the-code-you-need-to-edit.121613/