From 0a27e6451c8776a67571fb3864f7449d06eea775 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 19 Oct 2024 08:11:38 -0400 Subject: [PATCH] have notplayer activate unstuck if probably stuck, regen your oxygen on revive, actually put out fires on revive --- .../system/local_health/local_health.lua | 3 ++- .../system/notplayer_ai/notplayer_ai.lua | 24 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/quant.ew/files/system/local_health/local_health.lua b/quant.ew/files/system/local_health/local_health.lua index 75aadcc8..93267caf 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -329,10 +329,11 @@ ctx.cap.health = { end end end - local damage_model = EntityGetFirstComponentIncludingDisabled(entity, "DamageModelComponent") + local damage_model = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "DamageModelComponent") if damage_model ~= nil then ComponentSetValue2(damage_model, "mFireProbability", 0) ComponentSetValue2(damage_model, "mFireFramesLeft", 0) + ComponentSetValue2(damage_model, "air_in_lungs", ComponentGetValue2(damage_model, "air_in_lungs_max")) end inventory_helper.set_item_data(item_data, ctx.my_player) remove_inventory_tags() diff --git a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua index 2c4d3356..baeaa0d5 100644 --- a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua +++ b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua @@ -485,6 +485,7 @@ local function init_state() was_firing_wand = false, was_a = false, + was_s = false, was_w = false, was_d = false, init_timer = 0, @@ -557,6 +558,21 @@ local material_gas = -1 local stick = false local function choose_movement() + local my_x, my_y = EntityGetTransform(ctx.my_player.entity) + local did_hit_down, _, _ = RaytracePlatforms(my_x, my_y, my_x, my_y + 2) + if did_hit_down then + state.control_w = true + state.control_a = true + state.control_d = true + state.was_a = true + state.was_d = true + state.was_w = true + ComponentSetValue2(state.control_component, "mButtonFrameUp", GameGetFrameNum()+100) + ComponentSetValue2(state.control_component, "mButtonFrameFly", GameGetFrameNum()+100) + ComponentSetValue2(state.control_component, "mButtonFrameLeft", GameGetFrameNum()+100) + ComponentSetValue2(state.control_component, "mButtonFrameRight", GameGetFrameNum()+100) + return + end if 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 @@ -572,7 +588,6 @@ local function choose_movement() move = GameGetFrameNum() + 120 end state.control_w = true - local my_x, my_y = EntityGetTransform(ctx.my_player.entity) local did_hit_4, _, _ = RaytracePlatforms(my_x, my_y, my_x - 128, my_y) if not did_hit_4 or stick then stick = true @@ -589,7 +604,6 @@ local function choose_movement() stop_y = false rest = false end - local my_x, my_y = EntityGetTransform(ctx.my_player.entity) local t_x, t_y = EntityGetTransform(target) local dist = my_x - t_x local LIM = give_space @@ -1168,12 +1182,16 @@ local function update() state.was_d = state.control_d ComponentSetValue2(state.control_component, "mButtonDownDown", state.control_s and not state.control_w) - ComponentSetValue2(state.control_component, "mButtonDownUp", true) + ComponentSetValue2(state.control_component, "mButtonDownUp", state.control_w) ComponentSetValue2(state.control_component, "mButtonDownFly", state.control_w) if state.control_w and not state.was_w then ComponentSetValue2(state.control_component, "mButtonFrameUp", GameGetFrameNum()+1) ComponentSetValue2(state.control_component, "mButtonFrameFly", GameGetFrameNum()+1) end + if state.control_s and not state.control_w and not state.was_s then + ComponentSetValue2(state.control_component, "mButtonFrameDown", GameGetFrameNum()+1) + end + state.was_s = state.control_s and not state.control_w state.was_w = state.control_w local _, y_n = EntityGetTransform(ctx.my_player.entity) ComponentSetValue2(state.control_component, "mFlyingTargetY", y_n - 10)