Battles

Moon_Shooter
18 Feb 2013, 05:01
I'm just curious if Quest has the capabilities of creating simple, or even complex battle systems, such as the ones found in perhaps Persona 3 or even the FF series... rather, can such things be done without the deepest understanding of the Java language.

HegemonKhan
18 Feb 2013, 05:15
the mechanics can be done, but I'm not sure about rpg-like about menus~windows~screens, though I think the next version will include a way of adding in more panes, but I don't know how much capabilities they'll have.

you can take a look at Pertex' and Pixie's combat related libraries of combat, magic, attacking and equiping, and etc

-----------

I'm a total noob with coding, working on creating a battle system code, and I'm making some good progress for myself of it.

I got the function equations of like attack, defense, evasion, ar~ac, and etc functional.

here's my code (but there's a lot of junk stuff in there, as I was working on how to do equipment, and the code itself needs to be fixed up more cleanly, as I want to try to do this myself, to learn how to make better coding on my own):

feel free to copy and paste, and try it out.

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<btrns type="int">0</btrns>
<brnds type="int">0</brnds>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc" />
<escaped type="boolean">false</escaped>
<cur_hp type="int">100</cur_hp>
<max_hp type="int">100</max_hp>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<str type="int">100</str>
<end type="int">100</end>
<dex type="int">100</dex>
<agi type="int">100</agi>
<spd type="int">100</spd>
<hc type="int">100</hc>
<pd type="int">100</pd>
<pr type="int">100</pr>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc" />
<hostile type="boolean">true</hostile>
<dead type="boolean">false</dead>
<alias>orc</alias>
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">25</str>
<end type="int">25</end>
<dex type="int">25</dex>
<agi type="int">25</agi>
<spd type="int">25</spd>
<hc type="int">25</hc>
<pd type="int">25</pd>
<pr type="int">25</pr>
<exp type="int">100</exp>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
sa
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">0</cur_mp>
<max_mp type="int">0</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<hc type="int">0</hc>
<pd type="int">0</pd>
<fd type="int">0</fd>
<wd type="int">0</wd>
<ad type="int">0</ad>
<ed type="int">0</ed>
<ld type="int">0</ld>
<dd type="int">0</dd>
<pr type="int">0</pr>
<fr type="int">0</fr>
<wr type="int">0</wr>
<ar type="int">0</ar>
<er type="int">0</er>
<lr type="int">0</lr>
<dr type="int">0</dr>
<wt type="int">0</wt>
<ht type="int">0</ht>
<cur_arrow type="int">0</cur_arrow>
<cur_bolt type="int">0</cur_bolt>
<cur_bullet type="int">0</cur_bullet>
<max_arrow type="int">0</max_arrow>
<max_bolt type="int">0</max_bolt>
<max_bullet type="int">0</max_bullet>
<arrows type="int">0</arrows>
<bolts type="int">0</bolts>
<bullets type="int">0</bullets>
<cur_shuriken type="int">0</cur_shuriken>
<cur_throwing_axe type="int">0</cur_throwing_axe>
<cur_javelin type="int">0</cur_javelin>
<max_shuriken type="int">0</max_shuriken>
<max_throwing_axe type="int">0</max_throwing_axe>
<max_javelin type="int">0</max_javelin>
<shurikens type="int">0</shurikens>
<throwing_axes type="int">0</throwing_axes>
<javelins type="int">0</javelins>
<cur_throwing_knife type="int">0</cur_throwing_knife>
<max_throwing_knife type="int">0</max_throwing_knife>
<throwing_knives type="int">0</throwing_knives>
</type>
<type name="pc">
<inherit name="char" />
<escaped type="boolean">false</escaped>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = ;hc = ;pd = ;fd = ;wd = ;ad = ;ed = ;ld = ;dd = ;pr = ;fr = ;wr = ;ar = ;er = ;lr = ;dr = ;wt = ;ht = ;arrows = ;bolts = ;bullets = ;shurikens = ;throwing_axes = ;javelins = ;throwing_knives = </statusattributes>
</type>
<type name="npc">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
<hostility type="script">
if (this.hostile = true) {
this.alias = this.displayalias + "(hostile)"
this.displayverbs = split ("Look;Use;Cast;Fight", ";")
}
</hostility>
<death type="script">
if (this.dead = true) {
this.alias = this.displayalias + "(dead)"
game.pov.exp = game.pov.exp + this.exp
this.displayverbs = split ("Look;Steal;Give;Use;Cast", ";")
}
</death>
</type>
<type name="storage">
<inherit name="container_closed" />
<drop type="boolean">false</drop>
<inventoryverbs type="list">Look; Open; Close</inventoryverbs>
</type>
<type name="gear">
<wt type="int">0</wt>
<take type="boolean">true</take>
<give type="boolean">true</give>
<equipped type="boolean">false</equipped>
<equipable type="boolean">true</equipable>
<unequipable type="boolean">true</unequipable>
<equipable_layer type="int">3</equipable_layer>
<equipable_slots type="list"></equipable_slots>
<inventoryverbs type="listextend">Equip;Unequip</inventoryverbs>
</type>
<type name="weapon">
<inherit name="gear" />
<pd type="int">0</pd>
<hc type="int">0</hc>
</type>
<type name="one_handed">
<inherit name="weapon" />
<equipable_slots type="list">right_hand</equipable_slots>
</type>
<type name="two_handed">
<inherit name="weapon" />
<equipable_slots type="list">left_hand;right_hand</equipable_slots>
</type>
<type name="sword">
</type>
<type name="axe">
</type>
<type name="blunt">
</type>
<type name="spear">
<inherit name="two_handed" />
</type>
<type name="staff">
<inherit name="two_handed" />
</type>
<type name="dagger">
<inherit name="one_handed" />
</type>
<type name="whip">
<inherit name="one_handed" />
</type>
<type name="bow">
<inherit name="two_handed" />
</type>
<type name="crossbow">
<inherit name="two_handed" />
</type>
<type name="gun">
</type>
<type name="throwing">
</type>
<type name="armor">
<inherit name="gear" />
<pr type="int">0</pr>
</type>
<type name="shield">
<inherit name="armor" />
<equipable_slots type="list">left_hand</equipable_slots>
</type>
<type name="clothing">
<inherit name="gear" />
</type>
<type name="headwear">
<equipable_slots type="list">head</equipable_slots>
</type>
<type name="facewear">
<inherit name="clothing" />
<equipable_slots type="list">face</equipable_slots>
</type>
<type name="earwear">
<inherit name="clothing" />
<equipable_slots type="list">ear</equipable_slots>
</type>
<type name="neckwear">
<inherit name="clothing" />
<equipable_slots type="list">neck</equipable_slots>
</type>
<type name="shoulderwear">
<inherit name="armor" />
<equipable_slots type="list">shoulder</equipable_slots>
</type>
<type name="armwear">
<equipable_slots type="list">arm</equipable_slots>
</type>
<type name="handwear">
<equipable_slots type="list">hand</equipable_slots>
</type>
<type name="fingerwear">
<inherit name="clothing" />
<equipable_slots type="list">finger</equipable_slots>
</type>
<type name="chestwear">
<equipable_slots type="list">chest</equipable_slots>
</type>
<type name="backwear">
<inherit name="clothing" />
<equipable_slots type="list">back</equipable_slots>
</type>
<type name="waistwear">
<equipable_slots type="list">waist</equipable_slots>
</type>
<type name="legwear">
<equipable_slots type="list">leg</equipable_slots>
</type>
<type name="footwear">
<equipable_slots type="list">foot</equipable_slots>
</type>
<type name="arrow">
<cur_arrow type="int">0</cur_arrow>
</type>
<type name="arrow_case">
<inherit name="backwear" />
<max_arrow type="int">0</max_arrow>
</type>
<type name="bolt">
<cur_bolt type="int">0</cur_bolt>
</type>
<type name="bolt_case">
<inherit name="backwear" />
<max_bolt type="int">0</max_bolt>
</type>
<type name="bullet">
<cur_bullet type="int">0</cur_bullet>
</type>
<type name="bullet_case">
<inherit name="backwear" />
<max_bullet type="int">0</max_bullet>
</type>
<type name="spell">
<drop type="boolean">false</drop>
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
</type>
<type name="fire">
</type>
<type name="water">
</type>
<type name="air">
</type>
<type name="earth">
</type>
<type name="light">
</type>
<type name="dark">
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="sa">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
game.pov.arrows = game.pov.cur_arrow + " / " + game.pov.max_arrow
game.pov.bolts = game.pov.cur_bolt + " / " + game.pov.max_bolt
game.pov.bullets = game.pov.cur_bullet + " / " + game.pov.max_bullet
game.pov.shurikens = game.pov.cur_shuriken + " / " + game.pov.max_shuriken
game.pov.javelins = game.pov.cur_javelin + " / " + game.pov.max_javelin
game.pov.throwing_axes = game.pov.cur_throwing_axe + " / " + game.pov.max_throwing_axe
game.pov.throwing_knives = game.pov.cur_throwing_knife + " / " + game.pov.max_throwing_knife
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
first_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
first_value = false
}
else if (not Doesinherit (enemy,"npc")) {
msg ("You can not battle that!")
first_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
first_value = false
}
else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
first_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
first_value = false
}
else if (battle_sequence (self,enemy) = true) {
msg ("The battle is over.")
first_value = true
}
return (first_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
second_value = false
if (enemy.dead = false) {
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy.dead = false) {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
}
}
else {
second_value = true
}
return (second_value)
]]></function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
third_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (self.alias + " has " + self.cur_mp + " MP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
fourth_value = false
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
fourth_value = true
}
else if (fourth_value = false) {
if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
}
}
case ("Defend") {
if (self.defending = false) {
self.defending = true
}
}
case ("Cast") {
self.defending = false
}
case ("Item") {
self.defending = false
}
case ("Run") {
self.defending = false
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn (self,enemy)
}
else {
msg ("Your battle turn is over.")
third_value = false
}
}
else if (GetInt (enemy,"cur_hp") <= 0) {
msg (enemy.alias + " is dead.")
msg ("You have won the battle!")
enemy.defending = false
enemy.dead = true
third_value = true
wait {
ClearScreen
}
}
}
}
return (third_value)
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
fifth_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (self.alias + " has " + self.cur_mp + " MP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
result = GetRandomInt (1,3)
switch (result) {
case (1) {
sixth_value = false
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
msg ("You resisted the attack!")
sixth_value = true
}
else if (sixth_value = false) {
if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
}
}
case (2) {
if (enemy.defending = false) {
msg (enemy.alias + " has choosen to defend itself.")
enemy.defending = true
}
}
case (3) {
enemy.defending = false
msg ("Cast")
}
}
if (GetInt (self,"cur_hp") > 0) {
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
msg (enemy.alias + " gets an extra battle turn!")
wait {
enemy_battle_turn (self,enemy)
}
}
else {
msg (enemy.alias + " 's battle turn is over.")
fifth_value = true
}
}
else if (GetInt (self,"cur_hp") <= 0) {
msg (self.alias + " has died.")
msg ("GAME OVER")
finish
}
return (fifth_value)
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>

sgreig
18 Feb 2013, 06:38
It's technically possible to create almost anything you can think of in Quest, but just a small correction: Quest does not use Java. Quest's scripting language is called ASLX and I believe it's loosely based on Visual Basic.

And as far as menus and the like go, it's entirely possible to create your own "menu" system by writing functions to create lists of command links that execute scripts. You just need to be able to wrap your head around how to make it work.

Moon_Shooter
18 Feb 2013, 16:36
HegemonKhan wrote:the mechanics can be done, but I'm not sure about rpg-like about menus~windows~screens, though I think the next version will include a way of adding in more panes, but I don't know how much capabilities they'll have.

you can take a look at Pertex' and Pixie's combat related libraries of combat, magic, attacking and equiping, and etc

-----------

I'm a total noob with coding, working on creating a battle system code, and I'm making some good progress for myself of it.

I got the function equations of like attack, defense, evasion, ar~ac, and etc functional.

here's my code (but there's a lot of junk stuff in there, as I was working on how to do equipment, and the code itself needs to be fixed up more cleanly, as I want to try to do this myself, to learn how to make better coding on my own):

feel free to copy and paste, and try it out.

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<btrns type="int">0</btrns>
<brnds type="int">0</brnds>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc" />
<escaped type="boolean">false</escaped>
<cur_hp type="int">100</cur_hp>
<max_hp type="int">100</max_hp>
<cur_mp type="int">100</cur_mp>
<max_mp type="int">100</max_mp>
<str type="int">100</str>
<end type="int">100</end>
<dex type="int">100</dex>
<agi type="int">100</agi>
<spd type="int">100</spd>
<hc type="int">100</hc>
<pd type="int">100</pd>
<pr type="int">100</pr>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc" />
<hostile type="boolean">true</hostile>
<dead type="boolean">false</dead>
<alias>orc</alias>
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">25</str>
<end type="int">25</end>
<dex type="int">25</dex>
<agi type="int">25</agi>
<spd type="int">25</spd>
<hc type="int">25</hc>
<pd type="int">25</pd>
<pr type="int">25</pr>
<exp type="int">100</exp>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
game.pov.exp = game.pov.exp + 100
</drink>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<displayverbs>Look at; Take; Drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; Drink</inventoryverbs>
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
game.pov.exp = game.pov.exp + 300
</drink>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
lvlup
sa
game_over
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<lvl type="int">0</lvl>
<exp type="int">0</exp>
<cash type="int">0</cash>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<int type="int">0</int>
<spi type="int">0</spi>
<men type="int">0</men>
<cur_mp type="int">0</cur_mp>
<max_mp type="int">0</max_mp>
<hp type="int">0</hp>
<mp type="int">0</mp>
<hc type="int">0</hc>
<pd type="int">0</pd>
<fd type="int">0</fd>
<wd type="int">0</wd>
<ad type="int">0</ad>
<ed type="int">0</ed>
<ld type="int">0</ld>
<dd type="int">0</dd>
<pr type="int">0</pr>
<fr type="int">0</fr>
<wr type="int">0</wr>
<ar type="int">0</ar>
<er type="int">0</er>
<lr type="int">0</lr>
<dr type="int">0</dr>
<wt type="int">0</wt>
<ht type="int">0</ht>
<cur_arrow type="int">0</cur_arrow>
<cur_bolt type="int">0</cur_bolt>
<cur_bullet type="int">0</cur_bullet>
<max_arrow type="int">0</max_arrow>
<max_bolt type="int">0</max_bolt>
<max_bullet type="int">0</max_bullet>
<arrows type="int">0</arrows>
<bolts type="int">0</bolts>
<bullets type="int">0</bullets>
<cur_shuriken type="int">0</cur_shuriken>
<cur_throwing_axe type="int">0</cur_throwing_axe>
<cur_javelin type="int">0</cur_javelin>
<max_shuriken type="int">0</max_shuriken>
<max_throwing_axe type="int">0</max_throwing_axe>
<max_javelin type="int">0</max_javelin>
<shurikens type="int">0</shurikens>
<throwing_axes type="int">0</throwing_axes>
<javelins type="int">0</javelins>
<cur_throwing_knife type="int">0</cur_throwing_knife>
<max_throwing_knife type="int">0</max_throwing_knife>
<throwing_knives type="int">0</throwing_knives>
</type>
<type name="pc">
<inherit name="char" />
<escaped type="boolean">false</escaped>
<statusattributes type="stringdictionary">mp = ;hp = ;str = ;end = ;dex = ;agi = ;spd = ;int = ;spi = ;men = ;lvl = ;exp = ;cash = ;hc = ;pd = ;fd = ;wd = ;ad = ;ed = ;ld = ;dd = ;pr = ;fr = ;wr = ;ar = ;er = ;lr = ;dr = ;wt = ;ht = ;arrows = ;bolts = ;bullets = ;shurikens = ;throwing_axes = ;javelins = ;throwing_knives = </statusattributes>
</type>
<type name="npc">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look; Talk; Steal; Give; Use; Cast; Fight</displayverbs>
<hostility type="script">
if (this.hostile = true) {
this.alias = this.displayalias + "(hostile)"
this.displayverbs = split ("Look;Use;Cast;Fight", ";")
}
</hostility>
<death type="script">
if (this.dead = true) {
this.alias = this.displayalias + "(dead)"
game.pov.exp = game.pov.exp + this.exp
this.displayverbs = split ("Look;Steal;Give;Use;Cast", ";")
}
</death>
</type>
<type name="storage">
<inherit name="container_closed" />
<drop type="boolean">false</drop>
<inventoryverbs type="list">Look; Open; Close</inventoryverbs>
</type>
<type name="gear">
<wt type="int">0</wt>
<take type="boolean">true</take>
<give type="boolean">true</give>
<equipped type="boolean">false</equipped>
<equipable type="boolean">true</equipable>
<unequipable type="boolean">true</unequipable>
<equipable_layer type="int">3</equipable_layer>
<equipable_slots type="list"></equipable_slots>
<inventoryverbs type="listextend">Equip;Unequip</inventoryverbs>
</type>
<type name="weapon">
<inherit name="gear" />
<pd type="int">0</pd>
<hc type="int">0</hc>
</type>
<type name="one_handed">
<inherit name="weapon" />
<equipable_slots type="list">right_hand</equipable_slots>
</type>
<type name="two_handed">
<inherit name="weapon" />
<equipable_slots type="list">left_hand;right_hand</equipable_slots>
</type>
<type name="sword">
</type>
<type name="axe">
</type>
<type name="blunt">
</type>
<type name="spear">
<inherit name="two_handed" />
</type>
<type name="staff">
<inherit name="two_handed" />
</type>
<type name="dagger">
<inherit name="one_handed" />
</type>
<type name="whip">
<inherit name="one_handed" />
</type>
<type name="bow">
<inherit name="two_handed" />
</type>
<type name="crossbow">
<inherit name="two_handed" />
</type>
<type name="gun">
</type>
<type name="throwing">
</type>
<type name="armor">
<inherit name="gear" />
<pr type="int">0</pr>
</type>
<type name="shield">
<inherit name="armor" />
<equipable_slots type="list">left_hand</equipable_slots>
</type>
<type name="clothing">
<inherit name="gear" />
</type>
<type name="headwear">
<equipable_slots type="list">head</equipable_slots>
</type>
<type name="facewear">
<inherit name="clothing" />
<equipable_slots type="list">face</equipable_slots>
</type>
<type name="earwear">
<inherit name="clothing" />
<equipable_slots type="list">ear</equipable_slots>
</type>
<type name="neckwear">
<inherit name="clothing" />
<equipable_slots type="list">neck</equipable_slots>
</type>
<type name="shoulderwear">
<inherit name="armor" />
<equipable_slots type="list">shoulder</equipable_slots>
</type>
<type name="armwear">
<equipable_slots type="list">arm</equipable_slots>
</type>
<type name="handwear">
<equipable_slots type="list">hand</equipable_slots>
</type>
<type name="fingerwear">
<inherit name="clothing" />
<equipable_slots type="list">finger</equipable_slots>
</type>
<type name="chestwear">
<equipable_slots type="list">chest</equipable_slots>
</type>
<type name="backwear">
<inherit name="clothing" />
<equipable_slots type="list">back</equipable_slots>
</type>
<type name="waistwear">
<equipable_slots type="list">waist</equipable_slots>
</type>
<type name="legwear">
<equipable_slots type="list">leg</equipable_slots>
</type>
<type name="footwear">
<equipable_slots type="list">foot</equipable_slots>
</type>
<type name="arrow">
<cur_arrow type="int">0</cur_arrow>
</type>
<type name="arrow_case">
<inherit name="backwear" />
<max_arrow type="int">0</max_arrow>
</type>
<type name="bolt">
<cur_bolt type="int">0</cur_bolt>
</type>
<type name="bolt_case">
<inherit name="backwear" />
<max_bolt type="int">0</max_bolt>
</type>
<type name="bullet">
<cur_bullet type="int">0</cur_bullet>
</type>
<type name="bullet_case">
<inherit name="backwear" />
<max_bullet type="int">0</max_bullet>
</type>
<type name="spell">
<drop type="boolean">false</drop>
<inventoryverbs type="list">Learn</inventoryverbs>
<displayverbs type="list">Learn</displayverbs>
</type>
<type name="fire">
</type>
<type name="water">
</type>
<type name="air">
</type>
<type name="earth">
</type>
<type name="light">
</type>
<type name="dark">
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="sa">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
game.pov.mp = game.pov.cur_mp + " / " + game.pov.max_mp
game.pov.arrows = game.pov.cur_arrow + " / " + game.pov.max_arrow
game.pov.bolts = game.pov.cur_bolt + " / " + game.pov.max_bolt
game.pov.bullets = game.pov.cur_bullet + " / " + game.pov.max_bullet
game.pov.shurikens = game.pov.cur_shuriken + " / " + game.pov.max_shuriken
game.pov.javelins = game.pov.cur_javelin + " / " + game.pov.max_javelin
game.pov.throwing_axes = game.pov.cur_throwing_axe + " / " + game.pov.max_throwing_axe
game.pov.throwing_knives = game.pov.cur_throwing_knife + " / " + game.pov.max_throwing_knife
</function>
<function name="game_over">
if (game.pov.cur_hp = 0) {
msg (game.pov.alias + " has died.")
msg ("GAME OVER")
finish
}
</function>
<function name="lvlup"><![CDATA[
if (game.pov.exp >= game.pov.lvl * 100 + 100) {
game.pov.exp = game.pov.exp - (game.pov.lvl * 100 + 100)
game.pov.lvl = game.pov.lvl + 1
lvlup
}
]]></function>
<function name="battle_system" parameters="self,text" type="boolean">
first_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
first_value = false
}
else if (not Doesinherit (enemy,"npc")) {
msg ("You can not battle that!")
first_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
first_value = false
}
else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
first_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
first_value = false
}
else if (battle_sequence (self,enemy) = true) {
msg ("The battle is over.")
first_value = true
}
return (first_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
second_value = false
if (enemy.dead = false) {
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy.dead = false) {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
}
}
else {
second_value = true
}
return (second_value)
]]></function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
third_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (self.alias + " has " + self.cur_mp + " MP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
fourth_value = false
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
fourth_value = true
}
else if (fourth_value = false) {
if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
}
}
case ("Defend") {
if (self.defending = false) {
self.defending = true
}
}
case ("Cast") {
self.defending = false
}
case ("Item") {
self.defending = false
}
case ("Run") {
self.defending = false
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn (self,enemy)
}
else {
msg ("Your battle turn is over.")
third_value = false
}
}
else if (GetInt (enemy,"cur_hp") <= 0) {
msg (enemy.alias + " is dead.")
msg ("You have won the battle!")
enemy.defending = false
enemy.dead = true
third_value = true
wait {
ClearScreen
}
}
}
}
return (third_value)
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
fifth_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (self.alias + " has " + self.cur_mp + " MP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
result = GetRandomInt (1,3)
switch (result) {
case (1) {
sixth_value = false
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
msg ("You resisted the attack!")
sixth_value = true
}
else if (sixth_value = false) {
if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
}
}
case (2) {
if (enemy.defending = false) {
msg (enemy.alias + " has choosen to defend itself.")
enemy.defending = true
}
}
case (3) {
enemy.defending = false
msg ("Cast")
}
}
if (GetInt (self,"cur_hp") > 0) {
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
msg (enemy.alias + " gets an extra battle turn!")
wait {
enemy_battle_turn (self,enemy)
}
}
else {
msg (enemy.alias + " 's battle turn is over.")
fifth_value = true
}
}
else if (GetInt (self,"cur_hp") <= 0) {
msg (self.alias + " has died.")
msg ("GAME OVER")
finish
}
return (fifth_value)
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>


Believe me, of the two of us, I'm probably the bigger n00b because I'm completely clueless when it comes to figuring out where to even put the code :P. If you wouldn't mind clarifying, where might I post this, so I can at least get a general idea of how the code is set up, and how the elements interact with each other (in other words, where do I test it?).

Edit: Though my initial n00b status still stands, I believe I've figured out where to paste and try the code. I still run into the problem of an error on line 1. Do you know how I could possibly resolve the issue? Or is this something in which I'd have to write the code from scratch, rather than copypasta it?

Edit 2: FORGET IT. I got it. I figured out how to copypasta someone else's code, thank you for the reference XD .

Moon_Shooter
18 Feb 2013, 16:39
sgreig wrote:It's technically possible to create almost anything you can think of in Quest, but just a small correction: Quest does not use Java. Quest's scripting language is called ASLX and I believe it's loosely based on Visual Basic.

And as far as menus and the like go, it's entirely possible to create your own "menu" system by writing functions to create lists of command links that execute scripts. You just need to be able to wrap your head around how to make it work.


Oh! My mistake. I must have gotten Java from when I saw Javascript among the main tree in the editor's menu. Oh well, thanks for clarifying. Do you know of it as a difficult programming language to learn? From a scale of say... Python to C++

sgreig
18 Feb 2013, 17:18
Difficulty? It's much easier to learn syntax-wise than some languages for sure... but like with most programming related things, the more experience you have with the concept of programming and the logic behind how programs work, the easier it is to pick up any language. As far as Quest goes, on a scale of 1 to 10 I'd say it's probably about a 4 for the really basic stuff. But then again, like I said it's very subjective as it will depend on your current experience and how quickly you can pick things up.

And yes, you can write code using JavaScript and import it into your project, but it's probably worth mentioning there is a huge difference between Java and JavaScript. :)

HegemonKhan
19 Feb 2013, 06:52
if you need any help or questions with my code, or if you still need help with "adding it" (make a new game, and go into its coding, either via the GUI-editor's notepaper button toggle between GUI mode and Code View mode, or by opening up the game file with note, note++, or word pad, then delete all of the game's code, and paste in mine, and save file, and then just start it and play it, testing it), just ask me.

my apologies for my code not being specifically just for the battle system (it's got a lot of other junk in there), which will make it difficult for a noob, and~or anyone, to make sense of it, lol. I didn't make yet a file of only the battle system coding, sorry.

so please ask about any questions you have with it!

there is a bit more detail on it in the newest pages~posts of "Noob HK's Help Me" thread. (maybe there is a code of it that is just the battle system, as I think I might have done that, posted it on here, but I hadn't saved it as a game file yet, I should do go that now, lol).

------------

actually, here it is, use this instead:

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>d83ba5bb-2e3c-4f31-80c9-3e88a2dc082c</gameid>
<version>1.0</version>
<pov type="object">player</pov>
<start type="script">
cc
</start>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<inherit name="pc" />
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">100</str>
<end type="int">100</end>
<dex type="int">100</dex>
<agi type="int">100</agi>
<spd type="int">100</spd>
<hc type="int">100</hc>
<pd type="int">100</pd>
<pr type="int">100</pr>
</object>
<object name="orc1">
<inherit name="editor_object" />
<inherit name="npc" />
<hostile type="boolean">true</hostile>
<dead type="boolean">false</dead>
<alias>orc</alias>
<cur_hp type="int">999</cur_hp>
<max_hp type="int">999</max_hp>
<str type="int">25</str>
<end type="int">25</end>
<dex type="int">25</dex>
<agi type="int">25</agi>
<spd type="int">25</spd>
<hc type="int">25</hc>
<pd type="int">25</pd>
<pr type="int">25</pr>
</object>
</object>
<turnscript name="game_turns">
<enabled />
<script>
sa
game.turns = game.turns + 1
</script>
</turnscript>
<command name="fight">
<pattern>fight #text#</pattern>
<script>
battle_system (game.pov,text)
</script>
</command>
<type name="char">
<cur_hp type="int">0</cur_hp>
<drop type="boolean">false</drop>
<defending type="boolean">false</defending>
<max_hp type="int">0</max_hp>
<str type="int">0</str>
<end type="int">0</end>
<dex type="int">0</dex>
<agi type="int">0</agi>
<spd type="int">0</spd>
<hp type="int">0</hp>
<hc type="int">0</hc>
<pd type="int">0</pd>
<pr type="int">0</pr>
</type>
<type name="pc">
<inherit name="char" />
<statusattributes type="stringdictionary">hp = ;str = ;end = ;dex = ;agi = ;spd = ;hc = ;pd = ;pr = </statusattributes>
</type>
<type name="npc">
<inherit name="char" />
<dead type="boolean">false</dead>
<hostile type="boolean">false</hostile>
<displayverbs type="list">Look at; Talk; Fight</displayverbs>
</type>
<function name="cc">
msg ("What is your name?")
get input {
game.pov.alias = result
msg (" - " + game.pov.alias)
show menu ("What is your gender?", split ("male;female" , ";"), false) {
game.pov.gender = result
show menu ("What is your race?", split ("human;dwarf;elf" , ";"), false) {
game.pov.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
game.pov.class = result
msg (game.pov.alias + " is a " + game.pov.gender + " " + game.pov.race + " " + game.pov.class + ".")
wait {
ClearScreen
}
}
}
}
}
</function>
<function name="sa">
game.pov.hp = game.pov.cur_hp + " / " + game.pov.max_hp
</function>
<function name="battle_system" parameters="self,text" type="boolean">
first_value = false
enemy = GetObject (text)
if (enemy = null) {
foreach (obj,AllObjects()) {
if (obj.alias=text) {
enemy = obj
}
}
}
if (enemy = null) {
msg ("There is no " + text + " here.")
first_value = false
}
else if (not Doesinherit (enemy,"npc")) {
msg ("You can not battle that!")
first_value = false
}
else if (not npc_reachable (enemy)) {
msg ("There is no " + enemy.alias + " in your vicinity.")
first_value = false
}
else if (GetBoolean (enemy,"dead") = true) {
msg (enemy.alias + " is already dead.")
first_value = false
}
else if (GetBoolean (enemy,"hostile") = false) {
msg (enemy.alias + " is not hostile.")
first_value = false
}
else if (battle_sequence (self,enemy) = true) {
msg ("The battle is over.")
first_value = true
}
return (first_value)
</function>
<function name="battle_sequence" parameters="self,enemy" type="boolean"><![CDATA[
second_value = false
if (enemy.dead = false) {
if (GetInt (self,"spd") > GetInt (enemy,"spd")) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy.dead = false) {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") < GetInt (enemy,"spd")) {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else if (GetInt (self,"spd") = GetInt (enemy,"spd")) {
if (RandomChance (50) = true) {
on ready {
msg ("You get to go first for this round")
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
}
on ready {
if (enemy_battle_turn (self,enemy) = true) {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
else {
on ready {
msg (enemy.alias + " gets to go first for this round.")
if (enemy_battle_turn (self,enemy) = true) {
msg ("It is now your turn.")
}
}
on ready {
if (self_battle_turn (self,enemy) = true) {
battle_sequence (self,enemy)
}
else {
msg ("The round has ended.")
}
}
on ready {
battle_sequence (self,enemy)
}
}
}
}
else {
second_value = true
}
return (second_value)
]]></function>
<function name="self_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
third_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
wait {
show menu ("What is your battle choice?", split ("Attack;Defend;Cast;Item;Run", ";"), false) {
switch (result) {
case ("Attack") {
fourth_value = false
if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"spd")) = true) {
msg (enemy.alias + "evaded your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"Dex") - GetInt (self,"agi")) = true) {
msg (enemy.alias + "parried your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"agi") - GetInt (self,"dex")) = true) {
msg (enemy.alias + "blocked your attack!")
fourth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"spd")) = false) {
msg ("Your attack missed " + enemy.alias +"!")
fourth_value = true
}
else if (RandomChance (GetInt (enemy,"pr") - GetInt (self,"hc")) = true) {
msg ("Your attack got resisted by " + enemy.alias +"!")
fourth_value = true
}
else if (fourth_value = false) {
if (self.defending = true and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = true and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * 2 * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
self.defending = false
}
else if (self.defending = false and enemy.defending = true) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") / 2 + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
else if (self.defending = false and enemy.defending = false) {
enemy.cur_hp = enemy.cur_hp - (crit_hit (self) * GetInt (self,"pd") + GetInt (self,"pd") * (GetInt (self,"str") - GetInt (enemy,"end")) / 100)
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
}
}
}
case ("Defend") {
if (self.defending = false) {
self.defending = true
}
}
case ("Cast") {
self.defending = false
}
case ("Item") {
self.defending = false
}
case ("Run") {
self.defending = false
}
}
if (GetInt (enemy,"cur_hp") > 0) {
if (RandomChance (GetInt (self,"spd") - GetInt (enemy,"spd")) = true) {
msg ("You get an extra battle turn!")
self_battle_turn (self,enemy)
}
else {
msg ("Your battle turn is over.")
third_value = false
}
}
else if (GetInt (enemy,"cur_hp") <= 0) {
msg (enemy.alias + " is dead.")
msg ("You have won the battle!")
enemy.defending = false
enemy.dead = true
third_value = true
wait {
ClearScreen
}
}
}
}
return (third_value)
]]></function>
<function name="enemy_battle_turn" parameters="self,enemy" type="boolean"><![CDATA[
fifth_value = false
msg (self.alias + " has " + self.cur_hp + " HP left.")
msg (enemy.alias + " has " + enemy.cur_hp + " HP left.")
result = GetRandomInt (1,3)
switch (result) {
case (1) {
sixth_value = false
if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"spd")) = true) {
msg ("You have evaded the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"dex") - GetInt (enemy,"agi")) = true) {
msg ("You have parried the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"agi") - GetInt (enemy,"dex")) = true) {
msg ("You have blocked the attack!")
sixth_value = true
}
else if (RandomChance (GetInt (enemy,"dex") - GetInt (self,"spd")) = false) {
msg (enemy.alias +"'s attack missed!")
sixth_value = true
}
else if (RandomChance (GetInt (self,"pr") - GetInt (enemy,"hc")) = true) {
msg ("You resisted the attack!")
sixth_value = true
}
else if (sixth_value = false) {
if (enemy.defending = true and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = true and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * 2 * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
enemy.defending = false
}
else if (enemy.defending = false and self.defending = true) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") / 2 + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
else if (enemy.defending = false and self.defending = false) {
self.cur_hp = self.cur_hp - (crit_hit (enemy) * GetInt (enemy,"pd") + GetInt (enemy,"pd") * (GetInt (enemy,"str") - GetInt (self,"end")) / 100)
msg (self.alias + " has " + self.cur_hp + " HP left.")
}
}
}
case (2) {
if (enemy.defending = false) {
msg (enemy.alias + " has choosen to defend itself.")
enemy.defending = true
}
}
case (3) {
enemy.defending = false
msg ("Cast")
}
}
if (GetInt (self,"cur_hp") > 0) {
if (RandomChance (GetInt (enemy,"spd") - GetInt (self,"spd")) = true) {
msg (enemy.alias + " gets an extra battle turn!")
wait {
enemy_battle_turn (self,enemy)
}
}
else {
msg (enemy.alias + " 's battle turn is over.")
fifth_value = true
}
}
else if (GetInt (self,"cur_hp") <= 0) {
msg (self.alias + " has died.")
msg ("GAME OVER")
finish
}
return (fifth_value)
]]></function>
<function name="npc_reachable" parameters="object" type="boolean">
value = false
foreach (x,ScopeReachableNotHeld ()) {
if (x=object) {
value = true
}
}
return (value)
</function>
<function name="crit_hit" parameters="object" type="int">
if (RandomChance (GetInt (object,"luck")) = true) {
value = 2
}
else {
value = 1
}
return (value)
</function>
</asl>


also, here's a key~legend for it, due to my use of abrevs, lol:

(I'm now, in my game codes, writing out the names of stuff, so people know what it is, when I post it, to make it followable)

01. cc = character creation function
02. sa = status attributes (mainly for implementing/displaying of ' cur / max ' stats) function
03. char = character object type ("pcs", "npcs", "monsters", etc., so, not a room, item, equipment, spell, etc)
04. pc = playable character object type ("player" characters / game.povs)
05. npc = non-playable character ("people", "monsters", and etc, so not a "player" character / not a game.pov, I'm going to have a hostility system, so any npc can be friendly or hostile, instead of having an actual "monster/enemy" type set aside)
06. hp = hit points (life) stat attribute
07. mp = mana points (magic) stat attribute
08. str = strength (physical damage, carry weight / equipment requirement, etc) stat attribute
09. end = endurance (physical defense, and etc) stat attribute
10. dex = dexterity (weapon~attack skill, think of this as "if your attack connects or not, do you 'whiff' or not", so not to gete confused with hc, and etc) stat attribute
11. agi = agility (dodging/evading, and etc) stat attribute
12. spd = speed (who goes first in battle, extra battle turns, escaping from battle, and etc) stat attribute
13. hc = hit chance (think of this more as piercing their armor or not, so not to get confused with dex, and etc) stat attribute
14. pd = physical damage stat attribute
15. fp = fire damage stat attribute
16. wp = water damage stat attribute
17. ap = air damage stat attribute
18. ed = earth damage stat attribute
19. ld = light damage stat attribute
20. dd = dark damage stat attribute
21. pr = physical resistance stat attribute
22. fr = fire resistance stat attribute
23. wr = water resistance stat attribute
24. ar = air resistance stat attribute
25. er = earth resistance stat attribute
26. lr = light resistance stat attribute
27. dr = dark resistance stat attribute
28. defending = boolean (reduces damage done for that character and increases the damage done by that character, if they chosoe to attack on the next turn)
29. escaped = boolean, run from battle (not completed/implemented yet)
30. hostile = boolean, any npc can be friendly or a(n) "monster/enemy", based upon a hostility scale (0-100), but not completed
31. dead = boolean
32. crit_hit = critical hit (bonus damage based upon luck)
33. luck = luck stat attribute
34. lvl = level stat attribute
35. exp = experience stat attribute
36. cash = cash stat attribute (currency)
37. lvlup = level up function


use this code instead, it doesn't have all of the other junk in it, lol.

Don't try to understand the code though if you're a noob, this wasn't easy for me to do, this is a bit more advanced coding, at least for us noobs, sighs. (well it is easier to read and follow code, especially from the coding~programming experts as it is so short simple and clear, than to create the code yourself. My code is so messy and does everything is in the longest most complicated way, but I'm just happy that I got it to work. Improving my code writing, is a later step to worry about, for now)