From 56f88c797f2c809b7793a7f039b4d44cba49e446 Mon Sep 17 00:00:00 2001 From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com> Date: Wed, 19 Jan 2022 02:25:24 +0000 Subject: automatically clear visibilityflags set by wargames death effects on early respawn --- .../mod/scripts/vscripts/mp/levels/mp_wargames.nut | 45 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'Northstar.CustomServers/mod/scripts/vscripts/mp/levels') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut index 11587947..3f3a05f2 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/levels/mp_wargames.nut @@ -2,6 +2,8 @@ untyped global function CodeCallback_MapInit struct { + array marvinSpawners + float introStartTime entity militiaPod entity imcPod @@ -20,13 +22,14 @@ void function CodeCallback_MapInit() SetEvacSpaceNode( GetEnt( "end_spacenode" ) ) // dissolve effects - AddDeathCallback( "player", WargamesDissolveDeadEntity ) + AddDeathCallback( "player", WargamesDissolveDeadEntity ) AddDeathCallback( "npc_soldier", WargamesDissolveDeadEntity ) AddDeathCallback( "npc_spectre", WargamesDissolveDeadEntity ) AddDeathCallback( "npc_pilot_elite", WargamesDissolveDeadEntity ) AddDeathCallback( "npc_marvin", WargamesDissolveDeadEntity ) - FlagClear( "Disable_Marvins" ) + AddSpawnCallback( "info_spawnpoint_marvin", AddMarvinSpawner ) + AddCallback_GameStateEnter( eGameState.Prematch, SpawnMarvinsForRound ) // currently disabled until finished: intro if ( !IsFFAGame() ) @@ -40,6 +43,44 @@ void function WargamesDissolveDeadEntity( entity deadEnt, var damageInfo ) { deadEnt.Dissolve( ENTITY_DISSOLVE_CHAR, < 0, 0, 0 >, 0 ) EmitSoundAtPosition( TEAM_UNASSIGNED, deadEnt.GetOrigin(), "Object_Dissolve" ) + + if ( deadEnt.IsPlayer() ) + thread EnsureWargamesDeathEffectIsClearedForPlayer( deadEnt ) + } +} + +void function EnsureWargamesDeathEffectIsClearedForPlayer( entity player ) +{ + // this is slightly shit but whatever lol + player.EndSignal( "OnDestroy" ) + + float startTime = Time() + while ( player.kv.VisibilityFlags != "0" ) + { + if ( Time() > startTime + 4.0 ) // if we wait too long, just ignore + return + + WaitFrame() + } + + player.kv.VisibilityFlags = ENTITY_VISIBLE_TO_EVERYONE +} + +void function AddMarvinSpawner( entity spawn ) +{ + file.marvinSpawners.append( spawn ) +} + +void function SpawnMarvinsForRound() +{ + foreach ( entity spawner in file.marvinSpawners ) + { + entity marvin = CreateMarvin( TEAM_UNASSIGNED, spawner.GetOrigin(), spawner.GetAngles() ) + marvin.kv.health = 1 + marvin.kv.max_health = 1 + marvin.kv.spawnflags = 516 + DispatchSpawn( marvin ) + HideName( marvin ) } } -- cgit v1.2.3