diff options
author | RoyalBlue1 <malte.hoermeyer@web.de> | 2022-02-17 19:20:49 +0100 |
---|---|---|
committer | RoyalBlue1 <malte.hoermeyer@web.de> | 2022-03-25 19:58:11 +0100 |
commit | 62a2ffddc21cd6c8dba8dd7e072fbbad3194683f (patch) | |
tree | fb0420698176ed9fba94bd7afaae4f2d2659d72d /Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut | |
parent | c7178117149bdf57ba40a6a32d9022588ba998aa (diff) | |
download | NorthstarMods-62a2ffddc21cd6c8dba8dd7e072fbbad3194683f.tar.gz NorthstarMods-62a2ffddc21cd6c8dba8dd7e072fbbad3194683f.zip |
Harvester Color change with health
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut')
-rw-r--r-- | Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut | 137 |
1 files changed, 135 insertions, 2 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut index 84361454..8e5a0188 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_fd.nut @@ -1,17 +1,32 @@ global function GamemodeFD_Init global function RateSpawnpoints_FD +global function useHarvesterShieldBoost +struct HarvesterStruct { + entity harvester + entity particleBeam + entity particleShield + entity rings + float lastDamage + bool shieldBoost + +} + struct { array<entity> aiSpawnpoints array<entity> smokePoints array<entity> routeNodes + HarvesterStruct harvester + table<string,float> harvesterDamageSource + bool haversterWasDamaged }file void function GamemodeFD_Init() { PrecacheModel( MODEL_ATTRITION_BANK ) AddCallback_EntitiesDidLoad(LoadEntities) + AddDamageCallback("prop_script",OnDamagedPropScript) } void function RateSpawnpoints_FD(int _0, array<entity> _1, int _2, entity _3) @@ -19,6 +34,22 @@ void function RateSpawnpoints_FD(int _0, array<entity> _1, int _2, entity _3) } +bool function useHarvesterShieldBoost() //returns true when acturally used +{ + if(file.harvester.harvester.GetShieldHealth()<file.harvester.harvester.GetShieldHealthMax()) + { + thread useHarvesterShieldBoost_threaded() + return true + } + return false +} +bool function useHarvesterShieldBoost_threaded() +{ + file.harvester.shieldBoost = true + wait 5 + file.Harvester.shieldBoost = false +} + void function spawnSmokes() { @@ -38,7 +69,7 @@ array<entity> function getRoute(string routeName) return [] } -vector function getShopPosition() +vector function getShopPosition() { switch(GetMapName()) { @@ -51,12 +82,104 @@ vector function getShopPosition() } +void function waveStart() +{ + file.haversterWasDamaged = false +} + + +void function OnDamagedPropScript(entity prop,var damageInfo) +{ + + if(!IsValid(file.harvester.harvester)) + return + + if(!IsValid(prop)) + return + + if(file.harvester.harvester!=prop) + return + + if(structHarvester.shieldBoost) + { + 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 ( !attacker ) + return + //TODO Log damage source for round lose screen + file.harvester.lastDamage = Time() + if(prop.GetShieldHealth()==0) + { + float newHealth = prop.GetHealth()-damageAmount + if(newHealth<0) + { + newHealth=0 + file.harvester.rings.Destroy() + } + + + prop.SetHealth(newHealth) + file.haversterWasDamaged = true + } + + + +} + +void function HarvesterThink(HarvesterStruct structHarvester) +{ + entity harvester = structHarvester.harvester + entity particleBeam = structHarvester.particleBeam + entity particleShield = structHarvester.particleShield + + float lastTime = Time() + WaitFrame() + + + + while(IsAlive(harvester)){ + float currentTime = Time() + float deltaTime = currentTime -lastTime + vector shieldColor = GraphCappedVector(harvester.GetShieldHealth(), 0, harvester.GetShieldHealthMax(),TEAM_COLOR_ENEMY, TEAM_COLOR_FRIENDLY) + EffectSetControlPointVector( particleShield, 1, shieldColor ) + vector beamColor = GraphCappedVector(harvester.GetHealth(), 0, harvester.GetMaxHealth(), TEAM_COLOR_ENEMY, TEAM_COLOR_FRIENDLY) + EffectSetControlPointVector( particleBeam, 1, beamColor ) + if(((currentTime-structHarvester.lastDamage)>=GENERATOR_SHIELD_REGEN_DELAY)&&(harvester.GetShieldHealth()<harvester.GetShieldHealthMax())) + { + printt((currentTime-structHarvester.lastDamage)) + float newShieldHealth = (harvester.GetShieldHealthMax()/GENERATOR_SHIELD_REGEN_TIME*deltaTime)+harvester.GetShieldHealth() + if(newShieldHealth>=harvester.GetShieldHealthMax()) + { + harvester.SetShieldHealth(harvester.GetShieldHealthMax()) + } + else + { + harvester.SetShieldHealth(newShieldHealth) + } + } + lastTime = currentTime + WaitFrame() + } + +} void function LoadEntities() { CreateBoostStoreLocation(TEAM_MILITIA,getShopPosition(),<0,0,0>) - + OpenBoostStores() @@ -74,12 +197,16 @@ void function LoadEntities() harvester.SetOrigin( info_target.GetOrigin() ) harvester.SetAngles( info_target.GetAngles() ) harvester.kv.solid = SOLID_VPHYSICS + + harvester.SetMaxHealth(25000) harvester.SetHealth(25000) harvester.SetShieldHealthMax(6000) harvester.SetShieldHealth(6000) SetTeam(harvester,TEAM_IMC) DispatchSpawn( harvester ) + SetGlobalNetEnt("FD_activeHarvester",harvester) + // entity blackbox = CreatePropDynamic(MODEL_HARVESTER_TOWER_COLLISION,info_target.GetOrigin(),info_target.GetAngles(),6) // blackbox.Hide() // blackbox.kv.CollisionGroup = TRACE_COLLISION_GROUP_PLAYER @@ -92,6 +219,12 @@ void function LoadEntities() entity Harvester_Shield = StartParticleEffectOnEntity_ReturnEntity(harvester,GetParticleSystemIndex(FX_HARVESTER_OVERSHIELD),FX_PATTACH_ABSORIGIN_FOLLOW,0) EffectSetControlPointVector( Harvester_Shield, 1, < 126.0, 188.0, 236.0 > ) + file.harvester.harvester = harvester + file.harvester.particleBeam = Harvester_Beam + file.harvester.particleShield = Harvester_Shield + file.harvester.lastDamage = Time() + file.harvester.rings = rings + thread HarvesterThink(file.harvester) break case"info_fd_mode_model": entity prop = CreatePropDynamic( info_target.GetModelName(), info_target.GetOrigin(), info_target.GetAngles(), 6 ) |