Several fixes and improvements

- Change vscode Lua runtime to LuaJIT
- Remove worm entity overrides
- Remove preparePlayer() that sets HP and other stuff
- Change how entites are captured
- Increase entity capture radius
- Capture entities as soon as possible
- Modify entites immediately after they are captured
- Make stringArgs in print local
- Fix JSON marshaling of Noita vectors
- Fix NoitaEntity:GetComponents() and NoitaEntity:GetFirstComponent()
- Add varArg support to NoitaComponent:SetValue() and NoitaComponent:ObjectSetValue()
- Update some EmmyLua annotations
- Fix custom GamePrint
- Add table.pack function that is missing in LuaJIT
This commit is contained in:
David Vogel 2022-07-18 22:07:53 +02:00
parent 40f31011e8
commit f58b005155
10 changed files with 163 additions and 1508 deletions

View File

@ -29,5 +29,6 @@
"xmin",
"ymax",
"ymin"
]
],
"Lua.runtime.version": "LuaJIT"
}

View File

@ -1,229 +0,0 @@
<Entity
tags="mortal,hittable,teleportable_NOT,homing_target,enemy,worm"
name="$animal_worm"
>
<_Transform
position.x="0"
position.y="0"
rotation="0"
scale.x="1"
scale.y="1" >
</_Transform>
<WormComponent
acceleration="0.5"
gravity="0"
tail_gravity="0"
part_distance="10"
ground_check_offset="1"
hitbox_radius="5"
target_kill_radius="7"
target_kill_ragdoll_force="8"
ragdoll_filename=""
eat_anim_wait_mult="0.05 "
jump_cam_shake="6"
>
</WormComponent>
<WormAIComponent
speed="0"
speed_hunt="0"
direction_adjust_speed="0.012"
direction_adjust_speed_hunt="0.06"
hunt_box_radius="256"
random_target_box_radius="128"
new_hunt_target_check_every="120"
new_random_target_check_every="120"
give_up_area_radius="60"
give_up_time_frames="250"
>
</WormAIComponent>
<CellEaterComponent
radius="6" >
</CellEaterComponent>
<DamageModelComponent
air_needed="0"
falling_damages="0"
fire_damage_amount="0.2"
fire_probability_of_ignition="0.5"
blood_material="blood_worm"
blood_spray_material="blood_worm"
hp="20"
is_on_fire="0"
mAirAreWeInWater="0"
mFallCount="0"
mFallHighestY="3.40282e+038"
mFallIsOnGround="0"
mFireProbability="100"
mIsOnFire="0"
mLastCheckTime="0"
mLastCheckX="0"
mLastCheckY="0"
materials_damage="1"
materials_how_much_damage="0.1"
materials_that_damage="acid"
ragdoll_filenames_file=""
ragdoll_material="meat_worm"
ragdoll_offset_y="-6"
blood_sprite_directional="data/particles/bloodsplatters/bloodsplatter_directional_yellow_$[1-3].xml"
blood_sprite_large="data/particles/bloodsplatters/bloodsplatter_yellow_$[1-3].xml"
>
<damage_multipliers
drill="0.4"
>
</damage_multipliers>
</DamageModelComponent>
<PathFindingGridMarkerComponent
marker_offset_y="0"
marker_work_flag="16" >
</PathFindingGridMarkerComponent>
<GenomeDataComponent
_enabled="1"
herd_id="worm"
food_chain_rank="6"
is_predator="1" >
</GenomeDataComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_head.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="15"
offset_y="6"
update_transform="0"
z_index="-0.5"
>
</SpriteComponent>
<SpriteComponent
alpha="1"
image_file="data/enemies_gfx/worm_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="15"
offset_y="6"
update_transform="0"
z_index="-0.49"
>
</SpriteComponent>
<SpriteComponent
alpha="1"
image_file="data/enemies_gfx/worm_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="15"
offset_y="6"
update_transform="0"
z_index="-0.48"
>
</SpriteComponent>
<SpriteComponent
alpha="1"
image_file="data/enemies_gfx/worm_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="15"
offset_y="6"
update_transform="0"
z_index="-0.47"
>
</SpriteComponent>
<SpriteComponent
alpha="1"
image_file="data/enemies_gfx/worm_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="15"
offset_y="6"
update_transform="0"
z_index="-0.46"
>
</SpriteComponent>
<SpriteComponent
alpha="1"
image_file="data/enemies_gfx/worm_tail.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="15"
offset_y="6"
update_transform="0"
z_index="-0.45"
>
</SpriteComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="0">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="1">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="2">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="3">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="4">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="5">
</SpriteStainsComponent>
<StatusEffectDataComponent>
</StatusEffectDataComponent>
<CameraBoundComponent
max_count="10"
distance="2000">
</CameraBoundComponent>
<ItemChestComponent level="2" enemy_drop="1" >
</ItemChestComponent>
<MusicEnergyAffectorComponent
energy_target="1">
</MusicEnergyAffectorComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals">
</AudioComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals/worm" >
</AudioComponent>
<AudioLoopComponent
file="data/audio/Desktop/animals.snd"
event_name="animals/worm/movement_loop"
set_speed_parameter="1"
auto_play="1">
</AudioLoopComponent>
</Entity>

View File

@ -1,299 +0,0 @@
<Entity
tags="mortal,hittable,teleportable_NOT,homing_target,enemy,worm"
name="$animal_worm_big"
>
<_Transform
position.x="0"
position.y="0"
rotation="0"
scale.x="1"
scale.y="1" >
</_Transform>
<WormComponent
acceleration="1.5"
gravity="0"
tail_gravity="0"
part_distance="16"
ground_check_offset="8"
hitbox_radius="9"
target_kill_radius="10"
target_kill_ragdoll_force="10"
ragdoll_filename=""
eat_anim_wait_mult="0.05 "
jump_cam_shake="6"
>
</WormComponent>
<WormAIComponent
speed="0"
speed_hunt="0"
direction_adjust_speed="0.003"
direction_adjust_speed_hunt="0.04"
hunt_box_radius="256"
random_target_box_radius="128"
new_hunt_target_check_every="240"
new_random_target_check_every="240"
give_up_area_radius="150"
give_up_time_frames="250"
>
</WormAIComponent>
<CellEaterComponent
radius="9" >
</CellEaterComponent>
<DamageModelComponent
_enabled="1"
air_needed="0"
falling_damages="0"
fire_damage_amount="0.2"
fire_probability_of_ignition="0.5"
blood_material="blood_worm"
blood_spray_material="blood_worm"
hp="140"
is_on_fire="0"
mAirAreWeInWater="0"
mFallCount="0"
mFallHighestY="3.40282e+038"
mFallIsOnGround="0"
mFireProbability="100"
mIsOnFire="0"
mLastCheckTime="0"
mLastCheckX="0"
mLastCheckY="0"
materials_damage="1"
materials_how_much_damage="0.0001,0.0001"
materials_that_damage="acid,lava"
ragdoll_filenames_file=""
ragdoll_material="meat_worm"
ragdoll_offset_y="-6"
blood_sprite_directional="data/particles/bloodsplatters/bloodsplatter_directional_yellow_$[1-3].xml"
blood_sprite_large="data/particles/bloodsplatters/bloodsplatter_large_yellow_$[1-3].xml"
>
<damage_multipliers
drill="0.4"
>
</damage_multipliers>
</DamageModelComponent>
<PathFindingGridMarkerComponent
marker_offset_y="0"
marker_work_flag="16" >
</PathFindingGridMarkerComponent>
<GenomeDataComponent
_enabled="1"
herd_id="worm"
food_chain_rank="6"
is_predator="1" >
</GenomeDataComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_head.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.5"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_body.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.4"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_body.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.39"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_body.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.38"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_body.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.37"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_body.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.36"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_big_tail.xml"
rect_animation="eat"
next_rect_animation="eat"
next_rect_animation=""
offset_x="22"
offset_y="12"
update_transform="0"
z_index="-0.35"
>
</SpriteComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="0">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="1">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="2">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="3">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="4">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="5">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="6">
</SpriteStainsComponent>
<SpriteComponent
_tags="health_bar_back,ui,no_hitbox"
_enabled="1"
alpha="1"
has_special_scale="1"
image_file="data/ui_gfx/health_slider_back.png"
is_text_sprite="0"
next_rect_animation=""
offset_x="12"
offset_y="42"
rect_animation=""
special_scale_x="1"
special_scale_y="1"
ui_is_parent="0"
update_transform="1"
visible="1"
z_index="-9000"
>
</SpriteComponent>
<SpriteComponent
_tags="health_bar,ui,no_hitbox"
_enabled="1"
alpha="1"
has_special_scale="1"
image_file="data/ui_gfx/health_slider_front.png"
is_text_sprite="0"
next_rect_animation=""
offset_x="11"
offset_y="42"
rect_animation=""
special_scale_x="1"
special_scale_y="1"
ui_is_parent="0"
update_transform="1"
visible="1"
z_index="-9000"
>
</SpriteComponent>
<HealthBarComponent>
</HealthBarComponent>
<CameraBoundComponent
max_count="10"
distance="2000">
</CameraBoundComponent>
<ItemChestComponent level="3" enemy_drop="1" > </ItemChestComponent>
<LuaComponent
script_death="data/scripts/animals/worm_death.lua"
>
</LuaComponent>
<MusicEnergyAffectorComponent
energy_target="1">
</MusicEnergyAffectorComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals">
</AudioComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals/worm">
</AudioComponent>
<AudioLoopComponent
file="data/audio/Desktop/animals.snd"
event_name="animals/worm/movement_loop_big"
set_speed_parameter="1"
auto_play="1">
</AudioLoopComponent>
</Entity>

View File

@ -1,317 +0,0 @@
<Entity
tags="mortal,hittable,teleportable_NOT,homing_target,enemy,worm"
name="$animal_worm_end"
>
<_Transform
position.x="0"
position.y="0"
rotation="0"
scale.x="1"
scale.y="1" >
</_Transform>
<WormComponent
acceleration="0.5"
gravity="0"
tail_gravity="0"
part_distance="12"
ground_check_offset="8"
hitbox_radius="9"
bite_damage="1"
target_kill_radius="10"
target_kill_ragdoll_force="10"
ragdoll_filename="data/ragdolls/worm_skull/filenames.txt"
eat_anim_wait_mult="0.05 "
jump_cam_shake="2" >
</WormComponent>
<WormAIComponent
speed="0"
speed_hunt="0"
direction_adjust_speed="0.005"
direction_adjust_speed_hunt="0.04"
hunt_box_radius="256"
random_target_box_radius="128"
new_hunt_target_check_every="240"
new_random_target_check_every="240"
give_up_area_radius="150"
give_up_time_frames="250"
>
</WormAIComponent>
<DamageModelComponent
_enabled="1"
air_needed="0"
falling_damages="0"
fire_damage_amount="0.2"
fire_probability_of_ignition="0"
hp="25"
ragdoll_fx_forced="DISINTEGRATED"
is_on_fire="0"
mAirAreWeInWater="0"
mFallCount="0"
mFallHighestY="3.40282e+038"
mFallIsOnGround="0"
mFireProbability="100"
mIsOnFire="0"
mLastCheckTime="0"
mLastCheckX="0"
mLastCheckY="0"
materials_damage="1"
materials_how_much_damage="0.1"
materials_that_damage="acid"
ragdoll_filenames_file=""
ragdoll_offset_y="-6"
blood_material="lava"
blood_spray_material="lava"
ragdoll_material="lava"
blood_sprite_directional="data/particles/bloodsplatters/bloodsplatter_directional_orange_$[1-3].xml"
blood_sprite_large="data/particles/bloodsplatters/bloodsplatter_orange_$[1-3].xml"
>
<damage_multipliers
drill="0.4"
projectile="0.4"
>
</damage_multipliers>
</DamageModelComponent>
<PathFindingGridMarkerComponent
marker_offset_y="0"
marker_work_flag="16" >
</PathFindingGridMarkerComponent>
<GenomeDataComponent
_enabled="1"
herd_id="worm"
food_chain_rank="20"
is_predator="1" >
</GenomeDataComponent>
<CellEaterComponent
radius="9" >
</CellEaterComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_head.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-4"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.9"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.8"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.7"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.6"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.5"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.4"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.3"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.2"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.1"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-3.0"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-2.9"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-2.8"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_middle.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-2.7"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/endworm_tail.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="29"
offset_y="16"
update_transform="0"
z_index="-2.6"
>
</SpriteComponent>
<CameraBoundComponent
max_count="10"
distance="2000">
</CameraBoundComponent>
<MusicEnergyAffectorComponent
energy_target="1">
</MusicEnergyAffectorComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals">
</AudioComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals/worm">
</AudioComponent>
<AudioLoopComponent
file="data/audio/Desktop/animals.snd"
event_name="animals/worm/movement_loop_big"
set_speed_parameter="1"
auto_play="1">
</AudioLoopComponent>
</Entity>

View File

@ -1,330 +0,0 @@
<Entity
tags="mortal,hittable,teleportable_NOT,homing_target,enemy,worm"
name="$animal_worm_skull"
>
<_Transform
position.x="0"
position.y="0"
rotation="0"
scale.x="1"
scale.y="1" >
</_Transform>
<WormComponent
acceleration="0.5"
gravity="0"
tail_gravity="0"
part_distance="12"
ground_check_offset="8"
hitbox_radius="9"
bite_damage="1"
target_kill_radius="10"
target_kill_ragdoll_force="10"
ragdoll_filename="data/ragdolls/worm_skull/filenames.txt"
eat_anim_wait_mult="0.05 "
jump_cam_shake="2" >
</WormComponent>
<WormAIComponent
speed="0"
speed_hunt="0"
direction_adjust_speed="0.005"
direction_adjust_speed_hunt="0.04"
hunt_box_radius="256"
random_target_box_radius="128"
new_hunt_target_check_every="240"
new_random_target_check_every="240"
give_up_area_radius="150"
give_up_time_frames="250"
>
</WormAIComponent>
<DamageModelComponent
_enabled="1"
air_needed="0"
falling_damages="0"
fire_damage_amount="0.2"
fire_probability_of_ignition="0.5"
hp="25"
ragdoll_fx_forced="DISINTEGRATED"
is_on_fire="0"
mAirAreWeInWater="0"
mFallCount="0"
mFallHighestY="3.40282e+038"
mFallIsOnGround="0"
mFireProbability="100"
mIsOnFire="0"
mLastCheckTime="0"
mLastCheckX="0"
mLastCheckY="0"
materials_damage="1"
materials_how_much_damage="0.1"
materials_that_damage="acid"
ragdoll_filenames_file=""
ragdoll_offset_y="-6"
blood_material="plasma_fading"
blood_spray_material="plasma_fading"
ragdoll_material="plasma_fading"
blood_sprite_directional="data/particles/bloodsplatters/bloodsplatter_directional_blue_$[1-3].xml"
blood_sprite_large="data/particles/bloodsplatters/bloodsplatter_blue_$[1-3].xml"
>
<damage_multipliers
drill="0.1"
>
</damage_multipliers>
</DamageModelComponent>
<PathFindingGridMarkerComponent
marker_offset_y="0"
marker_work_flag="16" >
</PathFindingGridMarkerComponent>
<GenomeDataComponent
_enabled="1"
herd_id="ghost"
food_chain_rank="20"
is_predator="1" >
</GenomeDataComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_head.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-4.0"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="22"
emissive="1"
additive="1"
offset_y="16"
update_transform="0"
z_index="-3.9"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.8"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.7"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.6"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.5"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.4"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.3"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.2"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.1"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-3.0"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-2.9"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-2.8"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_body.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-2.7"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_skull_tail.xml"
rect_animation="eat"
next_rect_animation="eat"
emissive="1"
additive="1"
next_rect_animation=""
offset_x="22"
offset_y="16"
update_transform="0"
z_index="-2.6"
>
</SpriteComponent>
<CameraBoundComponent
max_count="10"
distance="2000">
</CameraBoundComponent>
<MusicEnergyAffectorComponent
energy_target="1">
</MusicEnergyAffectorComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals/ghost" >
</AudioComponent>
</Entity>

View File

@ -1,248 +0,0 @@
<Entity
tags="mortal,hittable,teleportable_NOT,homing_target,enemy,worm"
name="$animal_worm_tiny"
>
<_Transform
position.x="0"
position.y="0"
rotation="0"
scale.x="1"
scale.y="1" >
</_Transform>
<WormComponent
acceleration="0.3"
gravity="0"
tail_gravity="0"
part_distance="6"
ground_check_offset="1"
hitbox_radius="2"
bite_damage="0.3"
target_kill_radius="7"
target_kill_ragdoll_force="8"
ragdoll_filename="data/ragdolls/worm_tiny/filenames.txt"
eat_anim_wait_mult="0.05 "
jump_cam_shake="0"
>
</WormComponent>
<WormAIComponent
speed="0"
speed_hunt="0"
direction_adjust_speed="0.010"
direction_adjust_speed_hunt="0.04"
hunt_box_radius="256"
random_target_box_radius="128"
new_hunt_target_check_every="120"
new_random_target_check_every="120"
give_up_area_radius="60"
give_up_time_frames="250"
>
</WormAIComponent>
<CellEaterComponent
radius="3"
only_stain="1" >
</CellEaterComponent>
<DamageModelComponent
_enabled="1"
air_needed="0"
falling_damages="0"
fire_damage_amount="0.2"
fire_probability_of_ignition="0.5"
hp="3"
blood_material="blood_worm"
blood_spray_material="blood_worm"
is_on_fire="0"
mAirAreWeInWater="0"
mFallCount="0"
mFallHighestY="3.40282e+038"
mFallIsOnGround="0"
mFireProbability="100"
mIsOnFire="0"
mLastCheckTime="0"
mLastCheckX="0"
mLastCheckY="0"
materials_damage="1"
materials_how_much_damage="0.1"
materials_that_damage="acid"
ragdoll_filenames_file=""
ragdoll_material="meat_worm"
ragdoll_offset_y="-6"
blood_sprite_directional="data/particles/bloodsplatters/bloodsplatter_directional_yellow_$[1-3].xml"
blood_sprite_large="data/particles/bloodsplatters/bloodsplatter_yellow_$[1-3].xml"
>
<damage_multipliers
drill="0.4"
>
</damage_multipliers>
</DamageModelComponent>
<PathFindingGridMarkerComponent
marker_offset_y="0"
marker_work_flag="16" >
</PathFindingGridMarkerComponent>
<GenomeDataComponent
_enabled="1"
herd_id="worm"
food_chain_rank="18"
is_predator="1" >
</GenomeDataComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_head.xml"
rect_animation="eat"
next_rect_animation="eat"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-4.0"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-3.9"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-3.8"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-3.7"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-3.6"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_body.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-3.5"
>
</SpriteComponent>
<SpriteComponent
_enabled="1"
alpha="1"
image_file="data/enemies_gfx/worm_tiny_tail.xml"
rect_animation="stand"
next_rect_animation="stand"
offset_x="9"
offset_y="4.5"
update_transform="0"
z_index="-3.4"
>
</SpriteComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="0">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="1">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="2">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="3">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="4">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="5">
</SpriteStainsComponent>
<SpriteStainsComponent
fade_stains_towards_srite_top="0"
sprite_id="6">
</SpriteStainsComponent>
<CameraBoundComponent
max_count="10"
distance="2000">
</CameraBoundComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals">
</AudioComponent>
<AudioComponent
file="data/audio/Desktop/animals.snd"
event_root="animals/worm">
</AudioComponent>
<AudioLoopComponent
file="data/audio/Desktop/animals.snd"
event_name="animals/worm/movement_loop_small"
set_speed_parameter="1"
auto_play="1">
</AudioLoopComponent>
</Entity>

View File

@ -11,7 +11,6 @@ local json = dofile_once("mods/noita-mapcap/files/json-serialize.lua")
CAPTURE_PIXEL_SIZE = 1 -- Screen to virtual pixel ratio.
CAPTURE_GRID_SIZE = 512 -- in virtual (world) pixels. There will always be exactly 4 images overlapping if the virtual resolution is 1024x1024.
CAPTURE_FORCE_HP = 4 -- * 25HP
-- "Base layout" (Base layout. Every part outside this is based on a similar layout, but uses different materials/seeds)
CAPTURE_AREA_BASE_LAYOUT = {
@ -37,16 +36,108 @@ CAPTURE_AREA_EXTENDED = {
Bottom = 41984 -- in virtual (world) pixels. (Coordinate is not included in the rectangle)
}
local function preparePlayer()
local playerEntity = getPlayer()
addEffectToEntity(playerEntity, "PROTECTION_ALL")
local componentTypeNamesToDisable = {
"AnimalAIComponent",
"SimplePhysicsComponent",
"CharacterPlatformingComponent",
"WormComponent",
"WormAIComponent",
"DamageModelComponent",
"PhysicsBodyCollisionDamageComponent",
"ExplodeOnDamageComponent",
"SpriteOffsetAnimatorComponent",
--"PhysicsBody2Component", -- Disabling will hide barrels and similar stuff, also triggers an assertion.
--"PhysicsBodyComponent",
--"VelocityComponent", -- Disabling this component may cause a "...\component_updators\advancedfishai_system.cpp at line 107" exception.
--"SpriteComponent",
--"AudioComponent",
}
--addPerkToPlayer("BREATH_UNDERWATER")
--addPerkToPlayer("INVISIBILITY")
--addPerkToPlayer("REMOVE_FOG_OF_WAR")
--addPerkToPlayer("REPELLING_CAPE")
--addPerkToPlayer("WORM_DETRACTOR")
setPlayerHP(CAPTURE_FORCE_HP)
---
---@return file*|nil
local function createOrOpenEntityCaptureFile()
-- Make sure the file exists.
local file = io.open("mods/noita-mapcap/output/entities.json", "a")
if file ~= nil then file:close() end
-- Create or reopen entities CSV file.
file = io.open("mods/noita-mapcap/output/entities.json", "r+b") -- Open for reading (r) and writing (+) in binary mode. r+b will not truncate the file to 0.
if file == nil then return nil end
return file
end
---captureEntities gathers all entities on the screen (around x, y within radius), serializes them, appends them into entityFile and modifies those entities.
---@param entityFile file*|nil
---@param x number
---@param y number
---@param radius number
local function captureEntities(entityFile, x, y, radius)
if not entityFile then return end
local entities = noitaAPI.Entity.GetInRadius(x, y, radius)
for _, entity in ipairs(entities) do
-- Get to the root entity, as we are exporting entire entity trees.
local rootEntity = entity:GetRootEntity()
-- Make sure to only export entities when they are encountered the first time.
if not rootEntity:HasTag("MapCaptured") then
-- Some hacky way to generate valid JSON that doesn't break when the game crashes.
-- Well, as long as it does not crash between write and flush.
if entityFile:seek("end") == 0 then
-- First line.
entityFile:write("[\n\t", json.Marshal(rootEntity), "\n", "]")
else
-- Following lines.
entityFile:seek("end", -2) -- Seek a few bytes back, so we can overwrite some stuff.
entityFile:write(",\n\t", json.Marshal(rootEntity), "\n", "]")
end
-- Prevent recapturing.
rootEntity:AddTag("MapCaptured")
-- Disable some components.
for _, componentTypeName in ipairs(componentTypeNamesToDisable) do
local components = rootEntity:GetComponents(componentTypeName)
for _, component in ipairs(components) do
rootEntity:SetComponentsEnabled(component, false)
end
end
-- Modify the gravity of every VelocityComponent, so stuff will not fall.
local component = rootEntity:GetFirstComponent("VelocityComponent")
if component then
component:SetValue("gravity_x", 0)
component:SetValue("gravity_y", 0)
end
-- Modify the gravity of every CharacterPlatformingComponent, so mobs will not fall.
local component = rootEntity:GetFirstComponent("CharacterPlatformingComponent")
if component then
component:SetValue("pixel_gravity", 0)
end
-- Disable the hover and spinning animations of every ItemComponent.
local component = rootEntity:GetFirstComponent("ItemComponent")
if component then
component:SetValue("play_hover_animation", false)
component:SetValue("play_spinning_animation", false)
end
-- Disable the hover animation of cards. Disabling the "SpriteOffsetAnimatorComponent" does not help.
local components = rootEntity:GetComponents("SpriteOffsetAnimatorComponent")
for _, component in ipairs(components) do
component:SetValue("x_speed", 0)
component:SetValue("y_speed", 0)
component:SetValue("x_amount", 0)
component:SetValue("y_amount", 0)
end
end
end
-- Ensure everything is written to disk before noita decides to crash.
entityFile:flush()
end
--- Captures a screenshot at the given coordinates.
@ -81,60 +172,24 @@ local function captureScreenshot(x, y, rx, ry, entityFile)
DrawUI()
wait(0)
UiCaptureDelay = UiCaptureDelay + 1
until DoesWorldExistAt(xMin, yMin, xMax, yMax) -- Chunks will be drawn on the *next* frame.
-- Capture all entities right after the camera frame was moved.
local ok, err = pcall(captureEntities, entityFile, x, y, 5000)
if not ok then
print(string.format("Entity capture error: %s", err))
end
until DoesWorldExistAt(xMin, yMin, xMax, yMax) and UiCaptureDelay > 25 -- Chunks will be drawn on the *next* frame.
wait(0) -- Without this line empty chunks may still appear, also it's needed for the UI to disappear.
if not TriggerCapture(rx, ry) then
UiCaptureProblem = "Screen capture failed. Please restart Noita."
end
-- Capture entities right after capturing the screenshot.
if entityFile then
local ok, err = pcall(function()
local radius = math.sqrt(virtualHalfWidth^2 + virtualHalfHeight^2) + 1
local entities = noitaAPI.Entity.GetInRadius(x, y, radius)
for _, entity in ipairs(entities) do
-- Get to the root entity, as we are exporting entire entity trees.
local rootEntity = entity:GetRootEntity()
-- Make sure to only export entities when they are encountered the first time.
if not rootEntity:HasTag("MapCaptured") then
-- Some hacky way to generate valid JSON that doesn't break when the game crashes.
-- Well, as long as it does not crash between write and flush.
if entityFile:seek("end") == 0 then
-- First line.
entityFile:write("[\n\t", json.Marshal(rootEntity), "\n", "]")
else
-- Following lines.
entityFile:seek("end", -2) -- Seek a few bytes back, so we can overwrite some stuff.
entityFile:write(",\n\t", json.Marshal(rootEntity), "\n", "]")
end
rootEntity:AddTag("MapCaptured") -- Prevent recapturing.
end
end
end)
if not ok then
print("Entity export error:", err)
end
entityFile:flush() -- Ensure everything is written to disk before noita decides to crash.
end
-- Reset monitor and PC standby each screenshot.
ResetStandbyTimer()
end
local function createOrOpenEntityCaptureFile()
-- Make sure the file exists.
local file = io.open("mods/noita-mapcap/output/entities.json", "a")
if file ~= nil then file:close() end
-- Create or reopen entities CSV file.
file = io.open("mods/noita-mapcap/output/entities.json", "r+b") -- Open for reading (r) and writing (+) in binary mode. r+b will not truncate the file to 0.
if file == nil then return nil end
return file
end
function startCapturingSpiral()
local entityFile = createOrOpenEntityCaptureFile()
@ -149,8 +204,6 @@ function startCapturingSpiral()
local virtualHalfWidth, virtualHalfHeight = math.floor(virtualWidth / 2), math.floor(virtualHeight / 2)
preparePlayer()
GameSetCameraFree(true)
-- Coroutine to calculate next coordinate, and trigger screenshots.
@ -233,8 +286,6 @@ function startCapturingHilbert(area)
UiProgress = {Progress = 0, Max = gridWidth * gridHeight}
preparePlayer()
GameSetCameraFree(true)
-- Coroutine to calculate next coordinate, and trigger screenshots.

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2019-2020 David Vogel
-- Copyright (c) 2019-2022 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -9,8 +9,7 @@
local oldPrint = print
function print(...)
local arg = {...}
stringArgs = {}
local stringArgs = {}
for i, v in ipairs(arg) do
table.insert(stringArgs, tostring(v))
@ -23,8 +22,7 @@ end
--[[local logFile = io.open("lualog.txt", "w")
function print(...)
local arg = {...}
stringArgs = {}
local stringArgs = {}
local result = ""
for i, v in ipairs(arg) do

View File

@ -48,7 +48,15 @@ function NoitaComponent:MarshalJSON()
if membersTable then
for k, v in pairs(membersTable) do
if not componentValueKeysWithInvalidType[k] then
members[k] = self:GetValue(k) -- Try to get value with correct type. Assuming nil is an error, but this is not always the case... meh.
local packedResult = table.pack(self:GetValue(k)) -- Try to get value with correct type. Assuming nil is an error, but this is not always the case... meh.
if packedResult.n == 0 then
members[k] = nil -- Write no result as nil. Basically do nothing.
elseif packedResult.n == 1 then
members[k] = packedResult[1] -- Write single value result as single value.
else
packedResult.n = nil -- Discard n field, otherwise this is not a pure array.
members[k] = packedResult -- Write multi value result as array.
end
end
if members[k] == nil then
componentValueKeysWithInvalidType[k] = true
@ -187,10 +195,15 @@ end
---Returns a table of components filtered by the given parameters.
---@param componentTypeName string
---@param tag string
---@param tag string|nil
---@return NoitaComponent[]
function NoitaEntity:GetComponents(componentTypeName, tag)
local componentIDs = EntityGetComponent(self.ID, componentTypeName, tag) or {}
local componentIDs
if tag ~= nil then
componentIDs = EntityGetComponent(self.ID, componentTypeName, tag) or {}
else
componentIDs = EntityGetComponent(self.ID, componentTypeName) or {}
end
local result = {}
for _, componentID in ipairs(componentIDs) do
table.insert(result, setmetatable({ ID = componentID }, NoitaComponent))
@ -200,10 +213,15 @@ end
---Returns the first component of this entity that fits the given parameters.
---@param componentTypeName string
---@param tag string
---@param tag string|nil
---@return NoitaComponent|nil
function NoitaEntity:GetFirstComponent(componentTypeName, tag)
local componentID = EntityGetFirstComponent(self.ID, componentTypeName, tag)
local componentID
if tag ~= nil then
componentID = EntityGetFirstComponent(self.ID, componentTypeName, tag)
else
componentID = EntityGetFirstComponent(self.ID, componentTypeName)
end
if componentID == nil then
return nil
end
@ -426,15 +444,15 @@ end
---@param fieldName string
---@return any|nil
function NoitaComponent:GetValue(fieldName)
return ComponentGetValue2(self.ID, fieldName)
return ComponentGetValue2(self.ID, fieldName) -- TODO: Rework Noita API to handle vectors, and return a vector instead of some shitty multi value result
end
---Sets the value of a field. Value(s) should have a type matching the field type.
---Reports error if the values weren't given in correct type, the field type is not supported, or the component does not exist.
---@param fieldName string
---@param valueOrValues any|nil
function NoitaComponent:SetValue(fieldName, valueOrValues)
return ComponentSetValue2(self.ID, fieldName, valueOrValues)
---@param ... any|nil -- Vectors use one argument per dimension.
function NoitaComponent:SetValue(fieldName, ...)
return ComponentSetValue2(self.ID, fieldName, ...) -- TODO: Rework Noita API to handle vectors, and use a vector instead of shitty multi value arguments
end
---Returns one or many values matching the type or subtypes of the requested field in a component subobject.
@ -445,16 +463,16 @@ end
---@param fieldName string
---@return any|nil
function NoitaComponent:ObjectGetValue(objectName, fieldName)
return ComponentObjectGetValue2(self.ID, objectName, fieldName)
return ComponentObjectGetValue2(self.ID, objectName, fieldName) -- TODO: Rework Noita API to handle vectors, and return a vector instead of some shitty multi value result
end
---Sets the value of a field in a component subobject. Value(s) should have a type matching the field type.
---Reports error if the values weren't given in correct type, the field type is not supported or 'object_name' is not a metaobject.
---@param objectName string
---@param fieldName string
---@param valueOrValues any
function NoitaComponent:ObjectSetValue(objectName, fieldName, valueOrValues)
return ComponentObjectSetValue2(self.ID, objectName, fieldName, valueOrValues)
---@param ... any|nil -- Vectors use one argument per dimension.
function NoitaComponent:ObjectSetValue(objectName, fieldName, ...)
return ComponentObjectSetValue2(self.ID, objectName, fieldName, ...) -- TODO: Rework Noita API to handle vectors, and use a vector instead of shitty multi value arguments
end
---Creates a component of type 'component_type_name' and adds it to 'entity_id'.
@ -473,26 +491,26 @@ function NoitaEntity:EntityAddComponent(componentTypeName, tableOfComponentValue
return setmetatable({ ID = componentID }, NoitaComponent)
end
---'type_stored_in_vector' should be "int", "float" or "string".
---
---@param arrayMemberName string
---@param typeStoredInVector string
---@param typeStoredInVector "int"|"float"|"string"
---@return number
function NoitaComponent:GetVectorSize(arrayMemberName, typeStoredInVector)
return ComponentGetVectorSize(self.ID, arrayMemberName, typeStoredInVector)
end
---'type_stored_in_vector' should be "int", "float" or "string".
---
---@param arrayName string
---@param typeStoredInVector string
---@param typeStoredInVector "int"|"float"|"string"
---@param index number
---@return number|number|string|nil
function NoitaComponent:GetVectorValue(arrayName, typeStoredInVector, index)
return ComponentGetVectorValue(self.ID, arrayName, typeStoredInVector, index)
end
---'type_stored_in_vector' should be "int", "float" or "string".
---
---@param arrayName string
---@param typeStoredInVector string
---@param typeStoredInVector "int"|"float"|"string"
---@return number[]|number|string|nil
function NoitaComponent:GetVector(arrayName, typeStoredInVector)
return ComponentGetVector(self.ID, arrayName, typeStoredInVector)

View File

@ -1,4 +1,4 @@
-- Copyright (c) 2019-2020 David Vogel
-- Copyright (c) 2019-2022 David Vogel
--
-- This software is released under the MIT License.
-- https://opensource.org/licenses/MIT
@ -23,7 +23,7 @@ function GamePrint(...)
end
for line in result:gmatch("[^\r\n]+") do
for i, v in ipairs(splitStringByLength(line, 100)) do
for i, v in ipairs(SplitStringByLength(line, 100)) do
oldGamePrint(v)
end
end
@ -105,3 +105,13 @@ function progressBarString(progress, look)
return string.format(look.Format, barString, progress.Progress, progress.Max, factor * 100)
end
---Returns a new table with all arguments stored into keys `1`, `2`, etc. and with a field `"n"` with the total number of arguments.
---@param ... any
---@return table
function table.pack(...)
t = {...}
t.n = select("#", ...)
return t
end