1
0

fight.qsrc 26 KB

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