Help with something...easy?

Omega
It's been a good 2 years since i've laid off this game creation, but im back. Anyways, coming across a problem where I want to throw something at an object. BUT. You can't just throw it willy-nilly everywhere you go. You know?

So my story is attached at the bottom. Im looking to make the grenade be able to throw at specific items that are allowed for it to be tossed. For example, if I added a rock and a tree to the room; I want the player to be able to throw the grenade at the rock. Having the rock explode and disappear from the scenery.

if the player decided to throw it at the three.... well I wouldn't want that. So a message that would say 'you can't throw it there' would be something nice.

I'm assuming this might be somewhere along the lines of the Verb: throw or creating an object type where it can be assigned to an objects attribute for both rock and grenade (kind of like connecting the two so that if you typed throw at another object it wont work)

let me know if this is possible please.
new Quest is pretty bad ass too by the way.

jaynabonne
Attached is an example (it was easier than trying to integrate it into your game). The code is also here:

<!--Saved by Quest 5.5.5173.27901-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="throwattest">
<gameid>0d4a7838-1b4a-471f-a709-899fe6656c49</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="grenade">
<inherit name="editor_object" />
</object>
</object>
<object name="rock">
<inherit name="editor_object" />
<throwgrenade type="script">
msg ("You throw the grenade at the rock, and it explodes! ")
MakeObjectInvisible (rock)
</throwgrenade>
</object>
<object name="tree">
<inherit name="editor_object" />
</object>
</object>
<verb name="throwgrenade">
<pattern>throw grenade at #object#</pattern>
<separator>at</separator>
<multiobjectmenu>At what object?</multiobjectmenu>
<property>throwgrenade</property>
<defaulttext>You can't throw the grenade at that.</defaulttext>
</verb>
</asl>


The key is a verb called "throwgrenade" with pattern "throw grenade at #object#". If you wanted a generic "throw X at Y" verb, that could be done, but this seemed easier. The attribute (property) is set to "throwgrenade", and the default text is set for those objects without the attribute.

If you want all objects that can be exploded to act the same way, then you can create a base type (e.g. "explodable") which has the script for "throwgrenade" that prints some text and removes the object. Then you can simply inherit the explodable type in any object that you want to be explodable.

Omega
DUH! why do I complicate things so much on this? Thanks dude. (long time, no talk btw).
Now, that this was resolved there's only one thing to tackle for this and that's the object grenade.

So let's say you have 1 in your inventory. You find another and pick it up. How do you get this [grenade (2)] to show up in your inventory? I know we've talked about it at some other post as a multiple items code someone made. There's so many forums, it's hard to locate it again. Unless you have your own version now that Quest has been updated.

So basically it should go like this in game play:

You see a rock, tree, and a grenade [inventory: grenade (1)]
player types: pick grenade up

You picked grenade up [Inventory: grenade (2)]

player types: throw grenade at rock
rock blows up [Inventory: grenade (1)]

Thanks.

HegemonKhan
here's Sora's Stackable Library:

viewtopic.php?f=18&t=3515

ask if you don't know how to add libraries to your game

Omega
beastly. Thanks much.

Omega
So im curious to dark/light rooms. Playing through what i got so far is really cool but I have a cave the player goes into.

Now we all know our loving caves to be dark and go in pretty far. So when I tick the room is initially dark, I realize that the player can't travel further into the cave. Im guessing this makes the room invisible in a way unless player has a torch or something right? Unfortunately, the player isn't a cave man wanting a torch but does have night vision which I typed in for print message.

Should I change that nightvision type up to something of an object the player has so he/she can get through the cave? Or not bother with it, uncheck the initial dark, and describe how dark the room is?

jaynabonne
If I understand you correctly (and I'm not sure I do), then this might work for you. The idea is to have the player him/herself be a light source, and the command just "turns the player on". :)

<!--Saved by Quest 5.5.5173.27901-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="nightvision">
<gameid>bdcbbe26-c2de-4f91-a6d8-f455489e6488</gameid>
<version>1.0</version>
<firstpublished>2014</firstpublished>
<feature_lightdark />
</game>
<object name="room">
<inherit name="editor_room" />
<dark />
<darkroomdescription>The room is very dark. You can't see a thing.</darkroomdescription>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<feature_lightdark />
<lightsource type="boolean">false</lightsource>
<lightstrength>strong</lightstrength>
</object>
<object name="apple">
<inherit name="editor_object" />
</object>
</object>
<command name="nightvisioncommand">
<pattern>nightvision</pattern>
<script>
player.lightsource = true
</script>
</command>
</asl>


Omega
Thanks HK.

ok. So im just going to take a break from the story and run designs for combat. I did a simple firing code that makes my assault rifle shoot and then not shoot when it's out of rounds.

Here's what i'm having difficulty wrapping my head around. (could be because im starving so i'll go eat but just in case)

Im trying to make it where when you fire the weapons rounds go down by a random number. I got it.

Problem is when i test to see the number in game, the value goes past 0 and into the negatives. like -45.
Is there a code line im missing so that whatever random number subtracts it will only go as low as 0?

Here's the code for that, and my experiment file.
if (Got(F49 Assualt Rifle)) {
if (F49 Assualt Rifle.roundrifle <= 0) {
msg ("reload")
}
else {
msg ("you fired " +F49 Assualt Rifle.roundrifle+ " rounds")
set (F49 Assualt Rifle, "roundrifle", - (GetRandomInt(10,60)))
}
}

HegemonKhan
check my 2 pms for some code examples, but I'll also address your question here as well:

you need some kind of 'check' (an 'if' script), either to prevent from subtracting into the negatives, or afterwards, to return the value back to '= 0', instead of leaving it in the negatives.

the easy one is to jsut return it to zero:

// you fire off your rounds already, getting: player.gun.rounds = -50
if (player.gun.rounds < 0) {
player.gun.rounds = 0
}


but, unfortunately, in using rounds (projectile~ranged combat), you got bit of other issues to deal with... it's not as simple as you liked (see my pm), due to the real life scenerio of it (well if you want it to have this complexity anyways).

since your 'rounds' is your damage, then your damage is going to messed up, as you shot off more rounds than you have, thus doing more damage than you practically can do so, obviously. No magical extra bullets doing magical extra damage, lol.

-----------

orc: 10 HP
player: 1 round (or: 9 rounds)
if: 1 round = 5 damage (or if: 1 round = 1 damage)
then: you can't be shooting off more rounds than 1 (or 9), going into negative rounds
as: you would kill the orc, which you shouldn't be able to do so with only 1 round (or 9 rounds).

---------

unlike melee combat (unless you have 'durability' ~ breakable weapons, or 'fatigue' from swinging the heavy melee weapon), a 'round' is BOTH the number of times you can hit the monster AND determines the damage you do to the monster as well (either as: 1 round = 5 damage or 1 round = 1 damage)

Omega
fml.... yea. thanks for bringing me to light with that. I didn't realize that rounds will not be able to come with it's specific damage. Yet, can we make a function or command where it can check:
if ## rounds were fired
then ## damage given
????

Might not be simple though. haahah!! im just trying to get to your level of understanding when I code stuff. You know start with basics learn how it works. Evolve.

Im still trying to understand Function, Object Types, Commands.
Im somewhat ok with Timers from before and a tiny bit on Call function, but maybe could be but with the above.

Thanks bro.

Omega
Hey HK check the new topic I put up. There's a cleaner thing so yours and my PMs dont get too overwhelming.

HegemonKhan
actually, for new people, while coding itself is obviously an enormous learning curve... there's another just as 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 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 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.damage
monster.hp = monster.hp - final_damage

---------

okay, let's post for now on in the new thread, okay.

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

Support

Forums