Code viewer
Freezing Fog
#CustomActor
Applies a freezing effect on the player, damaging them every 2 seconds.
Applies a freezing fog effect to the player, causing them to take 2 damage and slow down. If you are about to use, found any issues in this Script, please let me know through discord: @SamiSha#0001
Uses 3 different classes:
SS_FreezingFogVolume
A custom volume that applies the effects while inside it.
SS_StatusEffect_FreezingFog
Applies all ice filter, the material on top of the player, damages the player every 2 seconds as long they are inside or some conditions occurs.
SS_StatusEffect_SlowingCold
30% slow reduction, only applies when you take the first hit, does not stack! Removed when the OnRemoved function is called in SS_StatusEffect_FreezingFog.
/** * * Copyright 2012-2015 Gears for Breakfast ApS. All Rights Reserved. * Applies a slowing freeze, every 2 seconds the player takes damage as long as they stay inside. */ class SS_FreezingFogVolume extends Volume placeable; var() Name VolumeName; var(Volume) Array<int> PermittedActs; var(Volume) Array<int> ForbiddenActs; var transient bool HasCheckedPermissions; var(Volume) bool Enabled; defaultproperties { bStatic = false; Enabled = true; } function CheckPermissions() { HasCheckedPermissions = true; if (Role == Role_Authority && Owner == None && CreationTime <= 0 && Enabled) { if (PermittedActs.Length > 0 && PermittedActs.Find(Hat_GameManager(worldinfo.game).GetCurrentAct()) == INDEX_NONE) { Enabled = false; return; } if (ForbiddenActs.Length > 0 && ForbiddenActs.Find(Hat_GameManager(worldinfo.game).GetCurrentAct()) != INDEX_NONE) { Enabled = false; return; } } } simulated function bool CanActivate(Actor Other) { if (!HasCheckedPermissions) CheckPermissions(); if (!Enabled) return false; if (VolumeName == '') return false; if (Hat_Player(Other) != None && !Hat_Player(Other).bIsPlayerOwner) return false; if (!Other.IsA('Pawn')) return false; if (Pawn(Other).Controller == None) return false; if (!Pawn(Other).Controller.IsA('Hat_PlayerController')) return false; return true; } simulated function bool IsTouchingOtherRelevantMusicVolumes(Actor Other) { local SS_FreezingFogVolume Fog; foreach Hat_Player(Other).TouchingActors(class'SS_FreezingFogVolume', Fog) { if (Fog == self) continue; if (!Fog.CanActivate(Other)) continue; return true; } return false; } simulated event Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal ) { local SS_StatusEffect_FreezingFog freezingfog; local SS_StatusEffect_IcePower ice; if(!Other.IsA('Hat_Player')) return; freezingfog = SS_StatusEffect_FreezingFog(Hat_Player(Other).GetStatusEffect(class'SS_StatusEffect_FreezingFog',false)); if (!HasCheckedPermissions) CheckPermissions(); if (CanActivate(Other)) { `SetMusicParameterInt(VolumeName, 1); if(Hat_Player(Other).HasStatusEffect(class'SS_StatusEffect_FreezingFog')) { freezingfog.LeftVolume = false; freezingfog.VolumeExitTimer = 0.75; } else Hat_Player(Other).GiveStatusEffect(class'SS_StatusEffect_FreezingFog'); if(Hat_Player(Other).HasStatusEffect(class'SS_StatusEffect_IcePower', false) && CheckForFogUpgrade(Other)) { ice = SS_StatusEffect_IcePower(Hat_Player(Other).GetStatusEffect(class'SS_StatusEffect_IcePower',false)); ice.InsideFog = true; // Causes the ability to last longer while inside the fog } } Super.Touch( Other, OtherComp, HitLocation, HitNormal ); } function bool CheckForFogUpgrade(Actor Other) { local Hat_PlayerController pc; pc = Hat_PlayerController(Pawn(Other).Controller); if (pc.GetLoadout().HasCollectible(class'SS_Collectible_Shard_Ice', 1)) return true; return false; } simulated event UnTouch( Actor Other ) { local SS_StatusEffect_FreezingFog freezingfog; local SS_StatusEffect_IcePower ice; if(!Other.IsA('Hat_Player')) return; freezingfog = SS_StatusEffect_FreezingFog(Hat_Player(Other).GetStatusEffect(class'SS_StatusEffect_FreezingFog',false)); if (Hat_Player(Other) != None && !Hat_Player(Other).bIsPlayerOwner) return; if (CanActivate(Other) && !IsTouchingOtherRelevantMusicVolumes(Other)) { `SetMusicParameterInt(VolumeName, 0); if(Hat_Player(Other).HasStatusEffect(class'SS_StatusEffect_FreezingFog')) { freezingfog.LeftVolume = true; } if(Hat_Player(Other).HasStatusEffect(class'SS_StatusEffect_IcePower', false) && CheckForFogUpgrade(Other)) { ice = SS_StatusEffect_IcePower(Hat_Player(Other).GetStatusEffect(class'SS_StatusEffect_IcePower',false)); ice.InsideFog = false; } } Super.UnTouch(Other); } simulated function Deactivate() { local Actor a; SetCollision(false, bBlockActors); Enabled = false; foreach TouchingActors(class'Actor', a) { UnTouch(a); } }
class SS_StatusEffect_FreezingFog extends Hat_StatusEffect; var SoundCue ColdSound; var SoundCue FirePowerRemoved; const FreezingDelay = 0.75f; const FirstDamageDelay = 1.25f; const DamageDelay = 2.0f; const VolumeExitDelay = 0.75; var float FreezingTimer; var float FirstDamageTimer; var float DamageTimer; // var bool IsFrozen; var bool LeftVolume; var float VolumeExitTimer; defaultproperties { Duration = -1; ColdSound = SoundCue'HatinTime_SFX_Player5.SoundCues.player_cold_overlay'; FirePowerRemoved = SoundCue'hatintime_sfx_deathwish.SoundCues.Overheating_Water_CoolDown'; } function OnAdded(Actor a) { Super.OnAdded(a); FreezingTimer = FreezingDelay; FirstDamageTimer = FirstDamageDelay; DamageTimer = DamageDelay; VolumeExitTimer = VolumeExitDelay; } simulated function OnRemoved(Actor a) { if(FreezingTimer <= 0) RemoveFreeze(); FirstDamageTimer = 1.0f; DamageTimer = 1.0f; Hat_Player(a).RemoveStatusEffect(class'SS_StatusEffect_SlowingCold'); RemovePlayer(a); } function RemovePlayer(Actor a) { Super.OnRemoved(a); } function bool Update(float d) { local Hat_Player plyr; plyr = Hat_Player(Owner); if (!Super.Update(d) || plyr == None) return false; if(LeftVolume) VolumeExitTimer -= d; else if(FreezingTimer >= 0) FreezingTimer -= d; else if(FirstDamageTimer >= 0) FirstDamageTimer -= d; else DamageTimer -= d; if(VolumeExitTimer <= 0) plyr.RemoveStatusEffect(class'SS_StatusEffect_FreezingFog'); if(FreezingTimer <= 0 && FirstDamageTimer == 1.25f && DamageTimer == 2.0f){ if(plyr.HasStatusEffect(class'SS_StatusEffect_FirePower')){ RemoveFirePower(); FreezingTimer = 1.0f; } else if(plyr.HasStatusEffect(class'SS_StatusEffect_IcePower')) FreezingTimer = 0.33f; else FreezePlayer(); } if(FirstDamageTimer <= 0 && DamageTimer == 2.0f) DamageFreeze(); if(DamageTimer <= 0){ DamageFreeze(); DamageTimer = 2.0f; } if(FreezingTimer <= 0 && (plyr.HasStatusEffect(class'SS_StatusEffect_IcePower') || plyr.HasStatusEffect(class'SS_StatusEffect_FirePower'))) ResetartFog(); return true; } function FreezePlayer() { local Hat_PlayerController pc; local Hat_Player plyr; pc = Hat_PlayerController(Owner); if (pc == None) { plyr = Hat_Player(Owner); pc = Hat_PlayerController(plyr.Controller); } else { plyr = Hat_Player(pc.Pawn); } Hat_HUD(pc.MyHUD).DoFreezingEffect(true); plyr.SetTransitionEffect('ColdWater', 0, 1, 1); plyr.PlaySound(ColdSound); plyr.RemoveStatusEffect(class'Hat_StatusEffect_Wet'); plyr.GiveStatusEffect(class'SS_StatusEffect_SlowingCold'); } function RemoveFreeze() { local Hat_PlayerController pc; local Hat_Player plyr; pc = Hat_PlayerController(Owner); if (pc == None) { plyr = Hat_Player(Owner); pc = Hat_PlayerController(plyr.Controller); } else { plyr = Hat_Player(pc.Pawn); } Hat_HUD(pc.MyHUD).DoFreezingEffect(false); plyr.SetTransitionEffect('ColdWater', 1, 0, 0.75); } function ResetartFog() { local Hat_PlayerController pc; local Hat_Player plyr; FreezingTimer = 0.75f; FirstDamageTimer = 1.25f; DamageTimer = 2.0f; pc = Hat_PlayerController(Owner); if (pc == None) { plyr = Hat_Player(Owner); pc = Hat_PlayerController(plyr.Controller); } else { plyr = Hat_Player(pc.Pawn); } Hat_HUD(pc.MyHUD).DoFreezingEffect(false); if(plyr.HasStatusEffect(class'SS_StatusEffect_IcePower')) return; else plyr.SetTransitionEffect('ColdWater', 1, 0, 0.25); } function RemoveFirePower() { Hat_Player(Owner).RemoveStatusEffect(class'SS_StatusEffect_FirePower'); Hat_Player(Owner).PlaySound(FirePowerRemoved); Hat_Player(Owner).GiveStatusEffect(class'Hat_StatusEffect_Wet'); } function DamageFreeze() { Hat_Player(Owner).TakeDamage(1.0, None, Hat_Player(Owner).Location, vect(0,0,0), class'Hat_DamageType_WorldNoAnim'); }
class SS_StatusEffect_SlowingCold extends Hat_StatusEffect; defaultproperties { Duration = -1; } function OnAdded(Actor a) { Super.OnAdded(a); } simulated function OnRemoved(Actor a) { Super.OnRemoved(a); } function bool Update(float d) { local Hat_Player plyr; plyr = Hat_Player(Owner); if (!Super.Update(d)) return false; if(plyr != None) { if (plyr.HasStatusEffect(class'Hat_StatusEffect_BadgeSprint', true) || plyr.HasStatusEffect(class'Hat_StatusEffect_BadgeScooter', true)) { plyr.StatusEffects.Sort(Sort_MoveStatusToEnd); } } return true; } delegate int Sort_MoveStatusToEnd(Hat_StatusEffect A, Hat_StatusEffect B) { if (A.IsA(Class.Name)) return -1; //Swap return 0; //Don't Swap } function float GetSpeedMultiplier() { return 0.7f; }