Assets
Modding
Modding
  • Introduction
  • How to add new items
  • How to add new events
  • How to add new stashes
  • How to add new tutorial message
  • How to add weapon HUD image
  • How to add new weapon and ammo
  • How to edit traders
  • How to add language
  • How to add new quest
  • How to add PDA markers
  • How to change in-game SFX
  • How to add ambient sounds to level
  • How to add new dialogue
  • How to change player data
  • How to add new enemy
Powered by GitBook
On this page

How to add new stashes

Tutorial "How to add new stashes"

Files & folders needed:

assets/gameplay/loot_containers.json

assets/scripts/p_game.gd

Here is JSON structure of regular container:

loot_containers.json
"loot_battery":{
    "name": "shelf",
    "caption": "box",
    "items_casual":[
        "medkit",
        "medkit"
    ],
    "items": [
	"af_battery",
	"medkit_army"
    ]
}
Properties description
loot_battery = container ID, must be unique
name = Any text or language key from lang_*.json
caption = cut-off feature, just leave blank
items_casual = (optional) list of items IDs that will be spawned in easy mode
items = array of items IDs

Create new container copy with ID "my_loot_container" and add there few medkits and antirads.

"my_loot_container":{
    "name": "box",
    "caption": "",
    "items": [
	"medkit",
	"medkit_army",
	"antirad"
    ]
}

How to test it? Well... We can do some trick. If you look into source code project, it has level_editor folder there.

Inside it, there will be prefabs that can be used in Godot Engine level editor but we can trick it with external scripts that inside game build path assets/scripts/.

Remember the path to the prefab: (in game root directory -> res://) /level_editor/usable_triggers/items_loot_trigger.tscn

items_loot_trigger.tscn
# this file contains keys parameter and you can change invisible state or loot id
# by scripts using: *Prefab_Node_When_Instantiated*.keys["key"] = ...
keys = {
    "invisible": true,
    "loot_id": "id_from_assets_gameplay_loot_containers_json"
}

Open assets/scripts/p_game.gd script and at the start of the game add this code:

"intro":
    # preload and spawn object to the scene tree
    var my_container_prefab = preload("res://level_editor/usable_triggers/items_loot_trigger.tscn").instantiate()
    # set stash ID with meds
    my_container_prefab.keys["loot_id"] = "my_loot_container"
    # always generate colliders and visibility for that type of prefabs
    # or you can use only GameManager.generate_collider(my_container_prefab or *other node*)
    GM._visibility_collision_generation(my_container_prefab)
    # add trigger zone to the current level
    GM.current_level.add_child(my_container_prefab)

Run the new game and look at the middle between corpses:

PreviousHow to add new eventsNextHow to add new tutorial message

Last updated 5 months ago

Loot trigger at the (0, 0, 0) position coordinates (because we don't change position when spawn)
Loo are there! Good job!