Skip to content

Commit

Permalink
Hero gates and spellbooks dynamically filled
Browse files Browse the repository at this point in the history
  • Loading branch information
Loobinex committed Aug 19, 2024
1 parent df36de9 commit 0559712
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 50 deletions.
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
55 changes: 29 additions & 26 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -100,34 +100,37 @@ func load_objects_data(cfg): # 10ms
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:
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])
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)

Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]
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

0 comments on commit 0559712

Please sign in to comment.