Skip to content

Commit 0559712

Browse files
committed
Hero gates and spellbooks dynamically filled
1 parent df36de9 commit 0559712

File tree

5 files changed

+36
-50
lines changed

5 files changed

+36
-50
lines changed

Autoload/Things.gd

+3-20
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ var GENRE_TO_TAB = {
168168
"TREASURE_HOARD": TAB_GOLD,
169169
"VALUABLE": TAB_GOLD,
170170
"WORKSHOPBOX": TAB_BOX,
171+
"HEROGATE": TAB_ACTION,
171172
}
172173

173174

@@ -203,26 +204,8 @@ var LIST_OF_GOLDPILES = [
203204
]
204205

205206

206-
var LIST_OF_SPELLBOOKS = [
207-
SPELLBOOK.HAND,
208-
SPELLBOOK.SLAP,
209-
SPELLBOOK.POSSESS,
210-
SPELLBOOK.IMP,
211-
SPELLBOOK.SIGHT,
212-
SPELLBOOK.SPEED,
213-
SPELLBOOK.OBEY,
214-
SPELLBOOK.CALL_TO_ARMS,
215-
SPELLBOOK.CONCEAL,
216-
SPELLBOOK.HOLD_AUDIENCE,
217-
SPELLBOOK.CAVE_IN,
218-
SPELLBOOK.HEAL_CREATURE,
219-
SPELLBOOK.LIGHTNING,
220-
SPELLBOOK.PROTECT,
221-
SPELLBOOK.CHICKEN,
222-
SPELLBOOK.DISEASE,
223-
SPELLBOOK.ARMAGEDDON,
224-
SPELLBOOK.DESTROY_WALLS,
225-
]
207+
var LIST_OF_SPELLBOOKS = [ ]
208+
var LIST_OF_HEROGATES = [ ]
226209

227210
enum SPELLBOOK {
228211
HAND = 11

Scenes/CfgLoader.gd

+29-26
Original file line numberDiff line numberDiff line change
@@ -100,34 +100,37 @@ func load_objects_data(cfg): # 10ms
100100
if section.begins_with("object"):
101101
var id = int(section)
102102
if id == 0: continue
103-
if id >= 136 or id in [100, 101, 102, 103, 104, 105]: # Dummy Boxes should be overwritten
104-
var objSection = cfg[section]
105-
var newName
106-
var animID
107-
var newSprite
108-
var newEditorTab
109-
var newGenre
103+
var objSection = cfg[section]
104+
var newName
105+
var animID
106+
var newSprite
107+
var newEditorTab
108+
var newGenre
109+
110+
if Things.DATA_OBJECT.has(id) == true:
111+
newName = objSection.get("Name", Things.DATA_OBJECT[id][Things.NAME_ID])
110112

111-
if Things.DATA_OBJECT.has(id) == true:
112-
newName = objSection.get("Name", Things.DATA_OBJECT[id][Things.NAME_ID])
113-
114-
animID = objSection.get("AnimationID")
115-
newSprite = get_sprite(animID, newName)
116-
if newSprite == null:
117-
newSprite = Things.DATA_OBJECT[id][Things.SPRITE]
118-
119-
newGenre = objSection.get("Genre")
120-
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.DATA_OBJECT[id][Things.EDITOR_TAB])
121-
else:
122-
newName = objSection.get("Name", "UNDEFINED_NAME")
123-
124-
animID = objSection.get("AnimationID")
125-
newSprite = get_sprite(animID, newName)
126-
127-
newGenre = objSection.get("Genre")
128-
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.TAB_DECORATION)
113+
animID = objSection.get("AnimationID")
114+
newSprite = get_sprite(animID, newName)
115+
if newSprite == null:
116+
newSprite = Things.DATA_OBJECT[id][Things.SPRITE]
117+
118+
newGenre = objSection.get("Genre")
119+
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.DATA_OBJECT[id][Things.EDITOR_TAB])
120+
if newGenre == "SPELLBOOK":
121+
Things.LIST_OF_SPELLBOOKS.append(id)
122+
if newGenre == "HEROGATE":
123+
Things.LIST_OF_HEROGATES.append(id)
124+
else:
125+
newName = objSection.get("Name", "UNDEFINED_NAME")
126+
127+
animID = objSection.get("AnimationID")
128+
newSprite = get_sprite(animID, newName)
129129

130-
Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]
130+
newGenre = objSection.get("Genre")
131+
newEditorTab = Things.GENRE_TO_TAB.get(newGenre, Things.TAB_DECORATION)
132+
133+
Things.DATA_OBJECT[id] = [newName, newSprite, newEditorTab]
131134

132135

133136
var keeperfx_edited_slabs = [Slabs.GEMS] # This is to help with backwards compatibility for previous keeperfx versions that don't have these edits.

Scenes/Instances.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func place_new_thing(newThingType, newSubtype, newPosition, newOwnership): # Pla
259259
id.parentTile = 65535 # "None"
260260
id.orientation = oPlacingSettings.orientation
261261

262-
if id.subtype == 49: # Hero Gate
262+
if id.subtype in Things.LIST_OF_HEROGATES: # Hero Gate
263263
id.herogateNumber = get_free_hero_gate_number() #originalInstance.herogateNumber
264264
elif id.subtype == 133: # Mysterious Box
265265
id.boxNumber = oPlacingSettings.boxNumber

Scenes/ReadData.gd

+2-2
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func read_tng(buffer):
351351
match id.thingType:
352352
Things.TYPE.OBJECT:
353353
id.parentTile = id.data11_12
354-
if id.subtype == 49: # Hero Gate
354+
if id.subtype in Things.LIST_OF_HEROGATES: # Hero Gate
355355
id.herogateNumber = id.data14
356356
elif id.subtype == 133: # Mysterious Box
357357
id.boxNumber = id.data14
@@ -415,7 +415,7 @@ func read_tngfx(buffer):
415415
match id.thingType:
416416
Things.TYPE.OBJECT:
417417
id.parentTile = c.get_value(section, "ParentTile")
418-
if id.subtype == 49: # Hero Gate
418+
if id.subtype in Things.LIST_OF_HEROGATES: # Hero Gate
419419
id.herogateNumber = c.get_value(section, "HerogateNumber")
420420
elif id.subtype == 133: # Mysterious Box
421421
id.boxNumber = c.get_value(section, "CustomBox")

Scenes/ThingInstance.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func _enter_tree():
7171
add_to_group("TreasuryGold")
7272
elif subtype in Things.LIST_OF_SPELLBOOKS:
7373
add_to_group("Spellbook")
74-
elif subtype == 49:
74+
elif subtype in Things.LIST_OF_HEROGATES:
7575
add_to_group("HeroGate")
7676
yield(get_tree(),'idle_frame')
7777
if oActionPointList:

0 commit comments

Comments
 (0)