Advertisement
Guest User

Artifact Craft Weapon

a guest
Oct 7th, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. class ArtifactCraftWeapon extends ArtifactCraftAutoTurret;
  2.  
  3. var bool bIsFree;
  4. var bool bIsDropped;
  5.  
  6. var PickUp Changeling;
  7. var class<PickUp> ChangelingClass;
  8.  
  9.  
  10.  
  11. function bool GetUsability()
  12. {
  13. //Can't use this if you don't have enough adrenaline...
  14. if (Instigator.Controller.Adrenaline < GetCost() )
  15. {
  16. Instigator.ReceiveLocalizedMessage(MessageClass, GetCost(), None, None, Class);
  17. return false;
  18. }
  19.  
  20. //Can't use this if we don't have scrap metal
  21. if (InvMetal.ScrapMetal[0] <= 0 && InvMetal.ScrapMetal[1] <= 0 && InvMetal.ScrapMetal[2] <= 0 && InvMetal.ScrapMetal[3] <= 0 && InvMetal.ScrapMetal[4] <= 0)
  22. {
  23. Instigator.ReceiveLocalizedMessage(MessageClass, 1000, None, None, Class);
  24. return false;
  25. }
  26.  
  27. return true;
  28. }
  29.  
  30. function AltActivate(optional string Param)
  31. {
  32. local float TimeDelta;
  33. local Vector StartTrace, EndTrace, SpawnLocation, HitNormal;
  34.  
  35.  
  36. if (Param != "")
  37. WeaponClass = class<Weapon>(DynamicLoadObject(Param, class'Class'));
  38.  
  39. if (Instigator == None || InvMetal == None)
  40. {
  41. Destroy();
  42. return;
  43. }
  44.  
  45. if (bIsFree != true)
  46. {
  47. if (GetUsability() != true)
  48. {
  49. bActive = false;
  50. GotoState('');
  51. return;
  52. }
  53. }
  54.  
  55.  
  56. //Check to see if we are allowed to use this again by time.
  57. TimeDelta = Level.TimeSeconds - LastUseTime;
  58. if (Level.TimeSeconds - LastUseTime < UseDelay)
  59. {
  60. Instigator.ReceiveLocalizedMessage(MessageClass, 5000 + UseDelay - TimeDelta, None, None, Class);
  61. bActive = false;
  62. GotoState('');
  63. return;
  64. }
  65.  
  66. LastUseTime = Level.TimeSeconds;
  67.  
  68. StartTrace = Instigator.Location;
  69. EndTrace = Instigator.Location + vector(Instigator.Rotation) * Instigator.GroundSpeed;
  70. if (Instigator.Trace(SpawnLocation, HitNormal, EndTrace, Instigator.Location) != None)
  71. {
  72. SpawnLocation -= vector(Instigator.Rotation) * 40;
  73.  
  74. A = spawn(Class'SillyRPG.xWeaponBaseSilly',,, SpawnLocation, Instigator.Rotation);
  75. }
  76. else
  77. A = spawn(Class'SillyRPG.xWeaponBaseSilly',,, EndTrace, Instigator.Rotation);
  78.  
  79.  
  80. if (A != None)
  81. {
  82. A.bHidden = true;
  83. Changeling = spawn(ChangelingClass,,, A.Location, A.Rotation);
  84.  
  85. if (WeaponClass == None)
  86. WeaponClass = Class'DWU2Weapons.WeaponRocketTurret';
  87.  
  88. A.bDelayedSpawn = true;
  89.  
  90. A.WeaponType=WeaponClass;
  91.  
  92. A.PostBeginPlay();
  93.  
  94. SetTimer(1,false);
  95.  
  96. }
  97. }
  98.  
  99. function Timer()
  100. {
  101. local int i;
  102. local PickUp WeaponPickUp;
  103.  
  104. if (A.myPickUp != None)
  105. WeaponPickUp = A.myPickUp;
  106.  
  107. if (Changeling != None)
  108. Changeling.Destroy();
  109. A.Destroy();
  110.  
  111. if (WeaponPickUp != None)
  112. {
  113. ModifyPickUp (WeaponPickUp);
  114.  
  115. //cost
  116. if (bIsFree != true)
  117. PayUp ();
  118. }
  119. }
  120.  
  121. function ModifyPickup (PickUp TMWeaponPickUp)
  122. {
  123. TMWeaponPickUp.GotoState( 'Pickup' );
  124.  
  125. TMWeaponPickUp.RespawnTime = 0;
  126. TMWeaponPickUp.bDropped = bIsDropped;
  127. TMWeaponPickUp.RespawnEffect();
  128. ////TMWeaponPickUp.AmmoAmount = GetAmmo();
  129. if (!TMWeaponPickUp.bDropped)
  130. TMWeaponPickUp.Lifespan = 120;
  131. TMWeaponPickUp.SetTimer(120, false);
  132.  
  133. TMWeaponPickUp.NetUpdateTime = Level.TimeSeconds - 1;
  134. TMWeaponPickUp.bHidden = false;
  135. }
  136.  
  137. function PayUp ()
  138. {
  139. local int i;
  140.  
  141. Instigator.Controller.Adrenaline -= GetCost();
  142. if (Instigator.Controller.Adrenaline < 0)
  143. Instigator.Controller.Adrenaline = 0;
  144.  
  145. //Remove scrap metal
  146. i = 4;
  147. while (InvMetal.ScrapMetal[i] <= 0 && i >= 0)
  148. i--;
  149. InvMetal.RemoveMetal(i);
  150. }
  151.  
  152.  
  153. defaultproperties
  154. {
  155. ChangelingClass=Class'SillyRPG.XIsAChangeling'
  156. AbilityLevel=1
  157. UseDelay=2
  158. WeaponClass=Class'DWU2Weapons.AutoTurretDeploy'
  159. bIsFree=true
  160. bIsDropped=false
  161. MinActivationTime=0.000001
  162. ActivateSound=Sound'WeaponSounds.BaseGunTech.BReload2'
  163. IconMaterial=Texture'ME_RPGExpansion.Icons.CraftSpiderMines'
  164. ItemName="Craft Weapon"
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement