sync more things

This commit is contained in:
bgkillas 2024-11-02 20:51:30 -04:00
parent 0bdb95c3ff
commit 889240bff9
7 changed files with 356 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,133 @@
<Entity
name="$projectile_default"
tags="resist_repulsion"
>
<Base file="data/entities/base_projectile.xml" >
<VelocityComponent
gravity_y="0"
air_friction="0"
mass="0.8"
>
</VelocityComponent>
</Base>
<HomingComponent
target_tag="mortal"
homing_targeting_coeff="7"
detect_distance="160"
homing_velocity_multiplier="1.0"
>
</HomingComponent>
<ProjectileComponent
_enabled="1"
lob_min="0.8"
lob_max="1.0"
speed_min="100"
speed_max="120"
die_on_low_velocity="0"
on_death_explode="1"
on_death_gfx_leave_sprite="0"
on_lifetime_out_explode="1"
explosion_dont_damage_shooter="1"
damage="2.8"
on_collision_die="1"
lifetime="300"
knockback_force="1.4"
collide_with_tag="ew_peer"
>
<config_explosion
never_cache="1"
camera_shake="4.0"
explosion_radius="20"
explosion_sprite="data/particles/explosion_032_slime.xml"
explosion_sprite_lifetime="0.0"
create_cell_probability="0"
ray_energy="230000"
hole_destroy_liquid="1"
hole_enabled="1"
damage = "1.5"
hole_image="data/temp/explosion_hole.png"
explosion_sprite_emissive="0"
explosion_sprite_additive="1"
particle_effect="0"
damage_mortals="1"
physics_explosion_power.min="0.4"
physics_explosion_power.max="0.6"
physics_throw_enabled="1"
shake_vegetation="1"
sparks_enabled="1"
sparks_count_max="40"
sparks_count_min="30"
spark_material="spark_green"
light_fade_time="1.2"
light_r="35"
light_g="240"
light_b="140"
stains_enabled="1"
stains_image="data/temp/explosion_stain.png"
audio_enabled="0" >
</config_explosion>
</ProjectileComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/projectiles_gfx/orb_green_big.xml"
next_rect_animation=""
offset_x="8"
offset_y="8"
rect_animation="fireball"
emissive="1"
additive="1"
update_transform_rotation="0"
>
</SpriteComponent>
<SpriteParticleEmitterComponent
sprite_file="data/particles/orb_green_big_out.xml"
delay="0"
lifetime="0"
additive="1"
emissive="1"
color.r="1" color.g="1" color.b="1" color.a="1"
color_change.r="0" color_change.g="0" color_change.b="0" color_change.a="0"
velocity.x="0" velocity.y="0"
gravity.x="0" gravity.y="10"
velocity_slowdown="0"
rotation="0"
angular_velocity="0"
use_velocity_as_rotation="0"
scale.x="1" scale.y="1"
scale_velocity.x="0" scale_velocity.y="0"
emission_interval_min_frames="1"
emission_interval_max_frames="1"
count_min="1" count_max="1"
randomize_rotation.min="-0.3415"
randomize_rotation.max="0.3415"
randomize_angular_velocity.min="-1.3415"
randomize_angular_velocity.max="1.3415"
is_emitting="1"
>
</SpriteParticleEmitterComponent>
<LightComponent
_enabled="1"
radius="150"
r="10"
g="240"
b="120">
</LightComponent>
<AudioComponent
file="data/audio/Desktop/projectiles.bank"
event_root="projectiles/orb_b" >
</AudioComponent>
<VariableStorageComponent
name="projectile_file"
value_string="data/entities/animals/maggot_tiny/orb.xml"
>
</VariableStorageComponent>
</Entity>

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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