From db9778a64c1e9e6e8e3112a4d8077f78f868ab68 Mon Sep 17 00:00:00 2001 From: x3Karma Date: Mon, 9 May 2022 19:01:31 +0800 Subject: Harvester changes (#350) - changed from PropScriptDamaged to AddEntityCallback_OnDamaged - should also register damage if there's an opposing enemy player - changed HarvesterStruct to HarvesterStruct& - fix looping harvester shield regenning noise - format some code (i cant stand it) --- .../scripts/vscripts/gamemodes/_gamemode_fd.nut | 377 ++++++++++----------- 1 file changed, 188 insertions(+), 189 deletions(-) (limited to 'Northstar.CustomServers') diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut index a89d5a30..95428281 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut @@ -49,7 +49,7 @@ global struct WaveEvent{ -global HarvesterStruct fd_harvester +global HarvesterStruct& fd_harvester global vector shopPosition global array > waveEvents global table > routes @@ -101,14 +101,13 @@ void function GamemodeFD_Init() AddCallback_EntitiesDidLoad(LoadEntities) - AddDamageCallback("prop_script",OnDamagedPropScript) AddCallback_GameStateEnter(eGameState.Prematch,FD_createHarvester) AddCallback_GameStateEnter( eGameState.Playing,startMainGameLoop) AddCallback_OnClientConnected(GamemodeFD_InitPlayer) AddCallback_OnPlayerKilled(GamemodeFD_OnPlayerKilled) AddCallback_OnRoundEndCleanup(FD_NPCCleanup) AddDamageByCallback("player",FD_DamageByPlayerCallback) - + AddDeathCallback("npc_titan",OnNpcDeath) AddDeathCallback("npc_stalker",OnNpcDeath) @@ -148,7 +147,7 @@ void function GamemodeFD_InitPlayer(entity player) data.scoreThisRound = 0 file.players[player] <- data - + } void function OnNpcDeath( entity ent, var damageInfo ) @@ -158,7 +157,7 @@ void function OnNpcDeath( entity ent, var damageInfo ) { file.spawnedNPCs.remove( findIndex ) } - + } void function RateSpawnpoints_FD(int _0, array _1, int _2, entity _3){} @@ -166,7 +165,7 @@ void function RateSpawnpoints_FD(int _0, array _1, int _2, entity _3){} bool function useShieldBoost(entity player,array args) { if((GetGlobalNetTime("FD_harvesterInvulTime")0)) - { + { fd_harvester.harvester.SetShieldHealth(fd_harvester.harvester.GetShieldHealthMax()) SetGlobalNetTime("FD_harvesterInvulTime",Time()+5) MessageToTeam(TEAM_MILITIA,eEventNotifications.FD_PlayerHealedHarvester) @@ -177,20 +176,20 @@ bool function useShieldBoost(entity player,array args) } void function startMainGameLoop() -{ +{ thread mainGameLoop() } void function mainGameLoop() -{ +{ startHarvester() - + bool showShop = false for(int i = GetGlobalNetInt("FD_currentWave");i function getRoute(string routeName) -{ +{ array ret array currentNode = [] foreach(entity node in file.routeNodes) @@ -219,7 +218,7 @@ array function getRoute(string routeName) currentNode = [node] break } - + } if(currentNode.len()==0) { @@ -257,7 +256,7 @@ array function getEnemyTypesForWave(int wave) // npcs[eFD_AITypeIDs.ION]<-0 // npcs[eFD_AITypeIDs.MONARCH]<-0 // npcs[eFD_AITypeIDs.TITAN_SNIPER]<-0 - + foreach(WaveEvent e in waveEvents[wave]) { @@ -309,7 +308,7 @@ array function getEnemyTypesForWave(int wave) } bool function runWave(int waveIndex,bool shouldDoBuyTime) -{ +{ SetGlobalNetInt("FD_currentWave",waveIndex) file.havesterWasDamaged = false @@ -321,7 +320,7 @@ bool function runWave(int waveIndex,bool shouldDoBuyTime) { player.diedThisRound = false player.scoreThisRound = 0 - } + } array enemys = getEnemyTypesForWave(waveIndex) foreach(entity player in GetPlayerArray()) { @@ -329,21 +328,21 @@ bool function runWave(int waveIndex,bool shouldDoBuyTime) } if(shouldDoBuyTime) { - + OpenBoostStores() foreach(entity player in GetPlayerArray()) Remote_CallFunction_NonReplay(player,"ServerCallback_FD_NotifyStoreOpen") while(Time() highestDamage = [0.0,0.0,0.0] array highestDamageSource = [-1,-1,-1] @@ -399,12 +398,12 @@ bool function runWave(int waveIndex,bool shouldDoBuyTime) highestDamageSource[2] = index } } - + foreach(entity player in GetPlayerArray()) { Remote_CallFunction_NonReplay(player,"ServerCallback_FD_DisplayHarvesterKiller",GetGlobalNetInt("FD_restartsRemaining"),getHintForTypeId(highestDamageSource[0]),highestDamageSource[0],highestDamage[0]/totalDamage,highestDamageSource[1],highestDamage[1]/totalDamage,highestDamageSource[2],highestDamage[2]/totalDamage) } - + if(GetGlobalNetInt("FD_restartsRemaining")>0) FD_DecrementRestarts() else @@ -420,7 +419,7 @@ bool function runWave(int waveIndex,bool shouldDoBuyTime) MessageToTeam(TEAM_MILITIA,eEventNotifications.FD_AnnounceWaveEnd) if(waveIndexTime()) + + if ( GetGlobalNetTime( "FD_harvesterInvulTime" ) > Time() ) { - prop.SetShieldHealth(prop.GetShieldHealthMax()) - return + harvester.SetShieldHealth( harvester.GetShieldHealthMax() ) + return } int damageSourceID = DamageInfo_GetDamageSourceIdentifier( damageInfo ) entity attacker = DamageInfo_GetAttacker( damageInfo ) float damageAmount = DamageInfo_GetDamage( damageInfo ) - - if ( !damageSourceID ) - return - if ( !damageAmount ) - return + if ( !damageSourceID && !damageAmount && !attacker ) + return - if ( !attacker ) - return - //TODO Log damage source for round lose screen - fd_harvester.lastDamage = Time() - if(prop.GetShieldHealth()==0) - { - int attackerID = FD_GetAITypeID_ByString(attacker.GetTargetName()) - - file.harvesterDamageSource[attackerID] += damageAmount - - float newHealth = prop.GetHealth()-damageAmount - if(newHealth<0) - { - EmitSoundAtPosition(TEAM_UNASSIGNED,fd_harvester.harvester.GetOrigin(),"coop_generator_destroyed") - newHealth=0 - fd_harvester.rings.Destroy()//TODO death animation - } - - prop.SetHealth(newHealth) - file.havesterWasDamaged = true + if ( harvester.GetShieldHealth() == 0 ) + { + float newHealth = harvester.GetHealth() - damageAmount + if( newHealth <= 0 ) + { + EmitSoundAtPosition(TEAM_UNASSIGNED,fd_harvester.harvester.GetOrigin(),"coop_generator_destroyed") + newHealth = 0 + fd_harvester.rings.Destroy() + } + harvester.SetHealth( newHealth ) } - - + if ( DamageInfo_GetDamageSourceIdentifier( damageInfo ) == eDamageSourceId.mp_titancore_laser_cannon ) + DamageInfo_SetDamage( damageInfo, DamageInfo_GetDamage( damageInfo )/10 ) // laser core shreds super well for some reason + + if ( attacker.IsPlayer() ) + attacker.NotifyDidDamage( harvester, DamageInfo_GetHitBox( damageInfo ), DamageInfo_GetDamagePosition( damageInfo ), DamageInfo_GetCustomDamageType( damageInfo ), DamageInfo_GetDamage( damageInfo ), DamageInfo_GetDamageFlags( damageInfo ), DamageInfo_GetHitGroup( damageInfo ), DamageInfo_GetWeapon( damageInfo ), DamageInfo_GetDistFromAttackOrigin( damageInfo ) ) } void function FD_NPCCleanup() { - foreach(entity npc in GetEntArrayByClass_Expensive("C_AI_BaseNPC")){ - if(IsValid(npc)) + foreach ( entity npc in GetEntArrayByClass_Expensive("C_AI_BaseNPC") ) + if ( IsValid( npc ) ) npc.Destroy() - } } void function HarvesterThink() -{ +{ entity harvester = fd_harvester.harvester - - EmitSoundOnEntity(harvester,"coop_generator_startup") + + EmitSoundOnEntity( harvester,"coop_generator_startup" ) + float lastTime = Time() wait 4 int lastShieldHealth = harvester.GetShieldHealth() - generateBeamFX(fd_harvester) - generateShieldFX(fd_harvester) - - EmitSoundOnEntity(harvester,"coop_generator_ambient_healthy") - - + generateBeamFX( fd_harvester ) + generateShieldFX( fd_harvester ) + + EmitSoundOnEntity( harvester, "coop_generator_ambient_healthy" ) + bool isRegening = false // stops the regenning sound to keep stacking on top of each other - while(IsAlive(harvester)){ + while ( IsAlive( harvester ) ) + { float currentTime = Time() float deltaTime = currentTime -lastTime - if(IsValid(fd_harvester.particleShield)) + + if ( IsValid( fd_harvester.particleShield ) ) { vector shieldColor = GetShieldTriLerpColor(1.0-(harvester.GetShieldHealth().tofloat()/harvester.GetShieldHealthMax().tofloat())) EffectSetControlPointVector( fd_harvester.particleShield, 1, shieldColor ) } - if(IsValid(fd_harvester.particleBeam)) + + if( IsValid( fd_harvester.particleBeam ) ) { - vector beamColor = GetShieldTriLerpColor(1.0-(harvester.GetHealth().tofloat()/harvester.GetMaxHealth().tofloat())) + vector beamColor = GetShieldTriLerpColor( 1.0 - (harvester.GetHealth().tofloat() / harvester.GetMaxHealth().tofloat() ) ) EffectSetControlPointVector( fd_harvester.particleBeam, 1, beamColor ) } - if(fd_harvester.harvester.GetShieldHealth()==0) - if(IsValid(fd_harvester.particleShield)) + + if ( fd_harvester.harvester.GetShieldHealth() == 0 ) + if( IsValid( fd_harvester.particleShield ) ) fd_harvester.particleShield.Destroy() - if(((currentTime-fd_harvester.lastDamage)>=GENERATOR_SHIELD_REGEN_DELAY)&&(harvester.GetShieldHealth()= GENERATOR_SHIELD_REGEN_DELAY ) && ( harvester.GetShieldHealth() < harvester.GetShieldHealthMax() ) ) + { + if( !IsValid(fd_harvester.particleShield) ) generateShieldFX(fd_harvester) + //printt((currentTime-fd_harvester.lastDamage)) + if(harvester.GetShieldHealth()==0) EmitSoundOnEntity(harvester,"coop_generator_shieldrecharge_start") - EmitSoundOnEntity(harvester,"coop_generator_shieldrecharge_resume") - float newShieldHealth = (harvester.GetShieldHealthMax()/GENERATOR_SHIELD_REGEN_TIME*deltaTime)+harvester.GetShieldHealth() - if(newShieldHealth>=harvester.GetShieldHealthMax()) + + if (!isRegening) + { + EmitSoundOnEntity( harvester,"coop_generator_shieldrecharge_resume" ) + isRegening = true + } + + float newShieldHealth = ( harvester.GetShieldHealthMax() / GENERATOR_SHIELD_REGEN_TIME * deltaTime ) + harvester.GetShieldHealth() + + if ( newShieldHealth >= harvester.GetShieldHealthMax() ) { StopSoundOnEntity(harvester,"coop_generator_shieldrecharge_resume") harvester.SetShieldHealth(harvester.GetShieldHealthMax()) EmitSoundOnEntity(harvester,"coop_generator_shieldrecharge_end") - + isRegening = false } else { harvester.SetShieldHealth(newShieldHealth) } - } - if((lastShieldHealth>0)&&(harvester.GetShieldHealth()==0)) + } else if ( ( ( currentTime-fd_harvester.lastDamage) < GENERATOR_SHIELD_REGEN_DELAY ) && ( harvester.GetShieldHealth() < harvester.GetShieldHealthMax() ) ) + isRegening = false + + if ( ( lastShieldHealth > 0 ) && ( harvester.GetShieldHealth() == 0 ) ) EmitSoundOnEntity(harvester,"coop_generator_shielddown") + lastShieldHealth = harvester.GetShieldHealth() lastTime = currentTime WaitFrame() } - + } void function startHarvester() { - + thread HarvesterThink() thread HarvesterAlarm() @@ -632,36 +633,34 @@ void function HarvesterAlarm() void function initNetVars() { SetGlobalNetInt("FD_totalWaves",waveEvents.len()) - + if(!FD_HasRestarted()) { bool showShop = false SetGlobalNetInt("FD_currentWave",0) if(FD_IsDifficultyLevelOrHigher(eFDDifficultyLevel.INSANE)) FD_SetNumAllowedRestarts(0) - else + else FD_SetNumAllowedRestarts(2) } - + } void function FD_DamageByPlayerCallback(entity victim,var damageInfo) -{ +{ entity player = DamageInfo_GetAttacker(damageInfo) if(!(player in file.players)) return float damage = DamageInfo_GetDamage(damageInfo) file.players[player].damageDealt += damage file.players[player].scoreThisRound += damage //TODO NOT HOW SCORE WORKS - + } void function FD_createHarvester() { - HarvesterStruct ret = SpawnHarvester(file.harvester_info.GetOrigin(),file.harvester_info.GetAngles(),25000,6000,TEAM_MILITIA) - fd_harvester.harvester = ret.harvester - fd_harvester.rings = ret.rings - fd_harvester.lastDamage = ret.lastDamage + fd_harvester = SpawnHarvester(file.harvester_info.GetOrigin(),file.harvester_info.GetAngles(),25000,6000,TEAM_MILITIA) + AddEntityCallback_OnDamaged( fd_harvester.harvester, OnHarvesterDamaged ) } bool function isFinalWave() @@ -669,16 +668,16 @@ bool function isFinalWave() return ((GetGlobalNetInt("FD_currentWave")+1)==GetGlobalNetInt("FD_totalWaves")) } -void function LoadEntities() -{ - +void function LoadEntities() +{ + CreateBoostStoreLocation(TEAM_MILITIA,shopPosition,<0,0,0>) foreach ( entity info_target in GetEntArrayByClass_Expensive("info_target") ) { - + if ( GameModeRemove( info_target ) ) continue - + if(info_target.HasKey("editorclass")){ switch(info_target.kv.editorclass){ case"info_fd_harvester": @@ -705,7 +704,7 @@ void function LoadEntities() } void function titanNav_thread(entity titan, string routeName,float nextDistance = 500.0) -{ +{ titan.EndSignal( "OnDeath" ) titan.EndSignal( "OnDestroy" ) @@ -713,19 +712,19 @@ void function titanNav_thread(entity titan, string routeName,float nextDistance printt("Start NAV") if(!titan.IsNPC()) return - - + + array routeArray = getRoute(routeName) WaitFrame()//so other code setting up what happens on signals is run before this if(routeArray.len()==0) - { - + { + titan.Signal("OnFailedToPath") return } foreach(entity node in routeArray) - { + { if(!IsAlive(fd_harvester.harvester)) return if(Distance(fd_harvester.harvester.GetOrigin(),titan.GetOrigin()) arg } int function getHintForTypeId(int typeId) -{ +{ //this is maybe a bit of an naive aproch switch(typeId) { @@ -801,13 +800,13 @@ int function getHintForTypeId(int typeId) } /****************************************************************************************************************\ -####### # # ####### # # ####### ##### ####### # # ####### ###### # ####### ####### ###### -# # # # ## # # # # # ## # # # # # # # # # # # -# # # # # # # # # # # # # # # # # # # # # # # -##### # # ##### # # # # # #### ##### # # # ##### ###### # # # # # ###### -# # # # # # # # # # # # # # # # # ####### # # # # # -# # # # # ## # # # # # ## # # # # # # # # # # -####### # ####### # # # ##### ####### # # ####### # # # # # ####### # # +####### # # ####### # # ####### ##### ####### # # ####### ###### # ####### ####### ###### +# # # # ## # # # # # ## # # # # # # # # # # # +# # # # # # # # # # # # # # # # # # # # # # # +##### # # ##### # # # # # #### ##### # # # ##### ###### # # # # # ###### +# # # # # # # # # # # # # # # # # ####### # # # # # +# # # # # ## # # # # # ## # # # # # # # # # # +####### # ####### # # # ##### ####### # # ####### # # # # # ####### # # \*****************************************************************************************************************/ WaveEvent function createSmokeEvent(vector position,float lifetime) @@ -966,17 +965,17 @@ WaveEvent function createCloakDroneEvent(vector origin,vector angles){ } /************************************************************************************************************\ -####### # # ####### # # ####### ####### # # # # ##### ####### ### ####### # # ##### -# # # # ## # # # # # ## # # # # # # # ## # # # -# # # # # # # # # # # # # # # # # # # # # # # -##### # # ##### # # # # ##### # # # # # # # # # # # # # ##### -# # # # # # # # # # # # # # # # # # # # # # # -# # # # # ## # # # # # ## # # # # # # # ## # # -####### # ####### # # # # ##### # # ##### # ### ####### # # ##### +####### # # ####### # # ####### ####### # # # # ##### ####### ### ####### # # ##### +# # # # ## # # # # # ## # # # # # # # ## # # # +# # # # # # # # # # # # # # # # # # # # # # # +##### # # ##### # # # # ##### # # # # # # # # # # # # # ##### +# # # # # # # # # # # # # # # # # # # # # # # +# # # # # ## # # # # # ## # # # # # # # ## # # +####### # ####### # # # # ##### # # ##### # ### ####### # # ##### \************************************************************************************************************/ void function spawnSmoke(SmokeEvent smokeEvent,SpawnEvent spawnEvent,WaitEvent waitEvent,SoundEvent soundEvent) -{ +{ printt("smoke") SmokescreenStruct smokescreen smokescreen.smokescreenFX = $"P_smokescreen_FD" @@ -992,7 +991,7 @@ void function spawnSmoke(SmokeEvent smokeEvent,SpawnEvent spawnEvent,WaitEvent w } void function spawnArcTitan(SmokeEvent smokeEvent,SpawnEvent spawnEvent,WaitEvent waitEvent,SoundEvent soundEvent) -{ +{ PingMinimap(spawnEvent.origin.x, spawnEvent.origin.y, 4, 600, 150, 0) entity npc = CreateArcTitan(TEAM_IMC,spawnEvent.origin,spawnEvent.angles) file.spawnedNPCs.append(npc) @@ -1007,7 +1006,7 @@ void function waitForTime(SmokeEvent smokeEvent,SpawnEvent spawnEvent,WaitEvent { float waitUntil = Time() + waitEvent.amount while(Time() ) SetTeam( pod, team ) InitFireteamDropPod( pod ) waitthread LaunchAnimDropPod( pod, "pod_testpath", origin, <0,0,0> ) - + string squadName = MakeSquadName( team, UniqueString( "ZiplineTable" ) ) array guys - - for ( int i = 0; i < 4; i++ ) + + for ( int i = 0; i < 4; i++ ) { entity guy = CreateSoldier( team, origin,<0,0,0> ) - + SetTeam( guy, team ) guy.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE ) DispatchSpawn( guy ) - + SetSquad( guy, squadName ) guys.append( guy ) } - + ActivateFireteamDropPod( pod, guys ) } void function CreateTrackedDroppodSpectreMortar( vector origin, int team) { - - + + entity pod = CreateDropPod( origin, <0,0,0> ) SetTeam( pod, team ) InitFireteamDropPod( pod ) waitthread LaunchAnimDropPod( pod, "pod_testpath", origin, <0,0,0> ) - + string squadName = MakeSquadName( team, UniqueString( "ZiplineTable" ) ) array guys - - for ( int i = 0; i < 4; i++ ) + + for ( int i = 0; i < 4; i++ ) { entity guy = CreateSpectre( team, origin,<0,0,0> ) - + SetTeam( guy, team ) guy.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE ) DispatchSpawn( guy ) - + SetSquad( guy, squadName ) guys.append( guy ) } - + ActivateFireteamDropPod( pod, guys ) } void function CreateTrackedDroppodStalker( vector origin, int team) { - - + + entity pod = CreateDropPod( origin, <0,0,0> ) SetTeam( pod, team ) InitFireteamDropPod( pod ) waitthread LaunchAnimDropPod( pod, "pod_testpath", origin, <0,0,0> ) - + string squadName = MakeSquadName( team, UniqueString( "ZiplineTable" ) ) array guys - - for ( int i = 0; i < 4; i++ ) + + for ( int i = 0; i < 4; i++ ) { entity guy = CreateStalker( team, origin,<0,0,0> ) - + SetTeam( guy, team ) guy.EnableNPCFlag( NPC_ALLOW_PATROL | NPC_ALLOW_INVESTIGATE | NPC_ALLOW_HAND_SIGNALS | NPC_ALLOW_FLEE ) DispatchSpawn( guy ) - + SetSquad( guy, squadName ) guys.append( guy ) } - + ActivateFireteamDropPod( pod, guys ) } @@ -1214,10 +1213,10 @@ void function PingMinimap(float x, float y, float duration, float spreadRadius, } void function waitUntilLessThanAmountAlive(int amount) -{ +{ printt("start wait") int aliveTitans = file.spawnedNPCs.len() - + while(aliveTitans>amount) { WaitFrame() @@ -1229,10 +1228,10 @@ void function waitUntilLessThanAmountAlive(int amount) } void function waitUntilLessThanAmountAlive_expensive(int amount) -{ +{ printt("start wait") int aliveTitans = GetEntArrayByClassWildCard_Expensive("*npc*").len() - + while(aliveTitans>amount) { WaitFrame() @@ -1241,4 +1240,4 @@ void function waitUntilLessThanAmountAlive_expensive(int amount) break printt("titans alive ", aliveTitans) } -} \ No newline at end of file +} -- cgit v1.2.3