Tuxemon Multiple event Idea


By tamashihoshi 6 Dec 2015 01:01

Champion · 251 comments

Hi guys,

I just watched shadowapex doing a livestream of tuxemon development. When he used the map editor, I've noticed the following:
If you have a point/event in the game, on which you can't stand on, you simulate triggering it, by putting multiple events outside of it. The problem is: You have the events multiplied, they are an almost exact copy of one, except the coordinates.
Now, I don't think that's a good way to solve the problem.

I have a few ideas/suggestions to solve the problem, but I'd like to know what you guys are thinking ^^

First important thing: Coordinates
Currently you put the coordinates of the events by hand into the condition. Instead, a method could be used.

Now lets start with the ideas... and epic drawn, hopefully self-explenatory images.

# 1 - Parent/Child System
(need the independant coordinate check for this!)
Inheriting stuff. I guess this one is clear to anyone who did object oriented programming before.

# 2 - Kinda more clever Cell-check System
This one is a little more complicated, but might be a little cooler... Here is the idea:
Instead of checking, if the position of the player is identical with the events position, the event could check, if the player is next to it.
How? Like this:
player.x > event.x -1 && player.x < event.x+1
player.y > event.y -1 && player.y < event.y+1

Or cleaner, if all coordinates are positive:
absolute value (player.x-event.x) <=1
absolute value (player.y-event.y) <=1

Logic-Nazi: "No! No! No! No! No! If the player is standing on the upper left corner, he can still trigger the event!!"

That's only one part of the condition check method. Look at this:
x_sep = absolute_value(player.x - event.x)
y_sep = absolute_value(player.y - event.y)

if (x_sep == 0 || y_sep == 0){
   if ( x_sep <= 1 && y_sep <=1 ){
      // do some sick stuff

Logic-Nazi: "This is not Python! You need more conentration!"

Yeah, I know. But you get what I mean, right?
No? Okay look at this:


fig 1
If the player is standing next to it, the x OR the y coordinate is identical with the events x or y coordinate. Which means, subtracting those, will get you a 0.

fig 2
When on a corner though, x and y are both different from the targets x and y coordinate. Both subtractions will be unequal to 0.

so yeah... what do you guys think? D: I hope I explained my thoughts in a reasonable way.

We'll meet again, don't know where, don't know when. But I know we'll meet again some sunny day!


By ShadowApex 6 Dec 2015 09:12

Lead Developer · 374 comments

This is a fantastic explanation, thanks! smile

I think that both of these ideas would be great to implement. Your second suggestion would definitely be the most elegant way to fix the current "Get Fruitera" event on the starting map.

Right now a condition called "facing_npc" already exists, which basically checks to see if your character is right next to an NPC and facing them. It should be relatively easy for me to do the same for facing a tile instead. I'll make plans to add a "facing_tile" condition that will solve this problem.

In regards to your first suggestion, I think this kind of functionality would also be useful for some situations. An action like "call_parent" or "call_event" would be nice to have. Every event has a unique id field that you could use to call another event, so something like this could work:

Event 1

cond1    is player_at 9,6
act1     call_event 2

Event 2

act1     add_monster Sumobug,10
act2     dialog Received Sumobug!


By ShadowApex 11 Dec 2015 23:12

Lead Developer · 374 comments

Happy to say I've implemented both of these new events in the latest development commit. You can now do both of these things.

Player Facing Tile

You can now use the player_facing_tile condition to check if the player is facing a particular tile. Here's an example of it in action:

cond1    is player_facing_tile
cond2    is button_pressed K_RETURN
act1     add_monster Fruitera,10
act2     dialog Received Fruitera!

Call Event Action

You can now use the call_event action to execute the actions from another event, ignoring its conditions. This is especially useful for creating events that can have CONDITION A OR CONDITION B be true.

In this example, if the player is at tile position (1, 2) OR (20, 5), they will receive Sumobug:

Event 1

cond1    is player_at 1,2
act1     call_event 3

Event 2

cond1    is player_at 20,5
act1     call_event 3

Event 3

act1     add_monster Sumobug,10
act2     dialog Received Sumobug!