Equip a weapon
Sazukan20
29 Dec 2013, 02:46i have been trying out Quest with the browser version as it would probably take hours to download it. but my dellema, before taking my new game idea to the idea of fighting an enemy, i need to equip a weapon, i have already made the object of which to equip. how can i make it so my character can equip the weapon?
TriangleGames
29 Dec 2013, 06:16There's more than one way to do it, and I'm sure some others will make some suggestions or point you to the right topic (I did a search and quickly found there's a lot to dig through looking for a concise answer).
There are some libraries in the wiki for "wearing clothes" that might be useful, but I haven't used them yet myself, and they may be more than you need. There are also some others in the libraries sub-forum that may be useful, but again, they may do more than you want/need at the moment.
I'll tell you two ways I've done it before. I'm giving full details since I'm not sure exactly how familiar you are with Quest currently.
EDIT: It has just occurred to me that this will be harder in the browser version, because it does not have the same access to adding attributes to the player (currently). You could still do it, but you'd have to use scripts to create the attributes in game. Most likely by putting them in the game's start script. I don't know what kind of computer or internet connection you have, but if you're main concern about downloading the desktop version is time, it actually shouldn't take too long. I don't recall it taking more a minute or two. In the meantime, bare in mind that what I'm about to suggest will require using scripts to add these attributes to the player, and probably the weapon as well.
My currently preferred method is to create an object attribute on the player that points to the currently equipped weapon. This way, all you need to do when the user equips a new weapon is set the attribute to equal the new weapon.
• Step 1: make a base object for when the player has no weapon equipped (I call mine "bare hands", more on that in a moment)
• Step2: add an attribute to the player which will point to whatever object is equipped (let's call it "equipped_weapon")
• Step 3: set the attribute type to Object
NOTE: As far as I know, Quest will not let you set an attribute type to object, without selecting a specific object for the attribute. This is why you need to make the "bare hands" object first; the "equipped_weapon" attribute will need something to point to.
• Step 4: Create an "equip" verb for the weapon, with a script that sets the "equipped_weapon" attribute to equal the "sword" object. In code this would look like:
In the gui, you would choose the script command called "Set a variable or attribute",
then enter player.equipped_weapon for "set variable"
and sword for "expression".
This way, anything you need to know about the currently equipped weapon can be accessed using the player attribute. So, for instance, if the "sword" object has an attribute called "damage" you can refer to it (once it is equipped) as "player.equipped_weapon.damage" just the same as "sword.damage".
The other way I've used in the past basically involves creating matching attributes on the player and the weapon and making all of the player's attributes equal the weapons attributes.
(starts like this)
sword.damage = 5
player.damage = 0
(then do this)
player.damage = sword.damage
(and end up with this)
sword.damage = 5
player.damage = 5
This is okay for really simple weapons, but if you want weapons with a variety of attributes, you'd have to set the matching player attribute for each one when they equip it.
There are some libraries in the wiki for "wearing clothes" that might be useful, but I haven't used them yet myself, and they may be more than you need. There are also some others in the libraries sub-forum that may be useful, but again, they may do more than you want/need at the moment.
I'll tell you two ways I've done it before. I'm giving full details since I'm not sure exactly how familiar you are with Quest currently.
EDIT: It has just occurred to me that this will be harder in the browser version, because it does not have the same access to adding attributes to the player (currently). You could still do it, but you'd have to use scripts to create the attributes in game. Most likely by putting them in the game's start script. I don't know what kind of computer or internet connection you have, but if you're main concern about downloading the desktop version is time, it actually shouldn't take too long. I don't recall it taking more a minute or two. In the meantime, bare in mind that what I'm about to suggest will require using scripts to add these attributes to the player, and probably the weapon as well.
My currently preferred method is to create an object attribute on the player that points to the currently equipped weapon. This way, all you need to do when the user equips a new weapon is set the attribute to equal the new weapon.
• Step 1: make a base object for when the player has no weapon equipped (I call mine "bare hands", more on that in a moment)
• Step2: add an attribute to the player which will point to whatever object is equipped (let's call it "equipped_weapon")
• Step 3: set the attribute type to Object
NOTE: As far as I know, Quest will not let you set an attribute type to object, without selecting a specific object for the attribute. This is why you need to make the "bare hands" object first; the "equipped_weapon" attribute will need something to point to.
• Step 4: Create an "equip" verb for the weapon, with a script that sets the "equipped_weapon" attribute to equal the "sword" object. In code this would look like:
player.equipped_weapon = sword
//This is really the most important part, and in the online editor you may need to JUST use a script that does THIS.
//The gist of it is, set an attribute on the player that refers to an object (the weapon).
In the gui, you would choose the script command called "Set a variable or attribute",
then enter player.equipped_weapon for "set variable"
and sword for "expression".
This way, anything you need to know about the currently equipped weapon can be accessed using the player attribute. So, for instance, if the "sword" object has an attribute called "damage" you can refer to it (once it is equipped) as "player.equipped_weapon.damage" just the same as "sword.damage".
The other way I've used in the past basically involves creating matching attributes on the player and the weapon and making all of the player's attributes equal the weapons attributes.
(starts like this)
sword.damage = 5
player.damage = 0
(then do this)
player.damage = sword.damage
(and end up with this)
sword.damage = 5
player.damage = 5
This is okay for really simple weapons, but if you want weapons with a variety of attributes, you'd have to set the matching player attribute for each one when they equip it.

Avantar
29 Dec 2013, 16:09Should you decide to download the desktop version, there is a big topic I have started for equipping and un-equipping weapons.
That was also my starting point for my game and one of my first questions.
here is the link:
http://forum.textadventures.co.uk/viewtopic.php?f=10&t=3972&p=26783&hilit=equip+weapon#p26744
I have pasted the basic scripts there and steps to take.
Happy Questing!
That was also my starting point for my game and one of my first questions.
here is the link:
http://forum.textadventures.co.uk/viewtopic.php?f=10&t=3972&p=26783&hilit=equip+weapon#p26744
I have pasted the basic scripts there and steps to take.
Happy Questing!
Sazukan20
29 Dec 2013, 20:46Okay, so from what i understand is that there are formulas involved correct? i never have made a text game and i never had any experience. im going to be posting the map, for the first part of the game when its descriptions are done, feel free to check under my games later on it may have the map tester up and online to make sure it operatres.
Sazukan20
29 Dec 2013, 21:51Okay so i have posted the map with a potion in it, (Yay i figured something out on my own!) but im trying to add a armour value to a shirt i just added to the game, would you know how to do that?

jaynabonne
29 Dec 2013, 22:11Posting is here: http://textadventures.co.uk/games/view/ ... map-tester
TriangleGames
30 Dec 2013, 01:18Sazukan20 wrote:... it may have the map tester up and online to make sure it operatres.
What you've got so far appears to work as it should, except I don't see the map. I'm not sure if you meant "map" in terms of the layout of the rooms or the actual map screen which can be displayed. If you didn't know yet, there is an option under the display tab to show the player an actual map screen.
All objects in quest work on the same principles, so once you decide how to handle weapons, armor will be quite similar. You'll just need more variables/attributes with different names for armor vs weapons. If you definitely want to use combat, weapons, etc, you might want to make sure you can get it to work in the web editor before you get too far into the game. It's not easy to take the game from the web-version to the desktop version (you basically have to ask the developer to do it for you as a favor, as far as I know anyway).