fight.qsrc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. # fight
  2. !2020/10/14/Gwen
  3. !{ To Use Fight:
  4. 1) Initialize fight to make sure previous fighter are cleared out.
  5. 2) Add Opponents and Allies
  6. 3) Set Fight Ending
  7. 4) Start Fight
  8. Example:
  9. Let''s make a fight where Tatiana helps us beat Kisame and a bandit
  10. gs 'fight','initFight'
  11. gs 'fight_npcdata', 'tatiana', 'pcs'
  12. gs 'fight_npcdata', 'kisame', 'opp'
  13. gs 'fight_npcdata', 'bandit', 'opp'
  14. fightEnding = 2
  15. gt 'fight', 'start'
  16. }
  17. !! Variables to be set for each participant before fight - in brackets so you can copy/paste
  18. !!{
  19. $opp_name[0] = <<name of opponent>>
  20. $opp_image[0] = opponent image ie. '<img <<$set_imgh>> src="images/characters/city/tobi/tobi.jpg">'
  21. opp_def[0] = opponent defence
  22. opp_run[0] = Opponent running skill used for player escape
  23. opp_wrstlng[0] = Wrestling skill
  24. opp_kick[0] = Kicking
  25. opp_punch[0] = Power punch
  26. opp_jab[0] = Light punch
  27. opp_stren[0] = Strengh
  28. opp_agil[0] = Agility
  29. opp_vital[0] = vitality
  30. opp_react[0] = Reactions
  31. opp_health[0] = Health
  32. opp_willpwr[0] = willpower
  33. opp_shoot[0] = opponent marksmanship (only required if they are armed)
  34. opp_magik[0] = only if they have magic
  35. opp_mana[0] = only if they have magic
  36. opp_fog[0] = (tuman): Obscures vision, makes hitting harder.
  37. opp_clone[0] = (klon): Copies of the char that absorb 1 hit and disappear. A char may have some number of them.
  38. opp_shield[0] = (defence): Shielding that absorbs damage before hitpoints.
  39. opp_dambonus[0] = (magweapbonus): damage added to melee attacks
  40. opp_init[0] = (initBonus): attack faster/first
  41. opp_stun[0] = (stunner): make target unable to act for some amount of time
  42. opp_spells[0] = comma delimited list of spell names
  43. }
  44. !! Use the above with [1] and [2] for extra opponents
  45. !! Use pcs_ prefix for Sveta and add [1] and [2] for allies. ie. $pcs_name[1] = 'Reinhold'
  46. if $ARGS[0] = 'initFight':
  47. !! Clear Opponents from previous battle
  48. killvar '$opp_name'
  49. killvar '$opp_image'
  50. killvar 'opp_def'
  51. killvar 'opp_run'
  52. killvar 'opp_wrstlng'
  53. killvar 'opp_kick'
  54. killvar 'opp_punch'
  55. killvar 'opp_jab'
  56. killvar 'opp_stren'
  57. killvar 'opp_agil'
  58. killvar 'opp_vital'
  59. killvar 'opp_react'
  60. killvar 'opp_health'
  61. killvar 'opp_willpwr'
  62. killvar 'opp_shoot'
  63. killvar 'opp_magik'
  64. killvar 'opp_mana'
  65. killvar 'opp_fog'
  66. killvar 'opp_clone'
  67. killvar 'opp_shield'
  68. killvar 'opp_dambonus'
  69. killvar 'opp_init'
  70. killvar 'opp_stun'
  71. killvar '$opp_spells'
  72. killvar 'opp_timer'
  73. !! Clear any allies from previous battle
  74. i = arrsize('pcs_health')
  75. :ClearAllyLoop
  76. if i > 1:
  77. gs 'fight', 'clearPCSArray', i-1
  78. i -= 1
  79. jump 'ClearAllyLoop'
  80. end
  81. killvar 'i'
  82. !! Initialize $pcs_name for Sveta
  83. $pcs_name[0] = 'You'
  84. if ARGS[1] = 1:
  85. $pcs_image[0] = 'images/system/intro/tg/self.jpg'
  86. else
  87. $pcs_image[0] = FUNC('$face_image')
  88. end
  89. end
  90. if $ARGS[0] = 'clearPCSArray':
  91. !{ Delete an Ally from the pcs data arrays
  92. ARGS[1] = Which ally slot tot delete
  93. }
  94. i = ARGS[1]
  95. killvar '$pcs_name', i
  96. killvar '$pcs_image', i
  97. killvar 'pcs_def', i
  98. killvar 'pcs_run', i
  99. killvar 'pcs_wrstlng', i
  100. killvar 'pcs_kick', i
  101. killvar 'pcs_punch', i
  102. killvar 'pcs_jab', i
  103. killvar 'pcs_stren', i
  104. killvar 'pcs_agil', i
  105. killvar 'pcs_vital', i
  106. killvar 'pcs_react', i
  107. killvar 'pcs_health', i
  108. killvar 'pcs_willpwr', i
  109. killvar 'pcs_shoot', i
  110. killvar 'pcs_magik', i
  111. killvar 'pcs_mana', i
  112. killvar 'pcs_fog', i
  113. killvar 'pcs_clone', i
  114. killvar 'pcs_shield', i
  115. killvar 'pcs_dambonus', i
  116. killvar 'pcs_init', i
  117. killvar 'pcs_stun', i
  118. killvar 'pcs_spells', i
  119. killvar 'pcs_timer', i
  120. killvar 'i'
  121. end
  122. if $ARGS[0] = 'randomOpp':
  123. !{ Generate a random Opponent
  124. ARGS[1] = Optional, raise difficulty of the attacker, 0 - 50
  125. }
  126. OppDiffBonus = ARGS[1]
  127. i = arrsize('opp_health')
  128. $opp_name[i] = 'Opponent 1'
  129. $opp_image[i] = 'images/locations/shared/street/mugger.jpg'
  130. opp_def[i] = rand(1,50) + OppDiffBonus
  131. opp_run[i] = rand(1,50) + OppDiffBonus
  132. opp_wrstlng[i] = rand(1,50) + OppDiffBonus
  133. opp_kick[i] = rand(1,50) + OppDiffBonus
  134. opp_punch[i] = rand(1,50) + OppDiffBonus
  135. opp_jab[i] = rand(1,50) + OppDiffBonus
  136. opp_stren[i] = rand(1,50) + OppDiffBonus
  137. opp_agil[i] = rand(1,50) + OppDiffBonus
  138. opp_vital[i] = rand(1,50) + OppDiffBonus
  139. opp_health[i] = (opp_vital * 10 + opp_stren * 5)
  140. opp_react[i] = rand(1,50) + OppDiffBonus
  141. opp_willpwr[i] = rand(1,50) + OppDiffBonus
  142. opp_shoot[i] = rand(1,50) + OppDiffBonus
  143. killvar 'OppDiffBonus'
  144. killvar 'i'
  145. end
  146. if $ARGS[0] = 'applyDamage':
  147. !{ Apply Damage to a participant taking into account clones and shields
  148. $ARGS[1] = Target Type ('opp','pcs')
  149. ARGS[2] = Target number
  150. ARGS[3] = damage to be applied
  151. }
  152. $fightAppDam['TargetType'] = $ARGS[1]
  153. fightAppDam['TargetNumber'] = ARGS[2]
  154. fightAppDam['Damage'] = ARGS[3]
  155. $fightAppDam['TargetName'] = dyneval('$result=$<<$fightAppDam[''TargetType'']>>_name[<<fightAppDam[''TargetNumber'']>>]')
  156. fightAppDam['Shield'] = dyneval('result=<<$fightAppDam[''TargetType'']>>_shield[<<fightAppDam[''TargetNumber'']>>]')
  157. fightAppDam['OverShieldDamage'] = dyneval('result=<<fightAppDam[''Damage'']>> - <<$fightAppDam[''TargetType'']>>_shield[<<fightAppDam[''TargetNumber'']>>]')
  158. dynamic "
  159. !!If the target has clones, destroy one
  160. if <<$fightAppDam['TargetType']>>_clone[<<fightAppDam['TargetNumber']>>] > 0:
  161. <<$fightAppDam['TargetType']>>_clone[<<fightAppDam['TargetNumber']>>] -= 1
  162. ""<<$fightAppDam['TargetName']>> loses a clone.""
  163. !!if the target has enough shields to mitigate, remove some shields
  164. elseif <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] >= <<fightAppDam['Damage']>>:
  165. <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] -= <<fightAppDam['Damage']>>
  166. ""<<$fightAppDam['TargetName']>> loses <<fightAppDam['Damage']>> defense.""
  167. !!otherwise remove shields to 0 and the remainder comes from health
  168. else
  169. if <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] > 0:
  170. <<$fightAppDam['TargetType']>>_shield[<<fightAppDam['TargetNumber']>>] = 0
  171. ""<<$fightAppDam['TargetName']>> losses <<fightAppDam['Shield']>> defense.""
  172. end
  173. if <<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] > <<fightAppDam['OverShieldDamage']>>:
  174. <<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] -= <<fightAppDam['OverShieldDamage']>>
  175. else
  176. <<$fightAppDam['TargetType']>>_health[<<fightAppDam['TargetNumber']>>] = 0
  177. end
  178. ""<<$fightAppDam['TargetName']>> loses <<fightAppDam['OverShieldDamage']>> health.""
  179. end
  180. "
  181. killvar '$fightAppDam'
  182. killvar 'fightAppDam'
  183. end
  184. if $ARGS[0] = 'start':
  185. menu_off = 1
  186. inFight = 1
  187. gs 'themes', 'indoors'
  188. cla
  189. if arrsize('pcs_health') > arrsize('opp_health'):
  190. tableSize = arrsize('pcs_health')
  191. else
  192. tableSize = arrsize('opp_health')
  193. end
  194. $HTMLText = '<table border=1>
  195. <tr>
  196. <th align="left"><b><font size=18>Allies</font></b></td>
  197. <th align="center" valign="center" rowspan=<<tableSize*2+1>> ><b><font size=18>vs.</font></b></center></td>
  198. <th align="right"><b><font size=18>Opponents</font></b></td>
  199. </tr>'
  200. i = 0
  201. :FightPoster
  202. if i < tableSize:
  203. $HTMLText += '
  204. <tr>
  205. <td align="left"><img HEIGHT=300 src="<<$pcs_image[i]>>"></left></td>
  206. <td align="right"><img HEIGHT=300 src="<<$opp_image[i]>>"></right></td>
  207. </tr>
  208. <tr>
  209. <td align="left"><b><font size=10><<$pcs_name[i]>></font></b></left></td>
  210. <td align="right"><b><font size=10><<$opp_name[i]>></font></b></right></td>
  211. </tr>'
  212. i += 1
  213. jump 'FightPoster'
  214. end
  215. $HTMLText += '</table>'
  216. *pl func('cleanHTML',$HTMLText)
  217. i=0
  218. :PCSTimerInit
  219. if i < arrsize('pcs_health'):
  220. pcs_timer[i] = 100 - pcs_react[i]
  221. i +=1
  222. jump 'PCSTimerInit'
  223. end
  224. i=0
  225. :OppTimerInit
  226. if i < arrsize('opp_health'):
  227. opp_timer[i] = 100 - opp_react[i]
  228. i +=1
  229. jump 'OppTimerInit'
  230. end
  231. act 'Fight!': gt 'fight', 'main'
  232. killvar '$HTMLText'
  233. killvar 'tableSize'
  234. killvar 'i'
  235. end
  236. if $ARGS[0] = 'findActiveTimer':
  237. !! Find the participant with the lowest Timer
  238. ! These values are passed back via two global variables.
  239. !
  240. ! $fightTimType = 'player' or 'opponent' depending on which group has the lowest member
  241. ! fightTimNum = the array number of the lowest participant
  242. $fightTimType = 'player'
  243. fightTimNum = 0
  244. !! set this to high so that everyone will be lower.
  245. fightTimLow = 99999
  246. !! Find lowest of pcs participants
  247. i = 0
  248. :LowTimerLoop1
  249. if i < arrsize('pcs_timer'):
  250. !Skip round if char is stunned
  251. if pcs_stun[i] > 0:
  252. pcs_stun[i] -= 1
  253. !Skip anyone with no Health
  254. elseif pcs_health[i] > 0:
  255. if pcs_timer[i] < fightTimLow:
  256. fightTimLow = pcs_timer[i]
  257. fightTimNum = i
  258. end
  259. end
  260. i += 1
  261. jump 'LowTimerLoop1'
  262. end
  263. !!Find if any Opponents have lower than best PCS
  264. i = 0
  265. :LowTimerLoop2
  266. if i < arrsize('opp_timer'):
  267. !Skip round if char is stunned
  268. if opp_stun[i] > 0:
  269. opp_stun[i] -= 1
  270. !Skip anyone with no Health
  271. elseif opp_health[i] > 0:
  272. if opp_timer[i] < fightTimLow:
  273. fightTimLow = opp_timer[i]
  274. fightTimNum = i
  275. $fightTimType = 'opponent'
  276. end
  277. end
  278. i += 1
  279. jump 'LowTimerLoop2'
  280. end
  281. killvar 'i'
  282. end
  283. if $ARGS[0] = 'main':
  284. gs 'fight', 'result_check'
  285. gs 'fight', 'findActiveTimer'
  286. gt 'fight', $fightTimType, fightTimNum
  287. end
  288. if $ARGS[0] = 'printStats':
  289. !{ Print the stats for a character
  290. $ARGS[1] = The Type of char ('opp','pcs')
  291. ARGS[2] = The member of the party
  292. }
  293. $fightPStats['CharType'] = $ARGS[1]
  294. i = ARGS[2]
  295. if $fightPStats['CharType'] = 'opp':
  296. $fightPStats['Name'] = $opp_name[i]
  297. fightPStats['Health'] = opp_health[i]
  298. fightPStats['Mana'] = opp_mana[i]
  299. fightPStats['Willpower'] = opp_willpwr[i]
  300. fightPStats['Shield'] = opp_shield[i]
  301. fightPStats['Fog'] = opp_fog[i]
  302. fightPStats['Clone'] = opp_clone[i]
  303. fightPStats['Stun'] = opp_stun[i]
  304. fightPStats['Timer'] = opp_timer[i]
  305. $fightPStats['Image'] = $opp_image[i]
  306. else
  307. $fightPStats['Name'] = $pcs_name[i]
  308. fightPStats['Health'] = pcs_health[i]
  309. fightPStats['Mana'] = pcs_mana[i]
  310. fightPStats['Willpower'] = pcs_willpwr[i]
  311. fightPStats['Shield'] = pcs_shield[i]
  312. fightPStats['Fog'] = pcs_fog[i]
  313. fightPStats['Clone'] = pcs_clone[i]
  314. fightPStats['Stun'] = pcs_stun[i]
  315. fightPStats['Timer'] = pcs_timer[i]
  316. $fightPStats['Image'] = $pcs_image[i]
  317. end
  318. $fightStatRowText = "
  319. <tr>
  320. <td rowspan=4 align=right valign=center>
  321. <img HEIGHT=70 src='<<$fightPStats['Image']>>'>
  322. <br> <b><<$fightPStats['Name']>></b>
  323. </td>
  324. <td align=right> Life </td>
  325. <td align=right> <b><font color = red><<fightPStats['Health']>></font></b> </td>
  326. <td rowspan=4 align=left valign=center>"
  327. if fightPStats['Shield'] > 0:$fightStatRowText += "<b><font color = purple>Protection <<fightPStats['Shield']>> units</font></b><br>"
  328. if fightPStats['Clone'] > 0:$fightStatRowText += "<b><font color = purple>Clones active <<fightPStats['Clone']>> </font></b><br>"
  329. if fightPStats['Fog'] > 0:$fightStatRowText += "<b><font color = purple>Obscuring Fog <<fightPStats['Fog']>> units</font></b><br>"
  330. if fightPStats['Stun'] > 0:$fightStatRowText += "<b><font color = purple>Stunned <<fightPStats['Stun']>> rounds</font></b>"
  331. $fightStatRowText += "
  332. </td>
  333. </tr>
  334. <tr>
  335. <td align=right> Mana </td>
  336. <td align=right> <b><font color = blue><<fightPStats['Mana']>></font></b> </td>
  337. </tr>
  338. <tr>
  339. <td align=right> Willpower </td>
  340. <td align=right> <b><font color = green><<fightPStats['Willpower']>></font></b> </td>
  341. </tr>
  342. <tr>
  343. <td align=right> Initiative </td>
  344. <td align=right> <b><font color = orange><<fightPStats['Timer']>></font></b> </td>
  345. </tr><tr><td colspan=4 bgcolor=grey></td></tr>"
  346. $result = $fightStatRowText
  347. killvar 'i'
  348. killvar 'fightPStats'
  349. killvar '$fightPStats'
  350. end
  351. if $ARGS[0] = 'statDisplay':
  352. $fightStatText = "
  353. <table border=1><th colspan=4><b><font size=12>Opponents</font></b></th>
  354. "
  355. j = 0
  356. :OppLoopRC1
  357. if j < arrsize('opp_health'):
  358. $fightStatText += func('fight', 'printStats', 'opp', j)
  359. j += 1
  360. jump 'OppLoopRC1'
  361. end
  362. $fightStatText += "</table>"
  363. *pl func('cleanHTML',$fightStatText)
  364. *nl
  365. $fightStatText = "
  366. <table border=1><th colspan=4><b><font size=12>Opponents</font></b></th>
  367. "
  368. j = 0
  369. :PCSLoopRC1
  370. if j < arrsize('pcs_health'):
  371. $fightStatText += func('fight', 'printStats', 'pcs', j)
  372. j += 1
  373. jump 'PCSLoopRC1'
  374. end
  375. $fightStatText += "</table>"
  376. *pl func('cleanHTML',$fightStatText)
  377. end
  378. if $ARGS[0] = 'result_check':
  379. !!cheat to auto-win fights check
  380. if fight_cheat = 1:
  381. xgt 'ender', 'win'
  382. gt $loc, $loc_arg
  383. exit
  384. end
  385. !!win/lose conditions
  386. if func('fight', 'AvailableTargets', 'pcs') = 0:
  387. '<b><font color = red> You lost!</font></b>'
  388. xgt'ender','loss'
  389. gt $loc, $loc_arg
  390. exit
  391. elseif func('fight', 'AvailableTargets', 'opp') = 0:
  392. '<b><font color = green><<$boydesc>> You won!</font></b>'
  393. xgt'ender','win'
  394. gt $loc, $loc_arg
  395. exit
  396. elseif pcs_willpwr <= 0:
  397. '<b><font color = red> You cannot summon the will to fight!</font></b>'
  398. xgt'ender','loss'
  399. gt $loc, $loc_arg
  400. exit
  401. end
  402. !gt 'fight', 'main'
  403. killvar 'i'
  404. end
  405. !! Kick
  406. $AttackType[0] = 'Kick'
  407. $AttackSkill[0] = 'kick'
  408. AttackMin[0] = 5
  409. AttackMax[0] = 8
  410. AttackTime[0] = 40
  411. !! Hard Punch
  412. $AttackType[1] = 'Hard Punch'
  413. $AttackSkill[1] = 'punch'
  414. AttackMin[1] = 4
  415. AttackMax[1] = 6
  416. AttackTime[1] = 30
  417. !! Jab
  418. $AttackType[2] = 'Jab'
  419. $AttackSkill[2] = 'jab'
  420. AttackMin[2] = 2
  421. AttackMax[2] = 3
  422. AttackTime[2] = 15
  423. !!{Attack a target
  424. $ARGS[0] = Attack Type
  425. $ARGS[1] = Target Type
  426. ARGS[2] = Which target
  427. ARGS[3] = Which Attacker
  428. }
  429. if $ARGS[0] = 'Attack':
  430. $fightAtk_Type = $ARGS[1]
  431. fightAtk_Type = arrpos('$AttackType',$fightAtk_Type)
  432. $fightAtk_TargetType = $ARGS[2]
  433. fightAtk_TargetNumber = ARGS[3]
  434. fightAtk_AttackerNumber = ARGS[4]
  435. if $fightAtk_TargetType = 'opp' and fightAtk_AttackerNumber = 0:
  436. $fightAtk_AttackerType = 'pcs'
  437. $fightAtk['DefenderName'] = $opp_name[fightAtk_TargetNumber]
  438. $fightAtk['AttackerName'] = 'You'
  439. !!Add Skill Exp
  440. dynamic "<<$AttackSkill[fightAtk_Type]>>_exp += rand(1,3)"
  441. elseif $fightAtk_TargetType = 'opp':
  442. $fightAtk['AttackerName'] = $pcs_name[fightAtk_AttackerNumber]
  443. $fightAtk['DefenderName'] = $opp_name[fightAtk_TargetNumber]
  444. $fightAtk_AttackerType = 'pcs'
  445. else
  446. $fightAtk_AttackerType = 'opp'
  447. $fightAtk['AttackerName'] = $opp_name[fightAtk_AttackerNumber]
  448. $fightAtk['DefenderName'] = $pcs_name[fightAtk_TargetNumber]
  449. end
  450. fightAtk['AttackerSkillValue'] = dyneval('result = <<$fightAtk_AttackerType>>_<<$AttackSkill[fightAtk_Type]>>[<<fightAtk_AttackerNumber>>]')
  451. fightAtk['TargetReactValue'] = dyneval('result = iif(<<$fightAtk_TargetType>>_stun[<<fightAtk_TargetNumber>>]>0,0,<<$fightAtk_TargetType>>_react[<<fightAtk_TargetNumber>>])')
  452. fightAtk['TargetAgilValue'] = dyneval('result = iif(<<$fightAtk_TargetType>>_stun[<<fightAtk_TargetNumber>>]>0,0,<<$fightAtk_TargetType>>_agil[<<fightAtk_TargetNumber>>])')
  453. fightAtk['TargetHealthBefore'] = dyneval('result = <<$fightAtk_TargetType>>_health[<<fightAtk_TargetNumber>>]')
  454. fightAtk['MinDamage'] = AttackMin[fightAtk_Type]
  455. fightAtk['MaxDamage'] = AttackMax[fightAtk_Type]
  456. if $fightAtk_TargetType = 'opp' and fightAtk_AttackerNumber = 0:
  457. 'You attempt to <<$fightAtk_Type>> <<$fightAtk["DefenderName"]>>!'
  458. else
  459. '<<$fightAtk["AttackerName"]>> attempts to <<$fightAtk_Type>> <<$fightAtk["DefenderName"]>>!'
  460. end
  461. *nl
  462. if fightAtk['AttackerSkillValue'] + rand(0,40) > fightAtk['TargetReactValue'] / 4 + 3 * fightAtk['TargetAgilValue'] / 4:
  463. !!Calculate Damage
  464. dynamic "fightAtk['Damage'] = <<$fightAtk_AttackerType>>_stren[<<fightAtk_AttackerNumber>>] * rand(<<fightAtk['MinDamage']>>,<<fightAtk['MaxDamage']>>) / 3"
  465. !!Apply Damage
  466. gs 'fight', 'applyDamage', $fightAtk_TargetType, fightAtk_TargetNumber, fightAtk['Damage']
  467. elseif rand(0,3) ! 0:
  468. !!Always chance to hit if rand = 0
  469. if $fightAtk_TargetType = 'pcs' and fightAtk_AttackerNumber = 0:
  470. 'You avoid the blow.'
  471. else
  472. '<<$fightAtk["DefenderName"]>> avoids the blow.'
  473. end
  474. else
  475. !!Apply Damage
  476. gs 'fight', 'applyDamage', $fightAtk_TargetType, fightAtk_TargetNumber, fightAtk['Damage']
  477. end
  478. !! Flavor text for size of the hit.
  479. fightAtk['TargetHealthLoss'] = fightAtk['TargetHealthBefore'] - dyneval('result = <<$fightAtk_TargetType>>_health[<<fightAtk_TargetNumber>>]')
  480. !! If blow does over half health in damage, causes stun
  481. if fightAtk['TargetHealthLoss']*2 > fightAtk['TargetHealthBefore']:
  482. if $fightAtk_TargetType = 'pcs' and fightAtk_TargetNumber = 0:
  483. 'It is a devastating blow. You are stunned.'
  484. else
  485. 'It is a devastating blow. <<$fightAtk["DefenderName"]>> is stunned.'
  486. end
  487. dynamic '<<$fightAtk_TargetType>>_stun[<<fightAtk_TargetNumber>>] += 1'
  488. dynamic '<<$fightAtk_TargetType>>_timer[<<fightAtk_TargetNumber>>] += AttackTime[<<fightAtk_Type>>]'
  489. !! Very hard hit
  490. elseif fightAtk['TargetHealthLoss'] > 50:
  491. if $fightAtk_TargetType = 'pcs' and fightAtk_TargetNumber = 0:
  492. 'The hit is hard and you reel in pain.'
  493. else
  494. 'The hit is hard and <<$fightAtk["DefenderName"]>> reels in pain.'
  495. end
  496. !! Does physical damage, but not a lot
  497. elseif fightAtk['TargetHealthLoss'] > 0:
  498. 'It''s a glancing blow, but still hurts.'
  499. !! No physical damage was done.
  500. else
  501. 'Defenses were not pierced.'
  502. end
  503. dynamic "<<$fightAtk_AttackerType>>_timer[<<fightAtk_AttackerNumber>>] += AttackTime[<<fightAtk_Type>>]"
  504. cla
  505. act 'Next': gt 'fight', 'main'
  506. end
  507. !! Make a list of targets that still have health
  508. ! $ARGS[1] = Target Type ('pcs','opp')
  509. if $ARGS[0] = 'AvailableTargets':
  510. killvar 'fightAvailTarg'
  511. i=0
  512. :AvailTargetLoop
  513. if i < arrsize($ARGS[1]+'_health'):
  514. if dyneval('result=<<$ARGS[1]>>_health[<<i>>]') > 0:
  515. fightAvailTarg[] = i
  516. end
  517. i +=1
  518. jump 'AvailTargetLoop'
  519. end
  520. result = arrsize('fightAvailTarg')
  521. killvar 'i'
  522. exit
  523. end
  524. !! Pick random target from list of targets. Returns the Target, or -1 if no target.
  525. ! $ARGS[1] = Target Type ('pcs','opp')
  526. if $ARGS[0] = 'RandomTarget':
  527. if func('fight', 'AvailableTargets', $ARGS[1]) > 0:
  528. result = fightAvailTarg[rand(0,arrsize('fightAvailTarg'))-1]
  529. else
  530. result = -1
  531. end
  532. exit
  533. end
  534. !! Find Action for an NPC fighter to take
  535. ! $ARGS[1] = Attacker Type ('opp','pcs')
  536. ! ARGS[2] = Attacker party member number
  537. if $ARGS[0] = 'fightAlgorithm':
  538. $AttackerType = $ARGS[1]
  539. AttackerNumber = ARGS[2]
  540. if $AttackerType = 'pcs':
  541. $TargetType = 'opp'
  542. else
  543. $TargetType = 'pcs'
  544. end
  545. TargetNumber = func('fight', 'RandomTarget', $TargetType)
  546. !! Some Target still has some hitpoints
  547. if TargetNumber>= 0:
  548. !!Fight Algorithm
  549. ActionMade = 0
  550. ! First try to cast spells
  551. if dyneval('result=<<$AttackerType>>_magik[<<AttackerNumber>>]') > 0:
  552. gs 'fight', 'buildCasterSpellList', $dyneval('$result=$<<$AttackerType>>_spells[<<AttackerNumber>>]')
  553. !Heal self if hurt badly
  554. if dyneval('result=<<$AttackerType>>_health[<<AttackerNumber>>]') < 50:
  555. ActionMade = func('fight','spellListCheck', '$comHealSpells',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)
  556. end
  557. !Clone if none left
  558. if dyneval('result=<<$AttackerType>>_clone[<<AttackerNumber>>]') = 0 and ActionMade = 0:
  559. ActionMade = func('fight','spellCheck', 'multiclone',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)
  560. if ActionMade = 0:
  561. ActionMade = func('fight','spellCheck', 'clone',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)
  562. end
  563. end
  564. !Shield if low shield
  565. if dyneval('result=<<$AttackerType>>_shield[<<AttackerNumber>>]') = 0 and ActionMade = 0:
  566. ActionMade = func('fight','spellListCheck', '$comShldSpells',$AttackerType,AttackerNumber,$AttackerType,AttackerNumber)
  567. end
  568. !Fog if no Fog , Any fog on the field makes casting fog impossible
  569. !if opp_fog[ARGS[2]] = 0 and ActionMade = 0:
  570. ! ActionMade = func('fight','spellCheck', 'fog','opp',ARGS[2],'opp',ARGS[2])
  571. !end
  572. !Buff if needed
  573. ! ToDo - How to determine if buff has already been applied
  574. !Attack Spell if Possible
  575. if ActionMade = 0:
  576. ActionMade = func('fight','spellListCheck', '$comAtkSpells',$TargetType,TargetNumber,$AttackerType,AttackerNumber)
  577. end
  578. !make sure we can continue the fight.
  579. !if ActionMode = 1:
  580. act 'Next': gt 'fight', 'main'
  581. !end
  582. end
  583. !Physical attack if nothing else can be done.
  584. if ActionMade = 0:
  585. if rand(0,dyneval('result=<<$AttackerType>>_kick[<<AttackerNumber>>]')) > 40:
  586. gs 'fight', 'Attack', 'Kick', $TargetType, TargetNumber, AttackerNumber
  587. elseif rand(0,dyneval('result=<<$AttackerType>>_punch[<<AttackerNumber>>]')) > 40:
  588. gs 'fight', 'Attack', 'Hard Punch', $TargetType, TargetNumber, AttackerNumber
  589. else
  590. gs 'fight', 'Attack', 'Jab', $TargetType, TargetNumber, AttackerNumber
  591. end
  592. !Spell was cast, so move timer.
  593. else
  594. dynamic "<<$AttackerType>>_timer[<<AttackerNumber>>] += 50"
  595. end
  596. !!This should never happen
  597. else
  598. gt 'fight', 'main'
  599. end
  600. killvar 'ActionMade'
  601. killvar 'TargetNumber'
  602. killvar '$TargetType'
  603. killvar '$AttackerType'
  604. killvar 'AttackerNumber'
  605. end
  606. if $ARGS[0] = 'opponent':
  607. gs 'fight', 'statDisplay'
  608. gs 'fight','fightAlgorithm','opp',ARGS[1]
  609. end
  610. if $ARGS[0] = 'player':
  611. gs 'fight', 'statDisplay'
  612. !! If this is the Player character
  613. if ARGS[2] = 0:
  614. if pcs_magik > 0:
  615. act 'Cast a Spell': gs 'fight', 'spellcast'
  616. end
  617. if func('fight', 'AvailableTargets', 'opp') > 0:
  618. i=0
  619. :loop000000
  620. if i < arrsize('fightAvailTarg'):
  621. $op_name_000000 = $opp_name[fightAvailTarg[i]]
  622. dynamic "
  623. act 'Kick <<$op_name_000000>>':
  624. gs 'fight', 'Attack', 'Kick', 'opp', <<fightAvailTarg[i]>>, 0
  625. end
  626. act 'Punch <<$op_name_000000>> hard':
  627. gs 'fight', 'Attack', 'Hard Punch', 'opp', <<fightAvailTarg[i]>>, 0
  628. end
  629. act 'Jab <<$op_name_000000>>':
  630. gs 'fight', 'Attack', 'Jab', 'opp', <<fightAvailTarg[i]>>, 0
  631. end
  632. "
  633. killvar '$op_name_000000'
  634. i +=1
  635. jump 'loop000000'
  636. end
  637. end
  638. act 'Surrender': gt 'ender', 'surrender'
  639. !! If this is a team member of the player
  640. else
  641. gs 'fight','fightAlgorithm','pcs',ARGS[2]
  642. end
  643. end
  644. !! Builds an array spell list from a comma delimited spell name list
  645. ! $ARGS[1] = comma delimited list of spell names
  646. if $ARGS[0] = 'buildCasterSpellList':
  647. killvar '$casterSpellList'
  648. $tmpStr = $trim($ARGS[1])
  649. :loop000001
  650. i=INSTR($tmpStr,',')
  651. if i > 0:
  652. $casterSpellList[] = $trim($mid($tmpStr,1,i-1))
  653. $tmpStr = $trim($mid($tmpStr,i+1))
  654. jump 'loop000001'
  655. else
  656. $casterSpellList[] = $trim($tmpStr)
  657. end
  658. killvar 'i'
  659. killvar '$tmpStr'
  660. exit
  661. end
  662. !! Check if spell will be cast
  663. ! $ARGS[1] = spell name
  664. ! $ARGS[2] = Target Type ('opp','pcs')
  665. ! ARGS[3] = Target party member number
  666. ! $ARGS[4] = Caster Type ('opp','pcs')
  667. ! ARGS[5] = Caster party member number
  668. if $ARGS[0] = 'spellCheck':
  669. $spellCheckVar['SpellName'] = $ARGS[1]
  670. $spellCheckVar['TargetType'] = $ARGS[2]
  671. spellCheckVar['TargetNumber'] = ARGS[3]
  672. $spellCheckVar['CasterType'] = $ARGS[4]
  673. spellCheckVar['CasterNumber'] = ARGS[5]
  674. spellCheckVar['CasterMana'] = dyneval("result = <<$spellCheckVar['CasterType']>>_mana[<<spellCheckVar['CasterNumber']>>]")
  675. if ARRPOS('$casterSpellList',$spellCheckVar['SpellName'])>=0 and spellCheckVar['CasterMana'] >= spellMana[$spellCheckVar['SpellName']]:
  676. if $spellTarget[$spellCheckVar['SpellName']] = 'self':
  677. gs 'castSpellNPC', $spellCheckVar['SpellName'], $spellCheckVar['CasterType'], spellCheckVar['CasterNumber'],$spellCheckVar['CasterType'], spellCheckVar['CasterNumber']
  678. else
  679. gs 'castSpellNPC', $spellCheckVar['SpellName'], $spellCheckVar['TargetType'], spellCheckVar['TargetNumber'],$spellCheckVar['CasterType'], spellCheckVar['CasterNumber']
  680. end
  681. result = 1
  682. else
  683. result = 0
  684. end
  685. killvar 'spellCheckVar'
  686. killvar '$spellCheckVar'
  687. exit
  688. end
  689. !! Check list of spells if they will be cast
  690. ! $ARGS[1] = spell List array name
  691. ! $ARGS[2] = Target Type ('opp','pcs')
  692. ! ARGS[3] = Target party member number
  693. ! $ARGS[4] = Caster Type ('opp','pcs')
  694. ! ARGS[5] = Caster party member number
  695. if $ARGS[0] = 'spellListCheck':
  696. i=0
  697. ActionMade1 = 0
  698. :loop000002
  699. if i < arrsize($ARGS[1]) and ActionMade1=0:
  700. ActionMade1 = func('fight','spellCheck','<<$ARGS[1]>>[<<i>>]',$ARGS[2],ARGS[3],$ARGS[4],ARGS[5])
  701. i+=1
  702. jump 'loop000002'
  703. end
  704. result = ActionMade1
  705. killvar 'ActionMade1'
  706. exit
  707. end
  708. if $ARGS[0] = 'spellcast':
  709. *clr
  710. cla
  711. act 'Next': gt 'fight', 'main'
  712. func('spellBook', 'targetable', '$combatSpells', 'gt ''fight'', ''main''', 'pcs_timer[0] += 50')
  713. end
  714. !!--------------------------------------------------old shit--------------------------------------------------
  715. if $ARGS[0] = 'sta':
  716. menu_off = 1
  717. cla
  718. damTip = 0
  719. damTipM = 0
  720. damTipV = 0
  721. damTipMV = 0
  722. magweapbonus = 0
  723. magweapbonusV = 0
  724. bonusSh = 0
  725. bonusShV = 0
  726. eleSh = 0
  727. eleShV = 0
  728. poisonAV = 0
  729. hidanAtk = 0
  730. '<b>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</b>'
  731. '<b><<$boydesc>></b> life <b><font color = red><<healthV>></font></b>, mana <b><font color = blue><<manaV>></font></b>, willpower <b><font color = green><<willpowerV>></font></b>'
  732. if defenceV > 0:'<b><font color = red>Protection <<defenceV>> units</font></b>'
  733. if defenceMV > 0:'<b><font color = red>Mana protection <<defenceMV>> units</font></b>'
  734. if defenceWV > 0:'<b><font color = red>Will protection <<defenceWV>> units</font></b>'
  735. 'Your life <b><font color = red><<pcs_health>></font></b>, mana <b><font color = blue><<pcs_mana>></font></b>, willpower <b><font color = green><<pcs_willpwr>></font></b>'
  736. if defence > 0:'<b><font color = green>Protection <<defence>> units</font></b>'
  737. if defenceM > 0:'<b><font color = green>Mana impact protection <<defenceM>> units</font></b>'
  738. if defenceW > 0:'<b><font color = green>Will impact protection <<defenceW>> units</font></b>'
  739. if defenceAct > 0:'<b><font color = green><<defenceAct>> Regeneration</font></b>'
  740. if defenceActM > 0:'<b><font color = green><<defenceActM>> Mana recovery protection</font></b>'
  741. '<b>= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</b>'
  742. if autocombat_cheat = 0: act 'Continue':gt'fight','start'
  743. if autocombat_cheat = 1: gt'fight','start'
  744. end
  745. --- fight ---------------------------------