From: hgn Date: Thu, 28 Mar 2024 21:20:55 +0000 (+0000) Subject: option between water plane / water trigger X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=bf13ef74cc454e1e820928484204ac67eb98a308;hp=bececcbb7b2e886e72425e7c070e1fdc3aa126dc;p=carveJwlIkooP6JGAAIwe30JlM.git option between water plane / water trigger --- diff --git a/entity.c b/entity.c index ae506bd..ffb5dee 100644 --- a/entity.c +++ b/entity.c @@ -11,6 +11,9 @@ #include "ent_region.h" #include "ent_glider.h" #include "ent_npc.h" +#include "world_water.h" + +#include void entity_call( world_instance *world, ent_call *call ) { @@ -30,7 +33,8 @@ void entity_call( world_instance *world, ent_call *call ) [k_ent_miniworld] = ent_miniworld_call, [k_ent_region] = ent_region_call, [k_ent_glider] = ent_glider_call, - [k_ent_npc] = ent_npc_call + [k_ent_npc] = ent_npc_call, + [k_ent_water] = ent_water_call, }; if( type >= vg_list_size(table) ){ @@ -58,10 +62,12 @@ void entity_call( world_instance *world, ent_call *call ) ent_marker *ent_find_marker( mdl_context *mdl, mdl_array_ptr *arr, const char *alias ) { - for( u32 i=0; ipstr_alias ), alias ) ){ + if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ) + { return marker; } } diff --git a/maps_src/mp_line1/main.mdl b/maps_src/mp_line1/main.mdl index bd56b3c..21dc6ee 100644 Binary files a/maps_src/mp_line1/main.mdl and b/maps_src/mp_line1/main.mdl differ diff --git a/player_glide.c b/player_glide.c index 4a5958e..6b5930b 100644 --- a/player_glide.c +++ b/player_glide.c @@ -273,11 +273,15 @@ void player_glide_update(void) v2f steer; joystick_state( k_srjoystick_steer, steer ); - if( glider_physics( steer ) ){ + if( glider_physics( steer ) ) + { vg_info( "player fell off due to glider hitting ground\n" ); player__dead_transition( k_player_die_type_generic ); localplayer.glider_orphan = 1; } + + if( !world_water_player_safe( world_current_instance(), 1.0f ) ) + return; } void player_glide_post_update(void) diff --git a/player_skate.c b/player_skate.c index 2dedefd..eb12d64 100644 --- a/player_skate.c +++ b/player_skate.c @@ -2230,20 +2230,10 @@ void player__skate_update(void){ struct player_skate_state *state = &player_skate.state; world_instance *world = world_current_instance(); - if( state->activity == k_skate_activity_handplant ){ + if( state->activity == k_skate_activity_handplant ) return; - } - if( world->water.enabled ){ - if( localplayer.rb.co[1]+0.25f < world->water.height ){ - vg_info( "player fell off due to being in water\n" ); - player__networked_sfx( k_player_subsystem_walk, 32, - k_player_walk_soundeffect_splash, - localplayer.rb.co, 1.0f ); - player__dead_transition( k_player_die_type_generic ); - return; - } - } + if( !world_water_player_safe( world, 0.25f ) ) return; v3_copy( localplayer.rb.co, state->prev_pos ); state->activity_prev = state->activity; diff --git a/player_walk.c b/player_walk.c index b892634..843a50e 100644 --- a/player_walk.c +++ b/player_walk.c @@ -468,17 +468,7 @@ static void player_walk_update_generic(void){ v3_zero( localplayer.rb.w ); world_instance *world = world_current_instance(); - - if( world->water.enabled ){ - if( localplayer.rb.co[1]+0.4f < world->water.height ){ - player__networked_sfx( k_player_subsystem_walk, 32, - k_player_walk_soundeffect_splash, - localplayer.rb.co, 1.0f ); - vg_info( "player fell of due to walking into walker\n" ); - player__dead_transition( k_player_die_type_generic ); - return; - } - } + if( !world_water_player_safe( world, 0.4f ) ) return; enum walk_activity prev_state = w->state.activity; diff --git a/skaterift_blender/sr_main.py b/skaterift_blender/sr_main.py index 1f4910b..b715493 100644 --- a/skaterift_blender/sr_main.py +++ b/skaterift_blender/sr_main.py @@ -55,7 +55,7 @@ MDL_VERSION_NR = 106 SR_TRIGGERABLE = [ 'ent_audio', 'ent_ccmd', 'ent_gate', 'ent_challenge', \ 'ent_relay', 'ent_skateshop', 'ent_objective', 'ent_route',\ 'ent_miniworld', 'ent_region', 'ent_glider', 'ent_list',\ - 'ent_npc' ] + 'ent_npc', 'ent_water' ] def get_entity_enum_id( alias ): #{ @@ -338,6 +338,7 @@ class ent_water(Structure): ("max_dist",c_float), ("reserved0",c_uint32), ("reserved1",c_uint32)] + sr_functions = { 0: "drown" } #} class volume_trigger(Structure): @@ -1781,6 +1782,9 @@ def sr_compile( collection ): else: worldinfo.timezone = obj_data.timezone + if obj_data.water_safe: + flags |= 0x2 + worldinfo.flags = flags worldinfo.pstr_skybox = sr_compile_string( obj_data.skybox ) sr_ent_push( worldinfo ) @@ -3316,8 +3320,11 @@ class SR_OBJECT_ENT_WORLD_INFO(bpy.types.PropertyGroup): timezone: bpy.props.FloatProperty(name="Timezone(hrs) (UTC0 +hrs)") fixed_time: bpy.props.FloatProperty(name="Fixed Time (0-1)") + water_safe: bpy.props.BoolProperty(name="Water is Safe") + @staticmethod - def sr_inspector( layout, data ):#{ + def sr_inspector( layout, data ): + #{ layout.prop( data[0], 'name' ) layout.prop( data[0], 'desc' ) layout.prop( data[0], 'author' ) @@ -3327,6 +3334,8 @@ class SR_OBJECT_ENT_WORLD_INFO(bpy.types.PropertyGroup): layout.prop( data[0], 'fixed_time' ) else: layout.prop( data[0], 'timezone' ) + + layout.prop( data[0], 'water_safe' ) #} #} diff --git a/world_render.c b/world_render.c index e1a3088..4b6568b 100644 --- a/world_render.c +++ b/world_render.c @@ -145,15 +145,6 @@ static GLuint world_get_texture( world_instance *world, u32 id ){ else return world->textures[ id ]; } -#if 0 -static void bindpoint_diffuse_texture1( world_instance *world, - struct world_surface *mat ){ - glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, - world_get_texture(world,mat->info.tex_diffuse) ); -} -#endif - /* * Passes Rendering * ---------------------------------------------------------------------------- diff --git a/world_water.c b/world_water.c index 970ea22..dc8206b 100644 --- a/world_water.c +++ b/world_water.c @@ -2,15 +2,15 @@ * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved */ -#ifndef WATER_C -#define WATER_C - #include "world_water.h" #include "world_render.h" #include "render.h" #include "shaders/scene_water.h" #include "shaders/scene_water_fast.h" #include "scene.h" +#include "player.h" +#include "player_walk.h" +#include "player_dead.h" struct world_water world_water; @@ -225,4 +225,36 @@ void render_water_surface( world_instance *world, vg_camera *cam ) } } -#endif /* WATER_C */ +static void world_water_drown(void) +{ + player__networked_sfx( k_player_subsystem_walk, 32, + k_player_walk_soundeffect_splash, + localplayer.rb.co, 1.0f ); + vg_info( "player fell of due to walking into walker\n" ); + player__dead_transition( k_player_die_type_generic ); +} + +bool world_water_player_safe( world_instance *world, f32 allowance ) +{ + if( !world->water.enabled ) return 1; + if( world->info.flags & 0x2 ) return 1; + + if( localplayer.rb.co[1]+allowance < world->water.height ) + { + world_water_drown(); + return 0; + } + + return 1; +} + +entity_call_result ent_water_call( world_instance *world, ent_call *call ) +{ + if( call->function == 0 ) + { + world_water_drown(); + return k_entity_call_result_OK; + } + + return k_entity_call_result_unhandled; +} diff --git a/world_water.h b/world_water.h index 47855b2..7ff9af5 100644 --- a/world_water.h +++ b/world_water.h @@ -14,3 +14,5 @@ void world_water_init(void); void water_set_surface( world_instance *world, f32 height ); void render_water_texture( world_instance *world, vg_camera *cam ); void render_water_surface( world_instance *world, vg_camera *cam ); +entity_call_result ent_water_call( world_instance *world, ent_call *call ); +bool world_water_player_safe( world_instance *world, f32 allowance );