-
Notifications
You must be signed in to change notification settings - Fork 99
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
Created new alternate threatfarming special, fixed killscore for biters with non-standard threat #493
base: master
Are you sure you want to change the base?
Conversation
…ays match the threat reduction from the kill.
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.
My high-level fear with this change is that this special will be rarely run and that we'll be left with the code lying around but unused.
So, to brainstorm some possible options:
- Just submit this as-is. If the scenarios is rarely run, someone in the future will have to contemplate removing it.
- Submit as-is, but with you making a commitment to revert the change within 6 months if the special is rarely run
@@ -394,7 +378,9 @@ local function on_entity_died(event) | |||
if event.entity.force.index == event.cause.force.index then | |||
return | |||
end | |||
if not entity_score_values[event.entity.name] then | |||
--multiply threat reduction by four to keep killscore similar to the previous killscore values |
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.
My gut feeling is that it is better to remove the *4
, but I'm not sure. It would be nice if threat and killscore matched perfectly, right?
local function generate_alt_threatfarming(defender_mult, spawner_mult) | ||
--Setup gamemode. | ||
global.active_special_games["alt_threatfarming"] = true | ||
if not global.special_games_variables["alt_threatfarming"] then |
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.
how about something like
local vars = global.special_game_variables["alt_threatfarming"]
if not vars then
...
end
and then you can use vars
in many places below
factor = factor * 1.0 / (1 - global.reanim_chance[game.forces[biter_not_boss_force].index]/100) | ||
end | ||
end | ||
if global.active_special_games["alt_threatfarming"] and global.special_games_variables["alt_threatfarming"]["affected_entities"][entity.name] then |
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.
again, I think that it is worth making a temporary for global.special_games_variables["alt_threatfarming"]
factor = factor * global.special_games_variables["alt_threatfarming"]["spawner_mult"] | ||
elseif not global.special_games_variables["alt_threatfarming"]["attack_biter_ids"][entity.unit_number] then | ||
--All biters are spawned either through the destruction of a spawner, as part of an attack, or as natural spawns (defending the spawners). | ||
--We record IDs whenever we spawn spawner and attack biters, so other biters are defenders by process of elimination. |
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.
This is fine as-is. I just want to mention that you could explicitly tag "defender biters" using https://lua-api.factorio.com/latest/events.html#on_entity_spawned if you wanted to.
This could also give a (very minor) performance boost by having just one map, and the map being unit_number -> factor
. But, meh, I'm not really saying it is worthwhile to do this, just throwing out ideas.
end | ||
--unit_numbers are never reused, so no need to clear the table entries |
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.
it is definitely worth clearing the table entries. Otherwise this is essentially a memory leak, and will make save game files larger, and will potentially hurt performance due to worse memory locality/cache effects.
You could potentially clear the table entries inside of ai_targets.lua on_entity_destroyed
Are you interested in resolving these comments and submitting this PR? If not, we can close it. |
Ah, sorry. I found myself busy when you requested changes and then I forgot about the PR. I'm not playing much BB these days, and like you say it's unlikely this special will see much use. I might come back and finish it in the future, but for now I think it would be best to close the PR. |
Brief description of the changes:
I've created a new special to test a change to threatfarming that should encourage destroying nests instead of just killing biters.
In this special, biters that spawn naturally around spawners are worth 0.5x as much threat, and biters that spawn when spawners are killed are worth 5x as much threat. Spawners, worms, and biters that spawn as part of attack groups are worth the same amount of threat. These values can be configured when starting the special.
In a change that I probably should have put in a separate pull request, I've changed the killscore calculation to use the same function as the threat reduction calculations. This corrects an issue where biters that do not reduce threat by the normal amount (boss biters, normal biters under the old threat logic, defender and spawner biters in my new special) award the wrong amount of killscore.
Tested Changes: