1
0

fight.qsrc 26 KB

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