-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1319 from myk002/myk_force
[force] support "Wildlife" synthetic event
- Loading branch information
Showing
5 changed files
with
67 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,58 @@ | ||
-- Forces an event (wrapper for modtools/force) | ||
local wildlife = reqscript('fix/wildlife') | ||
|
||
local utils = require 'utils' | ||
local args = {...} | ||
local function findCiv(civ) | ||
if civ == 'player' then return df.historical_entity.find(df.global.plotinfo.civ_id) end | ||
if tonumber(civ) then return df.historical_entity.find(tonumber(civ)) end | ||
civ = string.lower(tostring(civ)) | ||
for _,entity in ipairs(df.global.world.entities.all) do | ||
if string.lower(entity.entity_raw.code) == civ then return entity end | ||
end | ||
end | ||
|
||
local args = { ... } | ||
if #args < 1 then qerror('missing event type') end | ||
if args[1]:find('help') then | ||
print(dfhack.script_help()) | ||
return | ||
end | ||
local eventType = nil | ||
|
||
local eventType = args[1]:upper() | ||
|
||
-- handle synthetic events | ||
if eventType == 'WILDLIFE' then | ||
wildlife.free_all_wildlife(args[2] == 'all') | ||
return | ||
end | ||
|
||
-- handle native events | ||
for _, type in ipairs(df.timed_event_type) do | ||
if type:lower() == args[1]:lower() then | ||
eventType = type | ||
end | ||
end | ||
if not eventType then | ||
if not df.timed_event_type[eventType] then | ||
qerror('unknown event type: ' .. args[1]) | ||
end | ||
if eventType == 'FeatureAttack' then | ||
qerror('Event type: FeatureAttack is not currently supported') | ||
end | ||
|
||
local civ | ||
|
||
local newArgs = {'--eventType', eventType} | ||
if eventType == 'Caravan' or eventType == 'Diplomat' then | ||
table.insert(newArgs, '--civ') | ||
if not args[2] then | ||
table.insert(newArgs, 'player') | ||
else | ||
table.insert(newArgs, args[2]) | ||
civ = findCiv(args[2] or 'player') | ||
if not civ then | ||
qerror('unable to find civilization: '..tostring(civ)) | ||
end | ||
elseif eventType == 'Migrants' then | ||
civ = findCiv('player') | ||
end | ||
|
||
dfhack.run_script('modtools/force', table.unpack(newArgs)) | ||
df.global.timed_events:insert('#', { | ||
new=true, | ||
type=df.timed_event_type[eventType], | ||
season=df.global.cur_season, | ||
season_ticks=df.global.cur_season_tick, | ||
entity=civ, | ||
feature_ind=-1, | ||
}) |
This file was deleted.
Oops, something went wrong.