Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.99 KB | None | 0 0
  1. //Table of Contents
  2. //Section 1: Defining Bricks used in the gamemode.
  3. //Section 2: Lot code.
  4. //Section 3: Trigger Code.
  5.  
  6. //[SECTION 1]
  7. //Lot Bricks
  8. //Small House (16x16)
  9. datablock fxDTSBrickData(SmallHouseBrickData : brick16x16fData)
  10. {
  11. category = "PieRPG";
  12. subCategory = "House Bricks";
  13. uiName = "Small House Brick";
  14. };
  15. datablock fxDTSBrickData(HalfMediumHouseBrickData : brick16x32fData)
  16. {
  17. category = "PieRPG";
  18. subCategory = "House Bricks";
  19. uiName = "Half-Medium House Brick";
  20. };
  21. datablock fxDTSBrickData(MediumHouseBrickData : brick32x32fData)
  22. {
  23. category = "PieRPG";
  24. subCategory = "House Bricks";
  25. uiName = "Medium House Brick";
  26. };
  27. datablock fxdtsBrickData(LargeHouseBrickData : brick48x48fData)
  28. {
  29. category = "PieRPG";
  30. subCategory = "House Bricks";
  31. uiName = "Large House Brick";
  32. };
  33. //Bank Brick
  34. datablock fxDTSBrickData(BankBrickData : brick2x4fData)
  35. {
  36. category = "PieRPG";
  37. subCategory = "Menu Bricks";
  38. uiName = "Bank Brick";
  39. };
  40. datablock TriggerData(BankBrickTriggerData)
  41. {
  42. tickPeriodMS = 150;
  43. };
  44. function BankBrickData::onPlant(%this, %obj)
  45. {
  46. %obj.createTrigger(BankBrickTriggerData);
  47. }
  48. function BankBrickTriggerData::onEnterTrigger(%this, %trigger, %obj) //Code that gets executed every time someone steps foot on the brick.
  49. {
  50. %client = %obj.client;
  51. %client.chatMessage("\c3Welcome to the Bank!");
  52. %client.chatMessage("\c6Type 1 to withdraw money, and 2 to deposit.");
  53. if(%client.bank $= "")
  54. %client.bank = 0;
  55. %client.chatMessage("\c6Your account currently has \c3$" @ %client.bank @ "\c6.");
  56. %client.inBank = 1;
  57. }
  58. function BankBrickTriggerData::onLeaveTrigger(%this, %trigger, %obj) //Executed when someone leaves the brick.
  59. {
  60. %obj.client.chatMessage("\c3See you soon!");
  61. %obj.client.inBank = 0;
  62. %obj.client.banking = 0;
  63. }
  64. //School Brick
  65. datablock fxDTSBrickData(SchoolBrickData : brick2x4fData)
  66. {
  67. category = "PieRPG";
  68. subCategory = "Menu Bricks";
  69. uiName = "School Brick";
  70. };
  71. datablock TriggerData(SchoolBrickTriggerData)
  72. {
  73. tickPeriodMS = 150;
  74. };
  75. function SchoolBrickData::onPlant(%this, %obj)
  76. {
  77. %obj.createTrigger(SchoolBrickTriggerData);
  78. }
  79. function SchoolBrickTriggerData::onEnterTrigger(%this, %trigger, %obj)
  80. {
  81. %client = %obj.client;
  82. %client.chatMessage("\c3Welcome to the University!");
  83. %client.chatMessage("\c6Type 1 to learn a degree, 2 to list all possible degrees, and 3 to swap out your active degrees.");
  84. %client.inSchool = 1;
  85. }
  86. function SchoolBrickTriggerData::onLeaveTrigger(%this, %trigger, %obj)
  87. {
  88. %obj.client.chatMessage("\c3See you soon!");
  89. %obj.client.inSchool = 0;
  90. %obj.client.changeDegreesNum = 0;
  91. %obj.client.changeDegrees = 0;
  92. %obj.client.learn1 = 0;
  93. }
  94. //Packages
  95. package TriggerPackages
  96. {
  97. //This is so that inSchool isn't 1 when a player dies on the brick.
  98. function gameConnection::onDeath(%client)
  99. {
  100. parent::onDeath(%client);
  101. %client.inSchool = 0;
  102. %client.inBank = 0;
  103. %client.learn1 = 0;
  104. %client.changeDegrees = 0;
  105. %client.changeDegreesNum = 0;
  106. %client.banking = 0;
  107. }
  108. //This is so the 1234 commands get intercepted and not spoken.
  109. function servercmdMessageSent(%client, %msg)
  110. {
  111. if(%client.inSchool == 1)
  112. {
  113. if(%msg $= "1")
  114. {
  115. %client.chatMessage("\c3Majors that you haven't bought yet:");
  116. if(%client.canPolice == 0)
  117. %client.chatMessage("\c6Police Major");
  118. if(%client.canLaw == 0)
  119. %client.chatMessage("\c6Law Major");
  120. if(%client.canMedical == 0)
  121. %client.chatMessage("\c6Medical Major");
  122. if(%client.canTheif == 0)
  123. %client.chatMessage("\c6Theif Major");
  124. if(%client.canBounty == 0)
  125. %client.chatMessage("\c6Bounty Major");
  126. if(%client.canEconomics == 0)
  127. %client.chatMessage("\c6Economics Major");
  128. if(%client.canBusiness == 0)
  129. %client.chatMessage("\c6Business Degree");
  130. %client.chatMessage("\c3Type the name of the one you want to buy!");
  131. %client.learn1 = 1;
  132. %client.inSchool = 0;
  133. return;
  134. }
  135. else if(%msg $= "2")
  136. {
  137. %client.chatMessage("\c3Police Degree:\c6 Allows you to arrest criminals.");
  138. %client.chatMessage("\c3Law Degree:\c6 Allows you to bail out criminals from jail through lawsuits.");
  139. %client.chatMessage("\c3Medical Degree:\c6 Allows you to heal and revive citizens.");
  140. %client.chatMessage("\c3Theif Degree:\c6 Allows you to pickpocket citizens.");
  141. %client.chatMessage("\c3Bounty Degree:\c6 Allows you to collect bounties on citizens.");
  142. %client.chatMessage("\c3Economics Degree:\c6 You play the stock market, adding hundreds to your pay.");
  143. %client.chatMessage("\c3Business Degree:\c6: Allows you to open a shop, and sell items.");
  144. return;
  145. }
  146. else if(%msg $= "3")
  147. {
  148. if(%client.activeDegree1 !$= "" || %client.activeDegree2 !$= "")
  149. {
  150. %client.chatMessage("\c3Your active Degrees:");
  151. if(%client.activeDegree1 !$= "")
  152. %client.chatMessage("\c61. " @ %client.activeDegree1);
  153. if(%client.activeDegree2 !$= "")
  154. %client.chatMessage("\c62. " @ %client.activeDegree2);
  155. %client.chatMessage("\c2Type the number of the degree slot you want to change.");
  156. %client.changeDegrees = 1;
  157. %client.inSchool = 0;
  158. }
  159. else
  160. {
  161. %client.chatMessage("\c3You don't have any degrees!");
  162. }
  163. return;
  164. }
  165. }
  166. //Inbetween stages in menus. Tis a silly place, and the code is confusing.
  167. //Changing Degrees
  168. if(%client.changeDegrees == 1)
  169. {
  170. if(%msg $= "1")
  171. {
  172. %client.chatMessage("\c3Okay, what degree do you want to swap it out with?");
  173. %client.changeDegrees = 0;
  174. %client.changeDegreesNum = 1;
  175. return;
  176. }
  177. if(%msg $= "2")
  178. {
  179. %client.chatMessage("\c3Okay, what degree do you want to swap it out with?");
  180. %client.changeDegrees = 0;
  181. %client.changeDegreesNum = 2;
  182. return;
  183. }
  184. }
  185. if(%client.changeDegreesNum == 1 || %client.changeDegreesNum == 2)
  186. {
  187. if(%msg $= "Police" || %msg $= "Medical" || %msg $= "Law" || %msg $= "Theif" || %msg $= "Bounty" || %msg $= "Economics" || %msg $= "Business")
  188. {
  189. if(%client.can[%msg] == 1)
  190. {
  191. if(%client.changeDegreesNum == 1)
  192. %client.activeDegree1 = %msg;
  193. else if(%client.changeDegreesNum == 2)
  194. %client.activeDegree2 = %msg;
  195. %client.chatMessage("\c3The degrees have been swapped successfully.");
  196. %client.changeDegreesNum = 0;
  197. }
  198. return;
  199. }
  200. else
  201. {
  202. %client.chatMessage("\c3That isn't a possible degree!");
  203. return;
  204. }
  205. }
  206.  
  207. //Learning Degrees
  208. if(%client.learn1 == 1)
  209. {
  210. if(%msg $= "Police" || %msg $= "Medical" || %msg $= "Law" || %msg $= "Theif" || %msg $= "Bounty" || %msg $= "Economics" || %msg $= "Business" && %client.can[%msg] == 0)
  211. {
  212. if(%client.money >= 1000)
  213. {
  214. %client.can[%msg] = 1;
  215. %client.money -= 1000;
  216. %client.chatMessage("\c3You have learned the" SPC %msg SPC "degree!");
  217. return;
  218. }
  219. else
  220. %client.chatMessage("\c3You don't have enough money! To learn a degree it costs $600.");
  221. return;
  222. }
  223. else
  224. {
  225. %client.chatMessage("\c3That either isn't a valid degree, or you already have learned it.");
  226. %client.learn1 = 0;
  227. return;
  228. }
  229. }
  230. //Withdrawing and Depositing Money
  231. if(%client.inBank == 1)
  232. {
  233. if(%msg $= "1")
  234. {
  235. %client.chatMessage("\c3How much money do you want to withdraw?");
  236. %client.banking = 1; //This is withdrawing or depositing.
  237. %client.inBank = 0;
  238. return;
  239. }
  240. else if(%msg $= "2")
  241. {
  242. %client.chatMessage("\c3How much money do you want to deposit?");
  243. %client.banking = 2; //Depositing.
  244. %client.inBank = 0;
  245. return;
  246. }
  247. }
  248. if(%client.banking == 1 || %client.banking == 2)
  249. {
  250. if(%client.banking == 1)
  251. {
  252. if(%client.bank >= %msg)
  253. {
  254. %client.bank -= %msg;
  255. %client.money += %msg;
  256. %client.chatMessage("\c3You have withdrawn $" @ %msg @ ". Your current balance is now $" @ %client.bank @ ".");
  257. }
  258. else
  259. %client.chatMessage("\c3You don't have that much in your bank account! You currently have $" @ %client.bank SPC "in it.");
  260. return;
  261. }
  262. if(%client.banking == 2)
  263. {
  264. if(%client.money >= %msg)
  265. {
  266. %client.bank += %msg;
  267. %client.money -= %msg;
  268. %client.chatMessage("\c3You put $" @ %msg SPC "into your bank account. You now have $" @ %client.bank SPC "in it.");
  269. %client.banking = 0;
  270. return;
  271. }
  272. else
  273. {
  274. %client.chatMessage("\c3You don't have that much money to deposit!");
  275. return;
  276. }
  277. }
  278. }
  279. parent::servercmdMessageSent(%client, %msg);
  280. }
  281. };
  282. activatePackage(TriggerPackages);
  283.  
  284. //[SECTION 2]
  285. //Lot Code
  286. package LotCode
  287. {
  288. function deleteBrick(%brick)
  289. {
  290. %brick.delete();
  291. }
  292. function fxDTSBrick::OnPlant(%brick, %data)
  293. {
  294. parent::onPlant(%brick, %data);
  295. %client = %brick.client;
  296. %block = %brick.getDataBlock();
  297. if(%block.subCategory $= "House Bricks")
  298. {
  299. //Calculates the price for lot bricks.
  300. %name = %block.getName();
  301. if(%name $= "SmallHouseBrickData")
  302. %price = 1000;
  303. else if(%name $= "HalfMediumHouseBrickData")
  304. %price = 1500;
  305. else if(%name $= "MediumHouseBrickData")
  306. %price = 2000;
  307. else if(%name $= "LargeHouseBrickData")
  308. %price = 2500;
  309. //Checking if it's on the ground.
  310. if(%brick.haspathtoGround() && %brick.getNumDownBricks() == 0)
  311. {
  312. if(%client.money >= %price)
  313. {
  314. %client.chatMessage("\c3You successfully planted the house for $" @ %price);
  315. }
  316. else
  317. {
  318. %client.chatMessage("\c3You don't have enough money to do that! It costs $" @ %price);
  319. schedule(33, 0, deleteBrick, %brick);
  320. }
  321. }
  322. else
  323. {
  324. %client.chatMessage("\c3You can't place houses there.");
  325. schedule(33, 0, deleteBrick, %brick);
  326. }
  327. }
  328. else if(%block.getName() $= "VehicleBrickData")
  329. {
  330. if(%client.money >= 700)
  331. {
  332. %client.money -= 700;
  333. %client.chatMessage("\c3You spent $700 on the vehicle spawn.");
  334. }
  335. else
  336. {
  337. %client.chatMessage("\c3You don't have enough money! It costs $700.");
  338. schedule(33, 0, deleteBrick, %brick);
  339. }
  340. }
  341. else if(%brick.hasPathToGround() & %brick.getNumDownBricks() == 0)
  342. {
  343. %client.chatMessage("\c3You need to build upon a house baseplate!");
  344. schedule(33, 0, deleteBrick, %brick);
  345. }
  346. }
  347. };
  348. activatePackage(LotCode);
  349. //[SECTION 3]
  350. //Code neccisary for creation of triggers.
  351. //Triggers are used to make 1/2/3 menus in specialized bricks.
  352. function FxDTSBrick::createTrigger(%this, %data)
  353. {
  354. %t = new Trigger()
  355. {
  356. datablock = %data;
  357. polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1"; //this determines the shape of the trigger
  358. };
  359. missionCleanup.add(%t);
  360. %boxMax = getWords(%this.getWorldBox(), 3, 5);
  361. %boxMin = getWords(%this.getWorldBox(), 0, 2);
  362. %boxDiff = vectorSub(%boxMax,%boxMin);
  363. %boxDiff = vectorAdd(%boxDiff, "0 0 0.2");
  364. %t.setScale(%boxDiff);
  365. %posA = %this.getWorldBoxCenter();
  366. %posB = %t.getWorldBoxCenter();
  367. %posDiff = vectorSub(%posA, %posB);
  368. %posDiff = vectorAdd(%posDiff, "0 0 0.1");
  369. %t.setTransform(%posDiff);
  370. %this.trigger = %t;
  371. %t.brick = %this;
  372. return %t;
  373. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement