Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Plugin Port Request: Batch Event Collision and Collision Checking

Bizarre Monkey

I SHALL BE GLORIOUS!
Hello folks. My usual supplier of the codemonkey bizness is MIA and I don't know for how long and I can't keep waiting around. I can't imagine this should be too difficult for anyone who's into coding.

What do I want?
A port of a VX Ace script I had made at my request by Omegas7, into a plugin for MV.

What did this script do?
At base value, it was alike Tsukihime's event collision script for VX Ace, only without the erratic behaviour when moving sprites on a plan that wasn't flatly left or right (Jumps crashed the games, as did moving upper right, lower left, etc.) as well as alleviating the current legal issues, since I requested it for an IGMC entry, which made Tsukihime's scripts off limits, I'm aware his terms have changed now, but this was in mid 2014.

Essentially though, I figured Omegas7 was good enough to make my task a little easier, so I asked for the addition of batch event support. How this worked is that along with regular conditionals like this.
Code:
EventCollision.happens?(3,5)
Where that would check event with ID 3 against the location of event with ID 5.
Code:
EventCollision.happens?(0,11)
And this would check the player against event with ID 11.
Code:
EventCollision.happens?(0,[11])
This, a batch collision, would check all events with the comment <Batch 11> against it's argument, in this case 0 (the player.)

With this it made it substantially easier to event big aoe attacks and such as instead of doing all this:

And keeping in mind, that's for only one attack/event tile collision.

I could instead do this.

To add a bit of context, all events in <Batch 5>, which is a player attack that covers two tiles, is being checked against all events with <Batch 23>, which in this case was a boss monster.

But if you look at hectic evented bosses like this:
It looks really difficult to make, and it's really not, and without this script, it'd be no more difficult, just a lot more tedious and frustrating, not to mention an enormous strain on resources in comparison. Also the amount of variables you need to set aside for just this kind of thing is in the hundreds.

So that is what this does, and it's what I want the port to do.

Specifics on what exactly I want.
-I don't need any plugin commands for it.
-I want it to if at all possible, for it to use the same conditional checks as above. It would be a scripted conditional line like those shown.
-Comments that assign batches should only be active in the active event page, so for instance, if I turn an event that typically has batch ID in one page, I may not want it in another page where the attack is turned off. This should be pretty obvious, but it's worth mentioning.

Resources
Here's the original script.
Code:
# =============================================================================
# * Event collision checker
#  Author  : J.V.Wong - Omegas7 (admin@omega-dev.net)
#  Date  : June 16 2014
#  Free for commercial use
# =============================================================================
#  Determine if two events are colliding (have the same position)
#  Also allows you to group several events into a single batch, and then check
#  if two batches collide (or if 1 batch collides with an event, or viceversa)
# =============================================================================
#  USAGE:
#
#  * Check if event number 3 collides with number 5:
#
#  EventCollision.happens?(3,5)
#
#  * Create a batch of events:
#
#  Put a comment in the event page with the following format:
#  <batch N>
#  N is the batch ID for this event page.
#
#  * Check if any event in batch ID 8 collides event number 5:
#
#  EventCollision.happens?([8],5)
#
#  * Check if any event in batch ID 2 collides with any in batch ID 9:
#
#  EventCollision.happens?([2],[9])
#
#  * The player is considered as event number 0.
# =============================================================================
module EventCollision
  class << self
 
  # Get all events that belong to a given batch ID
  def events_for_batch_id(id)
  result = []
  $game_map.events.each_value do |e|
  next unless e.list
  e.list.each do |c|
  if (c.code == 108)
  c.parameters[0][/<batch (\d*)>/]
  if ($1.to_i == id)
  result << e
  break
  end
  end
  end
  end
  result
  end
 
  # Check for collision
  def happens?(first, second)
  events = $game_map.events
  a = (first.is_a?(Array) ? events_for_batch_id(first[0]) :
  [first == 0 ? $game_player : events[first]])
  b = (second.is_a?(Array) ? events_for_batch_id(second[0]) :
  [second == 0 ? $game_player : events[second]])
 
  a.each do |eventA|
  b.each do |eventB|
  return true if (eventA.x == eventB.x && eventA.y == eventB.y)
  end
  end
  return false
  end
 
  end
end
I'd super appreciate this.

What's in this for you?
Outside of my gratitude and credit in the game, you'll also be added to special thanks. You'll also be mentioned along with Omegas7 when people ask me how did I manage all this. You also would be very likely to earn a position in the Corporation of XVI as lead programmer, if you wanted.

I can't pay, sadly. Christmas is coming up and expenses are mounting.
 
Last edited:

Bizarre Monkey

I SHALL BE GLORIOUS!
Yep! Or if a player touches another event. I also want to be able to define a collision of one to multiple events using a comment, which is then checked for in the square brackets.
 

Bizarre Monkey

I SHALL BE GLORIOUS!
Overlapping. Player would be ID 0. You could also do -1 for "this event", but essentially that'd just be a bonus, as I personally don't rely on such a check.
 

Bizarre Monkey

I SHALL BE GLORIOUS!
That'd be super radical! No rush, as I'm having fun deving I314, but once I do get this fuctionality I can really get cracking on PFC, dev. Which sadly has been sort of stagnant lately.
 

Chaucer

Towns Guard
Xy$
0.00
Worked this up this morning, don't know if it's working perfectly, I kinda rushed it, apologies ^^; but hope it helps if theres any issues, feel free to let me know, and I'll update it. Just check the help window in plugin manager to see how to use it.
 

Bizarre Monkey

I SHALL BE GLORIOUS!
Alrighty! Thanks for the help, I've done some rigorous testing, here's misbehaviours and errors I've encountered/would really like altered.

Batch support:
-It really needs to be able to check two batches against each other.
-The reason I asked for comments rather than event notetags is because notetags are globally checked across all of an events pages. In some cases, this won't be ideal.

Event ID checks
-Player to batch checks work fine.
-Event to batch checks do not. In both the case of checking -1 (this event) and ID 41 (the event I wanted to check against batch:1) it gave me an error when placing them with the batch last, and no interaction was signaled when putting the batch first.

Really appreciate the help, if you can, I'd really like to have those errors fixed, and comments used for batches rather than note tags.
 

Chaucer

Towns Guard
Xy$
0.00
Apologies, as I said it was a bit rushed, D: seems I missed a few things, also didn't think of adding batch : batch support, it's now done, everything should be working as intended, also, any reason why you want comments rather than note tags(just curious, I left it as note for now) anyways, the original file has been updated, download it again and see if that works(unable to test right now, but it all looks sound)?
 

eivl

Local Hero
Xy$
0.00
using notes are much better then anything else, main reason is that notes are parsed and saved to the meta as name/value pairs.
 

Bizarre Monkey

I SHALL BE GLORIOUS!
The reason I want comments is that they are only active in a page of any event. So if i want to turn something off, it's very easy to do so. I just switch to an event page without the <batch:3> comment on it or what have you.

Notes are global to the whole event, it's easy enough to work around, though! I'm gonna be rebuilding most facets of the Perseverance engine anyway, so no biggie. But maybe in the future support for both? That'd be cool.

I'll rigorously test the update tomorrow, I've been awake for 16 hours and my body is demanding me to crash. I never seem to sleep long nowadays, so I should be back here with the results in 10 hours or so.

Thanks again for the help, fellas!
 

Bizarre Monkey

I SHALL BE GLORIOUS!
Rigorous testing brings the following:

-All collisions work now.
-However, they work regardless of if the condition is actually met. Meaning my enemy is hurting herself till death once the damage variable is set to be above 0.
 

Chaucer

Towns Guard
Xy$
0.00
Ok, working on this again, I'll be able to test this time, so I should be able to get it right this time, apologies for the delay, I'll have this finished by the end of the day.

edit: script's complete(and functioning correctly), and as for making it trigger from a comment, I'll look for a way, but I'm not entirely sure how to check for a comment xP sorry if anyone knows how, some advice would be appreciated~

Old download was removed, new one on this reply.

P.S: this call does not return a false value, so using
Code:
$gameMap.isCollision(1,0) === false
will not return true, if you really need to check if the value is not true, use one of these instead

JavaScript:
$gameMap.isCollision(1,0) !== true
//or use
$gameMap.isCollision(1,0) === undefined
 
Last edited:

Bizarre Monkey

I SHALL BE GLORIOUS!
Again, super appreciate the help! But uhm, this file appears to be exactly the same?

Collisions, with the new conditional checks or without, still repeat indefinitely and without the conditions being met.

You may have simply resent the same file, it does have the same name and file size, if that isn't the case, then it's still bugged in an identical fashion. :0
 

Chaucer

Towns Guard
Xy$
0.00
Hmm, I just reuploaded the file again, the file size should actually be almost exactly the same, smaller by a bit :P I've run the same script in a completely blank project and it seems to work just fine, I tested it with a single event vs single event, batch vs single event and batch vs batch(with many events on the map) I'm taking another look at it, maybe I missed something? ._.
just to verify the file size should be 4KB, is that the size it's at on your pc? I left the file name the same, since it's the same plugin, I just rewrote a few things, try completely deleting the plugin, and redownload it, maybe it got mixed up with the old one?

edit: tested, it's working on my project(blank), I reuploaded it once more with 2 minor changes(just to keep your console from getting spammed while it's being called), open up the help file, if it says Version 1.04 at the top then it's the right file, if not, then I think there's a mix up, I also changed the name to include an underscore.
 
Last edited:

Chaucer

Towns Guard
Xy$
0.00
Are you still getting the same issue? or has it been resolved, if it's still doing it for you I'm not sure what it could be, :| it might require someone else to take a crack at it, cause I still can't replicate the issue :(
 
Top