Compare commits

...

1 Commits

Author SHA1 Message Date
CaitSith2
3738399348 Factorio: Add an Allow Collect Option 2023-11-26 21:25:43 -08:00
6 changed files with 65 additions and 14 deletions

View File

@@ -1033,6 +1033,11 @@ class DeathLink(Toggle):
display_name = "Death Link"
class AllowCollect(DefaultOnToggle):
"""Allows checks in your world to be automatically marked as collected when !collect is run."""
display_name = "Allow Collect"
class ItemLinks(OptionList):
"""Share part of your item pool with other players."""
display_name = "Item Links"

View File

@@ -1,7 +1,8 @@
import typing
from BaseClasses import MultiWorld
from Options import Choice, Range, Option, Toggle, DefaultOnToggle, DeathLink, StartInventoryPool, PlandoBosses
from Options import Choice, Range, Option, Toggle, DefaultOnToggle, DeathLink, AllowCollect, StartInventoryPool, \
PlandoBosses
class Logic(Choice):
@@ -426,12 +427,6 @@ class BeemizerTrapChance(BeemizerRange):
display_name = "Beemizer Trap Chance"
class AllowCollect(Toggle):
"""Allows for !collect / co-op to auto-open chests containing items for other players.
Off by default, because it currently crashes on real hardware."""
display_name = "Allow Collection of checks for other players"
alttp_options: typing.Dict[str, type(Option)] = {
"crystals_needed_for_gt": CrystalsTower,
"crystals_needed_for_ganon": CrystalsGanon,

View File

@@ -2,8 +2,8 @@ from __future__ import annotations
import typing
import datetime
from Options import Choice, OptionDict, OptionSet, ItemDict, Option, DefaultOnToggle, Range, DeathLink, Toggle, \
StartInventoryPool
from Options import Choice, OptionDict, OptionSet, ItemDict, Option, DefaultOnToggle, Range, DeathLink, AllowCollect, \
Toggle, StartInventoryPool
from schema import Schema, Optional, And, Or
# schema helpers
@@ -454,6 +454,7 @@ factorio_options: typing.Dict[str, type(Option)] = {
"evolution_traps": EvolutionTrapCount,
"evolution_trap_increase": EvolutionTrapIncrease,
"death_link": DeathLink,
"allow_collect": AllowCollect,
"energy_link": EnergyLink,
"start_inventory_from_pool": StartInventoryPool,
}

View File

@@ -11,6 +11,7 @@ TRAP_EVO_FACTOR = {{ evolution_trap_increase }} / 100
MAX_SCIENCE_PACK = {{ max_science_pack }}
GOAL = {{ goal }}
ARCHIPELAGO_DEATH_LINK_SETTING = "archipelago-death-link-{{ slot_player }}-{{ seed_name }}"
ARCHIPELAGO_ALLOW_COLLECT_SETTING = "archipelago-allow-collect-{{ slot_player }}-{{ seed_name }}"
ENERGY_INCREMENT = {{ energy_link * 10000000 }}
ENERGY_LINK_EFFICIENCY = 0.75
@@ -20,6 +21,12 @@ else
DEATH_LINK = 0
end
if settings.global[ARCHIPELAGO_ALLOW_COLLECT_SETTING].value then
ALLOW_COLLECT = 1
else
ALLOW_COLLECT = 0
end
CURRENTLY_DEATH_LOCK = 0
{% if chunk_shuffle %}
@@ -257,6 +264,26 @@ function on_runtime_mod_setting_changed(event)
dumpInfo(force)
end
end
if event.setting == ARCHIPELAGO_ALLOW_COLLECT_SETTING then
local force = game.forces["player"]
if global.received_tech == nil then
global.received_tech = {}
end
if settings.global[ARCHIPELAGO_ALLOW_COLLECT_SETTING].value then
ALLOW_COLLECT = 1
for item_name, _ in pairs(global.received_tech) do
tech = force.technologies[item_name]
if tech ~= nil and tech.researched ~= true then
game.print({"", "Received [technology=" .. tech.name .. "] as it is already checked."})
game.play_sound({path="utility/research_completed"})
tech.researched = true
end
end
global.received_tech = {}
else
ALLOW_COLLECT = 0
end
end
end
script.on_event(defines.events.on_runtime_mod_setting_changed, on_runtime_mod_setting_changed)
@@ -658,18 +685,29 @@ commands.add_command("ap-get-technology", "Grant a technology, used by the Archi
if global.index_sync == nil then
global.index_sync = {}
end
if global.received_tech == nil then
global.received_tech = {}
end
local tech
local force = game.forces["player"]
chunks = split(call.parameter, "\t")
local item_name = chunks[1]
local index = chunks[2]
local index = tonumber(chunks[2]) or chunks[2]
local source = chunks[3] or "Archipelago"
if index == -1 then -- for coop sync and restoring from an older savegame
tech = force.technologies[item_name]
if tech == nil then
game.print("Unknown Item " .. item_name)
return
end
if tech.researched ~= true then
game.print({"", "Received [technology=" .. tech.name .. "] as it is already checked."})
game.play_sound({path="utility/research_completed"})
tech.researched = true
if ALLOW_COLLECT == 1 then
game.print({"", "Received [technology=" .. tech.name .. "] as it is already checked."})
game.play_sound({path="utility/research_completed"})
tech.researched = true
else
global.received_tech[item_name] = 1
end
end
return
elseif progressive_technologies[item_name] ~= nil then

View File

@@ -26,6 +26,8 @@ ap-{{ location.address }}-=Researching this technology sends something to someon
[mod-setting-name]
archipelago-death-link-{{ slot_player }}-{{ seed_name }}=Death Link
archipelago-allow-collect-{{ slot_player }}-{{ seed_name }}=Allow Collect
[mod-setting-description]
archipelago-death-link-{{ slot_player }}-{{ seed_name }}=Kill other players in the same Archipelago Multiworld that also have Death Link turned on, when you die.
archipelago-death-link-{{ slot_player }}-{{ seed_name }}=Kill other players in the same Archipelago Multiworld that also have Death Link turned on, when you die.
archipelago-allow-collect-{{ slot_player }}-{{ seed_name }}=Allows released/collected tech locations to be marked as researched automatically.

View File

@@ -26,5 +26,15 @@ data:extend({
{% else %}
default_value = false
{% endif %}
},
{
type = "bool-setting",
name = "archipelago-allow-collect-{{ slot_player }}-{{ seed_name }}",
setting_type = "runtime-global",
{% if allow_collect %}
default_value = true
{% else %}
default_value = false
{% endif %}
}
})