-
Notifications
You must be signed in to change notification settings - Fork 39
Random battles
In this tutorial, we'll be seeing how to set up random battles in gshtml5.
First, you need to create enemies in assets/dbs/enemies_db.json
db file. In this database file, you'll be setting specific stats and spritesheet of enemies (see detailed info here). See example below for Mini Goblin:
[
{
"key_name": "mini_goblin",
"name": "Mini Goblin",
"level": 17,
"turns": 1,
"max_hp": 220,
"max_pp": 0,
"hp_recovery": 0,
"pp_recovery": 0,
"atk": 209,
"def": 21,
"agi": 61,
"luk": 20,
"battle_scale": 1.0,
"battle_shadow_key": "00",
"status_sprite_shift": 15,
"defeat_voice": "monster_defeat/monster_2",
"items": [
{
"key_name": "herb",
"quantity": 1,
"use_weight": 0.25
}
],
"abilities": [
{
"key_name": "attack",
"use_weight": 0.75
}
],
"vulnerabilities": [],
"coins_reward": 120,
"item_reward": "",
"item_reward_chance": 0,
"exp_reward": 90,
"base_level": {
"venus": 1,
"mercury": 1,
"mars": 1,
"jupiter": 1
},
"base_power": {
"venus": 100,
"mercury": 100,
"mars": 100,
"jupiter": 100
},
"base_resist": {
"venus": 100,
"mercury": 100,
"mars": 100,
"jupiter": 100
},
"battle_animations_variations": {
"attack": "attack"
},
"battle_spritesheet": {
"spritesheet": {
"json": "assets/images/spritesheets/battle/mini_goblin_battle.json",
"image": "assets/images/spritesheets/battle/mini_goblin_battle.png"
},
"animations": [
"idle_back",
"idle_front",
"attack_back",
"attack_front",
"damage_back",
"damage_front",
"attack_init_back",
"attack_init_front",
"cast_back",
"cast_front",
"cast_init_back",
"cast_init_front"
],
"frames_count": [4, 4, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1],
"frame_rate": [3, 3, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1],
"loop": [
true,
true,
false,
false,
false,
false,
false,
false,
false,
false,
false,
false
]
}
}
]
After defining the characteristics of your enemies, you have to set up enemies' parties. For below example, beyond Mini Globin, I'll also use Wild Wolf and also Momonga. Please find details about enemies' parties here.
[
{
"key_name": "mini_goblin_party",
"name": "Mini Goblin's party",
"can_escape": true,
"members": [
{
"key": "wild_wolf",
"min": 0,
"max": 1
},
{
"key": "mini_goblin",
"min": 1,
"max": 1
},
{
"key": "wild_wolf",
"min": 0,
"max": 1
}
]
},
{
"key_name": "mini_goblin_party_2",
"name": "Mini Goblin's party",
"can_escape": true,
"members": [
{
"key": "wild_wolf",
"min": 0,
"max": 1
},
{
"key": "mini_goblin",
"min": 1,
"max": 1
},
{
"key": "momonga",
"min": 0,
"max": 1
}
]
}
]
Notice that is possible to have multiple parties using the same enemies. For each enemy entry, you can define how many of each enemy could show up in the party when facing an encounter. This quantity is bound by those "min"
and "max"
properties.
Encounter zones are regions that we create in the maps where is possible to encounter enemies' parties. These regions must be Tiled rectangles objects, it can't be any other form. See an example below for the Forest map in the demo:
Notice that these rectangles are inside an Object layer that was created specifically to hold encounter zones. This is a requirement. The Object layer that will hold the zones has to have the encounter_zone
custom layer property set and set to true. You also need to pass the base rate to find an enemy party inside this region by setting the base_rate
property. The higher this property, the bigger the chance to find an enemy party. You can have specific base rate values per zone if you set a custom property for it directly in the custom properties for the object that represents a zone. You can find all the details about these properties here.
In order to set which parties these zones will have, select a specific zone and set a custom property called parties
, this is of string type. For the value of this property, you need to pass a list of parties that you want to encounter in that specific zone in JSON format, example: ["mini_goblin_party", "mini_goblin_party_2"]
.
- Home
- Introduction for developers
- Tutorials
- Game initialization settings
- Map settings
-
Game Events
- Add item to party event
- Audio play event
- Battle event
- Branch event
- Camera fade event
- Camera follow event
- Camera move event
- Camera shake event
- Casting aura event
- Change collision layer event
- Char animation play event
- Char blend mode event
- Char exp event
- Char fall event
- Char hue event
- Char item manipulation event
- Char level change event
- Char rotation event
- Char shadow visibility event
- Char tween position event
- Chest event
- Colorize char event
- Colorize map event
- Control bgm event
- Create storage var event
- Custom collision body event
- Destroyer event
- Dialog event
- Djinn get event
- Djinn set status event
- Emoticon event
- Event activation event
- Event caller event
- Event holder event
- Event loop event
- Exit Sand mode event
- Face direction event
- Flame char event
- Generic sprite event
- Grant ability event
- IO anim play event
- IO tween position event
- Item checks event
- Jump event
- Layer tween event
- Layer visibility event
- Look event
- Main chars join split event
- Map blend mode event
- Map opacity event
- Move event
- Outline char event
- Particles event
- Party join event
- Permanent status event
- Psynergy stone event
- Set char activation event
- Set char collision event
- Set char visibility event
- Set IO activation event
- Set IO collision event
- Set IO visibility event
- Set NPC collision event
- Set party coins event
- Set value event
- Storage change event
- Summon event
- Teleport event
- Tile event manage event
- Timer event
- Tint char event
- Databases
- Code reference