Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Detect Closest Event Script?

Hello everyone. I'm working on a tactical fighting hybrid game similar to The Unholy War on PS1. The game makes use of two battle systems. A tactical one which is used on the map of the game, (I am making the tactical battle system with events because ruby makes no sense to me and it would be easier anyway), and when a unit attacks another on the map, the game switches to a fighting game battle system (which I am using the Tales of Battle system with major modifications I made to it).

Having the player move units on the tactical battle system is working well, the only problem I'm having is trying to find a practical way for the enemy AI to detect what player units are closest to its units so it can move its units towards the player units that are closest.

I tried using events to make this happen but it became clear that this was not a practical approach. So then I tried using ForeverZero's area activate script. But that didn't work out either.

So the only other way this detection could be achieved practically seems to be with scripts. But I don't know anything about ruby except for modifying certain things in scripts.
So I was wondering if anyone could help me make this script. Here's basically what I want it to do:

Detect what event with the comment "Priority X" on its active page is closest to a specified event. X would be the priority of which even it wants to find x and y map values to.

For example, say we want to detect which unit is closest to event 1 with a priority of 1. Then the script should search for which unit with comment "priority 1" in its active page is the closest. That way we can detect for only certain types of events. But the number of different priorities should be at least 10 if not infinite.

And when it detects which is closest, it will then store the closest unit's x and y values into game variables which should be user specified in the script.

Finally, to call the script, I would like that to be done within the script command of events. The script line should look something like this:

closest(event, priority). Event should be the map event ID that we are searching for units closest to it, and priority should be the priority number specified in the events that we are searching.

Thanks in advance guys, hopefully you scripting geniuses out there can help me with this.
 
Okay explain what the priority is for again?, Also is it just enemies finding ally events, or ally events finding enemy events?
Also are you wanting radial unit detection or, block unit detection(non-circular square area of detection)

Any other info you could provide me with would help as well. Just specifics on everything.

Also I think it would be better, instead of calling closest(event, priority), you could use event names like Enemy[priority], or Ally[priority] this would be set in the events name area, you could put it in a comment as well but w.e floats your boat you know :P

Thanks
Pandora/azrith001
 
Hey, thanks for the reply. The priority condition just helps you search for specific events in case you don't want to search for all events. For example, if there's enemy events and door events on the map, most cases you won't want to see if the door events are closest, just the enemy events. So having that priority helps with that. But not just enemy and ally events. Perhaps you may want to search for which item, door, lever, or any other kind of event which is closest too.

Radial detection would be preferable. I would like it to be called because this script should just return the closest unit's map x and y values to store in game variables so that way I can use, say, a pathfinding script to move an event towards the detected event.

In other words, this script should just detect the location of the unit given the specified priority and store it in game variables that you can specify in the script (for example, a setting in the script like detectx = choose which variable ID), and not detect whether or not a specific unit is closest as if it were a true false value.

Hope that helps. I think many others may find such a script useful too as I've not seen any scripts available that detect events closest to other events.
 
The priority thing still confuses me, give me a bit to try to figure out what you mean, but i am interested in making it :)

EDIT:

So you just wanna give em an easy search tag, in the form of a number XD? Alright so how would you wanna call a check for a specific priority.
 
It should be just a parameter given when you call the script like closest(eventmapID, priority tag). For example, calling closest(1,2) would see which event with the tag of 2 is closest to the event with the ID of 1. Also, -1 in eventmapID should be the player.

Also, I would like another script that should be really easy to do. I've been searching for days for a mp regen script for XP but never found one :(. I would like a simple MP regen script that regenerates mp by a specific % of total mp for all battlers (including enemies) per second. So somewhere in the script you should be able to specificy what number of % of mp all battlers regen per second. Also, a setting for whether or not this effect can take place outside of battle (for actors only) will be very helpful as well.

I hope that's not too much to ask for. Thank you for your support Pandora.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top