Skip to content

Commit

Permalink
balances and fixes, clay windows
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSupremo committed Jun 27, 2024
1 parent 99cc2e2 commit a1b1aed
Show file tree
Hide file tree
Showing 101 changed files with 5,179 additions and 937 deletions.
60 changes: 38 additions & 22 deletions components/firefly_goblin/firefly_goblin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function FireflyGoblin:fixup_post_load(old_save_data)
end
end

function FireflyGoblin:activate()
self:_remove_goblin_listeners()
end

function FireflyGoblin:post_activate()
self.trait_replacer_json = radiant.resources.load_json("swamp_goblins:trait_replacer", true, false)

Expand All @@ -23,7 +27,6 @@ function FireflyGoblin:post_activate()
if not radiant.entities.exists(self._entity) then
return
end
self:update_job_list()
self:add_goblin_race_abilities()
self:add_goblin_jobs_abilities()

Expand All @@ -34,25 +37,6 @@ function FireflyGoblin:post_activate()
end)
end

function FireflyGoblin:update_job_list()
local player_id = radiant.entities.get_player_id(self._entity)
local job_index = stonehearth.player:get_jobs(player_id)
local job_list = {}
for alias,data in pairs(job_index) do
if data.firefly_job then
job_list[alias] = true
end
end
local job_comp = self._entity:get_component("stonehearth:job")
local allowed_jobs = job_comp:get_allowed_jobs()
if allowed_jobs then
for alias,value in pairs(allowed_jobs) do
job_list[alias] = value
end
end
job_comp:set_allowed_jobs(job_list)
end

function FireflyGoblin:add_goblin_race_abilities()
self:fix_traits()
if swamp_goblins.ace_is_here then
Expand Down Expand Up @@ -96,17 +80,45 @@ function FireflyGoblin:fix_traits()
end

function FireflyGoblin:add_goblin_jobs_abilities()
self:_remove_goblin_listeners()

local job_comp = self._entity:get_component("stonehearth:job")
local job = job_comp:get_job_uri()
if job == "stonehearth:jobs:worker" then
self:add_goblin_worker_abilities()
end

self._equipment_changed_listener = radiant.events.listen(self._entity, 'stonehearth:equipment_changed', self, self._on_equipment_changed)
self:_on_equipment_changed()
self.job_has_changed = radiant.events.listen_once(self._entity, 'stonehearth:job_changed', self, self.add_goblin_jobs_abilities)
end

function FireflyGoblin:_on_equipment_changed()
local job_comp = self._entity:get_component("stonehearth:job")
local job_uri = job_comp:get_job_uri()
local player_id = radiant.entities.get_player_id(self._entity)
local job_index = stonehearth.player:get_jobs(player_id)
if job_index[job_uri].firefly_job then
return
end

if not self._equip_change_state then
self._equip_change_state = "waiting_events_end"

self._delay_start_timer = radiant.on_game_loop_once('FireflyGoblin _on_equipment_changed', function()
self._equip_change_state = "boot_equipped"

local equipment = "swamp_goblins:armor:boots_overrider"
radiant.entities.equip_item(self._entity, equipment)
end)
end
if self._equip_change_state == "boot_equipped" then
self._equip_change_state = "waiting_events_end_with_boots"

self._delay_start_timer = radiant.on_game_loop_once('FireflyGoblin _on_equipment_changed_with_boots', function()
self._equip_change_state = nil
end)
end
end

function FireflyGoblin:add_goblin_worker_abilities()
local equipment = "swamp_goblins:worker:abilities:goblin"
radiant.entities.equip_item(self._entity, equipment)
Expand Down Expand Up @@ -137,6 +149,10 @@ function FireflyGoblin:_remove_goblin_listeners()
self.job_has_changed:destroy()
self.job_has_changed = nil
end
if self._equipment_changed_listener then
self._equipment_changed_listener:destroy()
self._equipment_changed_listener = nil
end
end

function FireflyGoblin:destroy()
Expand Down
55 changes: 31 additions & 24 deletions components/job/custom_job_component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,10 @@ function SwampGoblinsJobComponent:promote_to(job_uri, options)
end
end
end
local render_info = self._entity:add_component('render_info')
local model = render_info:get_model_variant()
if not self:get_allowed_jobs() and not is_npc then
local player_id = radiant.entities.get_player_id(self._entity)
local job_index = stonehearth.player:get_jobs(player_id)
local firefly_job_list = {}
local hearthling_job_list = {}
for alias,data in pairs(job_index) do
if not data.firefly_job then
hearthling_job_list[alias] = true
else
if data.firefly_job == "exclusive" then
firefly_job_list[alias] = true
else
firefly_job_list[alias] = true
hearthling_job_list[alias] = true
end
end
end
if model == "firefly_goblin" then
self:set_allowed_jobs(firefly_job_list)
else
self:set_allowed_jobs(hearthling_job_list)
end
if not is_npc then
self:update_job_list()
end

if ACEJobComponent then
self:_goblin_ace_promote_to(job_uri, options)
else
Expand All @@ -50,6 +29,34 @@ function SwampGoblinsJobComponent:promote_to(job_uri, options)
self:apply_town_bonus()
end

function SwampGoblinsJobComponent:update_job_list()
local render_info = self._entity:add_component('render_info')
local model = render_info:get_model_variant()
local player_id = radiant.entities.get_player_id(self._entity)
local job_index = stonehearth.player:get_jobs(player_id)
local allowed_job_list = {}
if model == "firefly_goblin" then
for alias,data in pairs(job_index) do
if data.firefly_job ~= "disabled" then
allowed_job_list[alias] = true
end
end
else
for alias,data in pairs(job_index) do
if data.firefly_job ~= "exclusive" then
allowed_job_list[alias] = true
end
end
end
local previous_allowed_jobs = self:get_allowed_jobs()
if previous_allowed_jobs then
for alias,value in pairs(previous_allowed_jobs) do
allowed_job_list[alias] = value
end
end
self:set_allowed_jobs(allowed_job_list)
end

function SwampGoblinsJobComponent:apply_town_bonus()
local town = stonehearth.town:get_town(self._entity:get_player_id())
if town and town:get_town_bonus('swamp_goblins:town_bonus:book') then
Expand Down
14 changes: 14 additions & 0 deletions data/buffs/heal_aura/heal_aura.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "buff",
"axis": "buff",
"invisible_to_player": true,
"script": "stonehearth:buff_scripts:aura",
"script_info": {
"pulse": "30m",
"pulse_effect": "stonehearth:effects:heal_aura_effect:aoe_effect",
"aura_buff": "stonehearth:buffs:cleric:add_health_medium",
"radius": 30,
"affect_self": true,
"target_type": "mob"
}
}
1 change: 1 addition & 0 deletions data/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"constants": {
"equipment": {
"SLOT_TO_BONE_MAP": {
"legs": "torso",
"banner": "torso",
"root": "root",
"bodyPosition": "bodyPosition"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"max": 4,
"range": 5
},
"combat_leash_range": 15,
"combat_leash_range": 32,
"tuning": "swamp_goblins:monster_tuning:forest:easy_bear"
},
"red_bear": {
Expand All @@ -59,7 +59,7 @@
"max": 1,
"range": 5
},
"combat_leash_range": 15,
"combat_leash_range": 32,
"tuning": "swamp_goblins:monster_tuning:forest:insane_bear"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"unit_info": {
"description": "i18n(stonehearth:data.gm.campaigns.ambient_threats.wolf_pack_raid.wolves.description)"
},
"combat_leash_range": 15,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:forest:easy_alligator"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function FireflyBossDeathScript:start(ctx)
radiant.entities.set_attribute(nina, "spirit", 10)
local equips = nina:add_component('stonehearth:equipment')
equips:equip_item("stonehearth:geomancer:staff")
equips:equip_item("/stonehearth/jobs/cleric/cleric_abilities/cleric_abilities.json")
radiant.entities.add_buff(nina, "swamp_goblins:buffs:heal_aura")
radiant.terrain.place_entity(nina, ctx["firefly_human_encounter"].boss_location)
game_master_lib.register_entities(ctx, 'firefly_human_encounter', { boss = nina })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"type": "camp_piece",
"entities": {
"plushie": {
"uri": "stonehearth:toys:plushie_toy_rabbit",
"force_iconic": true,
"rotation": 270,
"location": {
"x": -5,
"y": 0,
"z": 4
}
},
"portculis": {
"uri": "stonehearth:portals:bronze_portcullis",
"force_iconic": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ function FireflyBossNeutral:start(ctx)
stonehearth.player:set_neutral_to_everyone(ctx.npc_player_id, true)
self._delay_for_nina = radiant.on_game_loop_once('delayed for nina ai', function()
local nina = ctx["firefly_human_encounter"].boss
local equips = nina:add_component('stonehearth:equipment')
equips:equip_item("/stonehearth/jobs/cleric/cleric_abilities/cleric_abilities.json")
radiant.entities.add_buff(nina, "swamp_goblins:buffs:heal_aura")
self._delay_for_nina = nil
end)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"y": 0
}
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:kobolds:kobold_archer_scout"
},
"citizens": {
Expand All @@ -36,7 +36,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:goblins:wolf"
},
"kobolds": {
Expand All @@ -50,7 +50,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:kobolds:kobold_archer_scout"
},
"orc_footmen": {
Expand All @@ -64,7 +64,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:orcs:footman"
},
"orc_knight": {
Expand All @@ -78,7 +78,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:orcs:knight"
},
"orc_worker": {
Expand All @@ -92,7 +92,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:orcs:worker"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"y": 0
}
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:kobolds:kobold_archer_scout"
},
"citizens": {
Expand All @@ -36,7 +36,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:kobolds:kobold_archer_scout"
},
"orc_footmen": {
Expand All @@ -50,7 +50,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:orcs:footman"
},
"orc_worker": {
Expand All @@ -64,7 +64,7 @@
},
"range": 5
},
"combat_leash_range": 20,
"combat_leash_range": 32,
"tuning": "stonehearth:monster_tuning:orcs:worker"
}
},
Expand Down
Loading

0 comments on commit a1b1aed

Please sign in to comment.