p_game.gd
Here is main gameplay script with all story logic.
# ALWAYS extend script from Node, else game will crash, cause script handler error.
extends Node
# # # # # # # # # # # # # #
# Description: Basic gameplay logic script for story of the game.
# ALSO, code here and for the game must be written in GDScript, GodotEngine4 scripting language.
# This language closely looks like Python programming language, so game modding must be easy. :)
# # # # # # # # # # # # # #
# ########## # [WARNING] # ########## #
# scripts can run only _ready() and _process(delta) functions!
#
# [TIP]
# If you want to access to another script, firstly make sure that you've created it,
# then add to _ready() function that code. Make sure to register it firstly:
#
# GameAPI.RunOutsideScript("your_script_name")
#
# And then script will be registered and handled in game and you can acces to it
# in any place using same code. Also you have access to your own functions inside
# that script. Example:
# ------------------------------- EXAMPLE -----------------------------
# Script "test.gd" in assets/scripts/
#
# func foo(a,b):
# var result = a + b
# return result
#
# Then inside game in func _ready() you can register your script and use your function:
#
# [VARIANT 1]:
#
# func _ready():
# var test = GameAPI.RunOutsideScript("test").foo(1,2)
# print(test) <--- will return 3 as result
#
# [VARIANT 2]:
#
# func _ready():
# GameAPI.RunOutsideScript("test")
# var test = GameAPI.RunOutsideScript("test").foo(1,2)
# print(test) <--- will return 3 as result
#
# ########## # [WARNING] # ########## #
# ########## # [VARIABLES] # ########## #
var GM = GameManager
var gui = GM.Gui as GUI
var world = GM.World
var weapon_system = GM.weapon_system as WeaponSystem
var inventory = GM.Gui.InventoryWindow as Inventory
var journal = GM.Gui.JournalWindow as Journal
var pda : Map = GM.Gui.MapWindow as Map
var skills : SkillSystem = GM.Gui.SkillWindow as SkillSystem
var dialogue : DialogueSystem = GM.Gui.DialogueWindow as DialogueSystem
var player : Player = GM.GameProcess.player as Player
var game_process : Game = GM.GameProcess as Game #game_process is Game.gd script
# Called when gameplay init completed and game starts play
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
# ------------------------
# Gameplay callbacks
# ------------------------
# Calls when player kill an hostile npc
# [ARGUMENTS]:
# eyezone <- returns battle eyezone with list of enemies
# _npc_id <- returns string with npc ID
# _loot <- returns array with items ID
#
# [TIP]:
#
# For checking how much enemies was killed, you can use _check_kills_on_level() from GameProcess
# game_process._check_kills_on_level("level_id" : string,amount : int, "eyezone_id" : string, eyezone <- don't touch this arg, keep it here always)
#
# [EXAMPLE]:
#
# if game_process._check_kills_on_level("test_level",5,"enemy_eyezone1",eyezone):
# print("Congrats, you kill 5 enemies on level test_level, now you can do something, maybe add quest)
# GM.AddQuestJson("quest_id")
func on_npc_kill(eyezone,_npc_id,_loot):
pass
# Calls every time when player change locations
# [level_id : String] argument of new level id
func on_level_changed(level_id):
pass
# Calls when any quest is added, argument - Dict{} of quest data, it looks like object from file assets/gameplay/quests.json
func on_quest_add(quest):
pass
# Calls when any quest is completed, argument - Dict{} of quest data
func on_quest_complete(quest):
pass
# Calls when player get Event Key [key : String],
# main function for gameplay logic as quests, events, some rules etc.
func on_event_key_add(key):
pass
# Call when any dialogue start, argument - ID of opened dialogue
func on_dialogue_start(id):
pass
# Call when any dialogue ends, argument - ID of closed dialogue
func on_dialogue_end(id):
pass
# Call when any item from lootbox was took, argument - ID of item
func on_loot_item_took(id):
pass
# Call when any door was used ID:
# (transition, transition_to_level), argument - Dict{} of level object data
func on_door_used(door_data):
pass
# Call when Player enter to any Area3D
func on_area3d_entered(area : Area3D, who : Player): #if p_game.gd hasn't this func - just create it there.
pass
# Call when Player exited from any Area3D
func on_area3d_exited(area : Area3D, who : Player): #if p_game.gd hasn't this func - just create it there.
pass
# Call when player came to any eyezone
func come_in_eyezone(eyezone : EYEZONE):
pass
# Call when player out from any eyezone
func out_from_eyezone(eyezone : EYEZONE):
pass
# Call when Player used any item. Argument is item object
func on_item_used(itm : item): #if p_game.gd hasn't this func - just create it there.
pass
# Call when NPC played animation and it was finished
func on_npc_animation_finished(npc : NPC, anim_name : String):
pass
# Call when Player press F and start talking to NPC
func on_npc_talk(npc : NPC): #if p_game.gd hasn't this func - just create it there.
pass
# Call when Player died
func on_player_death(): #if p_game.gd hasn't this func - just create it there.
pass
Last updated