make nightmare wands random, have karl work with spectate, make notplayer react to material damage gases

This commit is contained in:
bgkillas 2024-10-06 08:57:13 -04:00
parent 6d194a2b78
commit 990fbdabac
7 changed files with 116 additions and 6 deletions

View file

@ -0,0 +1,80 @@
dofile_once( "data/scripts/lib/utilities.lua" )
dofile_once("data/scripts/gun/procedural/gun_action_utils.lua")
local speed = 3
local entity_id = GetUpdatedEntityID()
local pos_x, pos_y = EntityGetTransform( entity_id )
local player = CrossCall("ew_spectator")
if player == nil then return end
-- update lap time display
local stopwatch_id = EntityGetClosestWithTag(pos_x, pos_y, "stopwatch_lap")
if stopwatch_id ~= nil then
local lcomp = get_variable_storage_component( entity_id, "lap_start_time" )
local scomp = get_variable_storage_component( stopwatch_id, "time" )
if ( scomp ~= nil ) and ( lcomp ~= nil ) then
component_read(get_variable_storage_component(entity_id, "lap_start_time"), { value_int = 0 }, function(comp)
local lap_time = GameGetFrameNum() - comp.value_int
ComponentSetValue2(get_variable_storage_component(stopwatch_id, "time"), "value_int", lap_time)
end)
end
end
-- see if stuck in a wall and try to release
if RaytracePlatforms(pos_x, pos_y, pos_x + 0.1, pos_y) then
local vx = 2
local vy = 0
for i=1,8 do
local x = vx + pos_x
local y = vy + pos_y
if not RaytracePlatforms(x, y, x + 0.1, y) then
EntitySetTransform(entity_id, x, y)
return
end
vx,vy = vec_rotate(vx, vy, math.pi / 4)
end
end
local x, y = EntityGetTransform(player)
local mx, my
if GameGetIsGamepadConnected() then
mx, my = InputGetJoystickAnalogStick(0, 1)
mx, my = mx * 60 + x, my * 60 + y
else
mx, my = DEBUG_GetMouseWorld()
end
local dir = math.atan2(my - y, mx - x)
EntitySetTransform(entity_id, pos_x, pos_y, dir)
-- move
edit_component( entity_id, "VelocityComponent", function(comp,vars)
-- thrust
player = EntityGetWithTag("player_unit")[1]
local vx = 0
local vy = 0
local controls_comp = EntityGetFirstComponent(player, "ControlsComponent")
local is_thrusting = controls_comp ~= nil and ComponentGetValue2( controls_comp, "mButtonDownFly")
if is_thrusting then
vx = speed
vx, vy = vec_rotate(vx, vy, dir)
end
vx, vy = vec_add(vx, vy, ComponentGetValueVector2(comp, "mVelocity"))
ComponentSetValueVector2( comp, "mVelocity", vx, vy)
-- jetpack
EntitySetComponentsWithTagEnabled(entity_id, "jetpack", is_thrusting)
-- sprite animation and orientation
local anim = "float"
if is_thrusting then anim = "fly" end
local scale_y = 1
if dir < -math.pi * 0.5 or dir > math.pi * 0.5 then scale_y = -1 end
local sprite_comp = EntityGetFirstComponent(entity_id, "SpriteComponent" )
component_write(sprite_comp, {
rect_animation = anim,
special_scale_y = scale_y
})
end)

View file

@ -367,7 +367,13 @@ function rpc.update_positions(position_data)
EntitySetTransform(item, x, y)
local costcom = EntityGetFirstComponentIncludingDisabled(item, "ItemCostComponent")
if costcom ~= nil then
ComponentSetValue2(costcom, "cost", price)
if price == 0 then
EntitySetComponentWithTagEnabled(item, "shop_cost", false)
ComponentSetValue2(costcom, "cost", 0)
else
EntitySetComponentWithTagEnabled(item, "shop_cost", true)
ComponentSetValue2(costcom, "cost", price)
end
end
else
util.log("Requesting again "..gid)

View file

@ -630,7 +630,8 @@ local function choose_movement()
end
end
--GamePrint(state.dtype)
if state.dtype == 32 then
local damage_model = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "DamageModelComponent")
if state.dtype == 32 and ComponentGetValue2(damage_model, "mLiquidCount") == 0 then
if (dist > 0 and did_hit_2) or (dist < 0 and did_hit_1) then
give_space = give_space + 10
else
@ -1044,7 +1045,7 @@ local function update()
if GameGetFrameNum() % 30 == 0 then
ComponentSetValue2(var, "value_int", 0)
end
--state.dtype = ComponentGetValue2(var, "value_int")
state.dtype = ComponentGetValue2(var, "value_int")
-- No taking control back, even after pressing esc.
ComponentSetValue2(state.control_component, "enabled", false)
ComponentSetValue2(state.inv_component, "mActive", false)

View file

@ -1,6 +1,4 @@
local function hide_perk(perk_id)
local perk_data = get_perk_with_id(perk_list, perk_id)
perk_data.not_in_default_perk_pool = true
end
hide_perk("REVENGE_RATS")
end

View file

@ -0,0 +1,16 @@
local orig = generate_gun
function generate_gun( cost, level, force_unshuffle )
local sx, sy = CrossCall("ew_per_peer_seed")
local entity_id = GetUpdatedEntityID()
local x, y = EntityGetTransform( entity_id )
SetRandomSeed( x + sx, y + sy )
local orig_SetRandomSeed = SetRandomSeed
function SetRandomSeed(a, b) end
local gun = orig(cost, level, force_unshuffle)
SetRandomSeed = orig_SetRandomSeed
return gun
end

View file

@ -1,3 +1,4 @@
ModLuaFileAppend("data/scripts/items/potion_starting.lua", "mods/quant.ew/files/system/random_start/override_potion.lua")
ModLuaFileAppend("data/scripts/gun/procedural/gun_procedural.lua", "mods/quant.ew/files/system/random_start/nightmare.lua")
return {}

View file

@ -40,6 +40,14 @@ np.CrossCallAdd("ew_per_peer_seed", function()
return tonumber(string.sub(ctx.my_id, 8, 12), 16), tonumber(string.sub(ctx.my_id, 12), 16)
end)
np.CrossCallAdd("ew_spectator", function()
if ctx.spectating_over_peer_id == nil then
return ctx.my_player.entity or EntityGetWithTag("player_unit")[1]
else
return ctx.players[ctx.spectating_over_peer_id].entity
end
end)
local function load_modules()
ctx.load_system("ewext_init")