Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // EXZoneinfo.
- //=============================================================================
- class EXZoneInfo extends ZoneInfo;
- // Can do custom events, link to a 3D Skybox, or do special healing/damage stuff for up to 32 different class types (includes child classes)
- // NOTE: Define the most specific subclasses LAST. Broad classes like Actor or Pawn should be listed first.
- struct ZDamage
- {
- var() class<Actor> ZAffectedClass;
- var() int ZDamageAmount; // Negative values will heal
- var() int ZPostZoneDamage; // If Mode 1-3, set post-zone damage (0 = same as in zone, <0 = decrement based on NumDamageTicks)
- var() int ZNumDamageTicks; // If 0, infinite (stops when you leave if Mode 0, or else when you die if Mode 1-3)
- var() name ZDamageType;
- var() float ZDamageRate; // How fast the damage timer runs (default: 1.0 seconds - don't set it much faster than 0.25 or so)
- var() byte ZDamageMode; // Mode 0 = Start damage immediately and stop when exiting zone (good for healing zones)
- }; // Mode 1 = Start damage immediately and continue when exiting zone (corrosive slime zones or something)
- // Mode 2 = As above, but NumDamageTicks will not begin counting down until exiting zone (good for lava zones that set you on fire)
- // Mode 3 = Wait until exiting zone before starting damage (might be useful to simulate exiting a spaceship airlock or some shit)
- var(EXDamageZone) ZDamage ZoneDamage[32];
- var(EXDamageZone) class<ZoneDamageBeacon> ZoneDamageBeaconClass;
- var(EXDamageZone) int ZPlayerPawnHealMax; // If healing, what's the max health allowed for PlayerPawns?
- var(EXDamageZone) bool bNoExternalBeacons; // Auto-remove beacons originating from other zones no matter what their settings are
- var(EXSkyZone) name SkyZoneTag;
- var(EXZoneEvents) bool bTransmitInstigator;
- var(EXZoneEvents) class<Actor> DetectedClass;
- var(EXZoneEvents) name ClassEntryEvent;
- var(EXZoneEvents) name ClassExitEvent;
- var int ClassTracker;
- //=====================================================================================
- simulated function PostBeginPlay()
- {
- local class<Actor> A;
- Super.PostBeginPlay();
- while( ClassTracker < ArrayCount(ZoneDamage) && ZoneDamage[ClassTracker].ZAffectedClass!=None )
- {
- if( ZoneDamage[ClassTracker].ZDamageRate<=0 )
- {
- ZoneDamage[ClassTracker].ZDamageRate = 1.0;
- log(self$" Attention asshole! You should not have set ZDamageRate["$ClassTracker$"] to ZERO because that means it won't work at all! Overriding rate to once per second. Fix this in UED!",'LevelDesignError');
- }
- if(
- ZoneDamage[ClassTracker].ZAffectedClass!=None
- && !ZoneDamage[ClassTracker].ZAffectedClass.default.bIsPawn
- && ZoneDamage[ClassTracker].ZDamageAmount < 0
- )
- log(self$" Hey! Don't give non-pawns (like "$ZoneDamage[ClassTracker].ZAffectedClass$" in slot ["$ClassTracker$"]) a healing value! That won't work, you buffoon! Fix this in UED!",'LevelDesignError');
- ClassTracker++;
- }
- }
- //=====================================================================================
- simulated function LinkToSkybox()
- {
- local SkyZoneInfo TempSkyZone;
- if( SkyZoneTag!='' && SkyZoneTag!='None' )
- foreach AllActors(class'SkyZoneInfo', TempSkyZone, SkyZoneTag)
- SkyZone = TempSkyZone;
- if( SkyZone==None )
- Super.LinkToSkybox();
- }
- //=====================================================================================
- // ActorEntered: Process entry stuff
- //=====================================================================================
- event ActorEntered( actor Other )
- {
- local Actor A;
- local ZoneDamageBeacon ZBeacon;
- local int i;
- if( Other==None )
- return;
- Super.ActorEntered(Other);
- //---------------------------------------------------
- if( ClassEntryEvent!='' && DetectedClass!=None )
- {
- if( bTransmitInstigator )
- Instigator = Pawn(Other);
- else
- Instigator = None;
- foreach allactors( DetectedClass, A, ClassEntryEvent )
- A.Trigger( self, Instigator );
- }
- //---------------------------------------------------
- if( ClassTracker==0 )
- return;
- for( i=ClassTracker; i >= 0; i-- )
- {
- if( ClassIsChildOf(Other.Class, ZoneDamage[i].ZAffectedClass) )
- {
- if( !bCheckValidityOf(Other, ZoneDamage[i].ZDamageAmount) )
- return;
- ZBeacon = FindBeaconFor(Other);
- if( ZBeacon!=None ) // A beacon was found; either remove it or reset it depending on damage mode
- {
- if( ZBeacon.OriginatingZone!=Self )
- {
- if( bNoExternalBeacons ) // Remove beacon on entry if set to
- ZBeacon.Destroy();
- }
- else
- {
- ZBeacon.CycleCount = 0; // Reset beacon if reentering original damage zone
- if( ZBeacon.ZDamageMode == 3 )
- ZBeacon.SetTimer(0.0, False); // Disable timer for beacons that should only function out-of-zone
- ZBeacon.bOutOfZone = False; // Notify beacon that it has reentered a damage zone
- }
- }
- // If no beacon was found, a beacon was removed, or a found beacon came from another zone, spawn new one for this zone
- if( ZBeacon==None || ZBeacon.OriginatingZone!=Self )
- {
- ZBeacon = Other.Spawn(ZoneDamageBeaconClass, Other); // Spawn a beacon since this class doesn't have one yet
- if( ZBeacon!=None )
- {
- ZBeacon.ZDamageAmount = ZoneDamage[i].ZDamageAmount;
- ZBeacon.ZPostZoneDamage = ZoneDamage[i].ZPostZoneDamage;
- ZBeacon.ZDamageRate = ZoneDamage[i].ZDamageRate;
- ZBeacon.ZNumDamageTicks = ZoneDamage[i].ZNumDamageTicks;
- ZBeacon.ZDamageMode = ZoneDamage[i].ZDamageMode;
- ZBeacon.ZPlayerPawnHealMax = ZPlayerPawnHealMax;
- ZBeacon.OriginatingZone = Self;
- if( ZoneDamage[i].ZDamageType!='' )
- ZBeacon.ZDamageType = ZoneDamage[i].ZDamageType;
- else if( DamageType!='' )
- ZBeacon.ZDamageType = DamageType; // Use global zone damage type if none is set
- else
- ZBeacon.ZDamageType = 'Unspecified';
- if( ZoneDamage[i].ZDamageMode < 3 ) // Begin damage immediately if set to
- ZBeacon.StartTimer(True);
- }
- }
- break;
- }
- }
- }
- //=====================================================================================
- // ActorLeaving: Process exit stuff
- //=====================================================================================
- event ActorLeaving( actor Other )
- {
- local Actor A;
- local ZoneDamageBeacon ZBeacon;
- local int i;
- if( Other==None )
- return;
- Super.ActorLeaving(Other);
- //---------------------------------------------------
- if( ClassExitEvent!='' && DetectedClass!=None )
- {
- if( bTransmitInstigator )
- Instigator = Pawn(Other);
- else
- Instigator = None;
- foreach allactors( DetectedClass, A, ClassExitEvent )
- A.Trigger( self, Instigator );
- }
- //---------------------------------------------------
- if( ClassTracker==0 )
- return;
- for( i=ClassTracker; i>=0; i-- ) // Reverse loop to catch specific subclasses first
- {
- if( ClassIsChildOf(Other.Class, ZoneDamage[i].ZAffectedClass) )
- {
- /// I think doing this in the exit function was causing some legit beacons to not be destroyed,
- /// like if a dead pawn left the zone; the beacon would not be destroyed if it was a permanent type
- /// Disabling this check for now to see how things go
- //if( !bCheckValidityOf(Other) )
- // return;
- ZBeacon = FindBeaconFor(Other); // Check if leaving actor has a damage beacon
- if( ZBeacon!=None && ZBeacon.OriginatingZone==Self )
- {
- if( ZBeacon.ZDamageMode == 0 ) // Destroy the beacon only if set to
- ZBeacon.Destroy();
- else
- {
- if( ZBeacon.ZDamageMode == 3 )
- ZBeacon.StartTimer(False); // Otherwise, START the damage if set to
- // In any other case, damage already started & continues without interruption
- ZBeacon.bOutOfZone = True; // Notify beacon the actor has left zone in case it needs to do something about that
- }
- }
- break;
- }
- }
- }
- //=====================================================================================
- function ZoneDamageBeacon FindBeaconFor( actor Other )
- {
- local ZoneDamageBeacon ZBeacon;
- if( Other==None )
- return None;
- foreach Other.ChildActors( class'ZoneDamageBeacon', ZBeacon )
- {
- if( ZBeacon!=None )
- return ZBeacon;
- }
- return None;
- }
- //=====================================================================================
- function bool bCheckValidityOf( actor Other, optional int DamageValue )
- {
- if( !Other.bProjTarget )
- return False;
- if( Other.bIsPawn && (Pawn(Other).Health<=0 || Other.GetStateName()=='Dying') )
- return False;
- if( DamageValue < 0 && !Other.bIsPawn )
- return False;
- return True;
- }
- /************************/
- /** Default Properties **/
- /************************/
- defaultproperties
- {
- ZoneDamageBeaconClass=Class'EXU.ZoneDamageBeacon'
- ZoneDamage(0)=(ZDamageRate=1.0)
- ZoneDamage(1)=(ZDamageRate=1.0)
- ZoneDamage(2)=(ZDamageRate=1.0)
- ZoneDamage(3)=(ZDamageRate=1.0)
- ZoneDamage(4)=(ZDamageRate=1.0)
- ZoneDamage(5)=(ZDamageRate=1.0)
- ZoneDamage(6)=(ZDamageRate=1.0)
- ZoneDamage(7)=(ZDamageRate=1.0)
- ZoneDamage(8)=(ZDamageRate=1.0)
- ZoneDamage(9)=(ZDamageRate=1.0)
- ZoneDamage(10)=(ZDamageRate=1.0)
- ZoneDamage(11)=(ZDamageRate=1.0)
- ZoneDamage(12)=(ZDamageRate=1.0)
- ZoneDamage(13)=(ZDamageRate=1.0)
- ZoneDamage(14)=(ZDamageRate=1.0)
- ZoneDamage(15)=(ZDamageRate=1.0)
- ZoneDamage(16)=(ZDamageRate=1.0)
- ZoneDamage(17)=(ZDamageRate=1.0)
- ZoneDamage(18)=(ZDamageRate=1.0)
- ZoneDamage(19)=(ZDamageRate=1.0)
- ZoneDamage(20)=(ZDamageRate=1.0)
- ZoneDamage(21)=(ZDamageRate=1.0)
- ZoneDamage(22)=(ZDamageRate=1.0)
- ZoneDamage(23)=(ZDamageRate=1.0)
- ZoneDamage(24)=(ZDamageRate=1.0)
- ZoneDamage(25)=(ZDamageRate=1.0)
- ZoneDamage(26)=(ZDamageRate=1.0)
- ZoneDamage(27)=(ZDamageRate=1.0)
- ZoneDamage(28)=(ZDamageRate=1.0)
- ZoneDamage(29)=(ZDamageRate=1.0)
- ZoneDamage(30)=(ZDamageRate=1.0)
- ZoneDamage(31)=(ZDamageRate=1.0)
- ZPlayerPawnHealMax=300
- Texture=Texture'EXU.Icons.S_EXZoneInfo'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement