Help with torquescript for melee weapons
by Terra Snover · in Torque 3D Professional · 08/29/2010 (3:14 am) · 7 replies
I'm trying to write the script for a three hit combo melee weapon that would require the user to click at a specific rate to continue the combo, however right now the script (ontriggerdown) isn't differentiating between someone clicking the trigger or holding it down so all someone has to do is hold down the mouse button to get the whole combo. Also I don't want to add ontriggerup states because that will create more interesting quirks when someone holds down the mouse button. Is there an "onclick" term in torquescript? Or another way to get it to differentiate between holding down the mouse button and clicking it?
I usually pick up a programming language as I go, cause I'm good at understanding and imitating what I've read but it makes it hard to solve issues if I've never seen something before.
I usually pick up a programming language as I go, cause I'm good at understanding and imitating what I've read but it makes it hard to solve issues if I've never seen something before.
#2
Anyway...
Good luck.like to know if this worked out
08/31/2010 (8:23 am)
I have give this problem a second thought and cam up with the following. It is more or less pseudo-code so to get this working you have to dig in it a little deeper.Anyway...
$comboTrigger = 0; //Global to track the number of button presses.
$comboScheduled = 0; //Global to hold the ID of the schedule function;
// function will be called by a schedule when the player doesn't press
// and release the left mousebutton within the desired time
function resetCombo()
{
$comboTrigger = 0;
}
// This function will be called every time the player release the
// left mouse button. Checks if there is a resetevent scheduled and
// cancel this. Increment the combo counter and schedule a next
// reset event.
function handleMouseButton0Release()
{
if($comboScheduled)
{
cancel($comboTrigger);
$comboScheduled=0;
}
$comboTrigger++;
$comboScheduled=schedule(1000,resetCombo());//Player have to press and RELEASE the mouse button 0 in 1 second (1000 ms) change this as you like
}
function handleMouseButton0Press()
{
if ($comboTrigger==2) // 2 times released therefore 3 times pressed
{
PerformYourCombo();
$comboTrigger=0;
if($comboScheduled)
cancel($comboScheduled);
}
else
{
$mvTriggerCount0++; // default mouse button 0 action
}
}
moveMap.bindCmd(mouse, button0, "handleMouseButton0Press();", "handleMouseButton0Release();");Good luck.like to know if this worked out
#3
I'm making a platformer and I'm trying to go for the classic platformer attack, where if the player hits the button once he'll get one hit, etc. Right now what I have is a number of states that call the individual attack animations (depending on which hit it is in the combo) and "Fire" the weapon. Here's the important bits, I built it based on the initial rocket launcher weapon (which is one of the reasons it's still got the rocket sounds, etc).
If there's a more elegant way to do this then I'd love to hear it.
08/31/2010 (8:30 pm)
If I'm understanding the code correctly then I think you may have misunderstood. I really didn't give enough information.I'm making a platformer and I'm trying to go for the classic platformer attack, where if the player hits the button once he'll get one hit, etc. Right now what I have is a number of states that call the individual attack animations (depending on which hit it is in the combo) and "Fire" the weapon. Here's the important bits, I built it based on the initial rocket launcher weapon (which is one of the reasons it's still got the rocket sounds, etc).
// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateTransitionOnTriggerDown[2] = "Fire";
stateSequence[2] = "Ready";
// Fire the weapon. Calls the fire script which does the actual work.
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "PostSwing1";
stateTimeoutValue[3] = 0.5;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = RocketLauncherFireSound;
stateEmitter[3] = RocketLauncherfiring1Emitter;
stateEmitterTime[3] = 0.6;
// Transition to second swing
stateName[4] = "PostSwing1";
stateTransitionOnTriggerDown[4] = "Fire2";
stateTransitionOnTimeout[4] = "PostSwing3";
stateTimeoutValue[4] = 1.0;
// Second swing
stateName[5] = "Fire2";
stateTransitionOnTimeout[5] = "PostSwing2";
stateTimeoutValue[5] = 0.5;
stateFire[5] = true;
stateRecoil[5] = LightRecoil;
stateAllowImageChange[5] = false;
stateSequence[5] = "Fire";
stateScript[5] = "onFire2";
stateSound[5] = RocketLauncherFireSound;
stateEmitter[5] = RocketLauncherfiring1Emitter;
stateEmitterTime[5] = 0.6;
// Transition to third swing
stateName[6] = "PostSwing2";
stateTransitionOnTriggerDown[6] = "Fire3";
stateTransitionOnTimeout[6] = "PostSwing3";
stateTimeoutValue[6] = 1.0;
// Third swing
stateName[7] = "Fire3";
stateTransitionOnTimeout[7] = "ComboFinal";
stateTimeoutValue[7] = 0.5;
stateFire[7] = true;
stateRecoil[7] = LightRecoil;
stateAllowImageChange[7] = false;
stateSequence[7] = "Fire";
stateScript[7] = "onFire3";
stateSound[7] = RocketLauncherFireSound;
stateEmitter[7] = RocketLauncherfiring1Emitter;
stateEmitterTime[7] = 0.6;
// Lull in between combos
stateName[8] = "ComboFinal";
stateTransitionOnTimeout[8] = "Ready";
stateTimeoutValue[8] = 1.0;If there's a more elegant way to do this then I'd love to hear it.
#4
08/31/2010 (8:35 pm)
Although your script is giving me ideas that I'm wondering why I didn't do in the first place...
#5
eg to enhance hit, range, effect etc. For better use some code on mouse clicks with projectile updates after any combo.
eg combo1
directDamage = 10;
radiusDamage = 3;
combo2
directDamage = 12;
radiusDamage = 20;
an idea is what I say¨)
08/31/2010 (9:31 pm)
meele for weapons I think we should approach them otherwise. As it has come projectile eighth but the combo be possessing some extra capacity.eg to enhance hit, range, effect etc. For better use some code on mouse clicks with projectile updates after any combo.
eg combo1
directDamage = 10;
radiusDamage = 3;
combo2
directDamage = 12;
radiusDamage = 20;
an idea is what I say¨)
#6
09/01/2010 (4:35 am)
Uhhh...
#7
I understand what you are trying to achieve. Although state transitions is not my field of expertise yet, but I think that the approach could be the same.
I have a similar melee fighting system on my wish list, but it is not a high priority for me. Good luck and if you're willing to share your solution I'm definitely interested.
09/01/2010 (7:22 am)
@Steele:I understand what you are trying to achieve. Although state transitions is not my field of expertise yet, but I think that the approach could be the same.
I have a similar melee fighting system on my wish list, but it is not a high priority for me. Good luck and if you're willing to share your solution I'm definitely interested.
Richard Marrevee
R.G.S - Richards Game Studio
bindCmd (string device, string action, string makeCmd, string breakCmd="")
When using the breakCmd the action is triggered when the player releases the key/trigger....