Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.95 KB | None | 0 0
  1. //=============================================================================
  2. // EXZoneinfo.
  3. //=============================================================================
  4. class EXZoneInfo extends ZoneInfo;
  5.  
  6. // 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)
  7. // NOTE: Define the most specific subclasses LAST. Broad classes like Actor or Pawn should be listed first.
  8.  
  9. struct ZDamage
  10. {
  11. var() class<Actor> ZAffectedClass;
  12. var() int ZDamageAmount; // Negative values will heal
  13. var() int ZPostZoneDamage; // If Mode 1-3, set post-zone damage (0 = same as in zone, <0 = decrement based on NumDamageTicks)
  14. var() int ZNumDamageTicks; // If 0, infinite (stops when you leave if Mode 0, or else when you die if Mode 1-3)
  15. var() name ZDamageType;
  16. var() float ZDamageRate; // How fast the damage timer runs (default: 1.0 seconds - don't set it much faster than 0.25 or so)
  17. var() byte ZDamageMode; // Mode 0 = Start damage immediately and stop when exiting zone (good for healing zones)
  18. }; // Mode 1 = Start damage immediately and continue when exiting zone (corrosive slime zones or something)
  19. // Mode 2 = As above, but NumDamageTicks will not begin counting down until exiting zone (good for lava zones that set you on fire)
  20. // Mode 3 = Wait until exiting zone before starting damage (might be useful to simulate exiting a spaceship airlock or some shit)
  21.  
  22. var(EXDamageZone) ZDamage ZoneDamage[32];
  23. var(EXDamageZone) class<ZoneDamageBeacon> ZoneDamageBeaconClass;
  24. var(EXDamageZone) int ZPlayerPawnHealMax; // If healing, what's the max health allowed for PlayerPawns?
  25. var(EXDamageZone) bool bNoExternalBeacons; // Auto-remove beacons originating from other zones no matter what their settings are
  26.  
  27. var(EXSkyZone) name SkyZoneTag;
  28.  
  29. var(EXZoneEvents) bool bTransmitInstigator;
  30. var(EXZoneEvents) class<Actor> DetectedClass;
  31. var(EXZoneEvents) name ClassEntryEvent;
  32. var(EXZoneEvents) name ClassExitEvent;
  33.  
  34. var int ClassTracker;
  35.  
  36. //=====================================================================================
  37. simulated function PostBeginPlay()
  38. {
  39. local class<Actor> A;
  40.  
  41. Super.PostBeginPlay();
  42.  
  43. while( ClassTracker < ArrayCount(ZoneDamage) && ZoneDamage[ClassTracker].ZAffectedClass!=None )
  44. {
  45. if( ZoneDamage[ClassTracker].ZDamageRate<=0 )
  46. {
  47. ZoneDamage[ClassTracker].ZDamageRate = 1.0;
  48. 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');
  49. }
  50.  
  51. if(
  52. ZoneDamage[ClassTracker].ZAffectedClass!=None
  53. && !ZoneDamage[ClassTracker].ZAffectedClass.default.bIsPawn
  54. && ZoneDamage[ClassTracker].ZDamageAmount < 0
  55. )
  56. 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');
  57.  
  58. ClassTracker++;
  59. }
  60. }
  61.  
  62. //=====================================================================================
  63. simulated function LinkToSkybox()
  64. {
  65. local SkyZoneInfo TempSkyZone;
  66.  
  67. if( SkyZoneTag!='' && SkyZoneTag!='None' )
  68. foreach AllActors(class'SkyZoneInfo', TempSkyZone, SkyZoneTag)
  69. SkyZone = TempSkyZone;
  70.  
  71. if( SkyZone==None )
  72. Super.LinkToSkybox();
  73. }
  74.  
  75. //=====================================================================================
  76. // ActorEntered: Process entry stuff
  77. //=====================================================================================
  78. event ActorEntered( actor Other )
  79. {
  80. local Actor A;
  81. local ZoneDamageBeacon ZBeacon;
  82. local int i;
  83.  
  84. if( Other==None )
  85. return;
  86.  
  87. Super.ActorEntered(Other);
  88.  
  89. //---------------------------------------------------
  90. if( ClassEntryEvent!='' && DetectedClass!=None )
  91. {
  92. if( bTransmitInstigator )
  93. Instigator = Pawn(Other);
  94. else
  95. Instigator = None;
  96.  
  97. foreach allactors( DetectedClass, A, ClassEntryEvent )
  98. A.Trigger( self, Instigator );
  99. }
  100.  
  101. //---------------------------------------------------
  102. if( ClassTracker==0 )
  103. return;
  104.  
  105. for( i=ClassTracker; i >= 0; i-- )
  106. {
  107. if( ClassIsChildOf(Other.Class, ZoneDamage[i].ZAffectedClass) )
  108. {
  109. if( !bCheckValidityOf(Other, ZoneDamage[i].ZDamageAmount) )
  110. return;
  111.  
  112. ZBeacon = FindBeaconFor(Other);
  113.  
  114. if( ZBeacon!=None ) // A beacon was found; either remove it or reset it depending on damage mode
  115. {
  116. if( ZBeacon.OriginatingZone!=Self )
  117. {
  118. if( bNoExternalBeacons ) // Remove beacon on entry if set to
  119. ZBeacon.Destroy();
  120. }
  121. else
  122. {
  123. ZBeacon.CycleCount = 0; // Reset beacon if reentering original damage zone
  124.  
  125. if( ZBeacon.ZDamageMode == 3 )
  126. ZBeacon.SetTimer(0.0, False); // Disable timer for beacons that should only function out-of-zone
  127.  
  128. ZBeacon.bOutOfZone = False; // Notify beacon that it has reentered a damage zone
  129. }
  130. }
  131.  
  132. // If no beacon was found, a beacon was removed, or a found beacon came from another zone, spawn new one for this zone
  133. if( ZBeacon==None || ZBeacon.OriginatingZone!=Self )
  134. {
  135. ZBeacon = Other.Spawn(ZoneDamageBeaconClass, Other); // Spawn a beacon since this class doesn't have one yet
  136. if( ZBeacon!=None )
  137. {
  138. ZBeacon.ZDamageAmount = ZoneDamage[i].ZDamageAmount;
  139. ZBeacon.ZPostZoneDamage = ZoneDamage[i].ZPostZoneDamage;
  140. ZBeacon.ZDamageRate = ZoneDamage[i].ZDamageRate;
  141. ZBeacon.ZNumDamageTicks = ZoneDamage[i].ZNumDamageTicks;
  142. ZBeacon.ZDamageMode = ZoneDamage[i].ZDamageMode;
  143. ZBeacon.ZPlayerPawnHealMax = ZPlayerPawnHealMax;
  144.  
  145. ZBeacon.OriginatingZone = Self;
  146.  
  147. if( ZoneDamage[i].ZDamageType!='' )
  148. ZBeacon.ZDamageType = ZoneDamage[i].ZDamageType;
  149. else if( DamageType!='' )
  150. ZBeacon.ZDamageType = DamageType; // Use global zone damage type if none is set
  151. else
  152. ZBeacon.ZDamageType = 'Unspecified';
  153.  
  154. if( ZoneDamage[i].ZDamageMode < 3 ) // Begin damage immediately if set to
  155. ZBeacon.StartTimer(True);
  156. }
  157. }
  158.  
  159. break;
  160. }
  161. }
  162. }
  163.  
  164. //=====================================================================================
  165. // ActorLeaving: Process exit stuff
  166. //=====================================================================================
  167. event ActorLeaving( actor Other )
  168. {
  169. local Actor A;
  170. local ZoneDamageBeacon ZBeacon;
  171. local int i;
  172.  
  173. if( Other==None )
  174. return;
  175.  
  176. Super.ActorLeaving(Other);
  177.  
  178. //---------------------------------------------------
  179. if( ClassExitEvent!='' && DetectedClass!=None )
  180. {
  181. if( bTransmitInstigator )
  182. Instigator = Pawn(Other);
  183. else
  184. Instigator = None;
  185.  
  186. foreach allactors( DetectedClass, A, ClassExitEvent )
  187. A.Trigger( self, Instigator );
  188. }
  189.  
  190. //---------------------------------------------------
  191. if( ClassTracker==0 )
  192. return;
  193.  
  194. for( i=ClassTracker; i>=0; i-- ) // Reverse loop to catch specific subclasses first
  195. {
  196. if( ClassIsChildOf(Other.Class, ZoneDamage[i].ZAffectedClass) )
  197. {
  198. /// I think doing this in the exit function was causing some legit beacons to not be destroyed,
  199. /// like if a dead pawn left the zone; the beacon would not be destroyed if it was a permanent type
  200. /// Disabling this check for now to see how things go
  201. //if( !bCheckValidityOf(Other) )
  202. // return;
  203.  
  204. ZBeacon = FindBeaconFor(Other); // Check if leaving actor has a damage beacon
  205.  
  206. if( ZBeacon!=None && ZBeacon.OriginatingZone==Self )
  207. {
  208. if( ZBeacon.ZDamageMode == 0 ) // Destroy the beacon only if set to
  209. ZBeacon.Destroy();
  210. else
  211. {
  212. if( ZBeacon.ZDamageMode == 3 )
  213. ZBeacon.StartTimer(False); // Otherwise, START the damage if set to
  214. // In any other case, damage already started & continues without interruption
  215. ZBeacon.bOutOfZone = True; // Notify beacon the actor has left zone in case it needs to do something about that
  216. }
  217. }
  218.  
  219. break;
  220. }
  221. }
  222. }
  223.  
  224. //=====================================================================================
  225. function ZoneDamageBeacon FindBeaconFor( actor Other )
  226. {
  227. local ZoneDamageBeacon ZBeacon;
  228.  
  229. if( Other==None )
  230. return None;
  231.  
  232. foreach Other.ChildActors( class'ZoneDamageBeacon', ZBeacon )
  233. {
  234. if( ZBeacon!=None )
  235. return ZBeacon;
  236. }
  237.  
  238. return None;
  239. }
  240.  
  241. //=====================================================================================
  242. function bool bCheckValidityOf( actor Other, optional int DamageValue )
  243. {
  244. if( !Other.bProjTarget )
  245. return False;
  246.  
  247. if( Other.bIsPawn && (Pawn(Other).Health<=0 || Other.GetStateName()=='Dying') )
  248. return False;
  249.  
  250. if( DamageValue < 0 && !Other.bIsPawn )
  251. return False;
  252.  
  253. return True;
  254. }
  255.  
  256. /************************/
  257. /** Default Properties **/
  258. /************************/
  259. defaultproperties
  260. {
  261. ZoneDamageBeaconClass=Class'EXU.ZoneDamageBeacon'
  262. ZoneDamage(0)=(ZDamageRate=1.0)
  263. ZoneDamage(1)=(ZDamageRate=1.0)
  264. ZoneDamage(2)=(ZDamageRate=1.0)
  265. ZoneDamage(3)=(ZDamageRate=1.0)
  266. ZoneDamage(4)=(ZDamageRate=1.0)
  267. ZoneDamage(5)=(ZDamageRate=1.0)
  268. ZoneDamage(6)=(ZDamageRate=1.0)
  269. ZoneDamage(7)=(ZDamageRate=1.0)
  270. ZoneDamage(8)=(ZDamageRate=1.0)
  271. ZoneDamage(9)=(ZDamageRate=1.0)
  272. ZoneDamage(10)=(ZDamageRate=1.0)
  273. ZoneDamage(11)=(ZDamageRate=1.0)
  274. ZoneDamage(12)=(ZDamageRate=1.0)
  275. ZoneDamage(13)=(ZDamageRate=1.0)
  276. ZoneDamage(14)=(ZDamageRate=1.0)
  277. ZoneDamage(15)=(ZDamageRate=1.0)
  278. ZoneDamage(16)=(ZDamageRate=1.0)
  279. ZoneDamage(17)=(ZDamageRate=1.0)
  280. ZoneDamage(18)=(ZDamageRate=1.0)
  281. ZoneDamage(19)=(ZDamageRate=1.0)
  282. ZoneDamage(20)=(ZDamageRate=1.0)
  283. ZoneDamage(21)=(ZDamageRate=1.0)
  284. ZoneDamage(22)=(ZDamageRate=1.0)
  285. ZoneDamage(23)=(ZDamageRate=1.0)
  286. ZoneDamage(24)=(ZDamageRate=1.0)
  287. ZoneDamage(25)=(ZDamageRate=1.0)
  288. ZoneDamage(26)=(ZDamageRate=1.0)
  289. ZoneDamage(27)=(ZDamageRate=1.0)
  290. ZoneDamage(28)=(ZDamageRate=1.0)
  291. ZoneDamage(29)=(ZDamageRate=1.0)
  292. ZoneDamage(30)=(ZDamageRate=1.0)
  293. ZoneDamage(31)=(ZDamageRate=1.0)
  294. ZPlayerPawnHealMax=300
  295. Texture=Texture'EXU.Icons.S_EXZoneInfo'
  296. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement