HK&Omega QuestCoop

Omega
Ok HK here's a place so PM doesnt get too overwhelming hahaa.

HegemonKhan
actually, for new people, while coding itself is obviously an enormous learning curve... there's another just as equally enormous learning curve: coding mentality~logic~thought process, that takes quite a while to train your brain at, lol (I've been learning quest for over like 1-3 years ~ too lazy to look how long I've been at this, laughs ~ anyways, it took that long to begin training my brain to think in this way). maybe an anology would be this: besides trying to improve my raw drawing skills, I got to learn to think in terms of perspective, in order to draw correctly, along with improving my raw drawing skills.

the easiest would actually to just do to a math equation expression (extremely simple concept example only ~ not in proper code):

weapon: final_damage = rounds x base damage

in your 'shoot' script:

rounds = GetRandomInt (0,10)
final_damage = rounds * player.weapon.base_damage
monster.hp = monster.hp - final_damage

---------

like 90% of all scripting, only needs these two 'SUPER SCRIPTS' :

1. the 'if' script:

GUI~Editor: run as script -> add a script -> scripts -> if -> [EXPRESSION] -> (see below)

2. the 'set a variable or attribute' script:

GUI~Editor: run as script -> add a script -> variables -> set a variable or attribute -> (see below)

Object_name.Attribute_name = Value_or_Expression

HK.strength_integer = 100
orc.dead_boolean = false
HK.favorite-color_string = black
HK.favorite_colors_stringlist = split ("black;red", ";")
HK.final_damage_integer = HK.weapon_damage_integer + HK.weapon_damage_integer * (HK.strength_integer - orc.endurance_integer) / 100

--------

GUI~Editor:

if [EXPRESSION] orc.dead = false
-> then...
else if [EXPRESSION] orc.dead = true
-> then....

--------

in code:

if (orc.dead = false) {
// script1
} else if (orc.dead = true) {
// script2
}

Omega
perfect that makes sense. I'm not there yet but if you want to you can get that set up. I know you have 540 and I 550. I don't think I have put anything from the 550 that the 40 can't do.

Here's what I got.

<game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<shoot type="script">
if (Got(weapon.attribute)) {
msg ("The weapon fires in the direction you point. ")
}
else {
msg ("There's nothing to shoot at now.")
}
</shoot>
<object name="F49 Assualt Rifle">
<inherit name="editor_object" />
<alias>assaultrifle</alias>
<look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
<alt type="stringlist">
<value>Assault Rifle</value>
</alt>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Reload</value>
</inventoryverbs>
<roundrifle type="int">60</roundrifle>
<take />
<fire type="string"></fire>
<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}
else {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle - GetRandomInt(10,60))
msg ("you fired " +F49 Assualt Rifle.roundrifle+ " rounds")
if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload. ")
}
}
}
]]></shoot>
<reload type="scriptdictionary">
<item key="F49 ammo"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (Got(F49 ammo)) {
if (F49 Assualt Rifle.roundrifle = 60) {
msg ("You don't need to reload.")
}
else if (F49 Assualt Rifle.roundrifle <60 ) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
if (F49 Assualt Rifle.roundrifle >60) {
F49 Assualt Rifle.roundrifle = 60
}
}
}
else if (not Got(F49 ammo)) {
msg ("You have no ammo to reload with. ")
}
}
else {
msg ("You can't do that now...")
}
]]></item>
</reload>
</object>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<rifleclip type="int">60</rifleclip>
<take />
</object>
</object>
<verb>
<property>reload</property>
<pattern>reload #object#</pattern>
<defaultexpression>"You can't reload " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>shoot</property>
<pattern>shoot #object#; fire #object#</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here. </defaulttext>
<knockout type="script">
if (object.health = 0) {
MakeObjectInvisible (object.alias)
}
</knockout>
</verb>


If you notice im still working on this one single weapon for my own without looking at the combat system you sent me. Haven't gotten lost yet. lol.

Im still trying to get the shoot/fire to stop showing rounds less than 0. I might just redo it since my reload is pretty set. Will need to practice with it more to get it going though.

Please feel free to change anything or if you see something easier go for it. Again, let's not jump all over the place with monster damage and stuff. Let's make sure this weapon works properly first. Then we can focus on how we can kill a monster.

Omega
lol. yea I know coding is worse as one progresses and when dealing with an actual full game.

But you know what, that's ok. that's how we will both learn. Maybe you'll get stuck at something that i'll go aha (prob not going to happen anytime soon lol) and vice versa.

Yea that math input/output is a great idea. I would have done something a whole lot more complicated. hahahaha!

But let's focus on just this weapon ok. Then once that is done make a list of weapons for us and apply the idea to those weapons. They will all obviously have something different, dont want to bore the player with same combat style.

Omega
lol ok dude. Yea i saw notepad and color coding is great. super helpful with seeing the coding instead of it all being one color. haha.

Only thing is how do I test it? Don't I have to go back and forth with it from notepad++ to quest and back to change? seems a lot of work. but ok.

HegemonKhan
ya, to actually test it, you got to have a quest game file (*.aslx) of it and start~play it obviously, but otherwise, you can put the code into notepad++ to better read it, write it, and~or troubleshoot it (quest's code view also helps, but it's at the least a bit more sluggish though).

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

I'm not sure why the 'returning to zero' doesn't work, as I don't use the 'set' code syntax (i just use the: Object_name.Attribute_name = Value_or_Expression)

does it display your message of 'reload.' ???

as this will tell us that it is (or is not able to do the) running~executing (of) your 'if' Script:

if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}


if you aren't seeing the 'reload.' message displayed, then maybe try to do this:

<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (player.F49 Assualt Rifle.roundrifle <0) {
player.F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}
// you'll need to fix up the rest of it, matching what's change with this part


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

I don't know about quest version 550, but in quest version 540, there was a shift over to this syntax structure, which maybe you need for quest version 550 (did you do the entire code by writing it in yourself, or did you use the GUI~Editor's buttons and drop down menus, tabs, add, and etc to create your game ?):

<roundrifle type="int">60</roundrifle>

change it to this:

<attr name="roundrifle" type="int">60</attr>

try this with each of these combinations:

<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}

OR

<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (player.F49 Assualt Rifle.roundrifle <0) {
player.F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}
// you'll need to fix up the rest of it, matching what's change with this part


maybe, this'll get it to work...

-----------

otherwise, maybe it's just having trouble finding your weapon (as it has to string~sentence parse~look for it, via your weapon's name, and your spaces in it and~or your 'alt (alternative aliases)' for it may be causing it to get confused and not find it nor work correctly)

jaynabonne
Just to be a late-to-the-table kibitzer (but mostly because I'd like to stop the promotion of unnecessary style, and these are pet peeves of mine lol), the following code:

if (orc.dead = false) {
// script1
} else if (orc.dead = true) {
// script2
}

shows two things that would be good to nip in the bud now.

First, an "if" statement takes a boolean expression. It can be something like "x > 10" or "player.parent = DeathRoom". But it can be any boolean value, including what is stored in a boolean attribute. So rather than

if (orc.dead = false)

or

if (orc.dead = true)

you can simply use:

if (not orc.dead)

or

if (orc.dead)


Second, a boolean value only has two states, true or false. If it's not one, it must be the other. It's not necessary or valuable to check both states.

Putting the two together, the above (after swapping the if/else bodies to deal with positive statements only) can be reduced to:

if (orc.dead) {
// script2
} else{
// script1
}

It's not a big thing, but it can really make the code much more readable - this now reads as "if the orc is dead, do something; else, do something else." That allows you to focus on the semantics of the statement and not odd things like "if this is true or that is false", which is less clear.

(If that helps! :) )

HegemonKhan
Jay has a good suggestion with the use of boolean attributes, as it is easier to read.

(I personally just still like to write out my booleans, as it helps me personally stay organized and know what I'm doing, such as with deep+complex nesting too:

if (1) {
if (2) {
// script
// script
// script
if (3) {
// script
// script
// script
if (4) {
// script
// script
// script
if (5) {
// script
// script
// script
if (6) {
// script
// script
// script
} else (6) {
// script
// script
// script
}
} else (5) {
// script
// script
// script
}
} else (4) {
// script
// script
// script
}
} else (3) {
// script
if (8) {
// script
// script
} else (8) {
// script
// script
if (9) {
if (10) {
}
} else (9) {
}
} else (11) {
// script
// script
} else if (7) {
// script
// script
// script
} else (7) {
// script
// script
// script
}
// script
// script
}
} else (2) {
// script
// script
// script
}
} else (1) {
// script
// script
// script
}


as you can see, it'd be very hard to match up the correct 'if' with its corresponding 'else' (remove the help numbers) ... as your script block gets larger and more layers of layers, so by writing out my if-booleans, I know what I'm doing for that if~else section, and not trying to figure out for every 'else' as to what part I'm doing with it (via trying to figure out which 'if' it matches up to). So, that's my reason for writing out my if-booleans, as while it does~can get a little confusing, for me it's far less confusing than not doing so. It also helps with with noticing forgotten-to-add 'elses' and~or their beginning~ending curly brackets too, lol-argh! As can be seen, you should be able to easily spot some mistakes I made in my haste to write it, lol. Also, for example, I'd have a very hard time figuring out whether else3 or else4 or else5 corresponds to if4, I'd have to scroll all the way up to find what if each else matches to, then scroll back down to the else, but by then, I've forgotten what I'm doing again, so I have to scroll back up to the if... laughs... HK pulls his hair out. I need to write out the if-booleans, but that's probably just me, lol)

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

Also, within your code, I think you want:

instead of 'msg ("reload."), you can actually activate your 'reload' Scriptdictionary:

use 'invoke' or 'do', (well for 'invoke' anyways) along with 'ScriptDictionaryItem' (look them up in the quest wiki site)

(for 'do', I'd have to look up it's syntax, as I don't know it off-hand, as I don't use 'do' much in what I'm trying to code in ~ in my learning to code more stuff)

invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo)

though, we'll have to code in something for 'getting' what weapon and ammo you're using, but we'll get to that later.

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

troubleshooting is fun... laughs

here's a simple new game code, to show in the simpliest use of 'returning to zero' (you'll then have to figure out what's causing it not to work within your own code):

copy and paste this into a new game file (delete the default new game code), as it should work fine (unless there's conflicts with my coding format and~or syntax and what it should be with quest version 550): try~'play' it actually out, lol.

(edited, thanks~credit to jay, for spotting some mistakes in it that I missed, my bad!)

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="testing game stuff">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<attr name="count_integer" type="int">0</attr>
<start type="script">
test_function
</start>
</game>
<function name="test_function"><![CDATA[
msg ("(1) " + game.count_integer)
game.count_integer = game.count_integer - 1
msg ("(2) " + game.count_integer)
if (game.count_integer < 0) {
game.count_integer = 0
msg ("(3) " + game.count_integer)
} else {
msg ("(4) " + game.count_integer)
}
msg ("(5) " + game.count_integer)
]]></function>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


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

I forgot to mention:

lastly, scour~scan for typos... as one wrong character, can make it not work, lol

for example: F49 Assualt Rifle vs F49 Assault Rifle

though you should get an error message, telling you of this or of something else, do you get any error messages with your code?

jaynabonne

lastly, scour~scan for typos... as one wrong character, can make it not work, lol



Like:

<asl version=550">


:)

HegemonKhan
my bane of trying to write in code as fast as I can, laughs.

thanks for noticing the missing left quote, lol. (that was a funny~embarrasing mistake on my part: scour the code for typos, ya: HK why don't you do the same with your very first code line! BIG OOPSY! hehe)

the missing include ref was cause I copied from omega's code, just to have the default new game code lines, but didn't notice he was missing the include ref, lol.

jaynabonne
You also need this:

  <include ref="English.aslx"/>
<include ref="Core.aslx"/>

else editor_room is undefined.

(Sorry, was just trying it out.)

HegemonKhan
since, you're here Jay, can you spot the mistake in omega's code, as I'm not familiar with the 'set' code line, and am unable to test (troubleshoot) it out in quest at the (very prolonged~lol) moment, he can't get the:

if (F49 Assualt Rifle.rifleround < 0) {
F49 Assault Rifle.rifleround = 0
}

to work, and I'm not sure what the reason is, just from looking at the code.

--------

these are my guesses at it:

HegemonKhan wrote:I'm not sure why the 'returning to zero' doesn't work, as I don't use the 'set' code syntax (i just use the: Object_name.Attribute_name = Value_or_Expression)

does it display your message of 'reload.' ???

as this will tell us that it is (or is not able to do the) running~executing (of) your 'if' Script:

if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}


if you aren't seeing the 'reload.' message displayed, then maybe try to do this:

<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (player.F49 Assualt Rifle.roundrifle <0) {
player.F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}
// you'll need to fix up the rest of it, matching what's change with this part


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

I don't know about quest version 550, but in quest version 540, there was a shift over to this syntax structure, which maybe you need for quest version 550 (did you do the entire code by writing it in yourself, or did you use the GUI~Editor's buttons and drop down menus, tabs, add, and etc to create your game ?):

<roundrifle type="int">60</roundrifle>

change it to this:

<attr name="roundrifle" type="int">60</attr>

try this with each of these combinations:

<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}

OR

<shoot type="script"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (player.F49 Assualt Rifle.roundrifle <0) {
player.F49 Assualt Rifle.roundrifle = 0
msg ("reload.")
}
// you'll need to fix up the rest of it, matching what's change with this part


maybe, this'll get it to work...

-----------

otherwise, maybe it's just having trouble finding your weapon (as it has to string~sentence parse~look for it, via your weapon's name, and your spaces in it and~or your 'alt (alternative aliases)' for it may be causing it to get confused and not find it nor work correctly)

--------

or lastly, a typo somewhere

jaynabonne
The code is working. It's just not in the right place. The way the code is now:

1) Subtract a random amount from the current count
2) Print out the amount left as the amount shot. (This is the first problem. It says "you shoot xx", but it's actually printing out what remains. To print out what you shoot, you need to save what GetRandomInt returns and print that. That's the amount you've shot.) Notice that it prints out the amount left before the following code (that is, before the value is set back to 0). So the printed value is typically negative at this point.
3) Check if the value is less than 0. If so, set it to 0. Again, note this is after the negative value was already output.

So, some thoughts...

First, you don't have to let the value go negative and then correct it back to 0. If you limit the value before you subtract it, then life gets easier:

amount_to_shoot = GetRandomInt(10, 60)
if (amount_to_shoot > F49 Assualt Rifle.rifleround) {
amount_to_shoot = F49 Assualt Rifle.rifleround
}

Then you don't need to compensate afterwards. You do need your reload check, though, but be sure to print reload if rifleround goes to 0 (not < 0).

To keep your current strategy, though, change the order to do this:

1) Subtract the random amount from rifleround. (I still think you want to store and print the amount shot rather than what's left, but that's me. lol)
2) If rifleround < 0, set it to 0.
3) Print the value of rifleround (if you're still using it)
4) If rifleround = 0, print "reload"

HegemonKhan
doh! so it was just that he was messaging the amount of bullets remaining, BEFORE, he changes it back to 0, and not having the message afterwards, which would show that it is now '=0'.

and I was just looking at the first instance of the 'if round<0, then round = 0', so I was looking at the wrong spot (no wonder I couldn't spot anything, lol):

<shoot type="script">
if (F49 Assualt Rifle.rifleround <0) {
F49 Assault Rifle.rifelround = 0
}


whereas, I needed to look at the second instance of it, which is this part:

else {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle - GetRandomInt(10,60))
msg ("you fired " +F49 Assualt Rifle.roundrifle+ " rounds")
if (F49 Assualt Rifle.roundrifle <0) {
F49 Assualt Rifle.roundrifle = 0
msg ("reload. ")


--------

sorry (jay and omega), about the correcting it back to zero afters, as I mentioned that to him, as it was the ~ easiest~simpliest thing to do code wise, though as you point out, it's not the best thing to do. though, if he wants the code to be more thorough (for example with the application of damage with the bullets~rounds fired, he needs to code in some additional checks and code lines, if he corrects it to zero beforehand, as opposed to afterwards, hence why afterwards is the ~ 'easiest~simpliest' code wise for him, and thus why I mentioned it to him).

-----------

P.S.

I like to message both the damage done and what is the remaining life amount, in my own coding, as it's doubly informative :D

(I still got to figure out a design method to include messages, and even colored fonts~texts messages, for when there's 'critical_hits', 'reflection', 'absorption', and etc, as I use equation expressions for my damage code lines, need to add in some functions that check for them and return the message~colored message, would be a way to do it, I think, though maybe there's better ways too... hmm)

jaynabonne
There are two straightforward ways to go with colored (or otherwise styled) text, using HTML styles:

1) Do the style change in-line. If (for example) you wanted part of your text to be red, you could use:

msg("Damage: <span style='color:red;'>" + damage + "</span>")

2) Use class names instead. If it's used a lot, you can change all your instances simply by varying the CSS:

msg("Damage: <span class='damage'>" + damage + "</span>")

Then you'd need to have a CSS entry with something like "span.damage : { color: red; }".

Quest gives you lots of flexibility in terms of formatting your output. :)

HegemonKhan
I'll have to study a bit up on that, (but thank you Jay for it ~ when I get around to working on this stuff, I'll definately try to learn and use it), as such, would this stuff work for this:

player is attacking monster:
if (player.defending and monster.defending) {
monster.hp = monster.hp - player.weapon.damage * (player.strength/100) - player.weapon.damage * critical_function (if true, returns int2, if false, returns int1) * 2 (defending's bonus damage) + monster.armor_resistance * (monster.endurance/100) + monster.armor_resistance * 2 (defending's defense bonus)
} else if (player.defending and not monster defending) {
} else if ...
}
....


would I be able to color message that a critical hit was done, like maybe while this is running (I guess this would need to maybe use the 'while' code line, which is probably still too confusing advanced for me, if your stuff doesn't work for it), and I'd like to add in some mor stuff too into this equation, like if an elemental damage was done vs a physical damage, and whatever else I can think of.

also, for other scripts, I'd like to color messages for different magic effects and~or status effects (using FF6 partially for an example: pink for 'haste', white for 'slow', green for poison, etc etc etc)

Omega
First off, Jay it's cool man you can check up on us. Your level of expertise is really good too. If there's something we get stuck on and one of us isn't here your input is always useful here.

LOL i noticed that when I was running my code on the weapon that the system was showing how many shots I had left not how many fired. hahaha!

Thanks both of you. I can understand the use of a boolean Jay but im also like HK i like to write it out to see what's actually happening instead. Makes me understand coding a whole lot more and see where mistakes may lay.

Also let's not cut around the bush so much here HK (and Jay).

I guess here's what Im doing atm attached below.

Look further at the next post HK. Let's not jump back and forth in the same code realm. You'll see what I mean

Omega
So by splitting the work around we can make progress on this game more efficiently and im not jumping back and forth with your code and mine. Plus if I type something like a new verb or something that your code doesn't have then combining it wont confuse the program, you know? Also notice how we are piecing this one code library at a time. The posted aslx is guntraining so anything with weapon coding will go in here. let's no focus on the badies just yet kk.

You can take this list as an idea for other weapons but remember not all weapons will just be bullets. If you get it let me know and i'll give you a weapon to code for with description of what it does in combat and what it looks like kk?

In the big picture im aiming for this for this particular weapon:

1. let's make the weapon fire bullets (randomly number) so the player has somewhat control on what to do during combat like take cover, use ability, etc (which of course will be later.)

2. let's of course when the rounds of the weapon reach 0 the player has to type reload to make it feel somewhat realistic. To tie into this, the weapon requires the player to have ammunition to reload. So...

3. Ammunition will have to found in the game with random rounds UNLESS!! it is stashed like in a carry bin that has full ammo. Think like the weapon found is brand new and fully loaded. which leads to the next thing...

4. If the player has the weapon already in the inventory, then picking up the same weapon will not be possible but instead the ammo will be. This can be a simple set up like having the ammo no visible in the room description but if player 'looks at' the weapon, the player gets a description that it has a reading of ____ ammo.

5. Weapons are drop/take. They will do damage and we agreed on a turn combat system. Damage and rounds fired will correlate.

let me know what you think of this and please add any of your input.

Omega
Updated my assualt rifle code. check attachment.

Im having a problem here with something im not seeing. Or it's not making sense to me.

So I have it set where i can fire my weapon and it will randomly fire bullets. I have the reload good and ready too.

One problem? when I reload and type fire weapon. It suddenly becomes infinite shots....um am I missing something?

Im guessing it has to do with the fact that the ammo isn't 'invisible' when used and it's going off by that constant reload without actually dropping roundrifle value of 60.

let me know what you got.

jaynabonne
(To wrap up the previous side-thread... :) )

would I be able to color message that a critical hit was done, like maybe while this is running (I guess this would need to maybe use the 'while' code line, which is probably still too confusing advanced for me, if your stuff doesn't work for it), and I'd like to add in some mor stuff too into this equation, like if an elemental damage was done vs a physical damage, and whatever else I can think of.

also, for other scripts, I'd like to color messages for different magic effects and~or status effects (using FF6 partially for an example: pink for 'haste', white for 'slow', green for poison, etc etc etc)



I think the most straightforward way would be to have different CSS classes. Then you can just dynamically change the class at output time. Something like (not tested):

if (some_check_about_type_of_damage) {
damage_class = "elemental_damage"
} else {
damage_class = "physical_damage"
}

msg("The something strikes you for <span class='" + damage_class + "'>" + damage_count + " damage</span>")


And your CSS would have things like:

span.elemental_damage { color: red }
span.physical_damage { color: blue }


That might not look very clear, but once set up, it could be quite powerful.

jaynabonne
Omega, the code you posted won't reload because of the "assualtrifle" misspell. Fixing that, there is another problem with this:

 set (F49 Assualt Rifle, "roundrifle", +assaultround.rifleclip)

There should not be a "+" in front.
Fixing that, there is another problem, again with naming. You might want to go through and fix all the spellings to be consistent (including spaces - I myself tend to shy away from names with spaces, but that's me).

Looking at the "reload" script, there's a bit of unnecessary code in there, which will only make it harder to modify later. You can either fix it now or not. It's up to you. I was going to try to point out what the issues were, but it got too confusing. So I'll just put the reduced code. I didn't restructure anything. I just got rid of "if"s that were either always true or always false. That way, you can see which code is actually going to run. (Some of it was unreachable.)

        <reload type="scriptdictionary">
<item key="assault round"><![CDATA[
if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle=60) {
if (Got(assault round)) {
msg ("Your weapon is fully reloaded. ")
}
}
else {
if (F49 Assualt Rifle.roundrifle<=0) {
if (Got(assault round)) {
set (F49 Assualt Rifle, "roundrifle", assaultround.rifleclip)
msg ("You reloaded your rifle.")
}
}
}
}
else {
msg ("You don't have the weapon to reload.")
}
]]></item>
</reload>


Hope it helps.

Omega
i dont think my code had mispell. the ammo is suppose to be F49 ammo.rifleclip.

a little lost on what you're saying. i'll put it back up after looking through it.

As for the script, im not sure where you're asking me to put it. Under the ammo attribute? under reload verb?

Omega
ok i looked through it and im not seeing what you are saying that is misspelling. I think when you were giving it a crack you were adding some other name to it.

Try to check through it again.

jaynabonne

You are in a room.

> shoot assaultrifle
you fired 60 rounds

> shoot assaultrifle
reload

> reload assaultrifle
Error running script: Error compiling expression 'F49 Assault Rifle.roundrifle<=0': Unknown object or variable 'F49 Assault Rifle'



Your object is named "F49 Assualt Rifle". That's what HK was talking about before when he mentioned checking your spelling.

Omega
i checked my code. im not seeing any misspelling of that word anywhere.

Omega
nvm i found it under attribute of the weapon under alt attribute.

ok i only found the alt one. but im assuming that means the alternate spelling of assault is acceptable during game play.

otherwise my entire code is spelled correctly.

jaynabonne
spelling.jpg

I've now shown you:
1) The error when run
2) How to reproduce the error when run
3) Where the misspelling is

I can't do any more. If you try the steps I did above and see the error, then fix the error, then you'll at least have things consistent.

Omega
sorry Jay not seeing what's wrong with that if the coding in the game can still recognize it. Am I not suppose to use that in the code?

jaynabonne
The coding in the game does not recognize it, as evidenced by the error I showed you above. Have you tried the steps I showed?

Your object is named "F49 Assualt Rifle", which is a misspelling. It doesn't matter if you use that misspelling everywhere, but you switched to using the correct spelling "Assault" in your script in at least one place, which is causing the error I showed.

Error running script: Error compiling expression 'F49 Assault Rifle.roundrifle<=0': Unknown object or variable 'F49 Assault Rifle'


Omega
Sorry Jay im still trying to wrap my head around it. Im looking at what you posted and what HK mentioned. I know that in game I type reload rifle with ammo. it works, but when i fire it just keeps firing without lowering the roundrifle like its ignoring the entire shoot script.

Also I updated the game it's not the same from before too Jay. Did you grab the recent upload i posted up? that one seems to be working just fine. I know when HK was saying stuff I had some pretty bad errors before and that was fixed which is why i placed the new version up.

I do know however when you just type reload rifle; it pops up saying using what? and gives option to ammo. clicking it says it doesn't work either (not really sure why) but when you just type out reload rifle with ammo it works just fine and you can shoot again.

HegemonKhan
I don't know how to open your file on this mac, argh. it comes up as an *aslx.html., and I can't just remove the .html and open it with the text editor, with this mac. I don't know how to use macs at all.

so, unless I can get help onhow to open the file, could you post your code, so that I can help you. (This is very frustrating for me being on a mac, which I don't know how to use at all, don't have quest on it to test anything, and I can't even get notepad++ on it for easy code work).

------

and sorry for doing my own code, it's just hard for me to adapt quickly and understand someone else's code, my hope was to just write my own code, and you can kind see how things are done, using them for your own style of code design. I'll try to only now work with your code, and do what I can to help you.

------

I can better help with coding, if you could list the things you want, providing you with different ways of coding things, and you can decide on which way you like best.

we'll work slowly, on simple stuff, slowly building up (sorry, I have trouble staying focused, on just doing simple small stuff at a time. I was trying to craft the entire combat system for you, instead of helping you code your own stuff piece by piece, my bad)

------

I think Jay is saying to look at all your:

F49 Assualt Rifle

as you have some with "...AU...' and some with "...UA..." spelling of the 'a' and 'u' in the middle of the word (I hate assualt~assault, I never remember which is the correct spelling, and it's easy to type in the wrong order of the a+u, accidentally even when you know whether the a or u comes first, laughs)

because your NAMES of your weapon isn't the same, it's not activating the script, which is why it's not working for you.

Omega
Here's the full code of the game.

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<shoot type="script">
if (Got(weapon.attribute)) {
msg ("The weapon fires in the direction you point. ")
}
else {
msg ("There's nothing to shoot at now.")
}
</shoot>
<object name="F49 Assualt Rifle">
<inherit name="editor_object" />
<scenery type="boolean">false</scenery>
<look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
<alt type="stringlist">
<value>Assualt Rifle</value>
</alt>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Reload</value>
</inventoryverbs>
<roundrifle type="int">60</roundrifle>
<take />
<fire type="string"></fire>
<shoot type="script"><![CDATA[
if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(F49 Assualt Rifle)) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle - GetRandomInt(10,60))
if (F49 Assualt Rifle.roundrifle <=0) {
F49 Assualt Rifle.roundrifle = 0
firsttime {
F49 Assualt Rifle.roundrifle = 0
msg ("you fired your weapon. reload")
}
otherwise {
msg ("reload your weapon.")
}
}
else if (F49 Assualt Rifle.roundrifle>0) {
msg ("you fired your weapon.")
}
}
]]></shoot>
<reload type="scriptdictionary">
<item key="F49 ammo"><![CDATA[
if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon to reload...")
}
else if (Got(F49 Assualt Rifle)) {
if (not Got(F49 ammo)) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo)) {
if (F49 Assualt Rifle.roundrifle =60) {
msg ("Your weapon is already fully reloaded")
}
else if (F49 Assualt Rifle.roundrifle <60) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
if (F49 Assualt Rifle.roundrifle >60) {
F49 Assualt Rifle.roundrifle = 60
msg ("your weapon is reloaded")
}
else {
msg ("Your weapon is reloaded (full).")
}
}
}
}
]]></item>
</reload>
<visible />
<usedefaultprefix />
</object>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<rifleclip type="int">60</rifleclip>
<take />
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
</inventoryverbs>
<usedefaultprefix />
</object>
</object>
<verb>
<property>reload</property>
<pattern>reload #object#</pattern>
<defaultexpression>"You can't reload " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>shoot</property>
<pattern>shoot #object#; fire #object#</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here. </defaulttext>
</verb>
</asl>


Here's where i'm at. Shoot code:

if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(F49 Assualt Rifle)) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle - GetRandomInt(10,60))
if (F49 Assualt Rifle.roundrifle <=0) {
F49 Assualt Rifle.roundrifle = 0
firsttime {
F49 Assualt Rifle.roundrifle = 0
msg ("you fired your weapon. reload")
}
otherwise {
msg ("reload your weapon.")
}
}
else if (F49 Assualt Rifle.roundrifle>0) {
msg ("you fired your weapon.")
}
}


Reload code:

if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon to reload...")
}
else if (Got(F49 Assualt Rifle)) {
if (not Got(F49 ammo)) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo)) {
if (F49 Assualt Rifle.roundrifle =60) {
msg ("Your weapon is already fully reloaded")
}
else if (F49 Assualt Rifle.roundrifle <60) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
if (F49 Assualt Rifle.roundrifle >60) {
F49 Assualt Rifle.roundrifle = 60
msg ("your weapon is reloaded")
}
else {
msg ("Your weapon is reloaded (full).")
}
}
}
}


Also, I feel your pain. I dont have a mac or ever will want one. Too much problems and always a hassle. Stick with PC, best way to go.

Omega
lol. i know the spelling can trip Quest up. i may be a newb but not that bad. haha.

I checked like three times and it all looks right to me.

Also, It's cool if you wanted to go ahead and develop the combat system. Go for it. I just wanted to make sure there was no confusion once the weapons were developed. If you feel safe and can adapt to any changes to the combat system go for it.

Set your code for the combat system here and i'll copy it into my system files under combat so it's stashed and ready to go.

HegemonKhan
ya, we were talking about your older code (it had spelling~typo issues in it, but not your newest code that you just provided: you already cleaned up all them)

----------

here you go (hopefully I fixed up your game code), see if you like this, and if it works or not:

(I was tired and it was late last night, but now I'm rested and staying focused this time, laughs. Being all rested up makes a big difference, lol. I could understand your code easily and have hopefully fixed it up, with it working perfectly... maybe, laughs)

(I included comments too, after you read them, you can remove them)

(comments only work within script blocks, and are initiated by the: //, so you can delete these and to the right of them to the end of the comment, but don't delete your actual code lines, obviously)

<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="guntraining">
    <gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
    <version>1.0</version>
    <firstpublished>2014</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <object name="F49 Assualt Rifle">
        <inherit name="editor_object" />
        <look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
        <alt type="stringlist">
          <value>Assualt Rifle</value>
        </alt>
        <inventoryverbs type="stringlist">
          <value>Look at</value>
          <value>Use</value>
          <value>Drop</value>
        </inventoryverbs>
        <roundrifle type="int">60</roundrifle>
        <take />
        <shoot type="script"><![CDATA[
          if (not Got(F49 Assualt Rifle)) {
            msg ("You don't have this weapon.")
          }
          else if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle = 0) {
msg ("You need to reload your gun")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo) // this activates your reloading (your 'reload' scriptdictionary)
} else {
roundrifle_fired = GetRandomInt (0, F49 Assualt Rifle.roundrifle) // by doing the 'F49 Assualt Rifle.roundrifle' for your max value for the 'GetRandomInt', you'll never fire off more bullets than you have (so, no negative roundrifle value)
roundrifle_left = F49 Assualt Rifle.roundrifle - roundrifle_fired // this line could have been skipped by putting the subraction in your 'set' line below, but I moved it out here, as I think it makes it more clear for you (as you don't have to remember that your new roundrifle value is your remaining rounds).
// the two variable (roundrifle_fired and roundrifle_left) code lines above, are also for messaging how many rounds were fired and how many rounds remain
set (F49 Assualt Rifle, "roundrifle", roundrifle_left) // this could ahve had the subtraction (F49 Assualt Rifle.roundrifle - roundrifle_fired) for it's value, but I decided to separate it out for you to see~understand this script block more clearly.
msg ("You fired off " + roundrifle_fired + " rounds, and now have only " + roundrifle_left + " rounds left.")
if (roundrifle_left = 0) {
msg ("reload")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo) // this activates your reloading (your 'reload' scriptdictionary)
}
}
}
        ]]></shoot>
        <reload type="scriptdictionary">
          <item key="F49 ammo"><![CDATA[
            if (not Got(F49 Assualt Rifle)) {
              msg ("You don't have this weapon to reload...")
            }
            else if (Got(F49 Assualt Rifle)) {
              if (not Got(F49 ammo) or F49 ammo.rifleclip = 0) {
                msg ("You have no ammo to reload with...")
              }
              else if (Got(F49 ammo) and F49 ammo.rifleclip > 0) {
              set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
msg ("You are fully loaded again.")
//
// some comments:
//
// if you want your F49 ammo to be a 'storage object' (can be emptied and restocked), let me know.
// if you want to 'reload' non-automatically (via a 'reload' Verb button or typed-in input), let me know.
// I took out other stuff too that wasn't needed, let me know if you want it back.
// if you want to be able to drop your F49 ammo, let me know, as it's a permanent and automatic roundrifle 'storage object', right now as I got it set up (well I forgot how to turn 'drop' to false, as it's been awhile since I won't with the built-in stuff, lol)
// I also took out the shooting of specific targets for now, as we don't have that implementd yet anyways.
// if you want anything else different or changed, let me know.
//
              }
            }
          ]]></item>
        </reload>
      </object>
    </object>
    <object name="F49 ammo">
      <inherit name="editor_object" />
      <rifleclip type="int">60</rifleclip>
      <take />
      <inventoryverbs type="stringlist">
        <value>Look at</value>
      </inventoryverbs>
      <usedefaultprefix />
    </object>
  </object>
  <verb>
    <property>shoot</property>
    <pattern>shoot</pattern>
    <defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
    <defaulttext>You can't do that here.</defaulttext>
  </verb>
</asl>

Omega
lol. i know about comments. I think I saw them the first time on someone elses code. it shows up green. I get it.

Yea. thanks. I thought I was going crazy when Jay kept saying it's misspelling. I was like, the newly posted aslx shoudn't have any errors. I cleaned them.

I'll check your code in a sec here and see if it works. Thanks for checking it.

Did you understand what I meant by the combat code?

Omega
HK. Very nice job dude. I like the clean up work. It fixed the problem to make sure I can see how many shots were fired. (obviously in game, I dont want the player to really see that so i'll take it out but for now it's good to see it since this is a tester script).

Now, even though I wasn't really having any problems with the shoot verb, my most concern was the reload.

Think you can get around that? check code above.

My issue is when i type reload rifle with ammo the game does it and replenishes the rifles 'roundedrifle' attribute but it's like Quest doesn't want to re-follow the script of shoot anymore.

I haven't tested it yet with your clean up code. So we'll see.

PS glad you got some sleep. haha get some more of that dude. it's the best. the worst is waking up poorly <--happens to me lots.
But coffee can fix that up.

Omega
HegemonKhan wrote:ya, we were talking about your older code (it had spelling~typo issues in it, but not your newest code that you just provided: you already cleaned up all them)

----------

here you go (hopefully I fixed up your game code), see if you like this, and if it works or not:

(I was tired and it was late last night, but now I'm rested and staying focused this time, laughs. Being all rested up makes a big difference, lol. I could understand your code easily and have hopefully fixed it up, with it working perfectly... maybe, laughs)

(I included comments too, after you read them, you can remove them)

(comments only work within script blocks, and are initiated by the: //, so you can delete these and to the right of them to the end of the comment, but don't delete your actual code lines, obviously)

<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="guntraining">
    <gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
    <version>1.0</version>
    <firstpublished>2014</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
      <object name="F49 Assualt Rifle">
        <inherit name="editor_object" />
        <look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
        <alt type="stringlist">
          <value>Assualt Rifle</value>
        </alt>
        <inventoryverbs type="stringlist">
          <value>Look at</value>
          <value>Use</value>
          <value>Drop</value>
        </inventoryverbs>
        <roundrifle type="int">60</roundrifle>
        <take />
        <shoot type="script"><![CDATA[
          if (not Got(F49 Assualt Rifle)) {
            msg ("You don't have this weapon.")
          }
          else if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle = 0) {
msg ("You need to reload your gun")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo) // this activates your reloading (your 'reload' scriptdictionary)
} else {
roundrifle_fired = GetRandomInt (0, F49 Assualt Rifle.roundrifle) // by doing the 'F49 Assualt Rifle.roundrifle' for your max value for the 'GetRandomInt', you'll never fire off more bullets than you have (so, no negative roundrifle value)
roundrifle_left = F49 Assualt Rifle.roundrifle - roundrifle_fired // this line could have been skipped by putting the subraction in your 'set' line below, but I moved it out here, as I think it makes it more clear for you (as you don't have to remember that your new roundrifle value is your remaining rounds).
// the two variable (roundrifle_fired and roundrifle_left) code lines above, are also for messaging how many rounds were fired and how many rounds remain
set (F49 Assualt Rifle, "roundrifle", roundrifle_left) // this could ahve had the subtraction (F49 Assualt Rifle.roundrifle - roundrifle_fired) for it's value, but I decided to separate it out for you to see~understand this script block more clearly.
msg ("You fired off " + roundrifle_fired + " rounds, and now have only " + roundrifle_left + " rounds left.")
if (roundrifle_left = 0) {
msg ("reload")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo) // this activates your reloading (your 'reload' scriptdictionary)
}
}
}
        ]]></shoot>
        <reload type="scriptdictionary">
          <item key="F49 ammo"><![CDATA[
            if (not Got(F49 Assualt Rifle)) {
              msg ("You don't have this weapon to reload...")
            }
            else if (Got(F49 Assualt Rifle)) {
              if (not Got(F49 ammo) or F49 ammo.rifleclip = 0) {
                msg ("You have no ammo to reload with...")
              }
              else if (Got(F49 ammo) and F49 ammo.rifleclip > 0) {
              set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
msg ("You are fully loaded again.")
//
// some comments:
//
// if you want your F49 ammo to be a 'storage object' (can be emptied and restocked), let me know.
// if you want to 'reload' non-automatically (via a 'reload' Verb button or typed-in input), let me know.
// I took out other stuff too that wasn't needed, let me know if you want it back.
// if you want to be able to drop your F49 ammo, let me know, as it's a permanent and automatic roundrifle 'storage object', right now as I got it set up (well I forgot how to turn 'drop' to false, as it's been awhile since I won't with the built-in stuff, lol)
// I also took out the shooting of specific targets for now, as we don't have that implementd yet anyways.
// if you want anything else different or changed, let me know.
//
              }
            }
          ]]></item>
        </reload>
      </object>
    </object>
    <object name="F49 ammo">
      <inherit name="editor_object" />
      <rifleclip type="int">60</rifleclip>
      <take />
      <inventoryverbs type="stringlist">
        <value>Look at</value>
      </inventoryverbs>
      <usedefaultprefix />
    </object>
  </object>
  <verb>
    <property>shoot</property>
    <pattern>shoot</pattern>
    <defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
    <defaulttext>You can't do that here.</defaulttext>
  </verb>
</asl>





:wink: ok I fixed some of the issues that didn't work out the first time BUT! there's a problem with the code you gave.

As you fire it goes down in bullets. that's fine.
but realize it's an assault rifle (which i just realized is misspelled so I have to go back and make it AU 8). That means that when i fire my weapon im going to be firing somewhere between 10 and all 60 rounds not five or six. hahaha.

Im not sure if it's the new version change but when i get down to 0 rounds in the gun it gives and error instead of reloading and then just goes to one round fired one round left. haha. i'll go into this and see if i can fix it.

If you get it before me then that's awesome since i'll be reviewing what you had cleaned up too.

HegemonKhan
my error is probably somehow with this (I've been having trouble with 'and' and 'or' with '>, >, >=, <=' expressions with some other code of my own that I'm working on, argh, which I can't understand why):

else if (Got(F49 Assualt Rifle)) {
if (not Got(F49 ammo) or F49 ammo.rifleclip = 0) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo) and F49 ammo.rifleclip > 0) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
msg ("You are fully loaded again.")


so try this, then (made changes to the above code below):

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<object name="F49 Assualt Rifle">
<inherit name="editor_object" />
<look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
<alt type="stringlist">
<value>Assualt Rifle</value>
</alt>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
</inventoryverbs>
<roundrifle type="int">60</roundrifle>
<take />
<shoot type="script"><![CDATA[
if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle = 0) {
msg ("You need to reload your gun")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo)
} else {
roundrifle_fired = GetRandomInt (0, F49 Assualt Rifle.roundrifle)
roundrifle_left = F49 Assualt Rifle.roundrifle - roundrifle_fired
set (F49 Assualt Rifle, "roundrifle", roundrifle_left)
msg ("You fired off " + roundrifle_fired + " rounds, and now have only " + roundrifle_left + " rounds left.")
if (roundrifle_left = 0) {
msg ("reload")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo) // this activates your reloading (your 'reload' scriptdictionary)
}
}
}
]]></shoot>
<reload type="scriptdictionary">
<item key="F49 ammo"><![CDATA[
if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon to reload...")
}
else if (Got(F49 Assualt Rifle)) {
if (not Got(F49 ammo)) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo)) {
if (F49 ammo.rifleclip = 0) {
msg ("You have no ammo to reload with...")
} else {
reloading_rounds = F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip
set (F49 Assualt Rifle, "roundrifle", reloading_rounds)
if (F49 Assualt Rifle.roundrifle = 60) {
msg ("You are fully loaded again.")
} else {
msg ("You are partially reloaded again.")
}
}
}
}
]]></item>
</reload>
</object>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<rifleclip type="int">60</rifleclip>
<take />
<inventoryverbs type="stringlist">
<value>Look at</value>
</inventoryverbs>
<usedefaultprefix />
</object>
</object>
<verb>
<property>shoot</property>
<pattern>shoot</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here.</defaulttext>
</verb>
</asl>


if this still isn't working, it's probably giving an error message of ~ "int" not equal to "string~object", I need to code in, to make sure that the Attributes are properly correct and match up.

----------

my combat code, wasn't really a universal system, I was just trying to code in your ranged~proejectile combat with monsters and damage, in a simple way, just to get something up, which we can then customize~change it to whatever you then want.

but, let's wait off on doing this, and first get this stuff working, then we can slowly build upon this, and with whatever else you want done, then we can work on fully doing a combat system, knowing everything that you want done, and having worked out all the individual parts first.

Besides, I need to write the combat code using your own game code's nomenclature~labeling~style system, as it'll be too hard to try to convert my own nomenclature~labelization~style over to yours, laughs. I like underscores, you like spaces, and etc... easier to just write the code up from scratch using your style.

--------

lastly, for game makers, you really need to develop your code style~nomenclature~labelization patterns quickly and universally for yourself, as it really helps making things easier for you, and avoids messy-webs-of_confusion later on, as your game code grows.

mine is this:

use underscores for spaces so I can easily read my Attributes and Objects, write out what those Objects~Attributes are in full for their Name, so I know exactly what they do or are for, add on it's attribute type at the end of the name, so I can keep the names the same, for example:

age_string = "adult"
age_integer = 18

this allows me to keep 'age' for both of them, but also two have them as two Attributes, by simply adding '_string' and '_integer'

instead of doing, maybe something ike this:

Age = 18
age = "adult"

or

age = 18
maturity = "adult"

or

intAge = 18
strAge = "adult"

(I hate caps, as it just causes more code work for you: easier to just have everything in lower case, as you can type quicker and without mistakes, opps didn't hit~hold the shift key or oops held shift key too long, nor remembering whether it's a cap or lower case)

(and by adding the Attribute type on it's end, I can see what type of Attribute it is, so I know what I'm working with, and to spot errors of conflicting Attribute Types in expressions)

and lastly, in using long descriptive NAMES, I ensure that they are unique, laughs. And it also acts as comments lines, as I'm am directly commenting on the attribute via it's name attribute, lol.

so this is my system that I've developed, and at least for the coding that I'm doing, it works pretty well (though I need to do a lot of copy and pasting, and my code is A LOT longer due to writing out long NAMES, but it helps me out with writing code).

(I moved to this after I made my original combat code long ago, using all these abrevs, and not only did know one else knew what they stood for, I too had no idea what they stood for, when I went back to look at it, laughs)

you can probably recognize these (as they're quite common rpg labels now):

HP (hit~health:life points)
MP (magic~mana points)
SP (skill~spell points)
LV or LVL (level)
G (gold ~ currency)
STR (strength)
END (endurance)
CON (constitution)
SPI (spirituality)
INT (intelligence)
MEN (mentality)
DEX (desterity)
AGI (agility)
SPE or SPD (speed)
LUK (luck)
SWD (sword)
SPR ~ SPE (spear)
PC (playable character)
NPC (nonplayable character)
ALI (alignment: evil~chaos, neutral, good~order)
CHA (charisma)
PIE (piety)
AR (attack rating)
AC (armor class)
DMG or DAM (damage)
PDEF (physical defense)
MDEF (magical defense)
etc etc etc


but, 'str' in quest coding also means 'string', so this could cause conflict problems, also I got into the issue of deciding more game attributes' abrevs:

'spe' could mean 'speed' or 'spear'

PC = playable character or personal computer, lol

personality = PER
perception = PER
what should I decide on the abrevs for each, as they both can't be PER

so, it's just easier to write everything out, as everyone can understand it, including you, and you don't waste time creating your own abrev language:

PERC = perception
PERS = personality
or, should I do:
PCN = perception
PSN = personality
or
PRCTN = perception
PRSNLTY = personality

trying to set all up your abrevs, so they are all different.

now imagine coding abrevs... I don't know how real coders are able to do it, as I look at their labelization and I'm completely lost, laughs. I guess over years of coding you learn these labelization standards that they use, like any new language or field of study (like learning all the biology terms or law terms or chem terms: CHO's, and etc... I took chemistry a long time ago, can't remember any of them anymore, laughs)

--------

also, as your game code becomes more like a REAL game code (millions of code lines and attributes and objects, lol), you need some major organization structure for finding~getting, and then using all your code lines~attributes~objects, I think this is the advanced coding stuff like 'parsing' and etc advanced code stuff.

for a simple example, for your Object's NAMES, I'd do this:

<object name="player_1"></object>
<object name="player_2"></object>
<object name="player_3"></object>

<object name="person_1"></object>
<object name="person_2"></object>
<object name="person_3"></object>

<object name="dragon_1"></object>
<object name="dragon_2"></object>
<object name="dragon_3"></object>

<object name="orc_1"></object>
<object name="orc_2"></object>
<object name="orc_3"></object>

<object name="home_1"></object>
<object name="home_2"></object>
<object name="home_3"></object>

<object name="inn_1"></object>
<object name="inn_2"></object>
<object name="inn_3"></object>

<object name="weapon_shop_1"></object>
<object name="weapon_shop_2"></object>
<object name="weapon_shop_3"></object>

<object name="armor_shop_1"></object>
<object name="armor_shop_2"></object>
<object name="armor_shop_3"></object>

<object name="spell_shop_1"></object>
<object name="spell_shop_2"></object>
<object name="spell_shop_3"></object>

<object name="item_shop_1"></object>
<object name="item_shop_2"></object>
<object name="item_shop_3"></object>

<object name="sword_1"></object>
<object name="sword_2"></object>
<object name="sword_3"></object>

etc etc etc


using ALIAS for what we'd know~see as it's name, leaving the NAME for your own code organization and parsing~finding~getting behind the scenes, from the person playing the game.

---------

so get established your own system for code writing, as it really helps you out, though this causes everyone to have their 'pet peeves', they like their system, and cringe at anyone else's system, as it's often uses all the things that they don't like, laughs.

Omega
lol it's cool dude. i fixed the errors. Now only one problem that im too tired to look at. check what I have and let me know. i'll be on again tomorrow to check it.

  <game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<object name="F49 Assualt Rifle">
<inherit name="editor_object" />
<look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
<alt type="stringlist">
<value>Assualt Rifle</value>
</alt>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
</inventoryverbs>
<roundrifle type="int">60</roundrifle>
<take />
<shoot type="script">
if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle = 0) {
msg ("You need to reload your weapon")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo))
}
else {
roundrifle_fired = GetRandomInt (10, F49 Assualt Rifle.roundrifle)
roundrifle_left = F49 Assualt Rifle.roundrifle - roundrifle_fired
set (F49 Assualt Rifle, "roundrifle", roundrifle_left)
msg ("You fired off " + roundrifle_fired + " rounds, and now have only " + roundrifle_left + " rounds left.")
if (roundrifle_left = 0) {
msg ("reload")
invoke (ScriptDictionaryItem (F49 Assualt Rifle.reload, F49 ammo))
}
}
}
</shoot>
<reload type="scriptdictionary">
<item key="F49 ammo"><![CDATA[
if (not Got(F49 Assualt Rifle)) {
msg ("You don't have this weapon to reload...")
}
else if (Got(F49 Assualt Rifle)) {
if (not Got(F49 ammo) or F49 ammo.rifleclip = 0) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo) and F49 Assualt Rifle.roundrifle =60) {
msg ("You rifle is already fully loaded. ")
}
else if (Got(F49 ammo) and F49 ammo.rifleclip > 0) {
set (F49 Assualt Rifle, "roundrifle", F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip)
msg ("You reloaded your rifle. ")
}
}
]]></item>
</reload>
</object>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<rifleclip type="int">60</rifleclip>
<take />
<inventoryverbs type="stringlist">
<value>Look at</value>
</inventoryverbs>
<usedefaultprefix />
</object>
</object>
<verb>
<property>shoot</property>
<pattern>shoot #object#; fire #object#</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here.</defaulttext>
</verb>
<verb>
<pattern>reload #object#</pattern>
<property>reload</property>
<defaulttext>You can't reload</defaulttext>
</verb>


The reload works and the firing/shooting works but again when I reach down to 0 and i hit fire rifle again it gives error. I know i have to add a script there saying if 0 then print msg saying reload. I can't exactly remember though if this is right.

Check it up and let me know if you changed/added anything to it. i'll review it.

jaynabonne
The error message is this:

Error running script: Error evaluating expression 'GetRandomInt (10, F49 Assualt Rifle.roundrifle)': 'minValue' cannot be greater than maxValue.Parameter name: minValue



The line of code is this:

roundrifle_fired = GetRandomInt (10, F49 Assualt Rifle.roundrifle)

You are trying to pick a random number between 10 and the amount left in the rifle. The problem comes in when the amount left is less than 10. Then it's trying to pick a number between (say) 10 and 2. Quest requires that the first number you pass to GetRandomInt (10 in this case) is less than or equal to the second number you pass (which in your code can run all the way down to 0). When the second number gets less than 10, you get this error.

(I had considered this scheme before as another solution for clipping the value to 0, but this particular problem and the need to lower the 10 as well made it seem more complicated than a simple "make sure you don't fire more than you have".)

You need to decide how you want it to behave when there are less than 10 rounds left. One solution to the problem is to simply set it to 1 instead of 10 always (so sometimes the gun will shoot less than 10 normally). The other is to go from 0 to the number of shots left, add 10 after you get the random number, and then clip it to the number of shots anyway. That's more complicated, and I'm not sure what it gains you from simply picking a number from 10-60 and clipping to the number of rounds left as you had originally.

(Regarding the spelling error, I've learned my lesson - in the future, when I see different behavior in the code I've downloaded from what the person is saying, I'll assume from now on that they haven't posted the code they're actually using. A tip, Omega: given that HK does not have the ability to run Quest at the moment, it will do you both well if you actually provide any error message when you report to him what you're seeing, as he has no way to reproduce what you're seeing and the error message is key to solving the problem.)

HegemonKhan
that's a new mistake, that I've never encountered before, nor would ever realize to check, laughs.

yes, omega, make sure your 'min' value is your min value, and you 'max' value is your max value :D

GetRandomInt (min_Value, max_Value)

so, ERROR: GetRandomInt (10, 0), as 10 ain't lesser or equal to 0, and 0 ain't greater than or equal to 10, due to that your roundrifle can be 0 to 60, and that you gave the min as 10, thus you can have the situation where you got:

[10,(0--9)]

good spot Jay, as I'd never even think of checking on this, lol.

some thing that you could also do, is to add 10 to your max value as well, if having the min value of 10 is more important to you, than reducing the min to 0 or 1 (though if you were to do 1, than you'll have to set your roundrifle to being 1 to 60 as well). I understand why you would want it to be 10, wanting to do at least some damage~shots~rounds, and it can cause major coding issues with combat and in actual game play too, which is why, at lot of games always code in for doing 1 or 1% with everything, so both you and the monster, can always possibly win and lose a fight, do and take damage, succeed and fail at things like trying to steal for example, etc etc etc

roundrifle_fired = GetRandomInt (10, F49 Assualt Rifle.roundrifle + 10)

and if you want to code for going over the max, it's an easy code fix addition:

max_value_x = F49 Assualt Rifle.roundrifle + 10
if (max_value_x > 60) {
max_value_x = 60
}
roundrifle_fired = GetRandomInt (10, max_value_x)

so, do whatever you like or think is best for your code~game goals :D

jaynabonne
I didn't think to check - it was in the error message. :)

Omega
lol. i thought that was the bug. just was really freakn tired and wanted to pass out. Thanks guys.

(but i want a random number between min 10 and max 0. it's called dividing by 0. BOOM! world ended).

Omega
So as i was going through and getting that max min fixed for the rifle I realized something.

If we added more weapons wont we have to single code each and everyone with a different shoot verb?

Im looking at verb shoot under the rifle and seeing if player has only the rifle then it works.
What about other weapons?

I guess my question here is: Shouldn't we just make an object type (weapon)that will contain all the attributes that will fall under shoot? so if I press shoot #any weapon in inventory# it will work no matter what.

Or do we really need to do this for every weapon that shoot falls under and just change rifle name and round name to whatever the new weapon is called?

jaynabonne
I would definitely go with a type to put the common code in one place.

Omega
That's what I though too Jay. Thanks.

Also here's a mind boggling code problem Im having.

I have the rifle set to have all 60 bullets in round.

when I type 'fire rifle' it proof reads it: You fired off 15 shots and have 0 left. reload.

Now, i know this isn't true since the rifle starts with 60. what happened to the other bullets in that round?

I know it's got to be somewhere in this code:

if (not Got(F49 Assault Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(F49 Assault Rifle)) {
if (F49 Assault Rifle.roundrifle = 0) {
msg ("You need to reload your weapon")
}
else {
roundrifle_fired = GetRandomInt (10, 60)
roundrifle_left = F49 Assault Rifle.roundrifle - roundrifle_fired
F49 Assault Rifle.roundrifle = roundrifle_left
if (roundrifle_fired > roundrifle_left) {
roundrifle_fired = roundrifle_left
roundrifle_left = 0
msg ("You fired off " + roundrifle_fired + " rounds, and now have only " + roundrifle_left + " rounds left. reload rifle")
if (roundrifle_left = 0) {
F49 Assault Rifle.roundrifle = 0
}
else if (roundrifle_left <=0) {
roundrifle_left = 0
msg ("reload...")
}
}
}
}


Trying to get it to fire the shots it has first all the way down to 0 then say your weapon needs to reload.

What's the missing code?

Omega
NVM! I fixed it... I think. it works when it gets down to zero and typing from beginning 'fire rifle' actually works and starts from 60 and not jump far.


Ok here's another problem.

firing the weapon works and picking up the ammo holding the weapon doesn't do anything bad.

But when I type reload rifle with ammo
some strange error pops up. Im not sure what it is:

"Error running script: Error evaluating expression 'ListContains(ScopeInventory(), obj)': Unable to cast object of type 'System.Boolean' to type 'TextAdventures.Quest.Element'.
Error running script: Error evaluating expression 'ListContains(ScopeInventory(), obj)': Unable to cast object of type 'System.Boolean' to type 'TextAdventures.Quest.Element'."

Any thoughts?

Here's the shooting code and reload code both separated.

shooting code
if (not Got(F49 Assault Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(F49 Assault Rifle)) {
if (F49 Assault Rifle.roundrifle = 0) {
msg ("You need to reload your weapon")
}
else if (F49 Assault Rifle.roundrifle >0) {
roundrifle_fired = GetRandomInt (10, 60)
roundrifle_left = F49 Assault Rifle.roundrifle - roundrifle_fired
if (roundrifle_fired > roundrifle_left) {
roundrifle_fired = roundrifle_left
roundrifle_left = 0
msg ("reload....")
F49 Assault Rifle.roundrifle = 0
}
else {
msg ("Your fired " +roundrifle_fired+ " and now have " +roundrifle_left+ ".")
}
}
}


reload code

if (not Got(F49 Assault Rifle)) {
msg ("You don't have this weapon to reload...")
}
else if (Got(F49 Assault Rifle)) {
if (not Got(F49 ammo) or F49 ammo.rifleclip = 0) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo) and F49 Assault Rifle.roundrifle =60) {
msg ("You rifle is already fully loaded. ")
}
else if (Got(Got(F49 ammo) and Got(F49 Assault Rifle.roundrifle <60))) {
F49 Assault Rifle.roundrifle = F49 Assualt Rifle.roundrifle + F49 ammo.rifleclip
msg ("You reloaded your rifle. ")
}
}

Omega
Ok i took some hours to retry it from blank. I got it down and fixed the problem. Not sure where the error was but whatever it can read the reload and now can go from there.

HegemonKhan
yep, that's the coding we need to do 'next', once we get these initial parts done (getting your shoot and rounds working, then damage + monsters), to dea with different weapons and multiple monsters, and etc.

there's (at least) three ways to do specifically (only adressing) do universal scripts:

(for multiple attributes, you use Object Types)
(scripts are a TYPE of attribute too)
(Attirbute Types: string, integer~int, double, script, boolean~flag, lists, dictionaries, and etc)

1. put the script attribute into an Object Type, then add (as an 'inherit' attribute in code) the Object Type to all of your gun objects.

2. put the script block into a function, and then add (as 'call function' in the GUI~Editor, or just the NAME of the function in code) the function to all of your gun objects.

3. (non-Verb: non-button, non-hyperlink) use a COMMAND (put the script block into it, or into a function that then goes into it), so you can dynamically type-in during game play what action you want.

Omega
mhm. So i got a object type set up and it's called weaponhuman.

How do we compose the assault rifle to fire shots AND
if we added a pistol how can it also inherit that verb type??

thoughts?

code for the whole game is below.

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<shoot type="script">
if (Got(weapon.attribute)) {
msg ("The weapon fires in the direction you point. ")
}
else {
msg ("There's nothing to shoot at now.")
}
</shoot>
<object name="Assault Rifle">
<inherit name="editor_object" />
<inherit name="weaponhuman" />
<alias>F49 Assault Rifle</alias>
<look>The rifle is long and somewhat bulky. It fires 500 rounds per minute with reloading clips of 60 per round. </look>
<alt type="stringlist">
<value>Assault Rifle</value>
<value>weapon</value>
</alt>
<inventoryverbs type="stringlist">
<value>Look at</value>
<value>Use</value>
<value>Drop</value>
<value>Reload</value>
</inventoryverbs>
<roundrifle type="int">60</roundrifle>
<take />
<fire type="string"></fire>
<human />
<listalias>Assault Rifle</listalias>
</object>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<rifleclip type="int">60</rifleclip>
<take />
</object>
</object>
<verb>
<property>reload</property>
<pattern>reload #object#</pattern>
<defaultexpression>"You can't reload " + object.article + "."</defaultexpression>
<rounds type="scriptdictionary">
<item key="round rifle"><![CDATA[
if (Got(Assault Rifle)) {
if (Assault Rifle.roundrifle=60) {
if (Got(F49 ammo)) {
msg ("Your weapon is fully reloaded. ")
}
}
else {
if (Assault Rifle.roundrifle<=0) {
if (Got(F49 ammo)) {
set (Assault Rifle, "roundrifle", F49 ammo.rifleclip)
msg ("You reloaded your rifle.")
}
}
}
}
else {
msg ("You don't have the weapon to reload.")
}
]]></item>
</rounds>
</verb>
<verb>
<property>shoot</property>
<pattern>shoot #object#; fire #object#</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here. </defaulttext>
</verb>
<type name="weaponhuman">
<inherit name="editor_object" />
<weapontrash type="boolean">false</weapontrash>
<shoot type="script"><![CDATA[
if (Got(Assault Rifle)) {
msg ("You don't have this weapon.")
}
else if (Got(Assault Rifle)) {
rifleshot_fired = GetRandomInt(10,60)
rifleshot_left = Assault Rifle.roundrifle - rifleshot_fired
Assault Rifle.roundrifle = rifleshot_left
if (Assault Rifle.roundrifle <=0) {
Assault Rifle.roundrifle = 0
msg ("reload your weapon.")
}
else if (Assault Rifle.roundrifle >0) {
msg ("gun shot. " +rifleshot_fired+ " fired. " +rifleshot_left+ " shots left.")
}
}
]]></shoot>
<reload type="script"><![CDATA[
if (not Got(Assault Rifle)) {
msg ("You don't have this weapon to reload...")
}
else if (Got(Assault Rifle)) {
if (not Got(F49 ammo)) {
msg ("You have no ammo to reload with...")
}
else if (Got(F49 ammo)) {
if (Assault Rifle.roundrifle =60) {
msg ("Your weapon is fully reloaded")
}
else if (Assault Rifle.roundrifle <60) {
set (Assault Rifle, "roundrifle", Assault Rifle.roundrifle + F49 ammo.rifleclip)
if (Assault Rifle.roundrifle >60) {
Assault Rifle.roundrifle = 60
msg ("your weapon is reloaded")
}
}
}
}
]]></reload>
<changedweapontrash type="script">
if (weapontrash= true) {
MakeObjectInvisible (Assault Rifle)
}
</changedweapontrash>
</type>
</asl>

HegemonKhan
let me just show you how object types work and look, using my own examples, just so you can see and get a sense of them:

An Object Type is merely a 'basket' (a group) that holds eggs (attributes), so if you give (add~put inside) some Object, a basket, then that object gets all of the eggs inside of that basket.

however, you can't alter those Attributes given to that Object via an Object Type, unless you over-write the attribute (add~set the attribute again).

<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_object_type" />
</object>

<object name="monster">
<inherit name="editor_object" />
<inherit name="editor_player" />
<inherit name="character_object_type" />
</object>

<type name="character_object_type">
<attr name="strength_integer" type="int">0</attr>
<attr name="endurance_integer" type="int">0</attr>
<attr name="dexterity_integer" type="int">0</attr>
<attr name="agility_integer" type="int">0</attr>
<attr name="speed_integer" type="int">0</attr>
<attr name="luck_integer" type="int">0</attr>
<attr name="piety_integer" type="int">0</attr>
<attr name="intelligence_integer" type="int">0</attr>
<attr name="spirituality_integer" type="int">0</attr>
<attr name="mentality_integer" type="int">0</attr>
<attr name="perception_integer" type="int">0</attr>
<attr name="deception_integer" type="int">0</attr>
<attr name="personality_integer" type="int">0</attr>
<attr name="alignment_integer" type="int">0</attr>
<attr name="charisma_integer" type="int">0</attr>
<attr name="leadership_integer" type="int">0</attr>
<attr name="current_life_integer" type="int">0</attr>
<attr name="maximum_life_integer" type="int">0</attr>
<attr name="current_mana_integer" type="int">0</attr>
<attr name="maximum_mana_integer" type="int">0</attr>
<attr name="level_integer" type="int">0</attr>
<attr name="experience_integer" type="int">0</attr>
<attr name="cash_integer" type="int">0</attr>
<attr name="life_string" type="string">0 / 0</attr>
<attr name="mana_string" type="string">0 / 0</attr>
<attr name="fight" type="script">
// script block code lines
</attr>
</type>

<object name="sword_1">
<inherit name="editor_object" />
<inherit name="equipment_object_type" />
<inherit name="weapon_object_type" />
<alias>claymore</alias>
</object>

<object name="armor_1">
<inherit name="editor_object" />
<inherit name="equipment_object_type" />
<inherit name="armor_object_type" />
<alias>obsidian full plate armor</alias>
</object>

<type name="equipment_object_type">
<attr name="price_integer" type="int">0</attr>
<attr name="equipment_type_string" type="string">unknown</attr>
<attr name="weight_integer" type="int">0</attr>
<attr name="equipment_slot_stringlist" type="simplestringlist"></attr>
<attr name="equipment_layer_integer" type="int">0</attr>
<attr name="status_effect_stringlist" type="simplestringlist"></attr>
<attr name="magic_effect_stringlist" type="simplestringlist"></attr>
<attr name="equip" type="script">
// script block code lines
</attr>
</type>

<type name="weapon_object_type">
<attr name="weapon_type_stringlist" type="simplestringlist"></attr>
<attr name="attack_rating_integer" type="int">0</attr>
<attr name="physical_damage_integer" type="int">0</attr>
<attr name="magical_damage_integer" type="int">0</attr>
<attr name="fire_damage_integer" type="int">0</attr>
<attr name="water_damage_integer" type="int">0</attr>
<attr name="air_damage_integer" type="int">0</attr>
<attr name="earth_damage_integer" type="int">0</attr>
<attr name="light_damage_integer" type="int">0</attr>
<attr name="dark_damage_integer" type="int">0</attr>
<attr name="holy_damage_integer" type="int">0</attr>
<attr name="unholy_damage_integer" type="int">0</attr>
</type>

<type name="armor_object_type">
<attr name="armor_type_stringlist" type="simplestringlist"></attr>
<attr name="armor_class_integer" type="int">0</attr>
<attr name="physical_resistance_integer" type="int">0</attr>
<attr name="magical_resistance_integer" type="int">0</attr>
<attr name="fire_resistance_integer" type="int">0</attr>
<attr name="water_resistance_integer" type="int">0</attr>
<attr name="air_resistance_integer" type="int">0</attr>
<attr name="earth_resistance_integer" type="int">0</attr>
<attr name="light_resistance_integer" type="int">0</attr>
<attr name="dark_resistance_integer" type="int">0</attr>
<attr name="holy_resistance_integer" type="int">0</attr>
<attr name="unholy_resistance_integer" type="int">0</attr>
</type>

<type name="clothing_object_type">
</type>


also, Object Types can hold other Object Types too (and you can have this as many layers~levels deep as you want)

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

for scripts, we got:

'this'

'this' gets the Object that is holding the script attribute, so it's universal.

here let me explain:

<object name="orc">
<inherit name="character_object_type" />
</object>

<object name="ogre">
<inherit name="character_object_type" />
</object>

<type name="character_object_type">
<attr name="fight" type="script">
if (orc.dead) {
}
</attr>
</type>

obviously, we got a problem, as you don't want 'if (orc.dead) { script }' for the 'ogre' Object, lol

so, alex created this special built-in code of 'this', which see how it works below:

<object name="orc">
<inherit name="character_object_type" />
</object>

<object name="ogre">
<inherit name="character_object_type" />
</object>

<type name="character_object_type">
<attr name="fight" type="script">
if (this.dead) {
}
</attr>
</type>

for the 'orc' Object, 'this' will internally (unseen by you) become 'orc', and for the 'ogre' Object, 'this' will internally (unseen by you) become 'ogre'.

Omega
ah very nice. So the 'this' code is structured to take the original dead code but for that object?

I understand how the object type works as I created the weaponhuman for the assault rifle.
So if I added a pistol

I would change the attribute in the object type or the actual object(pistol) attribute to this.weaponhuman?

The this is new to me. haven't seen it before but sorta understand what you mean. I'll play around with it for some time.

Omega
uh oh. the code I posted up has some kind of weird error. i have the assault rifle in the inventory but when i type fire rifle it now says you don't have this weapon with you....
wtf?

it's checked off as visible and i can see it in inventory.

HegemonKhan
normally, you've been doing this, doing each Oject's Attributes individually:

(lots of code redundancy is bad, as it makes your code much longer than it should~can be, lol)

<object name="orc">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'orc' Object's Verb
if (orc.dead) {
} else if (not orc.dead) {
}
</attr>
</object>

<object name="ogre">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'ogre' Object's Verb
if (ogre.dead) {
} else if (not ogre.dead) {
}
</attr>
</object>

<object name="troll">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'troll' Object's Verb
if (troll.dead) {
} else if (not troll.dead) {
}
</attr>
</object>

<object name="goblin">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'goblin' Object's Verb
if (goblin.dead) {
} else if (not goblin.dead) {
}
</attr>
</object>

<object name="gremlin">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'gremlin' Object's Verb
if (gremlin.dead) {
} else if (not ogre.gremlin) {
}
</attr>
</object>

<object name="dragon">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'dragon Object's Verb
if (dragon.dead) {
} else if (not dragon.dead) {
}
</attr>
</object>

<object name="townsperson">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'townsperson' Object's Verb
if (townsperson.dead) {
} else if (not townsperson.dead) {
}
</attr>
</object>

<object name="rogue">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'rogue' Object's Verb
if (rogue.dead) {
} else if (not rogue.dead) {
}
</attr>
</object>

<object name="mage_guild_acolyte">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'mage guild acolyte' Object's Verb
if (mage_guild_acolyte.dead) {
} else if (not acolyte.dead) {
}
</attr>
</object>

<verb>
<property>fight</property>
<pattern>fight</fight>
<defaultexpression>blah</defaultexpression>
</verb>


or, using 'this' instead (which you haven't been using though, as you just learned of it now, lol):

(lots of code redundancy is bad, as it makes your code much longer than it should~can be, lol)

<object name="orc">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'orc' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="ogre">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'ogre' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="troll">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'troll' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="goblin">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'goblin' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="gremlin">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'gremlin' Object's Verb
if (this.dead) {
} else if (not this.gremlin) {
}
</attr>
</object>

<object name="dragon">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'dragon Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="townsperson">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'townsperson' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="rogue">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'rogue' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<object name="mage_guild_acolyte">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script"> // this is your 'mage guild acolyte' Object's Verb
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</object>

<verb>
<property>fight</property>
<pattern>fight</fight>
<defaultexpression>blah</defaultexpression>
</verb>


--------

but, this isn't practical when you got more than a few Objects, lol, thus as one 'ways and means', you can use Object Types:

(as you can see, this is much shorter in lines and characters, much less code written in, which is good!)

<object name="orc">
<inherit name="non_playable_character_object_type" />
</object>

<object name="ogre">
<inherit name="non_playable_character_object_type" />
</object>

<object name="troll">
<inherit name="non_playable_character_object_type" />
</object>

<object name="goblin">
<inherit name="non_playable_character_object_type" />
</object>

<object name="gremlin">
<inherit name="non_playable_character_object_type" />
</object>

<object name="dragon">
<inherit name="non_playable_character_object_type" />
</object>

<object name="townsperson">
<inherit name="non_playable_character_object_type" />
</object>

<object name="rogue">
<inherit name="non_playable_character_object_type" />
</object>

<object name="shop_owner">
<inherit name="non_playable_character_object_type" />
</object>

<object name="mage_guild_acolyte">
<inherit name="non_playable_character_object_type" />
</object>

<verb>
<property>fight</property>
<pattern>fight</fight>
<defaultexpression>blah</defaultexpression>
</verb>

<type name="non_playable_character_object_type">
<attr name="dead" type="boolean">false</attr>
<attr name="fight" type="script">
if (this.dead) {
} else if (not this.dead) {
}
</attr>
</type>


---------

if you want to get more technical:

'this' is a built-in special 'GetObject' function, that gets (and returns) the parent Object of the script attribute that is using the 'this.Attribute_name' in it.

if you still are confused, let me know!

HegemonKhan
for your own code:

first, remove your 'reload' script block from your: <verb></verb>

******************

second, it remains 'visable', because you have no script that changes (sets, re-sets) your 'Object.weapontrash=false' to 'Object.weapontrash=true", thus never activating your 'changed' script (if Object.weapontrash = true, then make invisible), which will make it 'invisible.

here's a simple test game code, to see how booleans work:

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="testing game stuff">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<attr name="test" type="boolean">false</attr>
<attr name="count" type="int">0</attr>
<start type="script">
msg ("bye")
test_function
</start>
</game>
<function name="test_function"><![CDATA[
if (game.count <= 10) {
if (game.test = false) {
game.test = true
msg ("hi")
} else if (game.test = true) {
game.test = false
msg ("bye")
}
game.count = game.count + 1
test_function
}
]]></function>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
</asl>


*******************

third, I need to see the error message (please post, write out the error message), to better find what's causing why it's not seeing the rifle in your inventory (if it's not the un-needed 'reload' script block you got in the <verb></verb>)

-------

P.S.

just for getting a little better feel~understanding with coding:

in the GUI~Editor, at the lower left, is:

Filter -> (this is kind of hard to click on due it's tiny popup box) Show Library Elements (check~click on this, so it is checked in)

this reveals the Core (internal) coding, as light greyed text above (in the left side's 'tree of stuff'), which you can click on (so it is highlighted), allowing you to see alex' internal coding that makes quest work for us, making it easy for use to code or make our own games, and allows for them to work~run, hehe.

it'll be way too advanced for you (and it is for me too still as well, laughs), but it should give you a little better sense of things.

Omega
lol. k. i'll look over the examples you gave.

I think i got rid of that code of weapon invisible in objects type and it still did it. i'll look at it again. It didn't give an error code it only made it invisible and saying i dont have that weapon on me. hahahaha.

Also i've seen library elements from the filter. It is daunting at first but yea it's useful and important since you can copy the normal code of something and change it without affecting your quest. it's neat. But yea i have yet to really grasp that elements filter since most of it is stuff like the grid map and functions and stuff I don't touch hahaha.

Don't worry dude we'll get to expert level one day. haha.

Omega
ok. i've been trying some time using 'this'

nothing seems to really be useful.

So I have the code for shoot in object type set using 'this' which is just print msgs at the moment.

But now I want it to when you type shoot the game needs to check and see what type of weapon it is and then follow a script of that weapon.

Assault Rifle has attribute
weapon_type mediumrifle

Object Type inherited is:

if (not Got(this)) {
msg ("pick it up first")
this.equipped = False
}
else if (Got(this)) {
this.equipped = True
if (this.equipped = True) {
msg ("you shoot")
do (this, "weapon_type")
}
}


Where if this.equipped = true
msg: you shoot
????? <----want to have it check a list of weapons to see what type of weapon you have so it can fire the correct amount of bullets/rounds.

So if the player is carrying a pistol and types shoot pistol the max they shoot is 10
the rifle max is 60.
That's what im trying to get to but im stuck on what to type after the msg you shoot.

Omega
Any way I can invoke a scriptdictionary to an object type attribute?

HegemonKhan
how do you want to select your weapon, from a set list of choices, or from what you type-in during game play?

as there's a few ways to go about this, but it depends on how you want it to be done and what you want to be done.

the easiest thing to do is this:

<object name="player">
<attr name="equipped_weapon_object" type="object">unarmed</attr> // you'll need an 'equip' script to set that weapon to this attribute
</object>

<object name="monster">
<inherit name="non_playable_character_object_type" />
</object>

<type name="non_playable_character_object_type">
<shoot type="script><![CDATA[
weapon_x = GetObject (player.equipped_weapon_object)
if (not Got(weapon_x)) {
msg ("You don't have this weapon.")
}
else if (Got(weapon_x)) {
rounds_fired = GetRandomInt(10,60)
rounds_left = weapon_x.rounds - rounds_fired
weapon_x.rounds = rounds_left
if (weapon_x.rounds <=0) {
weapon_x.rounds = 0
msg ("reload your weapon.")
}
else if (weapon_x.rounds >0) {
msg ("gun shot. " +rounds_fired+ " fired. " +rounds_left+ " shots left.")
}
}
]]></shoot>
</attr>
</type>


--------

omega wrote:Any way I can invoke a scriptdictionary to an object type attribute?


I'm a bit confused by the wording of this, so I'm not sure what you're trying to ask me.

you can do this:

<type name="blah">
<attr name="blah" type="script">
invoke (ScriptDictionaryItem (Object.ScriptDictionary, Value)
</attr>
</type>

Omega
I like what you put up with player and monster. Yet doesn't that mean we have to make this code multiple times? weapon_x

or would I just make a list of weapon_x's; so something like this?:

weapon_x's

rifles
handguns
rockets
snipers

or how would you go by it?

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

What im talking about is:

if you look at my code i posted up I have an object type called weapon_human
in there i put shot as an attribute

in that attribute I have it all set where if you type shot this stuff happens
Now scroll down where it says msg 'you shoot'

I want something after that that can read the weapon_type attribute on the actual weapon.

So that way it can find out what type of shooting this weapon can fire at. pistol= 10 rounds? rifle=60 rounds?

But i think what you had with weapon_x i think i can go in that direction instead. seems easier.
I just don't know how to set it up where the coding looks at the weapon_type and pick out the script that shoots the right rounds.

HegemonKhan
no, the code (hopefully) works as it is, laughs

'weapon_x' is just a variable to hold your gotten equipped weapon, for the script to then use it. So, it should work... HK crosses his fingers.

-------

I did change up the names of the Attributes, so you decide what you want them to be, just make sure your entire game code uses the same names for your attributes.

all of your weapons use the same ammo quantity attribute: 'roundrifle', but I changed it's name to just: 'rounds', as 'roundrifle' wouldn't sound to right as a the ammo quantity attribute for a shotgun or machine gun or rocket launcher, etc...

-----

the 'shoot' action should work, but for the 'reloading', I'll need to craft code for that for you.

-----

if you want a message script to tell the person playing the game, about the weapon and its firing capability, that I can do too.

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

just for an example demonstration of how it works:

rifle: 50 damage, but only 2 rounds
machine gun: 1 damage, but 50 rounds

(Object Types is meaningless for our 'round' Attribute, as it's Value is different for each gun, but you can use Object Type to put the 'shoot' script on all of the guns)

<object name="player">
<attr name="equipped_weapon" type="object">unarmed</attr>
</object>

<object name="unarmed">
<inherit name="weapon_object_type" />
<attr name="damage" type="int">1</attr>
<attr name="rounds" type="int">0</attr>
</object>

<object name="rifle">
<inherit name="weapon_object_type" />
<attr name="rounds" type="int">2</attr>
<attr name="damage" type="int">50</attr>
</object>

<object name="machine gun">
<inherit name="weapon_object_type" />
<attr name="rounds" type="int">50</attr>
<attr name="damage" type="int">1</attr>
</object>

<type name="weapon_object_type">
<attr name="shoot" type="script">
weapon_x = GetObject (player.equipped_weapon)
//blah code lines
</attr>
</type>

// if weapon_x (=player.equipped_weapon_object=) = rifle: weapon_x.rounds = 2
// if weapon_x (=player.equipped_weapon_object=) = machine gun: weapon_x.rounds = 50
// if weapon_x (=player.equipped_weapon_object=) = unarmed: weapon_x.rounds = 0

Omega
lol right, right.
but see i got that and i know that works. The thing im trying to get to is once the player has the weapon. can a script set the weapon to shot the correct rounds?

so say you have 2 objects
rifle
pistol

they both have the inherited object type weapon_human
in that there's

shoot
which does stuff if player has it or not.

Now...
NOW how do we set it where it has to look at the attribute of the weapon so it fires the right amount of rounds

I don't want

rifle shoots 60 rounds
pistol shoots 60 rounds

i want

rifle shoots 60 rounds
pistol shoots 10 rounds

So if i type shoot rifle it looks to the weapon_type attri it has and goes to shooting the right amount of rounds
and the pistol shooting its own rounds

cuz we set that new variable (rifleshots_fired) to get random number btwn 10 n 60
pistol needs to be random number between 1 n 10

maybe set it where if 'this' object = weapon_type. handgun do the shots_fired btwn 1 n 10
this = weapon_type.mediumrifle do shots_fired btwn 10 n 60.

im going to attempt that. lol.

HegemonKhan
see my previous post, I edited in more to show you, if you don't understand how it works, let me know, as I didn't really fully explain it above, hoping you can see it full on your own, but if not, ask, and I'll try to explain it fully for you.

all you have to do is to have all the guns have the same Attribute_name, as it'll get that weapon's attribute's value (which is different for each gun, but the attribute name is the same, so that's how it works)

-------

ah, yes, I'll have to craft code for you, for the GetRandomInt, you are right about this, I forgot about it.

Omega
lol. actually....I got it. :lol:

hahaha! geez this code stuff kills your back.

I had to take the random number to look at the weapons attribute minam (minimum ammo to fire) and maxam (max ammo to fire)
the rest fell into place. now it's set and ready to go for other weapons.

Thanks for that tid bit before your edited post(on pg4) it was useful to look at it that way and step back a minute to get around that damn random number.

So now that the object type for human weapons is set up. i'll post up the entire code so you can look at it. let me know if there's any changes you want to it or make it clearer.

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<listalias>Assault Rifle</listalias>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<rifleclip type="int">60</rifleclip>
<take />
</object>
<object name="pistol">
<inherit name="editor_object" />
<inherit name="weapon_human" />
<rounds type="int">10</rounds>
<attr name="weapon_type">handgun</attr>
<take />
<minam type="int">1</minam>
<maxam type="int">10</maxam>
</object>
<object name="Assault Rifle">
<inherit name="editor_object" />
<inherit name="weapon_human" />
<take />
<minam type="int">10</minam>
<alt type="stringlist">
<value>rifle</value>
</alt>
<maxam type="int">60</maxam>
<rounds type="int">60</rounds>
<attr name="weapon_type">mediumrifle</attr>
</object>
</object>
<verb>
<property>reload</property>
<pattern>reload #object#</pattern>
<defaultexpression>"You can't reload " + object.article + "."</defaultexpression>
<rounds type="scriptdictionary">
<item key="round rifle"><![CDATA[
if (Got(Assault Rifle)) {
if (Assault Rifle.roundrifle=60) {
if (Got(F49 ammo)) {
msg ("Your weapon is fully reloaded. ")
}
}
else {
if (Assault Rifle.roundrifle<=0) {
if (Got(F49 ammo)) {
set (Assault Rifle, "roundrifle", F49 ammo.rifleclip)
msg ("You reloaded your rifle.")
}
}
}
}
else {
msg ("You don't have the weapon to reload.")
}
]]></item>
</rounds>
</verb>
<verb>
<property>shoot</property>
<pattern>shoot #object#; fire #object#</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here. </defaulttext>
</verb>
<type name="weapon_human">
<equipped type="boolean">false</equipped>
<fire>shoot</fire>
<shoot type="script"><![CDATA[
if (not Got(this)) {
msg ("You don't have this weapon.")
}
else if (Got(this)) {
this.equipped = True
shot_fired = GetRandomInt(this.minam,this.maxam)
shot_left = this.rounds - shot_fired
if (shot_left <=0) {
shot_left = 0
msg ("reload....")
}
else if (shot_fired > shot_left) {
shot_fired = shot_left
shot_left = 0
msg ("you shot all your bullets. reload")
}
else {
msg ("you shot " +shot_fired+ " and have " +shot_left+ ".")
}
}
]]></shoot>
</type>
</asl>

HegemonKhan
I'm tired right now, I'll look at your game code tomarrow, as I need to be able to think, which I can't do right now, lol.

Omega
lol it's cool dude.

I guess i'll put this up there now since im working on it.

Now that our weapons can shoot by their own range the reload is where it's tricky

Would i have to put reload under the actual weapon (the pistol for ex) or also put it with the object type so all weapons get inherited?

I think putting the reload with the weapon would make sense so it doesn't get confused with more weapons being added. i'll try that but if you got a better idea let me know.

HegemonKhan
well, as we have it right now, the reload is a script dictionary, but what we're missing is code (which would be added to the 'shoot' script attribute) to get~select the proper ammo object name, for what your equipped gun is, which I'll probably have to do, as it's a bit advanced, though maybe you'll surprise me, laughs, but I don't think you're ready for it yet.

------

with how much you seem to have learned so quickly (wow!), try looking at my own huge combat coding again, as in there I have to get~select the proper stuff too, and you may be able to better understand it now, that you may be able to see how I do the get~select of the proper stuff for using in a script (or for a script dictionary). It has a lot of stuff that you'll need to use for your own coding designs and goals.

Omega
lol. if only i can put on my resume 'i learn fast like superman flying' haha.

ok. i'll look at it again. i did earlier today to see how you got it for weapons stats to get to player so i can sorta do the same with the rifle/pistol to player. didn't really do the trick.

but ok. I guess i'll kill some more hours tonight/tomorrow morning again to tackle the reload.

let me know what you got at the end.

HegemonKhan
this may be of help too:

viewtopic.php?f=10&t=3972&start=30&hilit=hk+help+me+thread

also, take a look at the libraries:

Chase's Wearables (equipment) Library
Pixie's Simple Combat Library

and etc...

Omega
lol. you seem tired.

I got it done but im not sure if that's the best way to go by it.

Now the problem im facing is making sure the two (weapon and ammo) connect to each other.
What i mean here is

if I type reload rifle with rifle ammo it works
but if i type reload rifle with pistol ammo it shouldn't work.

right now the game can't see that those two aren't suppose to connect when i type reload.

so typing reload with pistol ammo gives its ammo to the rifle. in the real world we know that's not true.
it seems like a boolean but i tried several ways and nothing. any thoughts?

HegemonKhan
you probably are familiar with the built-in stuff how you can do, for example: 'use ____ on _____', if you can figure out how to do this on your own, that is part of the way:

shoot rifle with F49 ammo
shoot shotgun with shotgun shells
etc etc etc

though, you'll still need some checks for if it's the right ammo or not, and message it for the person playing the game if it's wrong ammo, or to execute the shoot script.

-----

the other half of the method is working with 'foreach' (such as getting all the objects in your inventory, in the room, or in the entire game, or etc etc etc), and using it to do 'string match comparison", for example:

look at Chase's Wearables Library, or Pixie's Spell library, or my explore and travel code, or my combat code (I think I use some of this coding in it ~ but maybe not).

I'll help you much more with this, but I'm actually tired right now (argh, being old sucks!), so maybe whenever I'm not tired and not busy (if not maybe later today, then maybe tomarrow, or if not, definately on the weekend, I'll help you with it).

here's a concept anology of what you're doing:

school class roll call (attendence), lol

you have a bunch of objects (such as within a room, player's inventory ~ within the player, the entire game, etc)

but, let's use a room as for our attendence~roll call example:

school class room's students:
1. bill
2. bob
3. john
4. joe

hey john! foreach:

if:
"bill" = "john" -> NOPE!
"bob" = "john" -> NOPE!
"john" = "john" -> DING DING DING !!!
then:
object_x (john).answer_the_question_!

and or... actually...

you could just use a String Dictionary too:

<attr name="weapon_to_ammo_stringdictionary" type="simplestringdictionary">Assualt Rifle = F49 ammo; machine gun = bullets; shotgun = shells; etc</attr>

invoke (ScriptDictionaryItem (Object.weapon_scriptdictionary, StringDictionaryItem (Object.weapon_stringdictionary, player.equipped_weapon_object)))

conceptually what is going on (read~follow it from right to left):

reload ______ ammo script (script dictionary) <----- _____ ammo <--stringdictionary's conversion-- ____ weapon <----- ________ weapon (player.equipped_weapon_object)

reload F49 ammo script of the script dictionary <- (script <- F49 ammo) <- (F49 ammo <- Assault Rifle) <- Assualt Rifle

reload shell ammo script of the script dictionary <- (script <- shell ammo) <- (shells <- shotgun) <- shotgun

reload bullet ammo script of the script dictionary <- (script <- bullet ammo) <- (bullets <- machine gun) <- machine gun

Omega
lol. it's ok dude. don't stress yourself out over my need of help. Rome wasn't built in a day (unless aliens did it and wasn't logged).

I'll attempt it again with what you gave me here. I looked at your combat code but don't think it had anything there. maybe the wearable list would work but haven't checked.

So in the mean time while I waited I just cleaned up my coding a lot and so it's easy to see. So besides getting ahead of myself i will take time to clean my code so when you look at it, it won't get all crazy.

So take some time off for yourself dude hahaha.

Omega
i edited this post because i got it down.

I have a script dict that will have the reload scripts per weapon.
also you don't have to type ' reload rifle with ___'
just type reload rifle or reload pistol. Hazza!

So....now what to do? haha. I haven't written much on my story to input all the weapons the game will use so i'll take some time to look up some of that.

I'll put the code up for the weapon set up so you can compare it with your combat code.

<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="guntraining">
<gameid>eaba3834-ff71-459e-8be5-5f72b041cfe9</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<listalias>Assault Rifle</listalias>
<object name="Assault Rifle">
<inherit name="editor_object" />
<inherit name="weapon_human" />
<take />
<minam type="int">10</minam>
<alt type="stringlist">
<value>rifle</value>
</alt>
<maxam type="int">60</maxam>
<rounds type="int">60</rounds>
<look>The F49 Assault Rifle is an effective weapon best used in group combat. Can fire 500 rpm. Max shots per round is 60. Range type: Medium to Close</look>
<F49reload type="boolean">false</F49reload>
<reload type="script">
if (not Got(F49 ammo)) {
msg ("you don't have the ammo")
}
else if (Got(F49 ammo)) {
invoke (ScriptDictionaryItem(this.weapon_to_ammo, "Assault Rifle"))
}
</reload>
</object>
<object name="F49 ammo">
<inherit name="editor_object" />
<inherit name="ammo_taken" />
<clip type="int">300</clip>
<take />
<alt type="stringlist">
<value>rifle ammo</value>
</alt>
<look>Ammo used with Assualt Rifle. Carrying capacity: 300</look>
<maxclip type="int">300</maxclip>
</object>
<object name="Pistol">
<inherit name="editor_object" />
<inherit name="weapon_human" />
<rounds type="int">10</rounds>
<attr name="weapon_type">handgunG9</attr>
<take />
<minam type="int">1</minam>
<maxam type="int">10</maxam>
<reload type="script">
if (not Got(G9 ammo)) {
msg ("you don't have the ammo")
}
else if (Got(G9 ammo)) {
invoke (ScriptDictionaryItem(this.weapon_to_ammo, "Pistol"))
}
</reload>
<look><![CDATA[This enhanced pistol is heavy and requires two hands to hold, but can fire shots as powerful as a .50 Dessert Eagle. <br/>Can fire off 10 shots per round with Range Combat: Close ]]></look>
</object>
<object name="G9 ammo">
<inherit name="editor_object" />
<inherit name="ammo_taken" />
<clip type="int">10</clip>
<alt type="stringlist">
<value>pistol ammo</value>
</alt>
<take />
<maxclip type="int">50</maxclip>
<look>Ammo used with G9 Pistol. Carrying capacity: 50</look>
</object>
<object name="STK Rifle">
<inherit name="editor_object" />
<inherit name="weapon_human" />
<minam type="int">10</minam>
<maxam type="int">30</maxam>
<rounds type="int">30</rounds>
<take />
<reload type="script">
if (not Got(Cal30 ammo)) {
msg ("you don't have the ammo")
}
else if (Got(Cal30 ammo)) {
invoke (ScriptDictionaryItem(this.weapon_to_ammo, "STK Rifle"))
}
</reload>
<alt type="stringlist">
<value>stk</value>
</alt>
</object>
<object name="Cal30 ammo">
<inherit name="editor_object" />
<inherit name="ammo_taken" />
<clip type="int">30</clip>
<maxclip type="int">180</maxclip>
<take />
<alt type="stringlist">
<value>stk ammo</value>
</alt>
</object>
</object>
</object>
<verb>
<property>reload</property>
<pattern>reload #object#</pattern>
<defaultexpression>"You can't reload " + object.article + "."</defaultexpression>
</verb>
<verb>
<property>shoot</property>
<pattern>shoot #object#; fire #object#</pattern>
<defaultexpression>"You can't shoot " + object.article + "."</defaultexpression>
<defaulttext>You can't do that here. </defaulttext>
</verb>
<object name="pile room">
<inherit name="editor_room" />
</object>
<type name="weapon_human">
<equipped type="boolean">false</equipped>
<fire>shoot</fire>
<shoot type="script"><![CDATA[
if (not Got(this)) {
msg ("You don't have this weapon.")
}
else if (Got(this)) {
if (this.rounds <=0) {
this.rounds = 0
msg ("reload....")
}
else if (this.rounds>0) {
this.equipped = True
shot_fired = GetRandomInt(this.minam,this.maxam)
shot_left = this.rounds - shot_fired
this.rounds = shot_left
if (shot_left <=0) {
shot_fired = shot_left
shot_left = 0
msg ("You fired all your rounds. Reload. ")
this.rounds = 0
}
else if (shot_left>0) {
msg ("You shot " +shot_fired+ " and have " +shot_left+ ".")
}
}
}
]]></shoot>
<weapon_to_ammo type="scriptdictionary">
<item key="Assault Rifle"><![CDATA[
if (Assault Rifle.rounds = Assault Rifle.maxam) {
msg ("Your weapon is fully loaded. ")
}
else if (Assault Rifle.rounds < Assault Rifle.maxam) {
if (F49 ammo.clip <= 0) {
msg ("There's no ammo left. ")
F49 ammo.usedammo = True
}
else if (F49 ammo.clip > 0 ) {
if (Assault Rifle.rounds = 0) {
Assault Rifle.rounds = F49 ammo.clip
F49 ammo.clip = 0
msg ("You reloaded with all your ammo.")
F49 ammo.usedammo = True
}
else if (Assault Rifle.rounds <= F49 ammo.clip) {
xii = Assault Rifle.rounds
Assault Rifle.rounds = Assault Rifle.rounds + F49 ammo.clip
if (Assault Rifle.rounds >=30) {
F49 ammo.clip = xii
msg ("You reloaded.")
Assault Rifle.rounds = 30
}
else if (Assault Rifle.rounds < xii) {
msg ("You reloaded.")
F49 ammo.clip = 0
F49 ammo.usedammo = True
}
}
else if (Assault Rifle.rounds>F49 ammo.clip) {
xi = F49 ammo.clip - Assault Rifle.rounds
Assault Rifle.rounds = F49 ammo.clip + Assault Rifle.rounds
if (Assault Rifle.rounds >= 30) {
Assault Rifle.rounds = 30
F49 ammo.clip = xi
if (F49 ammo.clip <= 0) {
F49 ammo.usedammo = True
}
msg ("You reloaded your weapon.")
}
else if (Assault Rifle.rounds >xi) {
F49 ammo.clip = 0
msg ("You reloaded.")
F49 ammo.usedammo = True
}
}
}
}
]]></item>
<item key="Pistol"><![CDATA[
if (Pistol.rounds = Pistol.maxam) {
msg ("Your weapon is fully loaded. ")
}
else if (Pistol.rounds < Pistol.maxam) {
if (G9 ammo.clip <= 0) {
msg ("There's no ammo left. ")
G9 ammo.usedammo = True
}
else if (G9 ammo.clip > 0 ) {
if (Pistol.rounds = 0) {
Pistol.rounds = G9 ammo.clip
G9 ammo.clip = 0
msg ("You reloaded with all your ammo.")
G9 ammo.usedammo = True
}
else if (Pistol.rounds <= G9 ammo.clip) {
xii = Pistol.rounds
Pistol.rounds = Pistol.rounds + G9 ammo.clip
if (Pistol.rounds >=30) {
G9 ammo.clip = xii
msg ("You reloaded.")
Pistol.rounds = 30
}
else if (Pistol.rounds < xii) {
msg ("You reloaded.")
G9 ammo.clip = 0
G9 ammo.usedammo = True
}
}
else if (Pistol.rounds> G9 ammo.clip) {
xi = G9 ammo.clip - Pistol.rounds
Pistol.rounds = G9 ammo.clip + Pistol.rounds
if (Pistol.rounds >= 30) {
Pistol.rounds = 30
G9 ammo.clip = xi
if (G9 ammo.clip <= 0) {
G9 ammo.usedammo = True
}
msg ("You reloaded your weapon.")
}
else if (Pistol.rounds >xi) {
G9 ammo.clip = 0
msg ("You reloaded")
G9 ammo.usedammo = True
}
}
}
}
]]></item>
<item key="STK Rifle"><![CDATA[
if (STK Rifle.rounds = STK Rifle.maxam) {
msg ("Your weapon is fully loaded. ")
}
else if (STK Rifle.rounds < STK Rifle.maxam) {
if (Cal30 ammo.clip <= 0) {
msg ("There's no ammo left. ")
Cal30 ammo.usedammo = True
}
else if (Cal30 ammo.clip > 0 ) {
if (STK Rifle.rounds = 0) {
STK Rifle.rounds = Cal30 ammo.clip
Cal30 ammo.clip = 0
msg ("You reloaded with all your ammo.")
Cal30 ammo.usedammo = True
}
else if (STK Rifle.rounds <= Cal30 ammo.clip) {
xii = STK Rifle.rounds
STK Rifle.rounds = STK Rifle.rounds + Cal30 ammo.clip
if (STK Rifle.rounds >=30) {
Cal30 ammo.clip = xii
msg ("You reloaded.")
STK Rifle.rounds = 30
}
else if (STK Rifle.rounds < xii) {
msg ("You reloaded (2).")
Cal30 ammo.clip = 0
Cal30 ammo.usedammo = True
}
}
else if (STK Rifle.rounds>Cal30 ammo.clip) {
xi = Cal30 ammo.clip - STK Rifle.rounds
STK Rifle.rounds = Cal30 ammo.clip + STK Rifle.rounds
if (STK Rifle.rounds >= 30) {
STK Rifle.rounds = 30
Cal30 ammo.clip = xi
if (Cal30 ammo.clip <= 0) {
Cal30 ammo.usedammo = True
}
msg ("You reloaded your weapon.")
}
else if (STK Rifle.rounds >xi) {
Cal30 ammo.clip = 0
msg ("You reloaded 1234")
Cal30 ammo.usedammo = True
}
}
}
}
]]></item>
</weapon_to_ammo>
</type>
<type name="ammo_taken">
<usedammo type="boolean">false</usedammo>
<changedusedammo type="script">
if (this.usedammo = True) {
MoveObject (this, pile room)
}
</changedusedammo>
</type>
</asl>



maybe i'll also put in the enemies. I made the list for them already and what they will be like during combat.
We should talk about how combat is going to be like because like I said it's not a turn based combat where monster attacks then your turn then monster attacks.

I don't know if it will be possible but making it where getting a random int will make the creature do something like shoot, panic, hide and it can be in different directions.

Omega
I just edited the code above. I have a problem with something here i can't quite find.
So sometimes I run a test on a weapon and it goes well.

Then there are times when I get to pretty much the same outcome but when i type 'reload ___" it responds with blank when it should get rid of the clip and reload how ever much the clip had.

I was testing it with the STK in case it's not happening to you with pistol or A. rifle.
Is this a glitch in Quest?

HegemonKhan
simple (monster) A.I. is actually pretty simple:

variable_x = GetRandomInt (min_value,max_value)

// the 'switch' code is just a different structure~design of~for doing multiple 'if' code lines

switch (variable_x) {
case (1) {
// 'shoot' scripting
}
case (2) {
// 'defend' scripting
}
case (3) {
// 'power ~ special ability' scripting
}
case (4) {
// 'item' scripting
}
// etc 'cases'
}


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

in my combat code, you can see this code for the monster's (ie my 'enemy' script block) A.I.

Omega
it's been awhile since I was last on. Lots of movement to jobs and such. I gave it some thought and decided to give this ATLAS game a break. Instead, let's do something simpler and more...holiday like.

Im working on a Haunted hotel/world for Halloween. [which i bet i wont finish before halloween.]

I worked up to getting to the hotel and there's an object in the front room. a computer.

So I bet you all played Fallout and remember when you use the computers it's like a close up of it and types? well, i took that idea and used it in my game. Here's the thing though.

I got it all set and ready and it works just fine but im confused on how you get back to the beginning. the main screen.

So basically im saying it shows 3 options. Apple, pizza, egg. if you choose pizza it gives another list: cookie, pie. but how do you go back? so it shows the first input options again(apple,pizza,egg)? So far it's basic that you'll just need to type in the 'use computer' to get back to the beginning which is kind of lame.

Any thoughts?

HegemonKhan
long time, good to 'see' you again :D

I'm not aware of any 'back' options, except maybe you can use the 'pages' (from the GameBook version of quest in the Text Adventure version of quest), to do so (or look at how they're done in code, hmm...), as otherwise, the only 'back' option, is to use the 'call upon' function (looping), though you'd need to make functions for each section you want, so that you can go back to those sections.

Silver
Put each page inside a function then set up commands triggering those functions to move between them which can be triggered with text processor-generated hyperlinks.

{command:page2:next}
{command:page1:back}

What happened with this coop then?

HegemonKhan
died a long time ago, laughs. Real life demands.

Silver
The forum is quiet lately so I keep clicking 'unread posts' because there's a treasure trove of info buried in it all. And then I have answers to questions where the posters are long gone. I'm tending to think that apart from a small minority, most people turn up, try to write their mega game and then evaporate at a later point. Never take on a sandbox monster-fest with player class options. It's too ambitious unless there's an army of folk doing it, imo. The kiss of death.

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

Support

Forums