-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makeown-plus #1212
Open
Crystalwarrior
wants to merge
9
commits into
DFHack:master
Choose a base branch
from
Crystalwarrior:makeown-plus
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Makeown-plus #1212
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2057829
makeown - fix army controller, enemy status slot and adjust professio…
Crystalwarrior dcd26bb
Clear enemy-of-civ/group status on makeown-ed units
Crystalwarrior e41d381
Flip the giants LARGE_PREDATOR caste flag off!
Crystalwarrior 5f57e53
Revert "Flip the giants LARGE_PREDATOR caste flag off!"
Crystalwarrior f1f4208
Merge branch 'master' into makeown-plus
Crystalwarrior 80502c9
Apply suggestions from code review
Crystalwarrior f81bcdc
fixUnitEnemyStatus as a module script yeeeeee
Crystalwarrior b6f50f6
docs
Crystalwarrior 33cc4fc
Implement suggestions
Crystalwarrior File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 |
---|---|---|
|
@@ -2,6 +2,12 @@ | |
|
||
local utils = require('utils') | ||
|
||
-- List of professions to convert From-To | ||
local convert_professions = { | ||
[df.profession.MERCHANT]=df.profession.TRADER, | ||
[df.profession.THIEF]=df.profession.STANDARD, | ||
} | ||
|
||
local function get_translation(race_id) | ||
local race_name = df.global.world.raws.creatures.all[race_id].creature_id | ||
for _,translation in ipairs(df.global.world.raws.language.translations) do | ||
|
@@ -76,8 +82,45 @@ local function fix_unit(unit) | |
|
||
unit.civ_id = df.global.plotinfo.civ_id; | ||
|
||
if unit.profession == df.profession.MERCHANT then unit.profession = df.profession.TRADER end | ||
if unit.profession2 == df.profession.MERCHANT then unit.profession2 = df.profession.TRADER end | ||
if convert_professions[unit.profession] then unit.profession = convert_professions[unit.profession] end | ||
if convert_professions[unit.profession2] then unit.profession2 = convert_professions[unit.profession2] end | ||
end | ||
|
||
local function fix_army(unit) | ||
-- Disassociate them from their army controller | ||
if unit.enemy.army_controller then | ||
myk002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if unit.enemy.army_controller.commander_hf == unit.hist_figure_id then | ||
unit.enemy.army_controller.commander_hf = -1 | ||
end | ||
unit.enemy.army_controller_id = -1 | ||
unit.enemy.army_controller = nil | ||
end | ||
fixUnitEnemyStatus(unit) | ||
end | ||
|
||
-- Also used by the script fix/loyaltycascade | ||
function fixUnitEnemyStatus(unit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "fix" is subjective. I think this should be named after what it actually does: |
||
if unit.enemy.enemy_status_slot ~= -1 then | ||
local status_cache = df.global.world.enemy_status_cache | ||
local status_slot = unit.enemy.enemy_status_slot | ||
|
||
unit.enemy.enemy_status_slot = -1 | ||
status_cache.slot_used[status_slot] = false | ||
|
||
for index, _ in pairs(status_cache.rel_map[status_slot]) do | ||
status_cache.rel_map[status_slot][index] = -1 | ||
end | ||
|
||
for index, _ in pairs(status_cache.rel_map) do | ||
status_cache.rel_map[index][status_slot] = -1 | ||
end | ||
|
||
-- TODO: what if there were status slots taken above status_slot? | ||
-- does everything need to be moved down by one? | ||
if status_cache.next_slot > status_slot then | ||
status_cache.next_slot = status_slot | ||
end | ||
end | ||
myk002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
local function add_to_entity(hf, eid) | ||
|
@@ -193,6 +236,14 @@ local function fix_histfig(unit) | |
entity_link(hf, eid, true, false, k) | ||
::continue:: | ||
end | ||
-- If you're makeown-ing an enemy of your civilization or group, people will feel vengeful without this | ||
if df.histfig_entity_link_enemyst:is_instance(el) then | ||
local eid = el.entity_id | ||
if eid == civ_id or eid == group_id then | ||
hf.entity_links:erase(k) | ||
el:delete() | ||
end | ||
end | ||
end | ||
|
||
-- add them to our civ/site if they aren't already | ||
|
@@ -205,6 +256,7 @@ function make_own(unit) | |
dfhack.units.makeown(unit) | ||
|
||
fix_unit(unit) | ||
fix_army(unit) | ||
fix_histfig(unit) | ||
fix_clothing_ownership(unit) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to get moved to changelog for current version. also, should likely go in
Fixes
, and say something like "Fix enemy creatures continuing to be hostile aftermakeown
"