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.

Collision with another event

cadz

Member

Hello all!
Firstly, if the the solution ends up being a script, then please move this topic. Also, I did a search, but with no avail D:

Right, I'll get straight to it. In my game, if the player is hit, his HP Variable goes down. What I need now is if his partner (who is just an event) gets touched by the monster (another event), their HP Variable goes down.

That's as simple as I can put it. I really need this sorting out, be it a simple event method or a script, because If I can't, this will hinder my games progression.

Thanks in advance!
Cadz.
 
This doesn't need a script, although it might benefit from one.

You can have a parallel process event tracking the X and Y coordinates of the two events, and have them react when those numbers get to be adjacent. If facing is important, you can track that, too, so you can make sure that the monster only hurts your partner when it's facing them.

Doing this with a lot of events is going to be massively lagtastic, though. Hopefully, you're tracking one or two monsters and one partner at most. Any larger numbers really, really need a script.
 

cadz

Member

Yeah, I've been experimenting with that, but the X and Y coordinates of both will never be the same without the event being in the exact same square at the other. And even if, for example, the Y coordinates are the same, that would mean that the monster could attack the parter even if it was in the same Y space, regardless of the X.

I'll give it a go, and I'll see what happens.
Thanks for responding ^_^
 

cadz

Member

I've got it as far as it will hit her if she is one square down diagonally...
Guh. This is frustrating.
I'll carry on, and hopefully by trial and error, I'll get it to work.
 
You just need some properly nested conditional statements. (I wish event code could handle OR statements, but you can work around it.)

Like, IF y1=y2, then if x1-x2=1, hit, else if x1-x2=-1, hit.

If that wasn't clear, let me know, and I'll mock up a screenshot.
 

cadz

Member

I sorted using a similar method. If the monster was facing down, it first checks if the X's are the same, if so, it subtracts 1 off the partners Y coordinate. Then it checks to see if the Y's are the same. Because it subtracts 1, the characters don't need to be in the same square, because the game thinks they are. Because both check out, it hits the partner.

Conditional Branch: [Monster #1] is facing Down.
Control Variables: [0001: Partner-X] = [Partner]'s Map X
Control Variables: [0002: Partner-Y] = [Partner]'s Map Y
Conditional Branch: Variable [0003: Monster-X] == Variable [0001: Partner-X]
Control Variables: [0002: Partner-Y] -= 1
Conditional Branch: Variable [0004: Monster-Y] == Variable [0002: Partner-Y]
Partner gets hit!

That's what I have for down. It's practically the same for Up, expept you swap subtract 1 for add one.
For left and right, you have to swap the order of the branches, so Y comes first.

Thanks for your help, that's how I ended up getting there ^_^.

This topic can be closed now, uness anyone wants to add an easier method?
 

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