Jump to content
The Dark Mod Forums

Blackjack-script


LEGION

Recommended Posts

I modified the Blackjack-script to include an attack-cancel-function triggered by the block-key. I oriented on the sword-script, though it´s different.

 

Right now it works (on my system, on Aida´s it leads to an OS-crash) but the hit-animation repeats itself as long as the block-key is hold.

 

The problem must be in here:

 

	// block key cancels the swing
if( WEAPON_BLOCK || WEAPON_LOWERWEAPON )
{
	pauseAnim( ANIMCHANNEL_ALL, 0 );
	m_bPlayerCancelledAttack = 1;
	// play the correct cancel animation:
	//string cancelAnim = "cancel_" + attackAnim;
	//playAnim( ANIMCHANNEL_ALL, cancelAnim );
	//waitUntil( animDone( ANIMCHANNEL_ALL, blendframes ) );
	playAnim( ANIMCHANNEL_ALL, "putaway" );
	waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
	weaponState( "Idle", BLACKJACK_HIT_TO_IDLE );
}

 

Uncommenting the commented stuff doesn´t work at all. I had to start a new animation with 'playAnim' otherwise I couldn´t get it to work. And what´s with 'pauseAnim'? I can´t get that working too.

 

For completeness, here the whole script:

 

 

/***********************************************************************

weapon_blackjack.script

***********************************************************************/

#ifndef __WEAPON_BLACKJACK__
#define __WEAPON_BLACKJACK__

// blend times
#define BLACKJACK_IDLE_TO_LOWER		4
#define BLACKJACK_IDLE_TO_HIT		.2
#define BLACKJACK_RAISE_TO_IDLE		4
#define BLACKJACK_HIT_TO_IDLE		12

object weapon_blackjack : weapon_base 
{
float		current_time;
float		finished_raising;
float		m_bPlayerCancelledAttack;

void		init();

void		Lower();
void		Raise();
void		Idle();
void		Attack();
void		Block();
void		ExitCinematic();
//string		GetFireAnim();
};

void weapon_blackjack::init() {
weaponState( "Raise", 0 );
m_bPlayerCancelledAttack = 0;
}

void weapon_blackjack::Raise() {
weaponRising();
playAnim( ANIMCHANNEL_ALL, "raise" );
waitUntil( animDone( ANIMCHANNEL_ALL, BLACKJACK_RAISE_TO_IDLE ) );
weaponState( "Idle", BLACKJACK_RAISE_TO_IDLE );
}

void weapon_blackjack::Lower() {
weaponLowering();
playAnim( ANIMCHANNEL_ALL, "putaway" );
waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
weaponHolstered();
waitUntil( WEAPON_RAISEWEAPON );
weaponState( "Raise", 0 );
}

void weapon_blackjack::Idle() {
weaponReady();
playCycle( ANIMCHANNEL_ALL, "idle" );
while( 1 ) {
	if ( WEAPON_LOWERWEAPON ) {
		weaponState( "Lower", BLACKJACK_IDLE_TO_LOWER );
	}
	if ( WEAPON_ATTACK ) {
		weaponState( "Attack", BLACKJACK_IDLE_TO_HIT );
	}
	if ( WEAPON_BLOCK && !m_bPlayerCancelledAttack )
	{
		weaponState( "Block", BLACKJACK_IDLE_TO_HIT );
	}

	// if player cancelled attack, reset latching var if block is released
	if( m_bPlayerCancelledAttack && !WEAPON_BLOCK && !WEAPON_ATTACK )
	{
		m_bPlayerCancelledAttack = 0;
	}
	waitFrame();
}
}

void weapon_blackjack::Attack() 
{
playAnim( ANIMCHANNEL_ALL, "hit_start");
//this line ensures you can't drop the blackjack before the raising animation has finished.
//waitUntil( animDone( ANIMCHANNEL_ALL, BLACKJACK_HIT_TO_IDLE ) );
//Except that the raising animation goes on after the grenade is raised, showing the hand moving around.
//So instead, we use this loop to make sure you can't drop the blackjack until a certain amount of time has passed
//giving enough time for the raising part of the animation to play, and then allowing it to fall even when it is not finished.
current_time = sys.getTime();
finished_raising = current_time + BLACKJACK_IDLE_TO_HIT;
while(current_time < finished_raising) 
{
		waitFrame();
		current_time = sys.getTime();
}
while( WEAPON_ATTACK && !WEAPON_BLOCK ) 
{
	// If the player hits the block button, break and cancel the attack
	waitFrame();
}

// block key cancels the swing
if( WEAPON_BLOCK || WEAPON_LOWERWEAPON )
{
	pauseAnim( ANIMCHANNEL_ALL, 0 );
	m_bPlayerCancelledAttack = 1;
	// play the correct cancel animation:
	//string cancelAnim = "cancel_" + attackAnim;
	//playAnim( ANIMCHANNEL_ALL, cancelAnim );
	//waitUntil( animDone( ANIMCHANNEL_ALL, blendframes ) );
	playAnim( ANIMCHANNEL_ALL, "putaway" );
	waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
	weaponState( "Idle", BLACKJACK_HIT_TO_IDLE );
}
else
playAnim( ANIMCHANNEL_ALL, "hit");

waitUntil( animDone( ANIMCHANNEL_ALL, 0 ) );
weaponState( "Idle", BLACKJACK_HIT_TO_IDLE );
}

void weapon_blackjack::Block() 
{
	pauseAnim( ANIMCHANNEL_ALL, 0 );
	weaponState( "Idle", 0 );
}

void weapon_blackjack::ExitCinematic() {
weaponState( "Idle", 0 );
}

#endif //__WEAPON_BLACKJACK__

 

-> Crisis of Capitalism

-> 9/11 Truth

->

(hard stuff), more
Link to comment
Share on other sites

Note that in 1.04 you'll be able to abort a held sword/bj attack by switching to a different weapon.

Link to comment
Share on other sites

Note that in 1.04 you'll be able to abort a held sword/bj attack by switching to a different weapon.

 

Wish someone had said that when I first asked about it. <_<

 

Or did someone?

 

Anyway, that's only getting us back to the imperfect way Old Thief worked. Why can't we have it work perfect way -- the way the bow-shot abort works?

Link to comment
Share on other sites

Wish someone had said that when I first asked about it.

 

It's a side-effect of something that was only just proposed by Grayman.

Link to comment
Share on other sites

Wish someone had said that when I first asked about it. <_<

 

Or did someone?

 

Anyway, that's only getting us back to the imperfect way Old Thief worked. Why can't we have it work perfect way -- the way the bow-shot abort works?

 

Here's the plan, which I described only yesterday in the "Grayman's working on ..." thread:

 

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

 

 

When you switch weapons, the current weapon should be replaced with the new weapon, even if fire button is depressed. If it is depressed, then the code should ignore the subsequent release. TDM weapons are two-phase weapons: fire button down prepares the weapon, and fire button released fires the weapon. A weapon switch before release should abort the release.

 

So if you have the BJ raised to strike, and you switch to the sword, the BJ would lower and be put away, the sword would be unsheathed and put into its idle state. Not raised to strike.

 

And if you have an arrow nocked and raised to fire, switching to another arrow would lower the bow, select the new arrow, and put the bow into its idle state. Not raised to fire. Identical behavior to hitting the ~ key.

 

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

 

 

 

 

 

Link to comment
Share on other sites

Grayman, that's an old trick from T1 days, switching weapons to abort... but (one of) the (many) cool things about TDM is that you don't have to switch weapons to abort a bow-shot -- you can press RMB. This is how it should work for the blackjack. It's an improvement. More often than wanting to switch weapons, I don't want to put away my blackjack... I just want to lower my ready-state and keep my blackjack at hand.

Link to comment
Share on other sites

Grayman, that's an old trick from T1 days, switching weapons to abort... but (one of) the (many) cool things about TDM is that you don't have to switch weapons to abort a bow-shot -- you can press RMB. This is how it should work for the blackjack. It's an improvement. More often than wanting to switch weapons, I don't want to put away my blackjack... I just want to lower my ready-state and keep my blackjack at hand.

 

Good point. I'll make sure RMB aborts each weapon's attack in the same manner.

Link to comment
Share on other sites

In the script above, why do you need to play the "put away" animation? You should be able to blend back to the idle animation directly, and the animation blending will do the lowering for you. I thought that's how the sword worked, but it's been a while since writing that script.

 

Great minds think alike.

 

I've already come to the same conclusion after examining the blackjack script. Since the idle state already has a path to the lowered state, it's easiest to create a new transition from the attack state to the idle state, then force that to go immediately to the lowered state.

 

I'm hoping the other weapon scripts are set up the same way.

Link to comment
Share on other sites

Grayman, that's an old trick from T1 days, switching weapons to abort... but (one of) the (many) cool things about TDM is that you don't have to switch weapons to abort a bow-shot -- you can press RMB. This is how it should work for the blackjack. It's an improvement. More often than wanting to switch weapons, I don't want to put away my blackjack... I just want to lower my ready-state and keep my blackjack at hand.

 

What action do you have your RMB set for? Your wording implies RMB cancels an "about to fire" weapon by default, but in my setup it does nothing.

Link to comment
Share on other sites

In the script above, why do you need to play the "put away" animation? You should be able to blend back to the idle animation directly, and the animation blending will do the lowering for you. I thought that's how the sword worked, but it's been a while since writing that script.

I tried that, but I´m under-skilled and working with blendtime, well, I hope you get it working. Also the sword does have an own cancel-animation.

 

And for the RMB: it´s the block-feature that aborts and Blackjack has no block. Then again, Bow hasn´t either. I should´ve looked at the bow instead of the sword...

 

I´m glad you´re looking into this Grayman!! :blush:

 

edit: I´m confused, there is no 'cancel'-void in the arrow-script (that is the bow); is it done just with that 'break'? But that was only related to release the Fire-button too early, found nothing with the block-key... :unsure:

Edited by LEGION

-> Crisis of Capitalism

-> 9/11 Truth

->

(hard stuff), more
Link to comment
Share on other sites

Everything's working, but I need Aprilsister's answer to finish out the RMB request.

 

I also added NH's arrow equip sound after you fire an arrow, to represent nocking a new arrow if you have any left.

Ha! :laugh: THANK YOU (I know you didn´t do it for me, but I want it as bad as 'Aprilsister') I can´t wait to see that script...

-> Crisis of Capitalism

-> 9/11 Truth

->

(hard stuff), more
Link to comment
Share on other sites

Ah but you have linked us to forbidden cited site sights... we are but simple interlopers, unaquainted with your arcane ways, mystified by such crytogramata, muzzled and muttled by this beyond...

 

 

Sorry. I didn't know that would happen.

 

Anyway ...

 

The weapons changes are committed for #597.

 

 

Please try it out and post comments. I think I accommodated everyone.

 

Here's how it works:

 

 

Arrows

 

If switching from one arrow type to another, the drop bow and raise bow animations no longer play. The arrow type changes and an equip sound plays, to indicate nocking a new arrow.

 

If you have the bow raised to fire (attack state), switching to another arrow type lowers the bow, selects the new arrow type, and puts the bow into its idle state.

 

When an arrow is fired, and more of the same arrow type remain, the equip sound plays to indicate nocking another arrow.

 

All Weapons

 

If you switch weapons, the current weapon is replaced with the new weapon in its idle state. (If you hit ~, no new weapon appears.)

 

If you switch weapons when the attack button is depressed, the attack animation ends, the weapon is lowered, and the new weapon appears in its idle state. The continued depression of the attack button and its subsequent release are ignored. (If you hit ~, no new weapon appears.)

 

If a weapon is in the attack state and the BLOCK button is pressed, the weapon returns to the idle state. All three weapon types behave this way, even though BLOCK only works with the sword.

 

Sword

 

If the sword is in the BLOCK state and you switch weapons, the sword is sheathed and the new weapon appears. (If you hit ~, no new weapon appears.)

 

 

 

Request for someone to look at an animation:

 

Whoever does animations needs to look at dropping the blackjack from its attack state to its idle state when you press the BLOCK button. The blackjack and the hand currently become separated as they lower, and it doesn't look good.

 

 

 

 

I committed a Windows DLL that you can pick up with a trunk update.

Link to comment
Share on other sites

I don't suppose this is something we players can get to?

 

These fixes were gamex86.dll-ish as opposed to scripts? Is that what is meant by this?

 

I'm trying to create a 1.03+ "patch" you can apply to 1.03.

 

The changes are in the scripts and the DLL.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 5 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
    • nbohr1more

      Looks like the "Reverse April Fools" releases were too well hidden. Darkfate still hasn't acknowledge all the new releases. Did you play any of the new April Fools missions?
      · 5 replies
×
×
  • Create New...