Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
I see Game_Interpreter.prototype.command285 in rpg_objects.js, but I don't understand it or the Yanfly code I have found online. Can someone explain how to accomplish what I'm trying to do below? And whether it is even possible to do it this way? If this is completely the wrong approach, what should I do instead?

JavaScript:
Scene_Map.prototype.attack_monster = function() {

    let x = $gamePlayer._x;
    let y = $gamePlayer._y;
    let attack = $gamePlayer.attack_dmg;

    let targetEvents = GetEventsAtLocation( x, y-1 ); // how would custom method 'GetEventsAtLocation(x,y)' return an array of events at that map location?
    let monster = FilterForMonster( targetEvents ); // loop to filtering for the first event.IsMonster == true found in the targetEvents array

    if ( monster ) {
        monster._hp = monster._hp - attack;
    }
}

I'm trying to put together a super barebones package for DIY ABS. (I don't want to use any of the ABS plugins that currently exist, and I want to put together a tutorial on how to make your own, since this category of question in pretty common)
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,579
Reaction score
5,339
First Language
English
Primarily Uses
RMMV
You should be able to just follow the code from the command285() method you're already looking at.

If you look at the line that says it's placing the Event ID into the variable, you can see it's calling the function $gameMap.eventIdXy(x, y); (right on line 10113 - I pointed this section out to you in the JavaScript questions thread).

So then you would do a search in the code for that function and find on line 5845 that the first thing it does is get all events as an array by calling this.eventsXy(x, y);

So I don't know where you got that code you're quoting above, but I'm presuming that GetEventsAtLocation is just calling $gameMap.eventsXy()

And then the whole monster bit you have to write...in default RPG Maker, there's no such thing as a monster on the map, so you'd need to determine that an event that has such and such a notetag or comment is what you consider to be a monster and go from there.
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Ah, beautiful. $gameMap.eventsXy() is what I've been looking for. As for finding a 'monster', I just plan to plant an 'IsMonster' property in events that count as monsters. I assume that's easy to do.

((I wrote the code above as an example of what I figured I had to do. I thought I had to create a `GetEventsAtLocation` that executed 285. I wasn't finding anything like $gameMap.eventsXy() anywhere.))
Ty!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,579
Reaction score
5,339
First Language
English
Primarily Uses
RMMV
Not...really? How are you going to know, at some point in your data loading process, that an event is a monster and should have the isMonster property? At some point, in some way, you need the user to be able to define that in the editor, which brings me back to my original point.

You can add it as a property, if you want, but it may well be unnecessarily redundant.
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
That makes sense. The Note field seems like a good place to store the necessary data. I'll figure out how to read those dynamically. Are there Note field limitations I should be aware of?
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,907
Reaction score
730
First Language
German
Primarily Uses
RMMZ
I cant show a solution because i lost the collected Data File.

But i would recomment using Screen x and y coordinates instead of Map x and y coordinates.
For static Objects Map coordinates work fine but if the Enemies or the Projectile are Moving fast,
it will look like if the Mechanic is broken because Attack Hits dont get registered sometimes. Thats because the Mapcoordinate of the Enemy allready changed to the new Maptile but the visible Sprite just started walking to that location.

Pseudo code Idea:
for a do 2 to 500
if event_id(a) is existing do
if event_id(a) contains the word "Enemy" in its description do
if self switch D of event_id(a) is Off (That means Enemy is still allive aslong self switch d is off)
Range of Enemy to Weapon =
(math abs.eventid(a).screenx - weapon_eventid(1).screenx) + (math abs.eventid(a).screeny - weapon_eventid(1).screeny
if Range of Enemy... Variable equal or less than 20 do
Textbox Enemy got Hit.
repeat loop will be executed until all ids are checked

Sadly iam still no Scripter and not good with the Syntax for this.

An additional Event Self Variables Plugin would easily allow you to set up HP and other states for various Enemies.
One self variable could also be used to determine if the Event is not a Monster or if it is one, than which one it is.

Edit: When Player made a swordslash animation , i place the invisible event1 to where he hits on the map, than i called a common event that contained the above code. It got only executed when needed.
 
Last edited:

pawsplay

Veteran
Veteran
Joined
Mar 29, 2012
Messages
495
Reaction score
270
First Language
English
Primarily Uses
RMMV
It seems like it might be helpful to give all the monster events meaningful names.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,907
Reaction score
730
First Language
German
Primarily Uses
RMMZ
I recovered some stuff from Steam Workshop.


Code:
for (var a = 1; a <= 100; a++) {
  if (!!$gameMap.event(a)) {   // check that event exists
    hitDist = Math.hypot($gameMap.event(a).screenX() - $gamePlayer.screenX(),  
                         $gameMap.event(a).screenY() - $gamePlayer.screenY());
    if (hitDist <= 20) {  // in range?
      if ($gameSelfSwitches.value([$gameMap.mapId(), a, 'D']) === false) {
        $gameSelfSwitches.setValue([$gameMap.mapId(), a, 'D'], true);
   
      } } } }
using math abs instead of math.hypot is also possible and less calculation intense.
 

Sethorion

Veteran
Veteran
Joined
May 8, 2015
Messages
52
Reaction score
19
First Language
English
Primarily Uses
Oh, I see. So `.screenX` etc will get the exact location, not just the x,y coordinate of the tile. Makes sense. ty!
 
  • Like
Reactions: Bex

Latest Threads

Latest Profile Posts

I tried a new thing.

fg.png
Another night, another game dev stream in about 20 minutes or so.

I've been busy. Warming up so I don't forget how to draw.
Fr4yy7TaEAUB57Z
I'd make a joke about the post office, but I'm afraid you won't get it.
I've been on a really good streak lately of working on my game for at least a little bit each day. Even if I only complete one small task, it is still a much better pace than what I was maintaining previously!

Forum statistics

Threads
129,784
Messages
1,205,123
Members
170,893
Latest member
LeeYoung
Top