New Tuxemon Events/Conditions

Avatar

By josepharaoh99 23 Nov 2015 16:23

Champion · 295 comments

As I work on a map for Tuxemon, I am finding a need for new events/conditions. If the ones I recommend are already implemented, let me know! I am looking at this page for reference: https://github.com/Tuxemon/Tuxemon/wiki/event-reference So, here are my suggestions:

Events:
remove_monster ... Suppose you wanted to release a monster, or trade one. So, you need an action to release it. Example: remove_monster,Pigabyte
change_map_texture ... Suppose you add a item ball to the map and you want to be able to pick it up, and the image goes away. Example: change_map_texture(1,1,default_grass)-   
                                      changes tile 1,1 to grass.
npc_face: ... make an npc face a certain direction. Or, can you do that with player_face.
heal_all_monsters ... heals all monsters in your inventory
heal_monster ... heals an individual monster. 

Conditions:
battle_won ... checks to see if a fought battle is won (is battle_won)
battle_lost ... checks to see if a fought battle is lost (is battle_lost)

This is all I have as far as ideas right now, but I'll probably add more later. Hopefully, I can draw up some scripts for this...
AND... I have a quick question. When you create event variables, can you access those same variables on another map? For example, could you create a met_boss variable in a gym and use it in the map the gym building is located in?

Last edited by josepharaoh99 (23 Nov 2015 17:12)


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By rsg167 23 Nov 2015 18:22

Member · 37 comments

All those actions look good.

I don't think we need battle_won or battle_lost. Losing a match traditionally takes you straight to the Pokécenter. On the other hand, the ability to check whether a battle is won or lost would allow us to make special scenes for if you lose against your rival...  big_smile

Avatar

By ShadowApex 23 Nov 2015 20:08

Lead Developer · 374 comments

These are great suggestions. I've been mostly creating new event actions/conditions as I've needed them, and these would make great additions. That event reference page pretty much has a list of all the currently available actions and conditions that you can use in Tuxemon.

remove_monster ... Suppose you wanted to release a monster, or trade one. So, you need an action to release it. Example: remove_monster,Pigabyte

This would be super easy to implement. If you want, look at how the add_monster event action works in core.components.event.actions.player, and it will be even simpler than that.

change_map_texture ... Suppose you add a item ball to the map and you want to be able to pick it up, and the image goes away.

Also a great suggestion, and I think we should have it. This might be a little more complicated to implement, but is also do-able.

npc_face: ... make an npc face a certain direction. Or, can you do that with player_face.

You're correct that, while there is an action to make the player face a direction, there's currently no way to make an NPC face a direction. This too would be pretty simple to implement and it could probably be based on how the current player_face action works.

heal_all_monsters ... heals all monsters in your inventory
heal_monster ... heals an individual monster.

Also great additions and should be easy to add. smile

Conditions:
battle_won ... checks to see if a fought battle is won (is battle_won)
battle_lost ... checks to see if a fought battle is lost (is battle_lost)

I don't think I would totally object to having something like last_battle_won or something similar, but right now you could do this with event variables. Just doing is variable_set rival_battle:won would accomplish the same thing.

When you create event variables, can you access those same variables on another map? For example, could you create a met_boss variable in a gym and use it in the map the gym building is located in?

Yes, game variables set through the set_variable action will persist through all maps. Right now they are all set with the game_variables attribute in the core.components.player.Player object.


Avatar

By josepharaoh99 24 Nov 2015 17:29

Champion · 295 comments

I'm making an updated Event Reference Manual here: https://github.com/josepharaoh99/Tuxemo … -Reference


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By ShadowApex 24 Nov 2015 17:54

Lead Developer · 374 comments
josepharaoh99 wrote

I'm making an updated Event Reference Manual here: https://github.com/josepharaoh99/Tuxemo … -Reference

The Offical Wiki is actually editable by anyone. No need to maintain two copies. smile


Avatar

By josepharaoh99 24 Nov 2015 18:34

Champion · 295 comments

So, where can I find a guide to make Tuxemon events? I found this: https://github.com/Tuxemon/Tuxemon/wiki … tom-Events but I'm still confused. I've got this for heal_monster:

def heal_monster(self, game, action):
	        """This effect heals the target based on the item's power attribute.
	
	        :param target: The monster object we are using this item on.
	        :param game: The main game object that contains all the game's variables.
	
	        :type target: core.monster.Monster
	        :type game: tuxemon.Game
	        
	        Valid Parameters: monster
	
	        :rtype: None
	        :returns: None	
	        """
	        
	        >>> action
		       ('heal_monster', 'Fruitera', '3', 1)
		>>>
		
	
	        # Heal the target monster to the max amount able
	        target.current_hp = target.hp

As you might see, it's built off of def heal. So, what would replace target? I'm kinda new to this stuff. Any help?


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By ShadowApex 24 Nov 2015 18:52

Lead Developer · 374 comments

The game variable is an instance of the core.tools.Control object that has access to all components of the game. Using that object, you can access any variable you need for your own actions. Try enabling the debug console and use the console to explore the variables in Tuxemon that are available to you. In python, you can append ".__dict__" to an object to print out everything inside that object. So, for example, when you run this in the debug console, you'll be printing all the properties of that core.tools.Control object:

>>> from pprint import pprint
>>> pprint(self.app.__dict__)

If you do that, you'll get something like this:

{'animations': {},
 'caption': 'Tuxemon',
 'cli': <core.components.cli.CommandLine instance at 0x7f436532bc68>,
 'clock': <Clock(fps=62.50)>,
 'config': <core.components.config.Config object at 0x7f4367617810>,
 'current_music': {'song': None, 'status': 'stopped'},
 'current_time': 383013,
 'player1': <core.components.player.Player object at 0x7f2e0b8f18d0>,
...

So if you print self.app.caption, you'll get this output:

>>> pprint(self.app.caption)
'Tuxemon'

For your particular scenario, you'll need to get a list of all the current player's monsters, and loop through them until you find the monster with the matching name. The player's monsters are in the player1 object instance stored in game.player1. Try using the debug console to explore the structure of Tuxemon; it will help with making other events in the future. If you're still having trouble, let me know, and I'll try and help the best I can.


Avatar

By josepharaoh99 13 Jul 2016 19:19

Champion · 295 comments

Has anyone worked on the world sprite function? I really would like to have that one done!! big_smile


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By dulsi 23 Jul 2016 03:44

Member · 27 comments
josepharaoh99 wrote

Has anyone worked on the world sprite function? I really would like to have that one done!! big_smile

By world sprite function do you mean the "change_map_texture" you proposed. I'm looking for things to help with and may be able to take a look.

Edit: Ah! Found mention in another thread that ShadowApex suggested changing the name and was going to implement it.

Last edited by dulsi (23 Jul 2016 03:59)

Avatar

By dulsi 23 Jul 2016 13:53

Member · 27 comments

I was thinking about the remove_monster command. For an event you could have someone who lost their tuxemon or is researching a particular tuxemon. Ideally though I don't want to simply take your tuxemon, I want to ask and have you answer yes or no. Additionally we would need a has_tuxemon conditional. Then you could do:

Event 1:
cond: no_tuxemon Pigabyte
act: dialog "I lost my pigabyte."

Event 2:
cond: has_tuxemon Pigabyte
act: yes_no_question "You found a pigabyte. Can I have it", 3, 4

Event 3:
act: remove_monster Pigabyte
act: dialog "Thank you so much!"

Event 4:
act: dialog "*whimper* I'll keep looking I guess"

(I haven't played with map editing yet so may be there is a better way of creating something like this.)

Avatar

By josepharaoh99 23 Jul 2016 17:28

Champion · 295 comments

That sounds very cool! I like the idea. Oh, and welcome to Tuxemon!  big_smile


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By ShadowApex 24 Jul 2016 02:47

Lead Developer · 374 comments
dulsi wrote

(I haven't played with map editing yet so may be there is a better way of creating something like this.)

Here's some good information if you're looking into the event system:
- Map Events
- Event Reference

dulsi wrote

I was thinking about the remove_monster command. For an event you could have someone who lost their tuxemon or is researching a particular tuxemon. Ideally though I don't want to simply take your tuxemon, I want to ask and have you answer yes or no. Additionally we would need a has_tuxemon conditional. Then you could do:

A dialog choice event would be great. Instead of yes_no_question we might be able to have a more generic dialog_choice action where you could specify the choices you want as a map maker. The last parameter of the event could be a player variable that is set just like the set_variable action. This would let you use the variable_set condition to check and see what the player decided and use it in other events.

Here's an example:

Event 1:
cond1: not has_tuxemon txmn_pigabyte_name
act1: dialog I lost my pigabyte.

Event 2:
cond1: is has_tuxemon txmn_pigabyte_name
act1: dialog You found a Pigabyte. Can I have it?
act2: dialog_choice Yes,No,Maybe,myvariable

Event 3:
cond1 is variable_set myvariable:Yes
act1: remove_monster Pigabyte
act2: dialog "Thank you so much!"

Event 4:
cond1 is variable_set myvariable:No
act1: dialog "*whimper* I'll keep looking I guess"

We should also include a translatable dialog choice action that uses slugs instead of hardcoded English choices:

translated_dialog_choice choice_yes,choice_no,choice_maybe,myvariable

Avatar

By dulsi 24 Jul 2016 03:18

Member · 27 comments

I'd be tempted to only put in translated_dialog_choice. It's a little more annoying if you don't plan to translate but I would prefer to enforce that as expected. I agree dialog_choice is a better idea.

I have remove_monster and has_monster in my github now. (I'd go with has_monster over has_tuxemon because the other functions like add and remove are monster not tuxemon.) I started looking at dialog_choice but don't know if I know enough to implement it at the moment. Would you like a pull request for the small stuff or wait until I have something more?

Avatar

By ShadowApex 24 Jul 2016 03:33

Lead Developer · 374 comments
dulsi wrote

I'd be tempted to only put in translated_dialog_choice. It's a little more annoying if you don't plan to translate but I would prefer to enforce that as expected. I agree dialog_choice is a better idea.

In the main Tuxemon campaign we definitely plan on only having translatable dialog, but it might be easier and more convenient for custom map makers to add the dialog in the map itself instead of editing json files to add a slug and dialog line, etc.

dulsi wrote

I have remove_monster and has_monster in my github now. (I'd go with has_monster over has_tuxemon because the other functions like add and remove are monster not tuxemon.) I started looking at dialog_choice but don't know if I know enough to implement it at the moment. Would you like a pull request for the small stuff or wait until I have something more?

I like has_monster too. Feel free to open a PR for small stuff. Pull requests should generally implement a single feature or bugfix. Keeping them in separate pull requests also makes it easier to have a dialog about individual features.

Thanks for working on these!


Avatar

By josepharaoh99 26 Jul 2016 18:57

Champion · 295 comments
dulsi wrote

I have remove_monster and has_monster in my github now. (I'd go with has_monster over has_tuxemon because the other functions like add and remove are monster not tuxemon.) I started looking at dialog_choice but don't know if I know enough to implement it at the moment. Would you like a pull request for the small stuff or wait until I have something more?

Wow, that's great!! big_smile You should totally make a pull request for an event like that! I'll be waiting for it - it'd be so much fun to mess with an event like that.

It's great to see you being involved so much in this crew! big_smile Most people would have burned out already. We need more steady members, and you look like one! Thanks for your help!


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By bitcraft 26 Jul 2016 20:07

Champion · 166 comments

I've opened a github issue for adding/removing items on the game map.

https://github.com/Tuxemon/Tuxemon/issues/193

Avatar

By josepharaoh99 27 Jul 2016 18:23

Champion · 295 comments
bitcraft wrote

I've opened a github issue for adding/removing items on the game map.
https://github.com/Tuxemon/Tuxemon/issues/193

Awesome! This is so cool! I'm definitely on pins and needles waiting for this one big_smile Thank you so much!

Last edited by josepharaoh99 (27 Jul 2016 18:23)


Multiple Media Producer
Jesus is God! http://www.upci.org/search

Avatar

By dulsi 28 Jul 2016 00:49

Member · 27 comments
josepharaoh99 wrote

It's great to see you being involved so much in this crew! big_smile Most people would have burned out already. We need more steady members, and you look like one! Thanks for your help!

I plan to stay around although I do have other projects and hobbies. I've been prioritizing your requests because you have been working on maps. I generally assume enabling others encourages them to contribute.

I've opened #197 for the dialog_choice event action. translated_dialog_choice is currently available in my github.