Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. // DRAK SERAT
  2. // Teaches various ninjutsu skills to us for pay
  3. // Sells rare ninjutsu items
  4.  
  5. const int Flag_First_Encounter = 0;
  6. const int Flag_First_Exit_Talk = 1;
  7. const int Flag_First_Exit = 2;
  8. const int Flag_First_Taught = 3;
  9. const int Flag_Second_Taught = 4;
  10. const int Flag_Failed_Lesson = 5;
  11. const int Flag_Failed_Lesson_Again = 6;
  12. const int Flag_Failed_Lesson_Yet_Again = 7;
  13. const int Flag_Recent_Training_Failed = 8;
  14. const int Flag_Explained_Services = 9;
  15.  
  16. const int CHOICETEXT_Training = 14;
  17.  
  18. const int SKILL_NINJITSU = 3;
  19. const int SKILL_STEALTH = 12;
  20. const int SKILL_DEFLECTION = 14;
  21. const int SKILL_SCOUT = 15;
  22. const int SKILL_IAJITSU = 16;
  23. const int SKILL_EVASION = 21;
  24. const int SKILL_SWORDSMANSHIP = 29;
  25. const int SKILL_POWERSTRIKE = 40;
  26. const int SKILL_HAND_2_HAND = 42;
  27.  
  28. const int TRAIN_STEALTH = 0;
  29. const int TRAIN_EVASION = 1;
  30. const int TRAIN_SCOUT = 2;
  31. const int TRAIN_HAND_2_HAND = 3;
  32. const int TRAIN_SWORDSMANSHIP = 4;
  33. const int TRAIN_DEFLECTION = 5;
  34. const int TRAIN_NINJITSU = 6;
  35. const int TRAIN_POWERSTRIKE = 7;
  36. const int TRAIN_IAJITSU = 8;
  37.  
  38. const int TRAIN_TOTAL = 9;
  39.  
  40. const int SKILL_MAXIMUM = 100;
  41. const int TEACHER_SKILL = 25;
  42.  
  43. const int LEVEL_IAJITSU = 12;
  44. const int LEVEL_MINIMUM_GROUP1 = 3;
  45. const int LEVEL_MINIMUM_GROUP2 = 6;
  46. const int LEVEL_MINIMUM_GROUP3 = 9;
  47.  
  48. const int GOLD_STEALTH = 3600;
  49. const int GOLD_EVASION = 2400;
  50. const int GOLD_SCOUT = 1800;
  51. const int GOLD_HAND_2_HAND = 7600;
  52. const int GOLD_SWORDSMANSHIP = 7200;
  53. const int GOLD_DEFLECTION = 11600;
  54. const int GOLD_NINJITSU = 24700;
  55. const int GOLD_POWERSTRIKE = 42200;
  56. const int GOLD_IAJITSU = 38800;
  57.  
  58. const int GOLD_TRAINING_MARGIN = 600;
  59.  
  60. const int LUT_WIDTH = 7;
  61. const int LUT_SKILL = 0;
  62. const int LUT_LEVEL = 1;
  63. const int LUT_GOLD = 2;
  64. const int LUT_PROF = 3;
  65. const int LUT_MAX = 4;
  66. const int LUT_ACQUIRE = 5;
  67. const int LUT_TEXT = 6;
  68.  
  69. const int TRAINRESULT_ABORT = -1;
  70. const int TRAINRESULT_FAILURE = 0;
  71. const int TRAINRESULT_SUCCESS = 1;
  72.  
  73. const int TEST_CHARMED_MERCENARY = 40;
  74. const int TEST_CHARMED_SERVICES = 50;
  75. const int TEST_AMITY_OWL = 3;
  76.  
  77. int [] tblTraining =
  78. {// skill index, minimum level to learn, cost, minimum profession, maximum train, level acquire,text
  79. SKILL_STEALTH,LEVEL_MINIMUM_GROUP1, GOLD_STEALTH,cROGUE,70,0,41,
  80. SKILL_EVASION,LEVEL_MINIMUM_GROUP1, GOLD_EVASION,cROGUE,80,0,42,
  81. SKILL_SCOUT,LEVEL_MINIMUM_GROUP1, GOLD_SCOUT,cWARRIOR,80,0,43,
  82. SKILL_HAND_2_HAND,LEVEL_MINIMUM_GROUP2, GOLD_HAND_2_HAND,cRANGER,70,0,9,
  83. SKILL_SWORDSMANSHIP, LEVEL_MINIMUM_GROUP2, GOLD_SWORDSMANSHIP,cWARRIOR,70,0,45,
  84. SKILL_DEFLECTION,LEVEL_MINIMUM_GROUP2, GOLD_DEFLECTION,cTEMPLAR,50,12,46,
  85. SKILL_NINJITSU,LEVEL_MINIMUM_GROUP3, GOLD_NINJITSU,cASSASSIN,60,0,47,
  86. SKILL_POWERSTRIKE,LEVEL_MINIMUM_GROUP3, GOLD_POWERSTRIKE,cTEMPLAR,50,18,48,
  87. SKILL_IAJITSU,LEVEL_MINIMUM_GROUP3, GOLD_IAJITSU,cASSASSIN,40,22,49
  88. };
  89.  
  90. int Trainer()
  91. {
  92. int enbits = 0;
  93. int prof = GetTalkerProfession();
  94. int lvl = GetTalkerLevel();
  95. int sk = 0;
  96. int currentsk = 0;
  97. int getsk = 0;
  98. int choice = -1;
  99. int c = 0;
  100. int row = 0;
  101. int cost = 0;
  102. bool trained = false;
  103.  
  104. // scan through training table array and see what kinds of training can
  105. // be offered to current speaker in party
  106. for(c = 0;c< TRAIN_TOTAL;c++)
  107. {
  108. row = c * LUT_WIDTH;
  109.  
  110. if(HasSkill(tblTraining[row + LUT_SKILL]) &&
  111. lvl >= tblTraining[row + LUT_LEVEL] &&
  112. prof >= tblTraining[row + LUT_PROF]
  113. )
  114. {
  115. enbits |= Bit(c);
  116. }
  117. }
  118.  
  119. if(enbits > 0)
  120. {
  121. choice = MultiChoice(CHOICETEXT_Training, enbits);
  122. }
  123. else
  124. {
  125. Say(37);
  126.  
  127. return(TRAINRESULT_ABORT);
  128. }
  129.  
  130. if(choice < 1)
  131. {
  132. RandomSay(37,38,39);
  133.  
  134. return(TRAINRESULT_ABORT);
  135. }
  136.  
  137. row = (choice - 1) * LUT_WIDTH;
  138.  
  139. sk = tblTraining[row + LUT_SKILL];
  140.  
  141. SubstituteTag(cTX_SKILLS,sk);
  142.  
  143. Say(40);
  144.  
  145. getsk = tblTraining[row + LUT_ACQUIRE];
  146.  
  147. if(HasSkill(sk) == false && getsk > 0 && lvl < getsk)
  148. {
  149. Say(44);
  150.  
  151. return(TRAINRESULT_ABORT);
  152. }
  153.  
  154. currentsk = GetTalkerSkill(sk);
  155.  
  156. if(currentsk >= SKILL_MAXIMUM)
  157. {
  158. RandomSay(53,54,55);
  159.  
  160. return(TRAINRESULT_ABORT);
  161. }
  162.  
  163. if(currentsk >= tblTraining[row + LUT_MAX])
  164. {
  165. RandomSay(50,52,56);
  166.  
  167. return(TRAINRESULT_ABORT);
  168. }
  169.  
  170. cost = tblTraining[row + LUT_GOLD];
  171.  
  172. cost = BarterPrice(cost,GOLD_TRAINING_MARGIN);
  173.  
  174. SetNumberText(cost);
  175.  
  176. Say(8);
  177.  
  178. if(GetGold(cost) == false)
  179. {
  180. Say(38);
  181.  
  182. return(TRAINRESULT_ABORT);
  183. }
  184.  
  185. GetTalkerName();
  186.  
  187. Narrative(tblTraining[row + LUT_TEXT]);
  188.  
  189. trained = LearnSkill(sk,TEACHER_SKILL);
  190.  
  191. return((trained == true) ? TRAINRESULT_SUCCESS : TRAINRESULT_FAILURE);
  192. }
  193.  
  194. bool OnSubject_YOU(int querytype)
  195. {
  196. if(Get(Flag_First_Exit) == false)
  197. {
  198. Say(3);
  199. }
  200. else
  201. {
  202. Say(61);
  203. }
  204.  
  205. return(true);
  206. }
  207.  
  208. bool OnSubject_JOB(int querytype)
  209. {
  210. if(Get(Flag_First_Exit) == false)
  211. {
  212. CharmSay(TEST_CHARMED_MERCENARY,63,4);
  213. }
  214. else
  215. {
  216. CharmSay(TEST_CHARMED_MERCENARY,63,62);
  217. }
  218.  
  219. return(true);
  220. }
  221.  
  222. bool OnSubject_TRAINING(int querytype)
  223. {
  224. if(Amicable() == false)
  225. {
  226. Say(51);
  227.  
  228. return(true);
  229. }
  230.  
  231. if(Get(Flag_Recent_Training_Failed) == true)
  232. {
  233. if(Get(Flag_Failed_Lesson_Yet_Again) == true)
  234. {
  235. RandomSay(32,35,36);
  236. }
  237. else if(Get(Flag_Failed_Lesson_Again) == true)
  238. {
  239. RandomSay(31,32,33);
  240. }
  241. else if(Get(Flag_Failed_Lesson) == true)
  242. {
  243. Say(33);
  244. }
  245. else if(Get(Flag_First_Taught) == false)
  246. {
  247. Say(28);
  248. }
  249. }
  250.  
  251. if(Get(Flag_First_Taught)==false)
  252. {
  253. Say(7);
  254. Say(28);
  255. }
  256. else if(Get(Flag_Second_Taught)==false)
  257. {
  258. Say(57);
  259. }
  260. else
  261. {
  262. RandomSay(58,59,60);
  263. }
  264.  
  265. int result = Trainer();
  266.  
  267. if(result == TRAINRESULT_ABORT)return(true);
  268.  
  269. if(Get(Flag_First_Taught)==false)
  270. {
  271. Set(Flag_First_Taught);
  272. }
  273. else if(Get(Flag_Second_Taught)==false)
  274. {
  275. Set(Flag_Second_Taught);
  276.  
  277. if(result == TRAINRESULT_SUCCESS)
  278. {
  279. Say(70);
  280. }
  281. }
  282.  
  283. if(result == TRAINRESULT_SUCCESS)
  284. {
  285. RandomSay(12,13,14);
  286.  
  287. // keep increasing trust and friendship with good students
  288. ModifyAmity(cPARTY_AGENTSOFWHITEOWL,+1);
  289.  
  290. ClearFlag(SELF,Flag_Recent_Training_Failed);
  291. }
  292. else
  293. {
  294. RandomSay(15,16,17);
  295.  
  296. Set(Flag_Recent_Training_Failed);
  297.  
  298. if(Get(Flag_Failed_Lesson) == false)
  299. {
  300. RandomSay(21,22,23);
  301.  
  302. Set(Flag_Failed_Lesson);
  303. }
  304. else if(Get(Flag_Failed_Lesson_Again) == false)
  305. {
  306. RandomSay(24,25,26);
  307.  
  308. Set(Flag_Failed_Lesson_Again);
  309. }
  310. else if(Get(Flag_Failed_Lesson_Yet_Again) == false)
  311. {
  312. RandomSay(27,21,24);
  313.  
  314. Set(Flag_Failed_Lesson_Yet_Again);
  315. }
  316. else
  317. {
  318. if(FlipCoin())
  319. {
  320. RandomSay(22,25,23);
  321. }
  322. else
  323. {
  324. RandomSay(21,24,26);
  325. }
  326. }
  327. }
  328.  
  329. return(true);
  330. }
  331.  
  332. bool OnSubject_SERVICES(int querytype)
  333. {
  334. switch(querytype)
  335. {
  336. case cDISPATCH_WHAT:
  337. default:
  338. if(Charmed(TEST_CHARMED_SERVICES) == true || GetAmity() > TEST_AMITY_OWL)
  339. {
  340. if(Get(Flag_Explained_Services)==false)
  341. {
  342. Say(64);
  343.  
  344. Set(Flag_Explained_Services);
  345. }
  346. else
  347. {
  348. Say(68);
  349. }
  350. }
  351. else
  352. {
  353. RandomSay(65,66,67);
  354. }
  355. break;
  356. }
  357.  
  358. return(true);
  359. }
  360.  
  361. bool OnEncounter(int value)
  362. {
  363. if(Get(Flag_First_Encounter)==false)
  364. {
  365. Narrative(1);
  366. Say(2);
  367.  
  368. Set(Flag_First_Encounter);
  369. }
  370.  
  371. return(true);
  372. }
  373.  
  374. bool OnExitEncounter(int value)
  375. {
  376. if(Get(Flag_First_Exit)==false)
  377. {
  378. Say(6);
  379.  
  380. Set(Flag_First_Exit);
  381.  
  382. return(true);
  383. }
  384.  
  385. return(true);
  386. }
  387.  
  388. bool OnExitTalk(int value)
  389. {
  390. if(Get(Flag_First_Exit_Talk)==false)
  391. {
  392. Say(69);
  393.  
  394. Set(Flag_First_Exit_Talk);
  395.  
  396. return(true);
  397. }
  398.  
  399. return(true);
  400. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement