Holstering of a Weapon
by Mahomed Ayoob · in Torque Game Engine · 07/06/2005 (1:43 am) · 10 replies
I have created an inventory system which deals with switching of weapons etc. but i was just after a way perhaps to holster a weapon, while it is still equiped, without having to change the mount point or something... (If this sounds noob it is because i am).
I will give an example of how i wish it to work in my game: I see a guard, i holster the weapons so he doesn't chase after me, i can draw it again if i need to shoot the guard or any other npc.
I will give an example of how i wish it to work in my game: I see a guard, i holster the weapons so he doesn't chase after me, i can draw it again if i need to shoot the guard or any other npc.
About the author
#2
You will still have the weapon equipped and as soon as you press the button again, the player will de-holster and the weapon will be in it's normal "ready" state again.
07/07/2005 (4:24 am)
It's actually pretty simple. Create a new state and animation for the arm which is the holstered state of the weapon. Then as soon as you press "h" (or whatever) that thread/state will play and tell the server that we are holstering, so the guards won't attack you.You will still have the weapon equipped and as soon as you press the button again, the player will de-holster and the weapon will be in it's normal "ready" state again.
#3
I'm watching my default 'player' with a pistol holstered[in correct orientation!] loaded with player_root.dsq and player_forward.dsq...I'm now gonna check it in v1.3 SDK....
I could probably just as easily add more Nodes to this shape....up to default code limit, getting their location and orientation is a little tedious...;).
...after reading this post, I got right busy and popped one out...:). Looks cool with a huge hogleg strapped to the players' side...
07/07/2005 (8:13 am)
Say.....;), for an example of such a setup, I'll trade a Ms3d rig that contains a Node[mount4] for just such a purpose[holstering/Rht side], & contains a Left Hand mount Node[mount3] for other items. This rig, once exported thru Ms3d, will load the default SDK sequences...I'm watching my default 'player' with a pistol holstered[in correct orientation!] loaded with player_root.dsq and player_forward.dsq...I'm now gonna check it in v1.3 SDK....
I could probably just as easily add more Nodes to this shape....up to default code limit, getting their location and orientation is a little tedious...;).
...after reading this post, I got right busy and popped one out...:). Looks cool with a huge hogleg strapped to the players' side...
#4
07/07/2005 (8:15 am)
Not sure what you're asking or saying Rex, but I'm glad you got it working :)
#5
I've produced a dts shape[& source file] that has the needed Nodes for this type of coding, :), and am now watching it run the range.DSQ...:P. I hope I cleared things up...it runs the defaults, kinda neat and convenient for a coder/anyone needing an asset to work with...;). I need help setting up such a holstering functionality...a coding tutorial on this type of weaponery 'standard', ie, different weapons and their poses, and how they interact with the WeaponClass FSM would be the coolest...
07/07/2005 (8:41 am)
I didn't understand the part about adding a 'new' state and animation[to the 'player'?]. I did/do understand the bit about the weapon's state machine and how it will play the recoil sequence as hardcoded for the playerDatablock[and that's it right??], it's getting the player to do something different[action/armThread] in sync with the weapon state, is the part I don't understand...I can add Nodes at will and have it[DTS] accept the sequences no problem[as I'm an artist], it's the code side of things that I need step by steps to get to a successful result, ;).I've produced a dts shape[& source file] that has the needed Nodes for this type of coding, :), and am now watching it run the range.DSQ...:P. I hope I cleared things up...it runs the defaults, kinda neat and convenient for a coder/anyone needing an asset to work with...;). I need help setting up such a holstering functionality...a coding tutorial on this type of weaponery 'standard', ie, different weapons and their poses, and how they interact with the WeaponClass FSM would be the coolest...
#6
I'm not very knowledgeable about how the system works, but that's the way I understood it, yes.
In this case it's a new animation for just THAT gun, think the Realmwars sword that Logan (I think it was Logan, sorry if not) made. It has a custom animation for when it swings the sword, if I remember correctly.
Unfortunatly, I'm not sure how they did it.
07/07/2005 (9:11 am)
Quote:
I didn't understand the part about adding a 'new' state and animation[to the 'player'?]. I did/do understand the bit about the weapon's state machine and how it will play the recoil sequence as hardcoded for the playerDatablock[and that's it right??], it's getting the player to do something different[action/armThread] in sync with the weapon state, is the part I don't understand...
I'm not very knowledgeable about how the system works, but that's the way I understood it, yes.
In this case it's a new animation for just THAT gun, think the Realmwars sword that Logan (I think it was Logan, sorry if not) made. It has a custom animation for when it swings the sword, if I remember correctly.
Unfortunatly, I'm not sure how they did it.
#7
What i am doing is i am manually setting the state of the weapon (by bingding setImageState(*) from the shapeBase.cc to a console function) to be holstered when called by the client...
ConsoleMethod( ShapeBase, setImageState, void, 4, 5,
"Usage: (int slot, int state, bool force)")
{
if(argc > 4)
object->setImageState(dAtoi(argv[2]), dAtoi(argv[3]), dAtob(argv[4]));
else
object->setImageState(dAtoi(argv[2]), dAtoi(argv[3]));
}
(got this from another thread)
this works but the thread animation doesn't :S
I ran an echo for the serverCmd to check the current state after I have changed the state manually using *.getImageState($WeaponSlot);
and it returns that the weapon is in the correct state: Holstered...
but the holstering animation doesn't play even if i set the stateFire[*] flag to true... kinda lost atm
anybody got any Ideas?
10/28/2005 (8:19 am)
I put this little coding effort off for a while but i now have it almost working...What i am doing is i am manually setting the state of the weapon (by bingding setImageState(*) from the shapeBase.cc to a console function) to be holstered when called by the client...
ConsoleMethod( ShapeBase, setImageState, void, 4, 5,
"Usage: (int slot, int state, bool force)")
{
if(argc > 4)
object->setImageState(dAtoi(argv[2]), dAtoi(argv[3]), dAtob(argv[4]));
else
object->setImageState(dAtoi(argv[2]), dAtoi(argv[3]));
}
(got this from another thread)
this works but the thread animation doesn't :S
I ran an echo for the serverCmd to check the current state after I have changed the state manually using *.getImageState($WeaponSlot);
and it returns that the weapon is in the correct state: Holstered...
but the holstering animation doesn't play even if i set the stateFire[*] flag to true... kinda lost atm
anybody got any Ideas?
#8
10/28/2005 (6:17 pm)
I've seen problems similair when doing other manual changes on Image states, I haven't looked into it myself yet, but you should go look at the ShapeImage source and see how it's setting the animations, to see if it's not being called properly somewhere in there.
#9
if(newState == image.dataBlock->fireState && isServerObject())
{
mShapeInstance->animate();
}
so if the stateFire[*] flag is true then the image.dataBlock->fireState returns true but maybe because i am setting the state of the image with %client.player.setImageState($WeaponSlot, %state); It is not registering it as a server object?
10/28/2005 (7:54 pm)
Well in ShapeImage inside the setImageState function there is a bit of code:if(newState == image.dataBlock->fireState && isServerObject())
{
mShapeInstance->animate();
}
so if the stateFire[*] flag is true then the image.dataBlock->fireState returns true but maybe because i am setting the state of the image with %client.player.setImageState($WeaponSlot, %state); It is not registering it as a server object?
#10
if ((newState == image.dataBlock->fireState || newState == image.dataBlock->holsterState) && isServerObject())
{
mShapeInstance->animate();
}
----
(Assuming there is a holsterState defined in the datablock?)
Edit: Sorry for the bad formatting. I'm not good with these quasi-html tag thingies. =)
10/28/2005 (10:55 pm)
Couldn't you change that to:if ((newState == image.dataBlock->fireState || newState == image.dataBlock->holsterState) && isServerObject())
{
mShapeInstance->animate();
}
----
(Assuming there is a holsterState defined in the datablock?)
Edit: Sorry for the bad formatting. I'm not good with these quasi-html tag thingies. =)
Torque Owner Chris Labombard
Premium Preferred