From 889240bff95b3efaca78a5566c8eccb4155581f3 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 2 Nov 2024 20:51:30 -0400 Subject: [PATCH] sync more things --- .../data/entities/animals/boss_fish/eye.lua | 86 +++++++++++ .../animals/boss_spirit/create_wand.lua | 40 ++++++ .../data/entities/animals/maggot_tiny/orb.xml | 133 ++++++++++++++++++ .../scripts/animals/fungus_giga_pollen.lua | 12 ++ .../animals/necromancer_super_chase.lua | 40 ++++++ .../animals/necromancer_super_chase_begin.lua | 30 ++++ quant.ew/data/scripts/magic/eradicate.lua | 15 ++ 7 files changed, 356 insertions(+) create mode 100644 quant.ew/data/entities/animals/boss_fish/eye.lua create mode 100644 quant.ew/data/entities/animals/boss_spirit/create_wand.lua create mode 100644 quant.ew/data/entities/animals/maggot_tiny/orb.xml create mode 100644 quant.ew/data/scripts/animals/fungus_giga_pollen.lua create mode 100644 quant.ew/data/scripts/animals/necromancer_super_chase.lua create mode 100644 quant.ew/data/scripts/animals/necromancer_super_chase_begin.lua create mode 100644 quant.ew/data/scripts/magic/eradicate.lua diff --git a/quant.ew/data/entities/animals/boss_fish/eye.lua b/quant.ew/data/entities/animals/boss_fish/eye.lua new file mode 100644 index 00000000..59cd6877 --- /dev/null +++ b/quant.ew/data/entities/animals/boss_fish/eye.lua @@ -0,0 +1,86 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local entity_id = GetUpdatedEntityID() +local root_id = EntityGetRootEntity( entity_id ) +local x, y = EntityGetTransform( entity_id ) + +local pcomp = 0 +local scomp = 0 +local timer = 0 + +local c = EntityGetComponent( entity_id, "VariableStorageComponent" ) +if ( c ~= nil ) then + for i,v in ipairs( c ) do + local n = ComponentGetValue2( v, "name" ) + if ( n == "phase_timer" ) then + timer = ComponentGetValue2( v, "value_int" ) + pcomp = v + end + end +end + +local hcomp = EntityGetFirstComponentIncludingDisabled( root_id, "HitboxComponent" ) + +if ( pcomp ~= 0 ) and ( hcomp ~= nil ) then + timer = timer + 1 + + local p = EntityGetInRadiusWithTag( x, y, 160, "ew_peer" ) + local eye = EntityGetFirstComponent( entity_id, "SpriteComponent" ) + if ( eye ~= nil ) then + local current = ComponentGetValue2( eye, "rect_animation" ) + + if ( #current == 0 ) then + ComponentSetValue2( eye, "rect_animation", "closed" ) + EntitySetComponentIsEnabled( entity_id, hcomp, false ) + end + + if ( #p == 0 ) then + if ( current == "opened" ) then + ComponentSetValue2( eye, "rect_animation", "close" ) + ComponentSetValue2( eye, "next_rect_animation", "closed" ) + timer = 0 + EntitySetComponentIsEnabled( entity_id, hcomp, false ) + elseif ( current == "close" ) and ( timer > 36 ) then + ComponentSetValue2( eye, "rect_animation", "closed" ) + ComponentSetValue2( eye, "next_rect_animation", "closed" ) + timer = 0 + elseif ( current == "open" ) and ( timer > 36 ) then + ComponentSetValue2( eye, "rect_animation", "opened" ) + ComponentSetValue2( eye, "next_rect_animation", "opened" ) + timer = 0 + EntitySetComponentIsEnabled( entity_id, hcomp, true ) + end + else + if ( current == "closed" ) then + ComponentSetValue2( eye, "rect_animation", "open" ) + ComponentSetValue2( eye, "next_rect_animation", "opened" ) + timer = 0 + elseif ( current == "open" ) and ( timer > 36 ) then + ComponentSetValue2( eye, "rect_animation", "opened" ) + ComponentSetValue2( eye, "next_rect_animation", "opened" ) + timer = 0 + EntitySetComponentIsEnabled( entity_id, hcomp, true ) + elseif ( current == "close" ) and ( timer > 36 ) then + ComponentSetValue2( eye, "rect_animation", "closed" ) + ComponentSetValue2( eye, "next_rect_animation", "closed" ) + timer = 0 + end + end + + if ( current == "opened" ) and ( timer > 360 ) then + timer = 0 + SetRandomSeed( x + y, GameGetFrameNum() ) + local offset = Random( 1, 100 ) * 0.01 * math.pi + local inc = ( math.pi * 2 ) / 8 + + for a=0,7 do + local vx = math.cos( offset + inc * a ) * 80 + local vy = 0 - math.sin( offset + inc * a ) * 80 + + shoot_projectile( root_id, "data/entities/animals/boss_fish/orb_big.xml", x, y, vx, vy ) + end + end + end + + ComponentSetValue2( pcomp, "value_int", timer ) +end \ No newline at end of file diff --git a/quant.ew/data/entities/animals/boss_spirit/create_wand.lua b/quant.ew/data/entities/animals/boss_spirit/create_wand.lua new file mode 100644 index 00000000..fe4656ce --- /dev/null +++ b/quant.ew/data/entities/animals/boss_spirit/create_wand.lua @@ -0,0 +1,40 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local entity_id = GetUpdatedEntityID() +local x, y = EntityGetTransform( GetUpdatedEntityID() ) +local radius = 260 + +local proj = "" + +local s = EntityGetComponent( entity_id, "VariableStorageComponent" ) +if ( s ~= nil ) then + for i,v in ipairs( s ) do + local name = ComponentGetValue2( v, "name" ) + + if ( name == "type" ) then + proj = ComponentGetValue2( v, "value_string" ) + end + end +end + +local targets = EntityGetInRadiusWithTag( x, y, radius, "ew_peer" ) +local closest +local v +for _, player in ipairs(targets) do + local px, py = EntityGetTransform(player) + local r = px * px + py * py + if closest == nil or r < closest then + closest = r + v = player + end +end + +if ( string.len( proj ) > 0 ) and ( v ~= nil ) then + local px, py = EntityGetTransform( v ) + local vel_x = math.cos( 0 - math.atan2( py - y, px - x ) ) * 2.0 + local vel_y = 0 - math.sin( 0 - math.atan2( py - y, px - x ) ) * 2.0 + + local eid = shoot_projectile_from_projectile( entity_id, proj, x, y, vel_x, vel_y ) + + EntityAddTag( eid, "boss_alchemist" ) +end \ No newline at end of file diff --git a/quant.ew/data/entities/animals/maggot_tiny/orb.xml b/quant.ew/data/entities/animals/maggot_tiny/orb.xml new file mode 100644 index 00000000..2b638771 --- /dev/null +++ b/quant.ew/data/entities/animals/maggot_tiny/orb.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/quant.ew/data/scripts/animals/fungus_giga_pollen.lua b/quant.ew/data/scripts/animals/fungus_giga_pollen.lua new file mode 100644 index 00000000..afc0c6d8 --- /dev/null +++ b/quant.ew/data/scripts/animals/fungus_giga_pollen.lua @@ -0,0 +1,12 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local entity_id = GetUpdatedEntityID() +local x,y = EntityGetTransform( entity_id ) + +local targets = EntityGetInRadiusWithTag( x, y, 64, "ew_peer" ) + +if ( #targets > 0 ) then + SetRandomSeed( x + entity_id, y + GameGetFrameNum() ) + + shoot_projectile( entity_id, "data/entities/projectiles/pollen.xml", x, y, Random( -300, 300 ), Random( -300, 10 ) ) +end \ No newline at end of file diff --git a/quant.ew/data/scripts/animals/necromancer_super_chase.lua b/quant.ew/data/scripts/animals/necromancer_super_chase.lua new file mode 100644 index 00000000..6f3980b0 --- /dev/null +++ b/quant.ew/data/scripts/animals/necromancer_super_chase.lua @@ -0,0 +1,40 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local range_near = 40 -- if below, stop chase +local range_far = 250 +local range_max = 600 -- if above, stop chase + +local speed_near = 0.5 -- speed used at range_near +local speed_far = 1 -- speed used at range_far + +local entity_id = GetUpdatedEntityID() +local pos_x, pos_y = EntityGetTransform(entity_id) + +local function set_fly_speed(spd) + component_write( EntityGetFirstComponent( entity_id, "CharacterPlatformingComponent" ), { fly_speed_mult = spd, fly_velocity_x = spd * 2 } ) +end + +local target = EntityGetClosestWithTag(pos_x, pos_y, "ew_peer") +if not target or target == 0 then + set_fly_speed(40) + return +end + +local vx, vy = EntityGetTransform(target) +vx, vy = vec_sub(vx, vy, pos_x, pos_y) +local dist = get_magnitude(vx, vy, pos_x, pos_y) + +if dist < range_near or dist > range_max then + set_fly_speed(40) + return +end + +-- move directly towards player +set_fly_speed(0) +local speed = map(dist, range_near, range_far, speed_near, speed_far) +speed = clamp(speed, speed_near, speed_far) +vx, vy = vec_normalize(vx, vy) +vx, vy = vec_mult(vx, vy, speed) + +pos_x, pos_y = vec_add(pos_x, pos_y, vx, vy) +EntitySetTransform(entity_id, pos_x, pos_y) \ No newline at end of file diff --git a/quant.ew/data/scripts/animals/necromancer_super_chase_begin.lua b/quant.ew/data/scripts/animals/necromancer_super_chase_begin.lua new file mode 100644 index 00000000..b3fdcfce --- /dev/null +++ b/quant.ew/data/scripts/animals/necromancer_super_chase_begin.lua @@ -0,0 +1,30 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local max_range = 150 +local min_range = 50 + +local entity_id = GetUpdatedEntityID() +local pos_x, pos_y = EntityGetTransform(entity_id) + +local function start_chase() + -- enable chase & cell eater, disable this script + print("start chase") + EntitySetComponentsWithTagEnabled(entity_id, "enable_when_player_seen", true) + EntityRemoveComponent(entity_id, GetUpdatedComponentID()) +end + +local target = EntityGetClosestWithTag(pos_x, pos_y, "ew_peer") +if not target or target == 0 then return end + +local tx, ty = EntityGetTransform(target) +local dist = get_distance(tx, ty, pos_x, pos_y) +if dist > max_range then return end -- too far +if dist < min_range then + -- very near + start_chase() + return +end + +-- check los +local did_hit = RaytraceSurfaces(pos_x, pos_y, tx, ty) +if not did_hit then start_chase() end \ No newline at end of file diff --git a/quant.ew/data/scripts/magic/eradicate.lua b/quant.ew/data/scripts/magic/eradicate.lua new file mode 100644 index 00000000..21279384 --- /dev/null +++ b/quant.ew/data/scripts/magic/eradicate.lua @@ -0,0 +1,15 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local entity_id = GetUpdatedEntityID() +local x, y = EntityGetTransform( entity_id ) + +local targets = EntityGetWithTag( "mortal" ) +for i,v in ipairs( targets ) do + if ( EntityHasTag( v, "ew_peer" ) == false ) then + local test = EntityGetFirstComponent( v, "DamageModelComponent" ) + + if ( test ~= nil ) then + EntityKill( v ) + end + end +end \ No newline at end of file