Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ScipioWright committed Oct 27, 2024
2 parents dfa53ff + 3e6466b commit 084a806
Show file tree
Hide file tree
Showing 15 changed files with 159 additions and 107 deletions.
12 changes: 0 additions & 12 deletions data/archipelago/entities/items/ap_progression_shopitem.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Entity>
<Base file="data/archipelago/entities/items/base_ap_shopitem.xml" />

<!-- https://noita.wiki.gg/wiki/Documentation:_SpriteComponent -->
<SpriteComponent
_tags="enabled_in_world,item"
offset_x="10"
offset_y="10"
image_file="data/archipelago/entities/items/icon-junk.png"
/>

</Entity>
<Entity>
<Base file="data/archipelago/entities/items/base_ap_shopitem.xml" />

<!-- https://noita.wiki.gg/wiki/Documentation:_SpriteComponent -->
<SpriteComponent
_tags="enabled_in_world,item"
offset_x="10"
offset_y="10"
image_file="data/archipelago/entities/items/icons/ap_logo_bigger.png"
update_transform_rotation="0"
/>

</Entity>
3 changes: 2 additions & 1 deletion data/archipelago/entities/items/ap_trap_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
_tags="enabled_in_world,item"
offset_x="10"
offset_y="10"
image_file="data/archipelago/entities/items/trap-$[1-4].png"
image_file="data/archipelago/entities/items/icons/ap_logo_bigger_trap$[1-4].png"
update_transform_rotation="0"
/>

</Entity>
12 changes: 0 additions & 12 deletions data/archipelago/entities/items/ap_useful_shopitem.xml

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 69 additions & 17 deletions data/archipelago/scripts/ap_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,32 +250,84 @@ end
function create_ap_entity_from_flags(location, x, y)
local flags = location.item_flags

local item_filename = "ap_junk_shopitem.xml"
local enable_prog_icon = false
local enable_useful_icon = false
local enable_filler_icon = true

local item_filename = "ap_standard_shopitem.xml"
local item_description = "$ap_shopdescription_junk"
if flags == nil then
-- todo: figure out how to make it so touching a pedestal item that broke like this doesn't crash the game
print("flags == nil")
print("error is at " .. x .. ", " .. y)
EntityLoadAtPlayer("data/archipelago/entities/items/pickup/ap_error_book_flags.xml")
item_description = "problem with item in create_ap_entity_from_flags"
elseif bit.band(flags, AP.ITEM_FLAG_USEFUL) ~= 0 then
item_filename = "ap_useful_shopitem.xml"
if bit.band(flags, AP.ITEM_FLAG_USEFUL) ~= 0 then
item_description = "$ap_shopdescription_useful"
elseif bit.band(flags, AP.ITEM_FLAG_PROGRESSION) ~= 0 then
item_filename = "ap_progression_shopitem.xml"
enable_useful_icon = true
enable_filler_icon = false
end
if bit.band(flags, AP.ITEM_FLAG_PROGRESSION) ~= 0 then
enable_prog_icon = true
enable_filler_icon = false
item_description = "$ap_shopdescription_progression"
elseif bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 then
if enable_useful_icon then
item_description = "$ap_shopdescription_proguseful"
end
end

if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 then
item_filename = "ap_trap_item.xml"
item_description = "$ap_shopdescription_trap" .. tostring(Random(1, 8))
item_description = "$ap_shopdescription_trap" .. tostring(Random(1, 9))
if enable_useful_icon then
item_description = "$ap_shopdescription_usefultrap"
end
if enable_prog_icon then
item_description = "$ap_shopdescription_progtrap"
if enable_useful_icon then
item_description = "$ap_shopdescription_progusefultrap"
end
end
if enable_filler_icon then
local random_number = Random(1, 3)
if random_number == 1 then
enable_filler_icon = false
enable_prog_icon = true
elseif random_number == 2 then
enable_filler_icon = false
enable_useful_icon = true
end
end
end

local item_entity = EntityLoad("data/archipelago/entities/items/" .. item_filename, x, y)
if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 and location.is_our_item then
EntityAddComponent(item_entity, "LuaComponent", {
_tags="archipelago",
script_item_picked_up="data/archipelago/scripts/items/ap_trap.lua",
if enable_prog_icon == true then
EntityAddComponent2(item_entity, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/progression_icon_bigger.png",
offset_x = 0,
offset_y = 0,
z_index = 0.7,
update_transform_rotation = false
})
end
if enable_useful_icon == true then
EntityAddComponent2(item_entity, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/useful_icon.png",
offset_x = 9,
offset_y = 9,
z_index = 0.7,
update_transform_rotation = false
})
end
if enable_filler_icon == true then
EntityAddComponent2(item_entity, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/filler_icon.png",
offset_x = 0,
offset_y = 0,
z_index = 0.7,
update_transform_rotation = false
})
end
if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 and location.is_our_item then
EntityAddComponent(item_entity, "LuaComponent", {
_tags="archipelago",
script_item_picked_up="data/archipelago/scripts/items/ap_trap.lua",
})
end
return item_entity, item_description
end

Expand Down
65 changes: 49 additions & 16 deletions data/archipelago/scripts/patches/ap_orb_init_random.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,32 @@ local function APOrbInitRandom()
local location = Globals.LocationScouts:get_key(location_id)
local flags = location.item_flags
local orb_image = "ap_logo_orb"
local check_type_icon = "filler_icon"
local enable_prog_icon = false
local enable_useful_icon = false
local enable_filler_icon = true

if flags == nil then
print("this orb is not a location check")
elseif bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 then
check_type_icon = "empty_icon"
if bit.band(flags, AP.ITEM_FLAG_USEFUL) ~= 0 then
enable_useful_icon = true
enable_filler_icon = false
end
if bit.band(flags, AP.ITEM_FLAG_PROGRESSION) ~= 0 then
enable_prog_icon = true
enable_filler_icon = false
end

if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 then
orb_image = "ap_logo_orb_trap_" .. tostring(Random(1,3))
elseif bit.band(flags, AP.ITEM_FLAG_USEFUL) ~= 0 then
check_type_icon = "empty_icon"
elseif bit.band(flags, AP.ITEM_FLAG_PROGRESSION) ~= 0 then
check_type_icon = "progression_icon"
-- if it is not prog+trap or useful+trap, give it a random icon
if enable_filler_icon then
local random_number = Random(1, 3)
if random_number == 1 then
enable_filler_icon = false
enable_prog_icon = true
elseif random_number == 2 then
enable_filler_icon = false
enable_useful_icon = true
end
end
end

if flags ~= nil then
Expand All @@ -57,14 +72,32 @@ local function APOrbInitRandom()
offset_x = 7,
offset_y = 20,
z_index = 0.8,
update_transform_rotation = false
})

EntityAddComponent2(entity_id, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/" .. check_type_icon .. ".png",
offset_x = 0,
offset_y = 10,
z_index = 0.7,
})
if enable_prog_icon == true then
EntityAddComponent2(entity_id, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/progression_icon.png",
offset_x = 0,
offset_y = 10,
z_index = 0.7,
})
end
if enable_useful_icon == true then
EntityAddComponent2(entity_id, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/useful_icon.png",
offset_x = 7,
offset_y = 19,
z_index = 0.7,
})
end
if enable_filler_icon == true then
EntityAddComponent2(entity_id, "SpriteComponent", {
image_file = "data/archipelago/entities/items/icons/filler_icon.png",
offset_x = 0,
offset_y = 10,
z_index = 0.7,
})
end
end
end

Expand Down
32 changes: 2 additions & 30 deletions data/archipelago/scripts/shopitem_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,43 +66,15 @@ function ShopItems.create_our_item_entity(item, x, y)
return entity_id
else -- error?
-- TODO
EntityLoad("data/archipelago/entities/items/ap_error_book.xml", x, y)
EntityLoad("data/archipelago/entities/items/pickup/ap_error_book.xml", x, y)
Log.Error("Failed to load our own shopitem!")
end
end


-- Basically chooses the item graphic depending on the generated item's flags
function ShopItems.create_ap_entity_from_flags(location, x, y)
local flags = location.item_flags

local item_filename = "ap_junk_shopitem.xml"
local item_description = "$ap_shopdescription_junk"
if bit.band(flags, AP.ITEM_FLAG_USEFUL) ~= 0 then
item_filename = "ap_useful_shopitem.xml"
item_description = "$ap_shopdescription_useful"
elseif bit.band(flags, AP.ITEM_FLAG_PROGRESSION) ~= 0 then
item_filename = "ap_progression_shopitem.xml"
item_description = "$ap_shopdescription_progression"
elseif bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 then
item_filename = "ap_trap_item.xml"
item_description = "$ap_shopdescription_trap" .. tostring(Random(1, 8))
end

local item_entity = EntityLoad("data/archipelago/entities/items/" .. item_filename, x, y)
if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 and location.is_our_item then
EntityAddComponent(item_entity, "LuaComponent", {
_tags="archipelago",
script_item_picked_up="data/archipelago/scripts/items/ap_trap.lua",
})
end
return item_entity, item_description
end


-- Spawns in an AP item (our own entity to represent items that don't exist in this game)
function ShopItems.create_foreign_item_entity(location, x, y)
local entity_id, description = ShopItems.create_ap_entity_from_flags(location, x, y)
local entity_id, description = create_ap_entity_from_flags(location, x, y)
local name = location.item_name

-- Change item name
Expand Down
5 changes: 5 additions & 0 deletions data/archipelago/translations.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"ap_shopdescription_junk","This looks useless.",,,,,,,,,,,,,
"ap_shopdescription_useful","This might help but it doesn’t look like it’s needed.",,,,,,,,,,,,,
"ap_shopdescription_progression","This item appears to be important.",,,,,,,,,,,,,
"ap_shopdescription_proguseful","This item appears to be very important.",,,,,,,,,,,,,
"ap_shopdescription_progtrap","This item appears to be very important and very dangerous.",,,,,,,,,,,,,
"ap_shopdescription_usefultrap","This item appears to good and dangerous.",,,,,,,,,,,,,
"ap_shopdescription_progusefultrap","This item appears to be an item for sure.",,,,,,,,,,,,,
"ap_shopdescription_trap1","You want this.",,,,,,,,,,,,,
"ap_shopdescription_trap2","Grab this immediately.",,,,,,,,,,,,,
"ap_shopdescription_trap3","Pick this up.",,,,,,,,,,,,,
Expand All @@ -14,6 +18,7 @@
"ap_shopdescription_trap6","It looks so friendly. Do not resist. Don’t struggle.",,,,,,,,,,,,"Subnautica reference to Mesmer enemy.",
"ap_shopdescription_trap7","You are so lucky that you found this most valuable artifact.",,,,,,,,,,,,"Satisfactory reference to Mercer Sphere object.",
"ap_shopdescription_trap8","The most fulfilling of lives is that in which you can buy anything!",,,,,,,,,,,,"Slay the Spire reference to The Ssssserpent event.",
"ap_shopdescription_trap9","Think about how funny it would be.",,,,,,,,,,,,,
"ap_chest_random","Archipelago Chest",,,,,,,,,,,,,
"mat_ap_chest","Archipelago Juice",,,,,,,,,,,,,
"ap_connected_notifier","Archipelago",,,,,,,,,,,,,
Expand Down
26 changes: 19 additions & 7 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local ConnIcon = dofile("data/archipelago/ui/connection_icon.lua")
-- See Options.py on the AP-side
-- Can also use to indicate whether AP sent the connected packet
local slot_options = nil
local connect_tags = {"Lua-APClientPP"}

local last_death_time = 0
local current_player_slot = -1
Expand All @@ -51,12 +52,21 @@ local ap = nil

-- Toggles DeathLink
local function SetDeathLinkEnabled(enabled)
local conn_tags = { "Lua-APClientPP" }
if enabled then
table.insert(conn_tags, "DeathLink")
death_link_status = true
if death_link_status == true then
-- it's already enabled, so no need to continue here
return
end
table.insert(connect_tags, "DeathLink")
end
if not enabled then
if death_link_status == false then
return
end
connect_tags = {"Lua-APClientPP"}
death_link_status = false
end
ap:ConnectUpdate(nil, conn_tags)
ap:ConnectUpdate(nil, connect_tags)
end


Expand All @@ -74,13 +84,14 @@ local function IsDeathLinkEnabled()
return 0
end
local death_link_setting = ModSettingGet("archipelago.death_link")
if slot_options.death_link == 0 then
if slot_options.death_link == 0 or death_link_setting == "off" then
return 0
elseif death_link_setting == "on" then
return 1
elseif death_link_setting == "traps" then
return 2
else
Log.Info(death_link_setting)
Log.Error("Error in IsDeathLinkEnabled")
return 0
end
Expand Down Expand Up @@ -130,7 +141,8 @@ local function GetItemName(player_id, item_id, flags)
item_name = "problem with LocationScouts"
end

if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 then
-- if it is trap + some other classification, we don't want to override its name
if bit.band(flags, AP.ITEM_FLAG_TRAP) ~= 0 and bit.band(flags, AP.ITEM_FLAG_PROGRESSION) == 0 and bit.band(flags, AP.ITEM_FLAG_USEFUL) == 0 then
item_name = GameTextGetTranslatedOrNot("$ap_trapname" .. Random(1, 10))
end

Expand Down Expand Up @@ -346,7 +358,7 @@ function RECV_MSG.Connected()

SetupLocationScouts()
-- Enable deathlink if the setting on the server and the mod setting said to
SetDeathLinkEnabled(IsDeathLinkEnabled())
SetDeathLinkEnabled(IsDeathLinkEnabled() > 0)
end

-- https://github.com/ArchipelagoMW/Archipelago/blob/main/docs/network%20protocol.md#receiveditems
Expand Down

0 comments on commit 084a806

Please sign in to comment.