Skip to content

Commit

Permalink
Merge pull request #10 from Loobinex/genre
Browse files Browse the repository at this point in the history
Hero gates and spellbooks dynamically filled
  • Loading branch information
rainlizard authored Jan 28, 2025
2 parents 9c11322 + 035ab32 commit 02c7bde
Show file tree
Hide file tree
Showing 5 changed files with 61 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
80 changes: 54 additions & 26 deletions Scenes/CfgLoader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -95,40 +95,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 @@ -352,7 +352,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 @@ -416,7 +416,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 02c7bde

Please sign in to comment.