The Pixie wrote:It is certainly possible, see this game:
http://textadventures.co.uk/games/view/ ... tcg/deeper
There is a general library I wrote here:
viewtopic.php?f=18&t=4886
This is version 2, which includes a load of weapons and monsters, but is fantasy-based, so may not be what you want:
viewtopic.php?f=18&t=5976
If you are determined to do it all yourself, start by reading the second post on this thread, and reading the links there:
viewtopic.php?f=10&t=5703&p=39301&hilit=combat#p39301
The Pixie wrote:Are you using my library? If you are, the "makedead" script already sets the "dead" attribute to true. You just need to edit it so it also adds the genetic mass (I guess based on an attribute of the monster).
player.genetic_mass = player.genetic_mass + monster.genetic_mass
initial setting:
sword.parent = shop_owner // the 'shop owner' Object has the 'sword' Object
Buying Script/Verb:
if (player.cash >= sword.price) { // checking if you got enough cash to buy the sword
player.cash = player.cash - sword.price // subtracting the sword's cost/price from your cash: you buy the sword
sword.parent = player // giving/setting/putting the sword into/to the player's possession
} else {
msg ("You don't have enough cash.")
}
initial setting:
sword.parent = player
Selling Script/Verb:
if (shop_owner.cash >= sword.price / 2) {
shop_owner.cash = shop_owner.cash - (sword.price / 2)
sword.parent = shop_owner
} else {
msg ("The shop owner doesn't have enough cash.")
}
HegemonKhan wrote:as Pixie already mentioned:
make sure you got the same named/labeled (quest is case sensitive by the way) and same data type (integer/double) for your 'genetic_material' Integer/Double Attribute, and that you add this Attribute to both your 'player' Player Object and your 'monster' Objects
here's an example of how an Attribute transaction (buying/selling) occurs (which is the same as getting experience/cash/genetic_material from a killed monster):
-------------------------
Buying:initial setting:
sword.parent = shop_owner // the 'shop owner' Object has the 'sword' Object
Buying Script/Verb:
if (player.cash >= sword.price) { // checking if you got enough cash to buy the sword
player.cash = player.cash - sword.price // subtracting the sword's cost/price from your cash: you buy the sword
sword.parent = player // giving/setting/putting the sword into/to the player's possession
} else {
msg ("You don't have enough cash.")
}
Selling:initial setting:
sword.parent = player
Selling Script/Verb:
if (shop_owner.cash >= sword.price / 2) {
shop_owner.cash = shop_owner.cash - (sword.price / 2)
sword.parent = shop_owner
} else {
msg ("The shop owner doesn't have enough cash.")
}
---------------------
you probably don't need this, but here's a guide on Attribute usage and the 'if' Script in/for quest:
viewtopic.php?f=18&t=5559
also if you want to take a look for ideas (and you may use freely of course), here's my own old combat code:
viewtopic.php?f=10&t=3348&start=120#p22483
(see the post below for the key/legend of all of my lame abrevs I used at the time)
HegemonKhan wrote:did you add the library properly into your game code? :
<include ref="library_file.aslx" />
otherwise, that error is strange, if you got the files in the correct location and there's no mis-spelling/typing of them...
only other highly unlikely possibility... you may need to generate a new random/unique 'gameid'... for your game
Zamorak789 wrote:...I'm probably going to scrap this version of the project and start over. The amount I've learned in just two days has revealed errors that I need to go over and fix (Such as trying to do the combat tutorial all in the GUI instead of a library.)
The Pixie wrote:"Zamorak789"
...I'm probably going to scrap this version of the project and start over. The amount I've learned in just two days has revealed errors that I need to go over and fix (Such as trying to do the combat tutorial all in the GUI instead of a library.)
Actually the best way to create a library is to do it in the GUI (though I would do it in code in the GUI!), and once it is working, copy the XML into your library.
What error are you getting? Depending on how you have set up the various files... Make a new quest game, and have it load just one library, and see if that is okay, then add another one, then another, at each step checking the game will play.
In fact, it is worthwhile designing the libraries so you can do this. Have an order, and ensure a library only depends on libraries higher up the list, never on a library lower in the list.
HegemonKhan wrote:so, it's Pixie's 'commands.xml' file... this may need to added to one of his/her other library file's code... I'm guessing
HegemonKhan wrote:maybe make sure that the order of library files is like this in whatever (one of the library or your game) file's code:
<include ref="Commands.xml" />
<include ref="CombatLib.aslx" />
or this (whichever it's order is suppose to be):
<include ref="CombatLib.aslx" />
<include ref="Commands.xml" />
as you notice that it fails an initialization (most likely the Commands.xml file):
loading _________
loading CombLib.aslx
------
otherwise... maybe try changing the file's ext to 'aslx' instead of 'xml'...
--------------
I still don't understand file linking that well... so I don't know what I'm talking about... wait for Pixie's help/solution... lol
HegemonKhan wrote:ah yes (I forgot about this possible issue)... depending on the content of the libraries, their order (upper to lower in code) can matter.
The Pixie wrote:This:
case (In a good way I hope) {
... should be
case ("In a good way I hope") {
The other case too.
HK.favorite_colors = split ("black;red", ";")
show menu ("Which is HK's favorite color?", HK.favorite_colors, false) {
switch (result) {
case ("black") {
msg ("Correct!")
}
case ("red") {
msg ("Wrong.")
}
}
}
HK.favorite_colors = NewStringList ()
list add (HK.favorite_colors, "black")
list add (HK.favorite_colors, "red")
show menu ("Which is HK's favorite color?", HK.favorite_colors, false) {
switch (result) {
case ("black") {
msg ("Correct!")
}
case ("red") {
msg ("Wrong.")
}
}
}
show menu ("Which is HK's favorite color?", split ("black;red", ";"), false) {
switch (result) {
case ("black") {
msg ("Correct!")
}
case ("red") {
msg ("Wrong.")
}
}
}
Zamorak wrote:Additional little question. I'm using your spell type to create some powers. One I want to be is telekinisis, and understanding that it would be difficult to actually program all the possibilities, I wanted to have it set a flag named "telekinisis" to the room object the player is in. How would I represent that? My first guess was like this.room or something, but I wanted your input.
Essentially when the 'spell' is cast, it will set the flag. In rooms where you can use telekinesis it will check for the flag, if it's set then the thing will happen.
<object name="room">
<object name="player">
</object>
</object>
HegemonKhan wrote:-Snip-