Advertisement
Guest User

Clonk Zukunftsfahrstuhl LiftDock

a guest
Sep 14th, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. /*-- Liftdock --*/
  2.  
  3. #strict
  4. #include BOB2
  5.  
  6. local basement, manager;
  7. local liftplate;
  8.  
  9.  
  10. /* Fundament und Schwebeplatte erzeugen */
  11.  
  12. protected func Initialize()
  13. {
  14. manager = CreateObject(BMAN,0,0,GetOwner());
  15. manager->Init(this(), 1);
  16. // Liftplatte
  17. SetAction("OffStatus");
  18. liftplate = CreateObject(SLP1,0,+10,GetOwner());
  19. liftplate->SetOwnerObject(this());
  20. return(1);
  21. }
  22.  
  23. protected func Construction()
  24. {
  25. basement = CreateObject(BSA2,0,+8,GetOwner());
  26. return(1);
  27. }
  28.  
  29. protected func Destruction()
  30. {
  31. PreDestruction();
  32. if (basement) RemoveObject(basement);
  33. return(1);
  34. }
  35.  
  36. public func PreDestruction()
  37. {
  38. if (manager) RemoveObject(manager);
  39. if (liftplate) RemoveObject(liftplate);
  40. return(inherited());
  41. }
  42.  
  43.  
  44. /* Steuerung */
  45.  
  46. public func ControlUp(clonk)
  47. {
  48. [Statusanzeige]
  49. if (!inherited(clonk)) return(1); // wenn verfeindeter Spieler
  50. ShowInfoBar(IBRE, this(), GetEnergy(), 100, 5, 1);
  51. if (!liftplate)
  52. Message("Kein Lift!",this());
  53. return(1);
  54. }
  55.  
  56. public func ControlThrow(clonk)
  57. {
  58. [Lift bauen]
  59. if (liftplate) return(Message("Lift bereits vorhanden!",this()));
  60. var obj;
  61. if (!FindContents(METL) && (obj = FindContents(METL,clonk))) PushObject(obj);
  62. if (!FindContents(SURO) && (obj = FindContents(SURO,clonk))) PushObject(obj);
  63. return(BuildLift());
  64. }
  65.  
  66. private func PushObject(obj)
  67. {
  68. Sound("Grab");
  69. Enter(this(), obj);
  70. return(1);
  71. }
  72.  
  73.  
  74. /* Energieüberprüfung */
  75.  
  76. public func CheckEnergy()
  77. {
  78. // Energieverbrauch
  79. if (liftplate)
  80. if (!Inside(GetY(liftplate)-GetY(), -3, 0)) // im Liftdock eingerastet?
  81. {
  82. var dir = GetComDir(liftplate);
  83. if (dir==COMD_Up()) DoEnergy(-5);
  84. if (dir==COMD_Stop()) DoEnergy(-3);
  85. if (dir==COMD_Down()) DoEnergy(-2);
  86. }
  87. // Update für Energieanzeige
  88. ShowInfoBar(IBRE, this(), GetEnergy(), 100, 0, 1);
  89. // genügende Energieversorgung / welcher Status gesetzt?
  90. var Energynum = GetEnergyNum();
  91. var Statusnum = GetStatusNum();
  92. // keine Statusänderung?
  93. if (Energynum == Statusnum) return(1);
  94. // neuen Status setzen
  95. if (Energynum == 0) SetAction("OffStatus");
  96. if (Energynum == 1) SetAction("WarningStatus");
  97. if (Energynum == 2) SetAction("NormalStatus");
  98. return(1);
  99. }
  100.  
  101. private func GetStatusNum()
  102. {
  103. if (GetAction() eq "NormalStatus") return(2);
  104. if (GetAction() eq "WarningStatus") return(1);
  105. return(0); // OffStatus
  106. }
  107.  
  108. private func GetEnergyNum()
  109. {
  110. if (GetEnergy() > 80) return(2); // ab 80
  111. if (!GetEnergy()) return(0); // genau 0
  112. return(1); // 1 bis 80
  113. }
  114.  
  115. public EnoughEnergy: return(GetEnergy());
  116.  
  117.  
  118. /* neuen Lift bauen */
  119.  
  120. public func BuildLift()
  121. {
  122. // genug Energie?
  123. if (GetEnergy() < 50)
  124. return(Message("Nicht genügend Energie!",this()));
  125. // Metall & Uranerz gebraucht
  126. if (!FindContents(METL) && !FindContents(SURO))
  127. return(Message("Benötigt|1x Metall|1x Uranerz",this()));
  128. if (!FindContents(METL))
  129. return(Message("Benötigt noch|1x Metall",this()));
  130. if (!FindContents(SURO))
  131. return(Message("Benötigt noch|1x Uranerz",this()));
  132. // beides verbrauchen
  133. RemoveObject(FindContents(METL));
  134. RemoveObject(FindContents(SURO));
  135. // Lift erstellen
  136. liftplate = CreateObject(SLP1,0,+10,GetOwner());
  137. liftplate->Init(this());
  138. return(1);
  139. }
  140.  
  141.  
  142. /* Eigenschaften */
  143.  
  144. public IsEnergyConsumer: return(1);
  145. public InfoBarPos: return(5);
  146. public InfoBarSize: return(3);
  147. public GetMaxDamage: return(65);
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162. /*-- LiftPlate --*/
  163.  
  164. #strict
  165. #include ELEV
  166.  
  167.  
  168. protected func PlateWidth()
  169. {
  170. return(48);
  171. }
  172.  
  173. protected func PlateHeight()
  174. {
  175. return(26);
  176. }
  177.  
  178. /* Schaden */
  179.  
  180. public func Destroy()
  181. {
  182. // Fragmente
  183. var obj, i;
  184. for (i = 0; i < 5; ++i)
  185. {
  186. obj = CreateObject(SFRX, Random(50)-25, Random(8), GetOwner());
  187. obj->Settings(i);
  188. }
  189. // Explosion
  190. Explode(20);
  191. return(1);
  192. }
  193.  
  194.  
  195. /* Eigenschaften */
  196.  
  197. public GetMaxDamage: return(60);
  198. public Repairable: return(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement