corvett

Warper
Member
Joined
Jun 10, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
I'm using the "Pearl" action battle system (with heavy modifications), and it uses event move-routes as part of its enemy behavior.

In any case, the current enemy's Automatic "move route" looks sorta like this:

Move Toward Player

Move Toward Player

script: use item 69

The "skip if cannot move" and "repeat" boxes are checked.

While this works excellently in real time, I don't want real-time. I've put in another script that only lets events' autonomous movement go forward if the user is moving, which makes the enemy movement more roguelike. It also makes for extremely easy battles.

I wish it were doable within the event's Autonomous Move Route on the event page, but no conditions are allowed there. Thus, I'll need to do a script.

I'd like to have a script that does something like this:

    selfx = this event's x

    selfy = this event's y

    charx = character's x

    chary = character's y

 

    If ( ((selfx-charx)(selfy-chary)) ) == 0 && (abs((selfx-charx)+(selfy-chary)) == 1 )

    then

    script:useitem 69 #(this is an already defined movement action)

    else

    ROUTE_MOVE_TOWARD #(or, do you use movement number 10 instead of the function name?)

 

    end

 

This would cause the enemy to move towards you if not orthagonal to you, but once orthagonally alligned, would cause it to use the attack function.

How do I accomplish this in Ruby? How do I call the individual events' x and y values? I'd like the script to be contained inside (or called as a common event) by events, so locality would be nice. Am I going to have to build pre-defined move routes and store them above this part of the script? If so, how do I do that?

 

Thanks for any help in advance!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,763
Reaction score
8,978
First Language
German
Primarily Uses
RMMV
There are no conditional branches inside the move routes, because you should place the conditional branches outside the move routes, and call two different move route commands in the two branches - or condition them on different pages of the event and use the page conditions instead of conditional branches.
 

corvett

Warper
Member
Joined
Jun 10, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Alright, so can you answer my other questions? Did you read anything past the first line of the post? Did you read where I know that I can't use the moveroute?

Is there a quick way to check the math on all this with an event "conditional branch" object? I feel like there needs to be a way to say $game_map.events[THISEVENT].x, but I don't know how to do that.

I guess, if I can condense the condition check to 1 line, I can get it working inside the event page without even needing to write a script. I just don't know if you can call those variables that locally without having to assign them.

Damn, this event programming system is clunky.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,023
First Language
Tagalog
Primarily Uses
RMVXA
$game_map.events[EVENT_ID].x

If you're calling it inside move route, you can use @event_id I think or something... else you'd need to declare the ID...
 

corvett

Warper
Member
Joined
Jun 10, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
I tried your way, and on the event actions, did a conditional branch with the "script" option asking for

((($game_player.x - $game_map.events[event_id].x)($game_player.y - $game_map.events[event_id].y)) == 0) && abs(((($game_player.x - $game_map.events[event_id].x) + ($game_player.y - $game_map.events[event_id].y))) == 1)

And it crashed the game.

Any thoughts?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,023
First Language
Tagalog
Primarily Uses
RMVXA
Did it show an error message? If yes what's the message? 

btw did you try to use @event_id instead of just event_id?

And as I said, that variable might not be present outside of a move route set...
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,647
Reaction score
15,742
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


though I'm not sure this is the correct forum. Are you asking for a completely new script to do this, or a change to the ABS to allow for it? If the latter, please provide a link to the script.
 

corvett

Warper
Member
Joined
Jun 10, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
I got it to work, thanks to the guys in the Reddit community.

Here's the condition that checks for orthagonal relations:

$game_player.x - $game_map.events[event_id].x == 0 || $game_player.y - $game_map.events[event_id].y == 0 && ($game_player.x - $game_map.events[event_id].x).abs + ($game_player.y - $game_map.events[event_id]
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,647
Reaction score
15,742
First Language
English
Primarily Uses
RMMV
I think you've left off half the formula there. Besides that, I don't think the syntax is correct, but can't be sure without seeing the full thing.


You could shorten that by making p = $game_player and e = $game_map.events[event_id] then just use p.x and p.y and e.x and e.y instead of writing out the whole thing each time.
 

Latest Threads

Latest Profile Posts

Apparently I'm a grandpa now.

20220128_181216.jpg20220128_181227.jpg
Sales Goal of Learn RPG Maker MV at 64% now! :kaopride:
When I was in the hospital I did actually have a nurse that was funny, did all these extra nice things for me and said she liked me. So you know what that means. That will be the last time I'll hear from her.
Anyone here ever confronted a never-ending loading screen? Took me 3 hours to realize the problem was the font format :yswt:
Ah, the problems a noob runs into...

Forum statistics

Threads
118,803
Messages
1,118,819
Members
155,982
Latest member
Limox
Top