mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
add perma death option, make cessation nicer, fix spectator shields and cursors not appearing sometimes, make default settings transfer nicer
This commit is contained in:
parent
79e8f73d63
commit
2fc0e76f2c
10 changed files with 331 additions and 131 deletions
37
quant.ew/data/entities/animals/nibbana.xml
Normal file
37
quant.ew/data/entities/animals/nibbana.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<Entity tags="polymorphed_cessation" name="$animal_player" >
|
||||
<PlatformShooterPlayerComponent
|
||||
center_camera_on_this_entity="1"
|
||||
aiming_reticle_distance_from_character="60"
|
||||
camera_max_distance_from_character="50"
|
||||
move_camera_with_aim="1"
|
||||
eating_area_min.x="-6"
|
||||
eating_area_max.x="6"
|
||||
eating_area_min.y="-4"
|
||||
eating_area_max.y="6"
|
||||
eating_cells_per_frame="2"
|
||||
></PlatformShooterPlayerComponent>
|
||||
<ControlsComponent
|
||||
enabled="1"
|
||||
gamepad_fire_on_thumbstick_extend="0"
|
||||
gamepad_fire_on_thumbstick_extend_threshold="0.9"
|
||||
gamepad_indirect_aiming_enabled="0"
|
||||
></ControlsComponent>
|
||||
<Entity name="cursor">
|
||||
<SpriteComponent
|
||||
alpha="1"
|
||||
image_file="mods/quant.ew/files/resource/sprites/cursor.png"
|
||||
next_rect_animation=""
|
||||
offset_x="6.5"
|
||||
offset_y="6.5"
|
||||
emissive="1"
|
||||
additive="1"
|
||||
rect_animation=""
|
||||
z_index="1"
|
||||
update_transform="1"
|
||||
update_transform_rotation="0"
|
||||
has_special_scale="1"
|
||||
special_scale_x="0.5"
|
||||
special_scale_y="0.5"
|
||||
></SpriteComponent>
|
||||
</Entity>
|
||||
</Entity>
|
|
@ -176,9 +176,22 @@ local function player_died()
|
|||
|
||||
-- This may look like a hack, but it allows to use existing poly machinery to change player entity AND to store the original player for later,
|
||||
-- Which is, like, perfect.
|
||||
GameAddFlagRun("ew_flag_notplayer_active")
|
||||
if ctx.proxy_opt.perma_death then
|
||||
local ent = LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/local_health/notplayer/cessation.xml")
|
||||
polymorph.switch_entity(ent + 1)
|
||||
GameAddFlagRun("msg_gods_looking")
|
||||
GameAddFlagRun("msg_gods_looking2")
|
||||
EntityAddTag(ctx.my_player.entity, "ew_notplayer")
|
||||
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
|
||||
if EntityGetName(child) == "cursor" then
|
||||
EntitySetComponentIsEnabled(child, EntityGetFirstComponentIncludingDisabled(child, "SpriteComponent"), false)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
local ent = LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/local_health/notplayer/poly_effect.xml")
|
||||
ctx.my_player.entity = ent + 1
|
||||
GameAddFlagRun("ew_flag_notplayer_active")
|
||||
do_switch_effect(false)
|
||||
EntitySetName(ctx.my_player.entity, ctx.my_id.."?")
|
||||
util.set_ent_health(ctx.my_player.entity, {max_hp, max_hp})
|
||||
|
@ -191,7 +204,7 @@ local function player_died()
|
|||
remove_healthbar_locally()
|
||||
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
|
||||
if EntityGetName(child) == "cursor" or EntityGetName(child) == "notcursor" then
|
||||
EntityKill(child)
|
||||
EntitySetComponentIsEnabled(child, EntityGetFirstComponentIncludingDisabled(child, "SpriteComponent"), false)
|
||||
end
|
||||
end
|
||||
inventory_helper.set_item_data(item_data, ctx.my_player)
|
||||
|
|
13
quant.ew/files/system/local_health/notplayer/cessation.xml
Normal file
13
quant.ew/files/system/local_health/notplayer/cessation.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<Entity>
|
||||
<InheritTransformComponent>
|
||||
</InheritTransformComponent>
|
||||
|
||||
<GameEffectComponent
|
||||
effect="POLYMORPH_CESSATION"
|
||||
frames="-1"
|
||||
disable_movement="0"
|
||||
polymorph_target="data/entities/animals/nibbana.xml"
|
||||
>
|
||||
</GameEffectComponent >
|
||||
|
||||
</Entity>
|
|
@ -637,6 +637,8 @@ local function choose_movement()
|
|||
ComponentSetValue2(state.control_component, "mButtonFrameRight", GameGetFrameNum()+100)
|
||||
return
|
||||
end
|
||||
local air = ComponentGetValue2(state.damage_model, "air_in_lungs")
|
||||
local fly = ComponentGetValue2(state.data_component, "mFlyingTimeLeft")
|
||||
if state.target == nil or (has_ambrosia(ctx.my_player.entity) and state.init_timer > no_shoot_time + 4) then
|
||||
state.control_a = false
|
||||
state.control_d = false
|
||||
|
@ -663,13 +665,14 @@ local function choose_movement()
|
|||
move = -1
|
||||
end
|
||||
|
||||
local air = ComponentGetValue2(state.damage_model, "air_in_lungs")
|
||||
if air < 1 then
|
||||
state.control_w = true
|
||||
state.control_s = false
|
||||
elseif air < 2 then
|
||||
state.control_s = true
|
||||
state.control_w = false
|
||||
if air < 2 then
|
||||
if fly < 0.5 then
|
||||
state.control_s = true
|
||||
state.control_w = false
|
||||
else
|
||||
state.control_w = true
|
||||
state.control_s = false
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
@ -752,7 +755,7 @@ local function choose_movement()
|
|||
on_right = my_x > t_x
|
||||
end
|
||||
|
||||
if ComponentGetValue2(state.data_component, "mFlyingTimeLeft") < 0.2 and GameGetFrameNum() % 300 > 250 then
|
||||
if fly < 0.2 and GameGetFrameNum() % 300 > 250 then
|
||||
rest = true
|
||||
give_space = give_space + 10
|
||||
swap_side = false
|
||||
|
@ -863,13 +866,14 @@ local function choose_movement()
|
|||
if did_hit_up and state.water_potion ~= nil then
|
||||
state.control_w = false
|
||||
end
|
||||
local air = ComponentGetValue2(state.damage_model, "air_in_lungs")
|
||||
if air < 1 then
|
||||
state.control_w = true
|
||||
state.control_s = false
|
||||
elseif air < 2 then
|
||||
state.control_s = true
|
||||
state.control_w = false
|
||||
if air < 2 then
|
||||
if fly < 0.5 then
|
||||
state.control_s = true
|
||||
state.control_w = false
|
||||
else
|
||||
state.control_w = true
|
||||
state.control_s = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1441,6 +1445,7 @@ end
|
|||
|
||||
function module.on_world_update()
|
||||
local active = GameHasFlagRun("ew_flag_notplayer_active")
|
||||
and not ctx.proxy_opt.perma_death
|
||||
if active and EntityGetIsAlive(ctx.my_player.entity) and EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
||||
if state == nil then
|
||||
init_state()
|
||||
|
|
|
@ -74,8 +74,15 @@ function module.on_world_update()
|
|||
local mx, my = GameGetCameraPos()
|
||||
for peer_id, player in pairs(ctx.players) do
|
||||
local ent = player.entity
|
||||
local children = EntityGetAllChildren(ent) or {}
|
||||
for _, child in ipairs(children) do
|
||||
if EntityGetName(child) == "cursor" or EntityGetName(child) == "notcursor" then
|
||||
EntitySetComponentIsEnabled(child, EntityGetFirstComponentIncludingDisabled(child, "SpriteComponent"), true)
|
||||
end
|
||||
end
|
||||
local x, y = EntityGetTransform(ent)
|
||||
local notplayer = EntityHasTag(ent, "ew_notplayer")
|
||||
and not ctx.proxy_opt.perma_death
|
||||
if notplayer and GameHasFlagRun("ending_game_completed") then
|
||||
goto continue
|
||||
end
|
||||
|
@ -84,7 +91,7 @@ function module.on_world_update()
|
|||
end
|
||||
local dx, dy = x - mx, y - my
|
||||
local cape
|
||||
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
|
||||
for _, child in ipairs(children) do
|
||||
if EntityGetName(child) == "cape" then
|
||||
local cpe = EntityGetFirstComponentIncludingDisabled(child, "VerletPhysicsComponent")
|
||||
local cx, cy = ComponentGetValue2(cpe, "m_position_previous")
|
||||
|
|
|
@ -72,7 +72,7 @@ local function get_me()
|
|||
local i = 0
|
||||
local alive = -1, -1
|
||||
for peer_id, potential_target in pairs(ctx.players) do
|
||||
if GameHasFlagRun("ending_game_completed") and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
if (GameHasFlagRun("ending_game_completed") or ctx.proxy_opt.perma_death) and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
goto continue
|
||||
end
|
||||
i = i + 1
|
||||
|
@ -218,7 +218,7 @@ local function set_camera_pos()
|
|||
if cam_target == nil or re_cam then
|
||||
local i = 0
|
||||
for peer_id, potential_target in pairs(ctx.players) do
|
||||
if GameHasFlagRun("ending_game_completed") and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
if (GameHasFlagRun("ending_game_completed") or ctx.proxy_opt.perma_death) and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
goto continue
|
||||
end
|
||||
i = i + 1
|
||||
|
@ -246,7 +246,8 @@ end
|
|||
local function update_i()
|
||||
local i = 0
|
||||
for peer_id, potential_target in pairs(ctx.players) do
|
||||
if GameHasFlagRun("ending_game_completed") and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
if (GameHasFlagRun("ending_game_completed") or ctx.proxy_opt.perma_death)
|
||||
and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
goto continue
|
||||
end
|
||||
i = i + 1
|
||||
|
@ -263,7 +264,7 @@ end
|
|||
local function number_of_players()
|
||||
local i = 0
|
||||
for _, potential_target in pairs(ctx.players) do
|
||||
if GameHasFlagRun("ending_game_completed") and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
if (GameHasFlagRun("ending_game_completed") or ctx.proxy_opt.perma_death) and EntityHasTag(potential_target.entity, "ew_notplayer") then
|
||||
goto continue
|
||||
end
|
||||
i = i + 1
|
||||
|
@ -296,7 +297,9 @@ function spectate.on_world_update()
|
|||
update_i()
|
||||
last_len = number_of_players()
|
||||
end
|
||||
if cam_target ~= nil and GameHasFlagRun("ending_game_completed") and EntityHasTag(cam_target.entity, "ew_notplayer") then
|
||||
if cam_target ~= nil
|
||||
and ((GameHasFlagRun("ending_game_completed") or ctx.proxy_opt.perma_death)
|
||||
and EntityHasTag(cam_target.entity, "ew_notplayer")) then
|
||||
update_i()
|
||||
last_len = number_of_players()
|
||||
end
|
||||
|
|
|
@ -2,6 +2,15 @@ local rpc = net.new_rpc_namespace()
|
|||
|
||||
local shield_entities = {}
|
||||
|
||||
local function remove_shield(peer_id)
|
||||
if shield_entities[peer_id] ~= nil then
|
||||
if EntityGetIsAlive(shield_entities[peer_id][2]) then
|
||||
EntityKill(shield_entities[peer_id][2])
|
||||
end
|
||||
shield_entities[peer_id] = nil
|
||||
end
|
||||
end
|
||||
|
||||
rpc.opts_everywhere()
|
||||
rpc.opts_reliable()
|
||||
function rpc.add_shield(target)
|
||||
|
@ -12,23 +21,21 @@ function rpc.add_shield(target)
|
|||
if not EntityGetIsAlive(entity) or EntityHasTag(entity, "polymorphed") then
|
||||
return
|
||||
end
|
||||
if shield_entities[ctx.rpc_peer_id] ~= nil then
|
||||
EntityKill(shield_entities[ctx.rpc_peer_id][2])
|
||||
if shield_entities[ctx.rpc_peer_id] == nil or shield_entities[ctx.rpc_peer_id][1] ~= target then
|
||||
if shield_entities[ctx.rpc_peer_id] ~= nil
|
||||
and EntityGetIsAlive(shield_entities[ctx.rpc_peer_id][2]) then
|
||||
EntityKill(shield_entities[ctx.rpc_peer_id][2])
|
||||
end
|
||||
local ent = EntityLoad("mods/quant.ew/files/system/spectator_helps/shield_base.xml")
|
||||
EntityAddChild(entity, ent)
|
||||
shield_entities[ctx.rpc_peer_id] = {target, ent}
|
||||
end
|
||||
local ent = EntityLoad("mods/quant.ew/files/system/spectator_helps/shield_base.xml")
|
||||
EntityAddChild(entity, ent)
|
||||
shield_entities[ctx.rpc_peer_id] = {target, ent}
|
||||
end
|
||||
|
||||
rpc.opts_everywhere()
|
||||
rpc.opts_reliable()
|
||||
function rpc.del_shield()
|
||||
if shield_entities[ctx.rpc_peer_id] ~= nil then
|
||||
if EntityGetIsAlive(shield_entities[ctx.rpc_peer_id][2]) then
|
||||
EntityKill(shield_entities[ctx.rpc_peer_id][2])
|
||||
end
|
||||
shield_entities[ctx.rpc_peer_id] = nil
|
||||
end
|
||||
remove_shield(ctx.rpc_peer_id)
|
||||
end
|
||||
|
||||
local module = {}
|
||||
|
@ -48,11 +55,11 @@ local function is_acceptable_help_target(spectating_over)
|
|||
return false
|
||||
end
|
||||
if shield_entities[ctx.my_id] ~= nil then
|
||||
if shield_entities[ctx.my_id][1] ~= spectating_over then
|
||||
if shield_entities[ctx.my_id][1] ~= spectating_over then
|
||||
rpc.del_shield()
|
||||
return false
|
||||
end
|
||||
return false
|
||||
return GameGetFrameNum() % 300 < 10
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
@ -77,7 +84,10 @@ end
|
|||
local last_spectate
|
||||
|
||||
function module.on_world_update()
|
||||
if GameHasFlagRun("ending_game_completed") then
|
||||
if GameHasFlagRun("ending_game_completed") or ctx.proxy_opt.perma_death then
|
||||
if not ctx.proxy_opt.perma_death then
|
||||
rpc.del_shield()
|
||||
end
|
||||
return
|
||||
end
|
||||
if GameGetFrameNum() % 10 == 8 then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue