Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hero gates and spellbooks dynamically filled #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions Autoload/Things.gd
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ var GENRE_TO_TAB = {
"TREASURE_HOARD": TAB_GOLD,
"VALUABLE": TAB_GOLD,
"WORKSHOPBOX": TAB_BOX,
"HEROGATE": TAB_ACTION,
}


Expand Down Expand Up @@ -203,26 +204,8 @@ var LIST_OF_GOLDPILES = [
]


var LIST_OF_SPELLBOOKS = [
SPELLBOOK.HAND,
SPELLBOOK.SLAP,
SPELLBOOK.POSSESS,
SPELLBOOK.IMP,
SPELLBOOK.SIGHT,
SPELLBOOK.SPEED,
SPELLBOOK.OBEY,
SPELLBOOK.CALL_TO_ARMS,
SPELLBOOK.CONCEAL,
SPELLBOOK.HOLD_AUDIENCE,
SPELLBOOK.CAVE_IN,
SPELLBOOK.HEAL_CREATURE,
SPELLBOOK.LIGHTNING,
SPELLBOOK.PROTECT,
SPELLBOOK.CHICKEN,
SPELLBOOK.DISEASE,
SPELLBOOK.ARMAGEDDON,
SPELLBOOK.DESTROY_WALLS,
]
var LIST_OF_SPELLBOOKS = [ ]
var LIST_OF_HEROGATES = [ ]

enum SPELLBOOK {
HAND = 11
Expand Down
80 changes: 54 additions & 26 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -94,40 +94,68 @@ func start(mapPath):

oCustomSlabSystem.load_unearth_custom_slabs_file()

var LIST_OF_OBJECTS_WITH_HARDCODED_SPRITES = [
"SPELLBOOK_HOE",
"SPELLBOOK_IMP",
"SPELLBOOK_OBEY",
"SPELLBOOK_SLAP",
"SPELLBOOK_SOE",
"SPELLBOOK_CTA",
"SPELLBOOK_CAVI",
"SPELLBOOK_HEAL",
"SPELLBOOK_HLDAUD",
"SPELLBOOK_LIGHTN",
"SPELLBOOK_SPDC",
"SPELLBOOK_PROT",
"SPELLBOOK_CONCL",
"SPELLBOOK_DISEASE",
"SPELLBOOK_CHKN",
"SPELLBOOK_DWAL",
"SPELLBOOK_TBMB",
"SPELLBOOK_ARMG",
"SPELLBOOK_POSS",
"SPELLBOOK_RBND",
"SPELLBOOK_FRZ",
"SPELLBOOK_SLOW",
"SPELLBOOK_FLGT",
"SPELLBOOK_VSN",
]

func load_objects_data(cfg): # 10ms
for section in cfg:
if section.begins_with("object"):
var id = int(section)
if id == 0: continue
if id >= 136 or id in [100, 101, 102, 103, 104, 105]: # Dummy Boxes should be overwritten
var objSection = cfg[section]
var newName
var animID
var newSprite
var newEditorTab
var newGenre
var objSection = cfg[section]
var newName
var animID
var newSprite
var newEditorTab
var newGenre

if Things.DATA_OBJECT.has(id) == true:
newName = objSection.get("Name", Things.DATA_OBJECT[id][Things.NAME_ID])

if Things.DATA_OBJECT.has(id) == true:
newName = objSection.get("Name", Things.DATA_OBJECT[id][Things.NAME_ID])

animID = objSection.get("AnimationID")
newSprite = get_sprite(animID, newName)
if newSprite == null:
newSprite = Things.DATA_OBJECT[id][Things.SPRITE]

newGenre = objSection.get("Genre")
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.DATA_OBJECT[id][Things.EDITOR_TAB])
else:
newName = objSection.get("Name", "UNDEFINED_NAME")

animID = objSection.get("AnimationID")
newSprite = get_sprite(animID, newName)

newGenre = objSection.get("Genre")
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.TAB_DECORATION)
animID = objSection.get("AnimationID")
newSprite = get_sprite(animID, newName)
if newSprite == null or newName in LIST_OF_OBJECTS_WITH_HARDCODED_SPRITES:
newSprite = Things.DATA_OBJECT[id][Things.SPRITE]

Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]
newGenre = objSection.get("Genre")
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.DATA_OBJECT[id][Things.EDITOR_TAB])
if newGenre == "SPELLBOOK":
Things.LIST_OF_SPELLBOOKS.append(id)
if newGenre == "HEROGATE":
Things.LIST_OF_HEROGATES.append(id)
else:
newName = objSection.get("Name", "UNDEFINED_NAME")
animID = objSection.get("AnimationID")
newSprite = get_sprite(animID, newName)

newGenre = objSection.get("Genre")
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.TAB_DECORATION)

Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]


var keeperfx_edited_slabs = [Slabs.GEMS] # This is to help with backwards compatibility for previous keeperfx versions that don't have these edits.
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func place_new_thing(newThingType, newSubtype, newPosition, newOwnership): # Pla
id.parentTile = 65535 # "None"
id.orientation = oPlacingSettings.orientation

if id.subtype == 49: # Hero Gate
if id.subtype in Things.LIST_OF_HEROGATES: # Hero Gate
id.herogateNumber = get_free_hero_gate_number() #originalInstance.herogateNumber
elif id.subtype == 133: # Mysterious Box
id.boxNumber = oPlacingSettings.boxNumber
Expand Down
4 changes: 2 additions & 2 deletions Scenes/ReadData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func read_tng(buffer):
match id.thingType:
Things.TYPE.OBJECT:
id.parentTile = id.data11_12
if id.subtype == 49: # Hero Gate
if id.subtype in Things.LIST_OF_HEROGATES: # Hero Gate
id.herogateNumber = id.data14
elif id.subtype == 133: # Mysterious Box
id.boxNumber = id.data14
Expand Down Expand Up @@ -415,7 +415,7 @@ func read_tngfx(buffer):
match id.thingType:
Things.TYPE.OBJECT:
id.parentTile = c.get_value(section, "ParentTile")
if id.subtype == 49: # Hero Gate
if id.subtype in Things.LIST_OF_HEROGATES: # Hero Gate
id.herogateNumber = c.get_value(section, "HerogateNumber")
elif id.subtype == 133: # Mysterious Box
id.boxNumber = c.get_value(section, "CustomBox")
Expand Down
2 changes: 1 addition & 1 deletion Scenes/ThingInstance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func _enter_tree():
add_to_group("TreasuryGold")
elif subtype in Things.LIST_OF_SPELLBOOKS:
add_to_group("Spellbook")
elif subtype == 49:
elif subtype in Things.LIST_OF_HEROGATES:
add_to_group("HeroGate")
yield(get_tree(),'idle_frame')
if oActionPointList:
Expand Down
Loading