Game Development Community

Get current item

by Nathan Kent · in Technical Issues · 09/26/2007 (3:42 pm) · 9 replies

Hi, I'm trying to make a code to cycle through weapons, but I can't seem to find how to get the users current weapon. If anyone could tell me how to do this, I'd appreciate it!

#1
09/27/2007 (2:45 am)
Set current item would be better topic name. There is a function that is called mountImage, that mounts the image of a weapon/item on a player mountpoint, find where that function i executed in your script and change it. My guess is that it looks something like this:
%player.mountImage(crossbowImage, 0);

You would change it to maybe this:
%player.mountImage(rifleImage, 0);

Simple eh? The tricky part is to get an argument that tells you which image to mount on the player, but that is also kind of easy.

The mountpoint vary depending on how you make your 3d models. A weaponimage is basically the weapon, when the player fires in starter.fps, it triggers the weaponImage to attack.
#2
09/27/2007 (4:50 am)
That's not entirely what I mean. I know about mountImage(), but what I need is a function the returns the current object mounted on the player. That way I know what to image to mount on the charictar.
#3
09/27/2007 (12:44 pm)
Allright the argument bit. I have not toyed around to much with the fps things, but i guess there are allready some example of switching weapons? Have you checked default.bind?
#4
09/27/2007 (5:04 pm)
Yeah, I've been toying in the torque demo's default.bind, but I still can't find anything.
#5
09/27/2007 (5:17 pm)
Nathan a few ideas for you -

getMountedImage( slot )

That will return the datablock id of the current mounted image.

Another idea is to simply make note, in code, of the weapon when it gets mounted. If you have different key binds to load different weapons, for example you could just change a variable to match what weapon he selects. By checking that variable you will always know what weapon he has selected.

Hope that helps!
#6
09/28/2007 (2:42 am)
Steve i dont think you read the topic. He wants to MOUNT a image, not check what image is mounted. Good tips though

In default.bind:
movemap.bind("2", equipImage, equipImage(bazooka));

Later in default.bind
equipImage(%image)
{
commandToServer(equipPlayer(%image));
}

And in
commands.cs in the server directory:
equipPlayer(%player, %image)
{
%player.mountImage(0, %image);
}

i am pretty sure its something like that, but im at schol(or college to be exact(thats right im older than you sucka)) right now so i am 100% sure that the syntax is wrong in at least some point. But thats the way your suposed to think anyway, do you want to be able to scroll with mousescrollbutton?
#7
09/28/2007 (6:19 am)
I don't see where he is asking that especially when he says "function the returns the current object mounted on the player"
#8
09/28/2007 (9:51 am)
Yeah your right i got it wrong
#9
09/28/2007 (12:48 pm)
Thanks! That's exactly what I needed!