mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-14 18:50:37 +00:00
World Conquest: Remove hard coded trainer indices (#9408)
--------- Co-authored-by: Richard <93877353+richardalbee@users.noreply.github.com>
This commit is contained in:
parent
34595668b4
commit
fbe2166c33
|
@ -246,6 +246,7 @@ World Conquest looks for `[world_conquest_data]` tags in the era and every loade
|
|||
image=attacks/wail.png
|
||||
name= _ "Blood Magic"
|
||||
dialogue= "You have found me, mortals? Well...let us show your recruits some blood magic!"
|
||||
manual_invest = false #Setting manual_invest to false will hide a trainer from the invest screen. Not specifying this variable at all includes a new trainer by default.
|
||||
[grade]
|
||||
[/grade]
|
||||
[grade]
|
||||
|
|
|
@ -137,7 +137,7 @@ function wc2_invest.invest()
|
|||
local heroes_available = stringx.split(side.variables["wc2.heroes"] or "")
|
||||
local commanders_available = stringx.split(side.variables["wc2.commanders"] or "")
|
||||
local deserters_available = stringx.split(side.variables["wc2.deserters"] or "")
|
||||
local trainings_available = wc2_training.list_available(side_num, {2,3,4,5,6})
|
||||
local trainings_available = wc2_training.list_available(side_num)
|
||||
local gold_available = true
|
||||
for i = 1,2 do
|
||||
local is_local = false
|
||||
|
|
|
@ -85,20 +85,23 @@ function training.has_max_training(side_num, trainer, amount)
|
|||
return training.available(side_num, trainer) == 0
|
||||
end
|
||||
|
||||
function training.list_available(side_num, among, amount)
|
||||
local av = among or wc2_utils.range(#training.get_list())
|
||||
function training.list_available(side_num, amount)
|
||||
local av = wc2_utils.range(#training.get_list())
|
||||
local res = {}
|
||||
for i,v in ipairs(av) do
|
||||
local j = tonumber(v)
|
||||
if training.available(side_num, j, amount) then
|
||||
table.insert(res, j)
|
||||
local trainer = training.get_trainer(j)
|
||||
if trainer and (trainer.manual_invest == nil or trainer.manual_invest == true) then
|
||||
if training.available(side_num, j, amount) then
|
||||
table.insert(res, j)
|
||||
end
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
function training.find_available(side_num, among, amount)
|
||||
local possible_traintypes = training.list_available(side_num, among, amount)
|
||||
function training.find_available(side_num, amount)
|
||||
local possible_traintypes = training.list_available(side_num, amount)
|
||||
if #possible_traintypes == 0 then
|
||||
return
|
||||
else
|
||||
|
@ -192,16 +195,10 @@ end
|
|||
|
||||
function training.pick_bonus(side_num)
|
||||
local amount = training.bonus_calculate_amount(side_num)
|
||||
-- dark training reduced chances
|
||||
local traintype_index = training.find_available(side_num, {1,2,3,4,5,6,2,3,4,5,6,2,3,4,5,6}, amount)
|
||||
local traintype_index = training.find_available(side_num, amount)
|
||||
if traintype_index == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
--dark training increased level.
|
||||
if traintype_index == 1 then
|
||||
amount = math.min(training.trainings_left(side_num, traintype_index), math.max(amount, wc2_scenario.scenario_num() - 1))
|
||||
end
|
||||
return traintype_index, amount
|
||||
end
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
image=attacks/curse.png
|
||||
name=_ "Dark"
|
||||
dialogue=_ "I haven’t lived centuries fighting others’ battles, but I could combat boredom teaching your men a couple of things about dark techniques."
|
||||
manual_invest = false
|
||||
[grade]
|
||||
[/grade]
|
||||
[grade]
|
||||
|
|
Loading…
Reference in New Issue
Block a user