mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
mostly fix revenge_*, fix genome/extra shop perks
This commit is contained in:
parent
0a27e6451c
commit
bd8c5eefe2
11 changed files with 190 additions and 39 deletions
|
@ -246,7 +246,7 @@ impl NetManager {
|
|||
}
|
||||
if self.friendly_fire.load(atomic::Ordering::Relaxed) {
|
||||
let team = self.friendly_fire_team.load(atomic::Ordering::Relaxed);
|
||||
if timer.elapsed().as_secs() > 2 {
|
||||
if timer.elapsed().as_secs() > 4 {
|
||||
state.try_ws_write_option("friendly_fire_team", (team + 1) as u32);
|
||||
timer = Instant::now()
|
||||
}
|
||||
|
|
|
@ -1,29 +1,5 @@
|
|||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
|
||||
local function get_herd_id( entity_id )
|
||||
local genome = EntityGetFirstComponentIncludingDisabled(entity_id, "GenomeDataComponent")
|
||||
local herd = ComponentGetValue2(genome, "herd_id")
|
||||
return herd
|
||||
end
|
||||
|
||||
local function shoot_projectile( who_shot, entity_file, x, y, vel_x, vel_y, send_message )
|
||||
local entity_id = EntityLoad( entity_file, x, y )
|
||||
local herd_id = get_herd_id( who_shot )
|
||||
if( send_message == nil ) then send_message = true end
|
||||
|
||||
GameShootProjectile( who_shot, x, y, x+vel_x, y+vel_y, entity_id, send_message )
|
||||
|
||||
edit_component( entity_id, "ProjectileComponent", function(comp,vars)
|
||||
vars.mWhoShot = who_shot
|
||||
vars.mShooterHerdId = herd_id
|
||||
end)
|
||||
|
||||
edit_component( entity_id, "VelocityComponent", function(comp,vars)
|
||||
ComponentSetValueVector2( comp, "mVelocity", vel_x, vel_y )
|
||||
end)
|
||||
|
||||
return entity_id
|
||||
end
|
||||
dofile_once("mods/quant.ew/files/resource/shoot_projectile_fix.lua")
|
||||
|
||||
function wand_fired( wand_id )
|
||||
local projectile_velocity = 600
|
||||
|
|
57
quant.ew/data/scripts/perks/revenge_bullet.lua
Normal file
57
quant.ew/data/scripts/perks/revenge_bullet.lua
Normal file
|
@ -0,0 +1,57 @@
|
|||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
dofile_once("mods/quant.ew/files/resource/shoot_projectile_fix.lua")
|
||||
|
||||
function damage_received( damage, desc, entity_who_caused, is_fatal, projectile_id )
|
||||
local entity_id = GetUpdatedEntityID()
|
||||
local x, y = EntityGetTransform( entity_id )
|
||||
|
||||
-- don't revenge tentacle on heal
|
||||
if( damage < 0 ) then return end
|
||||
|
||||
SetRandomSeed( GameGetFrameNum(), x + y + entity_id )
|
||||
|
||||
if entity_who_caused == 0 or entity_who_caused == 1 or ( entity_who_caused == entity_id ) or ( ( EntityGetParent( entity_id ) ~= NULL_ENTITY ) and ( entity_who_caused == EntityGetParent( entity_id ) ) ) then return end
|
||||
|
||||
-- check that we're only shooting every 10 frames
|
||||
if script_wait_frames( entity_id, 2 ) then return end
|
||||
|
||||
local angle = math.rad( Random( 1, 360 ) )
|
||||
local angle_random = math.rad( Random( -2, 2 ) )
|
||||
local vel_x = 0
|
||||
local vel_y = 0
|
||||
local length = 900
|
||||
local projectile = ""
|
||||
|
||||
if ( projectile_id ~= nil ) and ( projectile_id ~= NULL_ENTITY ) then
|
||||
local storages = EntityGetComponent( projectile_id, "VariableStorageComponent" )
|
||||
|
||||
if ( storages ~= nil ) then
|
||||
for i,comp in ipairs( storages ) do
|
||||
name = ComponentGetValue2( comp, "name" )
|
||||
if ( name == "projectile_file" ) then
|
||||
projectile = ComponentGetValue2( comp, "value_string" )
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if ( entity_who_caused ~= nil ) and ( entity_who_caused ~= NULL_ENTITY ) then
|
||||
local ex, ey = EntityGetTransform( entity_who_caused )
|
||||
|
||||
if ( ex ~= nil ) and ( ey ~= nil ) then
|
||||
angle = 0 - math.atan2( ey - y, ex - x )
|
||||
end
|
||||
end
|
||||
|
||||
if ( #projectile > 0 ) then
|
||||
vel_x = math.cos( angle + angle_random ) * length
|
||||
vel_y = 0- math.sin( angle + angle_random ) * length
|
||||
local pid = shoot_projectile( entity_id, projectile, x, y, vel_x, vel_y )
|
||||
|
||||
edit_component( pid, "ProjectileComponent", function(comp,vars)
|
||||
local dmg = ComponentGetValue2( comp, "damage" ) * 2.0
|
||||
ComponentSetValue2( comp, "damage", dmg )
|
||||
end)
|
||||
end
|
||||
end
|
32
quant.ew/data/scripts/perks/revenge_explosion.lua
Normal file
32
quant.ew/data/scripts/perks/revenge_explosion.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
dofile_once("mods/quant.ew/files/resource/shoot_projectile_fix.lua")
|
||||
|
||||
function damage_received( damage, desc, entity_who_caused, is_fatal )
|
||||
local entity_id = GetUpdatedEntityID()
|
||||
local pos_x, pos_y = EntityGetTransform( entity_id )
|
||||
|
||||
if( damage < 0 ) then return end
|
||||
if entity_who_caused == 0 or entity_who_caused == 1 or ( entity_who_caused == entity_id ) or ( ( EntityGetParent( entity_id ) ~= NULL_ENTITY ) and ( entity_who_caused == EntityGetParent( entity_id ) ) ) then return end
|
||||
|
||||
-- check that we're only shooting every 10 frames
|
||||
if script_wait_frames( entity_id, 5 ) then return end
|
||||
local eid = shoot_projectile( entity_id, "data/entities/misc/perks/revenge_explosion.xml", pos_x, pos_y, 0, 0 )
|
||||
|
||||
local herd_id = -1
|
||||
edit_component( entity_id, "GenomeDataComponent", function(comp,vars)
|
||||
herd_id = ComponentGetValue2( comp, "herd_id" )
|
||||
end)
|
||||
|
||||
local new_ent = entity_id
|
||||
|
||||
if EntityHasTag(entity_id, "ew_client") and not EntityHasTag(entity_id, "ew_notplayer") then
|
||||
new_ent = EntityGetWithTag("player_unit")[1]
|
||||
end
|
||||
|
||||
edit_component( eid, "ProjectileComponent", function(comp,vars)
|
||||
ComponentSetValue2(comp, "mWhoShot", new_ent)
|
||||
ComponentSetValue2(comp, "mShooterHerdId", herd_id)
|
||||
|
||||
ComponentObjectSetValue(comp, "config_explosion", "dont_damage_this", new_ent)
|
||||
end)
|
||||
end
|
34
quant.ew/data/scripts/perks/revenge_tentacle.lua
Normal file
34
quant.ew/data/scripts/perks/revenge_tentacle.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
dofile_once("mods/quant.ew/files/resource/shoot_projectile_fix.lua")
|
||||
|
||||
function damage_received( damage, desc, entity_who_caused, is_fatal )
|
||||
local entity_id = GetUpdatedEntityID()
|
||||
local x, y = EntityGetTransform( entity_id )
|
||||
|
||||
-- don't revenge tentacle on heal
|
||||
if( damage < 0 ) then return end
|
||||
|
||||
SetRandomSeed( GameGetFrameNum(), x + y + entity_id )
|
||||
if entity_who_caused == 0 or entity_who_caused == 1 or ( entity_who_caused == entity_id ) or ( ( EntityGetParent( entity_id ) ~= NULL_ENTITY ) and ( entity_who_caused == EntityGetParent( entity_id ) ) ) then return end
|
||||
|
||||
-- check that we're only shooting every 10 frames
|
||||
if script_wait_frames( entity_id, 2 ) then return end
|
||||
|
||||
local angle = math.rad( Random( 1, 360 ) )
|
||||
local angle_random = math.rad( Random( -5, 5 ) )
|
||||
local vel_x = 0
|
||||
local vel_y = 0
|
||||
local length = 900
|
||||
|
||||
if ( entity_who_caused ~= nil ) and ( entity_who_caused ~= NULL_ENTITY ) then
|
||||
local ex, ey = EntityGetTransform( entity_who_caused )
|
||||
|
||||
if ( ex ~= nil ) and ( ey ~= nil ) then
|
||||
angle = 0 - math.atan2( ey - y, ex - x )
|
||||
end
|
||||
end
|
||||
|
||||
vel_x = math.cos( angle + angle_random ) * length
|
||||
vel_y = 0- math.sin( angle + angle_random ) * length
|
||||
shoot_projectile( entity_id, "data/entities/misc/perks/revenge_tentacle_tentacle.xml", x, y, vel_x, vel_y )
|
||||
end
|
|
@ -8,8 +8,7 @@ local perk_fns = {}
|
|||
|
||||
-- Which perks we do not add to clients.
|
||||
local perks_to_ignore = {
|
||||
GAMBLE = true, -- Tends to get readded, causing players to get a lot of random perks.
|
||||
-- Doesn't make sense to duplicate those to clients.
|
||||
GAMBLE = true,
|
||||
PERKS_LOTTERY = true,
|
||||
REMOVE_FOG_OF_WAR = true,
|
||||
MEGA_BEAM_STONE = true,
|
||||
|
@ -20,9 +19,6 @@ local perks_to_ignore = {
|
|||
EXTRA_PERK = true,
|
||||
FASTER_WANDS = true,
|
||||
EXTRA_MANA = true,
|
||||
-- TODO: Needs extra work to work correctly
|
||||
-- NO_MORE_SHUFFLE = true,
|
||||
-- UNLIMITED_SPELLS = true,
|
||||
}
|
||||
|
||||
function perk_fns.get_my_perks()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function damage_about_to_be_received( damage, x, y, entity_thats_responsible, critical_hit_chance )
|
||||
if(entity_thats_responsible ~= GameGetWorldStateEntity())then
|
||||
if entity_thats_responsible ~= GameGetWorldStateEntity() then
|
||||
return 2^-128, 0
|
||||
end
|
||||
|
||||
|
|
24
quant.ew/files/resource/shoot_projectile_fix.lua
Normal file
24
quant.ew/files/resource/shoot_projectile_fix.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
function get_herd_id( entity_id )
|
||||
local genome = EntityGetFirstComponentIncludingDisabled(entity_id, "GenomeDataComponent")
|
||||
local herd = ComponentGetValue2(genome, "herd_id")
|
||||
return herd
|
||||
end
|
||||
|
||||
function shoot_projectile( who_shot, entity_file, x, y, vel_x, vel_y, send_message )
|
||||
local entity_id = EntityLoad( entity_file, x, y )
|
||||
local herd_id = get_herd_id( who_shot )
|
||||
if( send_message == nil ) then send_message = true end
|
||||
|
||||
GameShootProjectile( who_shot, x, y, x+vel_x, y+vel_y, entity_id, send_message )
|
||||
|
||||
edit_component( entity_id, "ProjectileComponent", function(comp,vars)
|
||||
vars.mWhoShot = who_shot
|
||||
vars.mShooterHerdId = herd_id
|
||||
end)
|
||||
|
||||
edit_component( entity_id, "VelocityComponent", function(comp,vars)
|
||||
ComponentSetValueVector2( comp, "mVelocity", vel_x, vel_y )
|
||||
end)
|
||||
|
||||
return entity_id
|
||||
end
|
|
@ -117,12 +117,9 @@ local function allow_notplayer_perk(perk_id)
|
|||
ALWAYS_CAST = true,
|
||||
EXTRA_SLOTS = true,
|
||||
EXTRA_PERK = true,
|
||||
EXTRA_SHOP_ITEM = true,
|
||||
FASTER_WANDS = true,
|
||||
EXTRA_MANA = true,
|
||||
RESPAWN = true,
|
||||
GENOME_MORE_HATRED = true,
|
||||
GENOME_MORE_LOVE = true,
|
||||
ESSENCE_LASER = true,
|
||||
ESSENCE_FIRE = true,
|
||||
ESSENCE_WATER = true,
|
||||
|
|
|
@ -14,10 +14,6 @@ end
|
|||
hide_perk("ABILITY_ACTIONS_MATERIALIZED")
|
||||
hide_perk("TELEKINESIS")
|
||||
hide_perk("HOMUNCULUS")
|
||||
hide_perk("REVENGE_EXPLOSION")
|
||||
hide_perk("EXTRA_SHOP_ITEM")
|
||||
hide_perk("GENOME_MORE_LOVE")
|
||||
hide_perk("GENOME_MORE_HATRED")
|
||||
|
||||
patch_perk_2("SHIELD", function(entity_perk_item, entity_who_picked, item_name, pickup_count, orig_fn)
|
||||
GlobalsSetValue("PERK_SHIELD_COUNT", tostring(pickup_count-1))
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
|
||||
local net = dofile_once("mods/quant.ew/files/core/net.lua")
|
||||
local np = require("noitapatcher")
|
||||
local perk_fns = dofile_once("mods/quant.ew/files/core/perk_fns.lua")
|
||||
|
||||
local rpc = net.new_rpc_namespace()
|
||||
|
||||
local module = {}
|
||||
|
||||
local default_items = 5
|
||||
|
||||
ModLuaFileAppend("data/scripts/perks/perk_list.lua", "mods/quant.ew/files/system/perk_patches/append/perks_common.lua")
|
||||
ModLuaFileAppend("data/scripts/perks/perk_utilities.lua", "mods/quant.ew/files/system/perk_patches/append/cosmetics_append.lua")
|
||||
|
||||
|
@ -37,4 +40,40 @@ end
|
|||
|
||||
np.CrossCallAdd("ew_perks_modify_max_hp", rpc.modify_max_hp)
|
||||
|
||||
rpc.opts_everywhere()
|
||||
function rpc.sync_perk_amount(items, genome)
|
||||
GlobalsSetValue("TEMPLE_SHOP_ITEM_COUNT", tostring(items))
|
||||
local world = GameGetWorldStateEntity()
|
||||
local com = EntityGetFirstComponent(world, "WorldStateComponent")
|
||||
ComponentSetValue(com, "global_genome_relations_modifier", tostring(genome))
|
||||
end
|
||||
|
||||
function module.on_world_update()
|
||||
if GameGetFrameNum() == 5 then
|
||||
default_items = tonumber(GlobalsGetValue("TEMPLE_SHOP_ITEM_COUNT", "5"))
|
||||
end
|
||||
if ctx.is_host and GameGetFrameNum() % 120 == 24 then
|
||||
local items = default_items
|
||||
local genome = 0
|
||||
for peer, player in pairs(ctx.players) do
|
||||
local perks = {}
|
||||
if peer == ctx.my_id then
|
||||
perks = perk_fns.get_my_perks()
|
||||
else
|
||||
perks = util.get_ent_variable(player.entity, "ew_current_perks") or {}
|
||||
end
|
||||
for perk, count in pairs(perks) do
|
||||
if perk == "EXTRA_SHOP_ITEM" then
|
||||
items = items + count
|
||||
elseif perk == "GENOME_MORE_LOVE" then
|
||||
genome = genome + count
|
||||
elseif perk == "GENOME_MORE_HATRED" then
|
||||
genome = genome - count
|
||||
end
|
||||
end
|
||||
end
|
||||
rpc.sync_perk_amount(items, genome * 25)
|
||||
end
|
||||
end
|
||||
|
||||
return module
|
Loading…
Add table
Add a link
Reference in a new issue