General How to-

Silverwolf14
Alright... I'm sure that someone has asked how to create specific systems which is what I was going to do but I think it would be better if it was posted all at once instead of separately again. What I want to ask is how to create a:

Turn-based Combat system
Stats
Health
Creating Health Restorative Items
Conversations
a Morale system (if Possible)
If other characters can be used in combat (say like a party of like 3 again if possible)


and I noticed that "Adult" was an available tag is there actually a section with adult content or is that a special add on. Thank you in advanced for any help given on this thread.

Liam315
Most of those things are covered in the wiki -
http://quest5.net/wiki/Main_Page
http://quest5.net/wiki/How_to

Things like stats and health are done using status attributes - http://quest5.net/wiki/Status_Attributes
Objects to restore health merely have to include in their scripts something that affects said attribute. Morale could be implemented using status attributes also.

There are many ways to make a combat system depending on how you want it to look and what you want it to achieve. There are many ideas here - http://quest5.net/wiki/Simple_Combat_System_(Advanced)
To have turn based fighting the best thing to do is transport the player to a special "fight room" which they are transported out of at the end.

Turn based combat with different characters would involve changing characters - http://quest5.net/wiki/Changing_Characters

Conversations are a big issue in interactive fiction and can be done many ways depending on what you want to achieve. Some are discussed and illustrated here - http://quest5.net/wiki/Conversations

If you run into specific problems with your scripts anywhere and can't get a particular thing to work, or you can't decide on something and want some general advice we can help you. But there is no definitive way to do most things- it all depends on the context of what you're trying to achieve. If you haven't done so yet, it might be a good idea to go through the tutorial first to get the grasp of the basics which can then be combined to do more complicated things. - http://quest5.net/wiki/Tutorial

Alex
The Adult category only appears if you are logged in, have given a date of birth, and are over 18.

HegemonKhan
1. Turn-Based Combat System

there's other ways to do turn based, and there's NON-turn based combat systems too, which either, are or might be, easier for you to do.

For example, Pixie has a combat guide: http://quest5.net/wiki/Simple_Combat_System_(Advanced)

--------

this is not for noobs to do, it requires some complex coding. here's my own code for a turn based combat system (it's incomplete, messy ~ I still haven't fixed~cleaned up it ~ still has some unneeded code lines in it, and old, but it, well the "attack" anyways, works):

(this probably won't work for v5.4, you'll have to make some changes to it to be compatible~work with v5.4 and you'll have to chang the asl version to "540" too of course, or if you can find a v5.3 download, then this code will work for you. I'm not sure if Alex keeps older versions for download on his site or not)

I used Pertex' Combat Code for this, so the credit goes to him~her:

<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>


and here's a legend~key for it:

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


2A. Stats (Attributes)

Simply add Attributes ( if you're doing many objects, you might want to look into Object Types: http://quest5.net/wiki/Using_Types ) to your objects:

for example:

Player -> Attributes (Tab) -> Attributes (bottom box) -> Add ->

name: strength
type: int (integer)
value: 0

however, you got to also add them as "status attributes" to have them actually be displayed for the game player to see them, or you could create a command that shows them, as like a quest version of a "stats screen" on many rpgs.

2B. Status Attributes

for example:

Game -> Attributes (Tab) -> Status Attributes (top box) -> Add ->
~OR~
Player -> Attributes (Tab) -> Status Attributes (top box) -> Add ->

name~key: strength
format (or whatever it is called)~value: (either leave blank or type in this: ! , ~ as I can't remember which you do)

3. Health

you can either choose the built-in health, which I don't really understand how to use myself, lol, or you can create your own health system.

the built-in health is activated this way:

Game -> Player (Tab) -> [] Show health -> [X] Show health

or, to create your own health:

for example:

Player -> Attributes (Tab) -> Attributes (bottom box) -> Add (repeat to make them all) ->

name: hp
type: string
value: current_hp + " / " + maximum_hp (this will cause it to display like this, for example: 999 / 999 )

name: current_hp
type: int
value: 0 (or whatever you want your starting hp to be)

name: maximum_hp
type: int
value: 0 (or whatever you want your starting hp to be)

Player -> Attributes (Tab) -> Status Attributes (top box) -> Add ->

name~key: hp
format~value: ( leave blank, or type in this: ! , ~ as I can't remember which you need to do, so that the word "Hp" itself gets displayed)

4. Creating Health Restorative Items

for example:

Room -> Objects (Tab) -> Add ->

name: hp_50_potion
parent: Room

hp_50_potion -> Verbs -> Add -> drink -> [run a script] -> Add new script -> Variables -> Set a variable or attribute ->

Set variable player.current_hp = [expression] player.current_hp + 50

This will add ("heal") +50 hp to the player's current_hp amount when you drink this object (you'll need to limit the current_hp from exceeding the maximum_hp obviously too, if you need help with this and~or where to do~add-in this code, let me know).

here's a code that shows a lot of this stuff you're asking for:

(I don't think this code will work with v5.4, unless you can change the show menu code format~syntax to match how it's done~changed in v5.4, as this was made using v5.3)

<asl version="540"> // if you can find v5.3 still and download it, then change it to: <asl version="530"> and it will work
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>cd102f9d-370a-4bda-b6ea-ca42288f619c</gameid>
<version>1.0</version>
<showscore />
<showhealth />
<start type="script">
msg ("What is your name?")
get input {
msg (" - " + result)
player.alias = result
show menu ("What is your gender?", split ("male;female" , ";"), false) {
player.gender = result
show menu ("What is your race?", split ("human;elf;dwarf" , ";"), false) {
player.race = result
show menu ("What is your class?", split ("warrior;cleric;mage;thief" , ";"), false) {
player.class = result
msg (player.alias + " is a " + " " + player.gender + " " + player.race + " " + player.class + ".")
}
}
}
}
</start>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="defaultplayer" />
<age type="int">0</age>
<height type="int">0</height>
<weight type="int">0</weight>
<strength type="int">0</strength>
<intelligence type="int">0</intelligence>
<agility type="int">0</agility>
<statusattributes type="stringdictionary">age = ;height = ;weight = ;strength = ;intelligence = ;agility = ;level = ;experience = ;cash = ;turns = </statusattributes>
<level type="int">0</level>
<experience type="int">0</experience>
<cash type="int">0</cash>
<turns type="int">0</turns>
</object>
<object name="potion100">
<inherit name="editor_object" />
<alias>100 exp potion</alias>
<take />
<alt type="list"></alt>
<drink type="script">
msg ("You drink the exp potion, receiving 100 experience.")
player.experience = player.experience + 100
</drink>
<displayverbs>Look at; Take; drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
</object>
<object name="potion300">
<inherit name="editor_object" />
<alias>300 exp potion</alias>
<take />
<drink type="script">
msg ("You drink the exp potion, receiving 300 experience.")
player.experience = player.experience + 300
</drink>
<displayverbs>Look at; Take; drink</displayverbs>
<inventoryverbs>Look at; Use; Drop; drink</inventoryverbs>
</object>
</object>
<turnscript name="turns lvlup script">
<enabled />
<script>
lvlup
player.turns = player.turns + 1
</script>
</turnscript>
<function name="lvlup"><![CDATA[
expneeded = player.level * 100 + 100
if (player.experience >= expneeded) {
player.level = player.level + 1
player.experience = player.experience - expneeded
switch (player.gender) {
case ("male") {
player.strength = player.strength + 1
}
case ("female") {
player.agility = player.agility + 1
}
}
switch (player.race) {
case ("dwarf") {
player.strength = player.strength + 2
}
case ("elf") {
player.agility = player.intelligence + 2
}
case ("human") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
switch (player.class) {
case ("warrior") {
player.strength = player.strength + 2
}
case ("cleric") {
player.intelligence = player.intelligence + 1
player.agility = player.agility + 1
}
case ("mage") {
player.intelligence = player.intelligence + 2
}
case ("thief") {
player.strength = player.strength + 1
player.agility = player.agility + 1
}
}
lvlup
}
]]></function>
</asl>


5. Conversations

these can be simple or complex (and it depends on how many objects you're using~making conversations for too)

you can just make a Verb for whatever object, choose: run as a script -> and use the "show menu" script (and probably the "Switch" script too).

if you don't mind doing "yes/now" conversation than that is already built-in as the "ask/tell" tab-category.

for advanced conversations (and multiple objects using~having conversations), you'll want to use lists or dictionaries.

for random conversations:

http://quest5.net/wiki/GetRandomInt

for example (briefly in code form):

result = GetRandomInt (1,3)

use with a "Switch" script (set the cases as: "1", "2", "3"):

switch (result)
-> cases
->-> "1"
->->-> msg ("blah_1")
->-> "2"
->->-> msg ("blah_2")
->-> "3"
->->-> msg ("blah_3")

(Or, use with lists or dictionaries):

GetRandomInt (1,3) - 1

http://quest5.net/wiki/Using_Lists
http://quest5.net/wiki/Using_Dictionaries

6. A Morale System

see the questions above that I've already talked about. All it is, is attributes and status attributes, though what you want to do exactly with~for~as your morale system can make it a bit more complex.

tell me what you want to do exactly, and I can then give some example methods for you.

7. Party~Team members

see the link that the other poster already gave, and~or try to apply your other team~party members into the combat system.

and here's a vital code for you (credit goes to Sgreig), that is apart of creating party~team members:

Sgreig's "Following" code:

(I'm not sure if this will work with v5.4, as it was written for~with v5.3)

<asl version="530">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="test">
<gameid>f26302df-aa5c-4ebd-b389-e9d18be20930</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turnCount type="int">0</turnCount> // This is a variable we will use to keep track of the number of turns for the npc behaviour.
</game>
<object name="room1">
<inherit name="editor_room" />
<alias>Library</alias>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="NPC">
<inherit name="editor_object" />
<inherit name="male" />
<alias>Happy McGoo</alias>
<usedefaultprefix />
<look>He stares at you blankly, a small rope of drool forming at the corner of his lopsided grin.</look>
// This creates the string list with the behaviour descriptions. Pretty straightforward.
<behaviorDesc type="list">Happy's index finger begins an exploratory mission to the inner depths of his nasal cavity.; Happy seems to have discovered that the walls make an interesting hollow thumping noise when he slams his forehead against them.; Happy appears to be chewing on something. You figure it's better not to ask questions.</behaviorDesc>
</object>
<exit alias="east" to="room2">
<inherit name="eastdirection" />
</exit>
</object>
<turnscript name="npc_stuff">
<enabled />
<script><![CDATA[
if (GetBoolean(NPC, "following")) { // This line checks to see if the "following" attribute of the npc object is set to true or not.
if (NPC.parent <> player.parent) { // If it IS set to true, this line checks to see if the npc is not in the same room as the player.
NPC.parent = player.parent // This line moves the npc to the room the player is in. If they're already in the same room, this won't happen.
}
}
game.turnCount = game.turnCount + 1 // This line increased the variable game.turnCount by 1 every turn.
if (game.turnCount = 2) { // If game.turnCount = 2, then the next line happens.
if (NPC.parent = player.parent) { // This line checks to see if the npc and the player are in the same room or not. If not, you won't see the behaviour message.
msg (StringListItem(NPC.behaviorDesc, GetRandomInt(1,3) - 1)) // This displays a random behaviour message from the stringlist on the npc object.
}
game.turnCount = 0 // This line resets the game.turnCount variable to 0. This ensures the behaviour messages display every 2 turns.
}
]]></script>
</turnscript>
<object name="room2">
<inherit name="editor_room" />
<alias>Foyer</alias>
<exit alias="west" to="room1">
<inherit name="westdirection" />
</exit>
<exit alias="east" to="room3">
<inherit name="eastdirection" />
</exit>
</object>
<object name="room3">
<inherit name="editor_room" />
<alias>Dining Room</alias>
<object name="Patrol">
<inherit name="editor_object" />
<inherit name="maleplural" />
<alias>Patrol</alias>
<look>A patrol of guards.</look>
</object>
<exit alias="west" to="room2">
<inherit name="westdirection" />
</exit>
</object>
<command name="follow">
<pattern>follow me</pattern> // This line creates the "follow me" command.
<script>
msg ("Happy begins to follow you.") // This gives the player feedback that the command has worked.
SetObjectFlagOn (NPC, "following") // This line sets the NPC.following value to "true" for the turnscript.
</script>
</command>
<command name="unfollow">
<pattern>unfollow me</pattern> // This command allows you to stop the npc from following you.
<script>
SetObjectFlagOff (NPC, "following") // This sets the "following" value on the npc object to "false."
</script>
</command>
<turnscript name="Patrol_Duty"> // This turnscript controls the guards' patrol route.
<enabled />
<script>
SetTurnTimeout (2) { // Every 2 turns
if (Patrol.parent = room3) { // This line checks to see if the patrol is in room3. If so, the patrol is moved to room2 on the next line.
Patrol.parent = room2
Patrol.previousRoom = room3 // This variable is created to keep track of the last room the patrol was in because we want the patrol to go 3-2-1-2-3. Since room2 has 2 exits, we want to make sure the patrol doesn't go back the way they came.
}
else if (Patrol.parent = room2) { // Now, if the patrol is room 2...
if (Patrol.previousRoom = room3) { // We check the previous room variable to determine where to go next. If they were last in room3, we move them to...
Patrol.parent = room1 // room1
}
else if (Patrol.previousRoom = room1) { // Otherwise if they were just in room1 we move them to...
Patrol.parent = room3 // room3
}
}
else if (Patrol.parent = room1) { // If they're currently in room1
Patrol.parent = room2 // Move them to room2
Patrol.previousRoom = room1 // Set the previous room variable to room1.
}
}
</script>
</turnscript>
</asl>


and also here's another sample (my own, but using sgreig's code model) of the "Following" code too (credit goes to Sgreig again):

(again, it may not work with v5.4)

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="NPC Crowd">
<gameid>70d76bbb-2e9b-455e-a69e-b79f47955343</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turns type="int">0</turns>
<statusattributes type="stringdictionary">turns = </statusattributes>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<drop type="boolean">false</drop>
</object>
<object name="locked_door">
<inherit name="editor_object" />
<drop type="boolean">false</drop>
<knock type="script">
if (NPC_Crowd.parent = locked_room) {
msg ("You hear a voice call out, \"Give me a moment! I'll be right out!\" from behind the door.")
}
else if (NPC_Crowd.parent = room) {
msg ("Nobody answers.")
}
</knock>
</object>
<object name="NPC_Crowd">
<inherit name="editor_object" />
<alias>crowd</alias>
<behaviorDesc type="list">A dusty old tome.; It's a weathered volume.; A very old book with that familiar musty book smell.</behaviorDesc>
<drop type="boolean">false</drop>
<speak type="script">
msg (StringListItem(NPC_Crowd.behaviorDesc, GetRandomInt(1,3) - 1))
</speak>
</object>
</object>
<object name="locked_room">
<inherit name="editor_room" />
</object>
<turnscript>
<enabled />
<script>
SetTurnTimeout (5) {
if (NPC_Crowd.parent = room) {
MoveObject (NPC_Crowd, locked_room)
}
else if (NPC_Crowd.parent = locked_room) {
MoveObject (NPC_Crowd, room)
}
}
</script>
</turnscript>
</asl>


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

here's some very useful links:

http://quest5.net/wiki/Main_Page

http://quest5.net/wiki/Tutorial

http://quest5.net/wiki/How_to

http://quest5.net/wiki/Category:All_Fun ... t_Commands

viewforum.php?f=18

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums