Forum Archive

Go Back   3D Realms Forums > 3D Realms Topics > Duke Nukem > Duke Nukem 3D Modifications
Blogs FAQ Community Calendar

Notices

 
 
Thread Tools
Old 02-10-2009, 08:56 AM   #1
EmericaSkater

EmericaSkater's Avatar
Help on melee fighting
Okay, so this post is the result of a fledgling newbie that has a rough understanding of the coding in eduke. Sorry if I should've put this somewhere else.

Basically I want to flesh out the melee combat in duke, and I've looked through the wiki, and FAQ's, and asked around a bit (over PM's, which might've been a mistake), and what I've gathered is that adding new melee attacks/weapons involves defining new projectiles. That makes sense to me, and I've learned how to make certain 'types' of new projectiles, but doing it with melee is kind of throwing me off, and I'm still left with a lot of questions.

A) Is the actual animation for the attack carried out through the defineprojectile commands, and if so, how do you string them all together (since someone swinging a sword is pretty clearly going to involve more than just one tile)? Are there any limitations to the number of tiles?

B) Other than what the weapon shoots, what other changes have to be done to the weapon in order for it to sync up properly with the projectile? Assuming that I'm right about the projectile command governing the attacking tiles (and I'm probably not, but for all intents and purposes...), doesn't that mean you'd have to delete the original weapon tiles altogether?

C) If I get the melee attack working the way I want, are there ways to vary how you attack with said weapon? Like the attack key combined with certain directional keys produces a different animation, or pressing the attack key in a certain sequence produces a sort of combo involving different animations (like the warrior's fist attacks in Hexen)?

Any help I can get on this would be greatly appreciated, and I'm hoping nobody's going to think I haven't given this stuff a shot. I have tried it, and had success with other less important things, and like I said, I kind of know how to go about doing it, but I really need somebody to help me connect the dots. As it is right now, I just feel like I'm blindly fumbling around with it, and I really want to understand it.
EmericaSkater is offline  
Old 02-10-2009, 09:25 AM   #2
XTHX2

XTHX2's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
Okay, so this post is the result of a fledgling newbie that has a rough understanding of the coding in eduke. Sorry if I should've put this somewhere else.

Basically I want to flesh out the melee combat in duke, and I've looked through the wiki, and FAQ's, and asked around a bit (over PM's, which might've been a mistake), and what I've gathered is that adding new melee attacks/weapons involves defining new projectiles. That makes sense to me, and I've learned how to make certain 'types' of new projectiles, but doing it with melee is kind of throwing me off, and I'm still left with a lot of questions.

A) Is the actual animation for the attack carried out through the defineprojectile commands, and if so, how do you string them all together (since someone swinging a sword is pretty clearly going to involve more than just one tile)? Are there any limitations to the number of tiles?

B) Other than what the weapon shoots, what other changes have to be done to the weapon in order for it to sync up properly with the projectile? Assuming that I'm right about the projectile command governing the attacking tiles (and I'm probably not, but for all intents and purposes...), doesn't that mean you'd have to delete the original weapon tiles altogether?

C) If I get the melee attack working the way I want, are there ways to vary how you attack with said weapon? Like the attack key combined with certain directional keys produces a different animation, or pressing the attack key in a certain sequence produces a sort of combo involving different animations (like the warrior's fist attacks in Hexen)?

Any help I can get on this would be greatly appreciated, and I'm hoping nobody's going to think I haven't given this stuff a shot. I have tried it, and had success with other less important things, and like I said, I kind of know how to go about doing it, but I really need somebody to help me connect the dots. As it is right now, I just feel like I'm blindly fumbling around with it, and I really want to understand it.
A) Yes you can, see weaponcount. It is as much as the value of, TOTALTIME of a weapon, the frame amount.

You can't put animation of weapons with just defineprojectile, it needs more work than just that.

B) See FIREDELAY for making it fire on the right frame.

C) Yes you can have varieties, and most likely make fighter's punch and even the knockback for it, but you need some extra work, I say try to get yourself a working punch first, mainly base it around with something like Doom's fist; then add more complexity to it.
XTHX2 is offline  
Old 02-10-2009, 10:02 AM   #3
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Thanks for the help, I went ahead and got the animations for the Doom punch from an old mod to work with your suggestion. A few quick questions before I try to work on it; if I'm trying to replace an existing weapon, I've noticed that the majority of the Duke weapons have one tile for your character holding the weapon, then separate tiles for shooting, and those tiles only cover the tip of the weapon, while the initial tile remains the same. That's fine for a ranged weapon, but it won't work out with the Doom punch (or any other melee attack, probably). Is that hard-coded, or is there anyway to change it? I wanna say that it could just be done by changing the definition for the weapon you want to replace in the defs.con, but it probably isn't that easy.

I'd never heard of weaponcount before, but I read old FAQ's over eduke (which explicitly stated that the number of frames in a weapon animation couldn't be changed) so it's not too surprising that it's not familiar. It's a gamevar, so would I set it up like this?

gamevar weaponcount <weapon number> <number of tiles>

sorry if that's not right or completely off the mark.

Also, if projectiles don't determine tiles in the weapon animation, then what are they capable of changing for a melee attack? Just the range? Because it seems like anything else you'd need could be done by changing the values for that specific weapon.

I also know what you mean about the attack variations. I'm trying to take it all in stride, so those changes will come when I'm good and ready for them, but I figured I'd go ahead and ask right of the bat.

Again thanks a lot for taking the time to help me out. Because it's looking like I'm really gonna need it.
EmericaSkater is offline  
Old 02-10-2009, 10:18 AM   #4
XTHX2

XTHX2's Avatar
Re: Help on melee fighting
See EVENT_DISPLAYWEAPON and the whole event list, read the whole wiki and then ask (or better, search there first)

You check the weapon counts value in order to display something on screen, see rotatesprite.
Last edited by XTHX2; 02-10-2009 at 10:21 AM.
XTHX2 is offline  
Old 02-26-2009, 12:34 PM   #5
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Alright after a long struggle I've finally figured out how to move around/add new frames to the weapon tiles, so the basic part is knocked out. Now I'm trying to figure out how to vary the attacks by combing the fire button with certain other keys. I was hoping one thing I could do would be to combine fire with the strafing buttons, but I think that'd have to be done through the event list, and the different animations must be added through the display weapon event, if I'm correct, so what I 'want' to do probably isn't possible.
Right now I've got a somewhat sloppy code involving ifp commands that still needs alot of touching up before it looks good, but now I'm wondering if there's another way to go about doing this.
So question is as follows; is the display weapon event the ONLY way to get different tiles for weapon attacks to show up and if it is, have I overlooked something in regards to getting it to work with things other than ifp commands?

...And before anybody tells me to, I've already read the wiki.
EmericaSkater is offline  
Old 02-26-2009, 01:02 PM   #6
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
There are various display events which can be used to display tiles on the screen, including DISPLAYWEAPON, DRAWWEAPON (not sure what the difference between those is, but I always use the second one) and DISPLAYREST.

So that answers the question you asked, but I don't see how it helps you, because adding new animations should have nothing to do with using more than one display event.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 02-26-2009, 01:56 PM   #7
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Yeah, I guess I should have phrased the question a bit more clearly. Basically Iwant to get a different attack animation with the same weapon by combining the fire key with either of the strafe keys. To the best of my knowledge, the only way to get that animation onto the screen is through an event (any of the events you mentioned, apparently) BUT the only way to get the strafing called in as well is ALSO through an event (event_strafeleft/right), and it says right there on the wiki that events are accessed only through the onevent command. So I was wondering if there was any way to call in the strafe key without using an event, or if there was someway to call in an event inside another event (?) Sorry if it's still awkwardly worded.

I've also just now noticed that, though my sloppy ifp command code works insofar as getting the alternate animation to show up, the original idle animation I have at the other end of the screen is still sitting there. Not quite sure how to get it to go away.
EmericaSkater is offline  
Old 02-26-2009, 02:15 PM   #8
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
You can collect input data and put it into a variable, then you can check the variable in the player code. It is similar using ifhitspace, but you would be checking the strafing keys or any others you like.

http://wiki.eduke32.com/wiki/Bits
http://wiki.eduke32.com/wiki/Extbits

You grab the input data like this:

Code:
 
gamevar bits 0 1
gamevar extbits 0 1
 
onevent EVENT_PROCESSINPUT
 
getinput[THISACTOR].bits bits
getinput[THISACTOR].extbits extbits
 
endevent
Then in the player code, you can check the input bits with ifvarand (which is true when the specified bit is on).

for example:

Code:
 
ifvarand bits 1 ifvarand extbits 4
{
   quote 125
}
^that code will cause quote 125 to display when the player presses jump and strafe left simultaneously.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 02-26-2009, 02:15 PM   #9
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Thank you, thank you, THANKYOU

...and now for the next (and hopefully/probably 'last') problem. The alternate attack works, but somethings up with the frames for the two seperate attacks getting tangeled up with eachother.





the sword on the left is the normal attack, about halfway through. The sword on the right is the same, but for the alternate attack. I've looked through the code, and can't figure out where it's going wrong. Both of the attacks are in seperate states, and the displayweapon event has specific circumstances for how the animations show. Here's the state for the normal attack (which replaces weapon 0, the foot)

"state displayblade
switch weaponcount
case 0
setvar xweapon 270
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 230
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 0
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 1
case 2
case 3
case 4
setvar xweapon 250
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 225
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 1
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 5
case 6
case 7
case 8
setvar xweapon 230
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 220
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 2
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 9
case 10
case 11
case 12
setvar xweapon 210
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 215
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 3
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 13
case 14
case 15
case 16
setvar xweapon 190
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 210
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 4
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 17
case 18
case 19
case 20
setvar xweapon 170
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 205
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 5
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 24
setvar xweapon 150
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 200
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 6
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
endswitch
ends
"

then the state for the alternate attack

"state cleavesword
switch weaponcount
case 0
setvar xweapon 275
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 250
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 11
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 1
case 2
case 3
case 4
setvar xweapon 260
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 250
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 11
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 5
case 6
case 7
case 8
setvar xweapon 255
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 235
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 12
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 9
case 10
case 11
case 12
setvar xweapon 252
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 230
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 13
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 13
case 14
case 15
case 16
setvar xweapon 249
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 225
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenum 14
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 17
case 18
case 19
case 20
setvar xweapon 245
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 220
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenum 15
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
endswitch
ends
"

then the event that calls them...

"onevent EVENT_DISPLAYWEAPON

ifvare currentweapon 0
{
setvar RETURN -1
{ state displayblade }
}
ifvarand bits 4 ifvarand extbits 4
{ state swingswordright }
ifvarand bits 4 ifvarand extbits 1
{ state cleavesword }


endevent
"


...The only thing I can figure is that the fire key is getting them tangeled up somewhere, but I'm not sure how and if there's anything I could do about it. Would I just have to nix the fire key altogether? I've noticed when I hold the key down more of the alternate animation comes onto the screen which is...odd...
Last edited by EmericaSkater; 02-26-2009 at 03:39 PM.
EmericaSkater is offline  
Old 02-27-2009, 08:32 AM   #10
XTHX2

XTHX2's Avatar
Re: Help on melee fighting
What is swingswordright state? Also, put your code in code tags like this.

Code:
Example.
EDIT : The problem is that if you use normal attack, it will work because displayblade state needs no condition (Nothing special than the other states) However, since you haven't done that, whenever you use alternate, it will also display the normal attack along with the alternative. You should check if the player is firing or not AND if the player is using alt fire or not. (I'm not entirely sure, I don't have time to read the rest.)
Last edited by XTHX2; 02-27-2009 at 08:35 AM.
XTHX2 is offline  
Old 02-27-2009, 10:21 AM   #11
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Nix that, that one little tip you gave helped me figure it out.
EmericaSkater is offline  
Old 02-28-2009, 02:26 PM   #12
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Everything's going swimmingly now, so this is more a curiosity question than anything else; when i hold the attack button down, the alternate animation plays completely through. That's how I want it, so I'm not bothered, I'm just wondering why it does that automatically.
EmericaSkater is offline  
Old 02-28-2009, 03:53 PM   #13
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
Everything's going swimmingly now, so this is more a curiosity question than anything else; when i hold the attack button down, the alternate animation plays completely through. That's how I want it, so I'm not bothered, I'm just wondering why it does that automatically.
Assuming that your current code resembles what you posted above, that's because weaponcount continues to increment automatically once the weapon is fired, regardless of whether you are still holding the key or which frames are being displayed.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 02-28-2009, 10:39 PM   #14
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Ah, so to adjust that I'd just have to set weaponcount equal to the number of frames I have set aside for the attack in the event that calls it, right? Or would I have mess around with it's kickback pic? For this attack, it doesn't really matter to me, but I'm thinking if I wanted to make the same effect for a ranged sort of attack, it'd probably be better to have the whole animation play with one press of the fire button rather than holding it down.
EmericaSkater is offline  
Old 02-28-2009, 11:15 PM   #15
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
Ah, so to adjust that I'd just have to set weaponcount equal to the number of frames I have set aside for the attack in the event that calls it, right? Or would I have mess around with it's kickback pic? For this attack, it doesn't really matter to me, but I'm thinking if I wanted to make the same effect for a ranged sort of attack, it'd probably be better to have the whole animation play with one press of the fire button rather than holding it down.

I can tell you're struggling with some stuff, and maybe this will help.

The kickback_pic member of the player struct holds the current weapon frame. Actually, "frame" is misleading, because there need not be different pics displayed for each one. Kickback_pic is used as a counter that starts at 1 when the weapon fires and goes up to the TOTALTIME of the weapon. Kickback_pic will continue to increment automatically, and then will return to 0 (exception: certain weapons do not return to 0 if you hold down the fire key, they continue to cycle between the middle and end of the sequence). Here's another fun fact about kickback_pic: you can force a weapon to fire by setting it to 1, even if the player hasn't pressed the fire key (maybe you knew that already). This bring us to weaponcount: weaponcount is similar to kickback_pic, but it's a gamevar used for display purposes (do NOT use it outside of display events).
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 03-01-2009, 07:29 AM   #16
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Hah, fledgling newbie, like I said. I'm just hoping the questions aren't irritating you guys, but I've read the wiki and gone through the faqs and all that good stuff, so when I can't figure something out, going to the forums is pretty much the only thing I can do. But hey, I've figured some stuff out on my own! I've gotten this far, right? (Opptomist...)

I actually did understand the kickback's function to an extent, but I didn't know that you could force a weapon to fire with it. But honestly, now that you've explained that, things are like, three times as confusing now. You said the problem was due to weaponcount incrementing automatically, so I'd pretty much have to work within the state I set for the weapon display right? Does kickback even have anything to do with it? At first the glitch didn't bother me too much, but now that I study it a bit more closely, I've notcied that hiting the fire button once (not holding it) makes the first tile for the alternate attack appear then stop, which makes the whole thing appear wonky and inconsistent. It'll still work if I hold it, but I'd rather know what's going on and how to fix it. But yeah, the code is pretty much the same, so I'm figuring I have to change something in the state or in my event...
EmericaSkater is offline  
Old 03-01-2009, 09:20 AM   #17
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
Hah, fledgling newbie, like I said. I'm just hoping the questions aren't irritating you guys, but I've read the wiki and gone through the faqs and all that good stuff, so when I can't figure something out, going to the forums is pretty much the only thing I can do. But hey, I've figured some stuff out on my own! I've gotten this far, right? (Opptomist...)

I actually did understand the kickback's function to an extent, but I didn't know that you could force a weapon to fire with it. But honestly, now that you've explained that, things are like, three times as confusing now. You said the problem was due to weaponcount incrementing automatically, so I'd pretty much have to work within the state I set for the weapon display right? Does kickback even have anything to do with it? At first the glitch didn't bother me too much, but now that I study it a bit more closely, I've notcied that hiting the fire button once (not holding it) makes the first tile for the alternate attack appear then stop, which makes the whole thing appear wonky and inconsistent. It'll still work if I hold it, but I'd rather know what's going on and how to fix it. But yeah, the code is pretty much the same, so I'm figuring I have to change something in the state or in my event...
I made a rather complicated melee weapon before, which was a sword that had five different strikes. When you're doing something like that, it's best to do it from scratch and bypass the hardcoded stuff entirely. That means you don't make it a weapon at all. Make your own counter with a gamevar, initiate the counter to different numbers when the player presses certain key combinations, then make the counter increment and display the appropriate frames depending on the counter. You can have your code check to see if the counter is at certain numbers and then switch to other numbers depending on what the player is pressing. Make the player actor shoot KNEE multiple times or your own custom projectile when the counter is at certain numbers. That way you don't have to worry about hardcoded stuff with kickback_pic or the weapon flags etc; you are in complete control.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 03-01-2009, 09:31 AM   #18
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
You said you made a sword too? I'd definately be interested in seeing that if you still had it, if nothing else just to see what it's like in-game...

Nixing the hard-coded stuff sounds appealing, but sort of intimidating at the same time. If I were to do that, would I set the animations up in an event still? I'd hate to ask you to walk me through this, but honestly, that's a pretty foreign concept to me.
EmericaSkater is offline  
Old 03-07-2009, 11:02 AM   #19
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Quote:
certain weapons do not return to 0 if you hold down the fire key, they continue to cycle between the middle and end of the sequence
Okay, I've looked at it closer in-game and this is definately the problem, but for the life of me I can NOT figure out how to fix it! I've been picking at it for upwards of a week and absolutely no luck. Here's my code for the alternate attack's state

Code:
 state cleaveblade
switch weaponcount
case 0
setvar xweapon 258
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 200
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 0
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 1
case 2
setvar xweapon 260
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 250
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 11
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 3
case 4
setvar xweapon 255
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 235
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 12
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 5
case 6
setvar xweapon 252
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 230
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
setvar tilenumweapon SWORD
addvar tilenumweapon 13
ifvare weaponcount 6 break
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
endswitch
ends
the ifvare at the bottom was my latest attempt to handle it which did essentially nothing. I've noticed that if I take the firing condition out of my display event (ie bits 4) and leave the extbits by itself everything works perfectly. The problem with this is that doing that forces me to take the projectile I have the alternate attack shoot out of the code, since walking shoots it. This is the display event code...

Code:
ifvare currentweapon 0
ifvarand extbits 1 ifvarand bits 4
{
  state cleaveblade
  shoot MELEEHIT
  }



..and so on so forth. I've seriously hit a wall, here. What the heck am I doing wrong?
EmericaSkater is offline  
Old 03-08-2009, 04:04 PM   #20
XTHX2

XTHX2's Avatar
Re: Help on melee fighting
I didn't really get what your problem is... maybe I'm just too dumb <.<

Quote:
Here's another fun fact about kickback_pic: you can force a weapon to fire by setting it to 1, even if the player hasn't pressed the fire key (maybe you knew that already).
Great! I didn't know about that
XTHX2 is offline  
Old 03-08-2009, 10:15 PM   #21
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Well, I actually got it working the way I want just now Remember those alternate melee attacks we talked about way earlier in the thread? Basically when I started putting them in, something weird happened in the attacks that required the fire button (ifvarand bits 4) where only tapping the attack button once would only show the first frame, but holding it down would repeat the middle of the attack animation. I found a work-around to it earlier this morning though by taking the firing command out of the displayweapon event, and moving my shoot command (which shot the projectile that would make the alternate attack do more damage) to the state which actually 'displayed' the attack. It works like a charm now.
EmericaSkater is offline  
Old 03-08-2009, 11:26 PM   #22
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
I'm not sure why that worked for you, but in general you shouldn't have anything that changes the game world (such as shooting a projectile) occuring in a display event or in a state called by it. In some cases, changing the game world in a display event is a necessary evil in order to achieve certain effects, but it breaks multiplayer. Also, shooting something in a display event sounds like it would risk having the timing and/or quantity of the shots depend on your framerate (although it depends on how it is coded).

One solution to your kickback_pic progression problem would be to change the flags in the workslike value of the weapon that is being fired during your melee attacks. But the solution I prefer, (as I mentioned several posts ago) is to forego using a real weapon like that and code your melee attacks from scratch. Maybe you don't know what I mean by that.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 03-09-2009, 11:15 AM   #23
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Quote:
Maybe you don't know what I mean by that.
Not quite, but I asked you, because I actually 'was' genuinely curious to know how I could go about doing that. And you never answered. I also tried changing the weapon's flag to four (automatic) because I thought it was refering to automatically reseting the pic to 0, but nothing changed. I still had the same problem. If you'd like to help me figure it out with either of the two things you mentioned, you already know you're totally welcome
EmericaSkater is offline  
Old 03-09-2009, 11:19 AM   #24
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by DeeperThought View Post
I made a rather complicated melee weapon before, which was a sword that had five different strikes. When you're doing something like that, it's best to do it from scratch and bypass the hardcoded stuff entirely. That means you don't make it a weapon at all. Make your own counter with a gamevar, initiate the counter to different numbers when the player presses certain key combinations, then make the counter increment and display the appropriate frames depending on the counter. You can have your code check to see if the counter is at certain numbers and then switch to other numbers depending on what the player is pressing. Make the player actor shoot KNEE multiple times or your own custom projectile when the counter is at certain numbers. That way you don't have to worry about hardcoded stuff with kickback_pic or the weapon flags etc; you are in complete control.
Quote:
Originally Posted by EmericaSkater View Post
Not quite, but I asked you, because I actually 'was' genuinely curious to know how I could go about doing that. And you never answered.
Why do you say I never answered, when in fact I did a pretty good job of explaining what I meant when I first suggested it?
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 03-09-2009, 11:40 AM   #25
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Quote:
You said you made a sword too? I'd definately be interested in seeing that if you still had it, if nothing else just to see what it's like in-game...

Nixing the hard-coded stuff sounds appealing, but sort of intimidating at the same time. If I were to do that, would I set the animations up in an event still? I'd hate to ask you to walk me through this, but honestly, that's a pretty foreign concept to me.
My post verbatim. To argue semantics, I say you never answered because you never answered. You never responded to that post. And yeah, you went in depth in the initial post, but I didn't even know how you could GET something to work like a weapon without it actually being a weapon, so I needed something more in-depth. Sorry if it seems like I'm asking for too much hand-holding or something, but I really don't know what else to say. I just happened to get lucky and have lightbulb go off one day while I was reading the code for NS to figure out how weaponcount and the displayweapon event actually worked together. It's exactly like I said way earlier, I've read the wiki, I continue to read the wiki first whenever I have a problem, but the wiki doesn't always connect the dots, and who knows, maybe it shouldn't. Maybe you need to have the cojones to ask a dumb question, or a huge favor every now and again for something to get done.
EmericaSkater is offline  
Old 03-09-2009, 12:32 PM   #26
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
To answer the question you quoted: You would still use a display event to display the animation. The main difference is you would be displaying the frames based on your own counting variable, instead of using weaponcount. You can set the variable to any number you want, depending on what the player is doing. You can make it start at 1 when pressing a certain key and then count up, or whatever you want.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 03-09-2009, 02:26 PM   #27
Plagman

Plagman's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
It's exactly like I said way earlier, I've read the wiki, I continue to read the wiki first whenever I have a problem, but the wiki doesn't always connect the dots, and who knows, maybe it shouldn't. Maybe you need to have the cojones to ask a dumb question, or a huge favor every now and again for something to get done.
Keep in mind that you're encouraged to contribute to the wiki to make it connect the dots after you've got the answer you needed from the community. Do it!
__________________
EDuke32 - "The corrupt doctrine of terror has begun."
Plagman is offline  
Old 03-10-2009, 02:15 AM   #28
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Muy bien, how it displayed was one of the things that really threw me off. But at this going rate, does this mean there isn't going to be an idle animation for the attack if it isn't technically a weapon, or am I just initiating the counter to different values when the player is standing and walking? If the player 'is' walking, how would I retain the weapon sway for an idle animation? Are the weapon xoffset, lookingang and gunpos commands still applicable to something that isn't a weapon? Sorry for asking all the questions, but I'm only doing so because you've piqued my curiosity.

Quote:
Keep in mind that you're encouraged to contribute to the wiki to make it connect the dots after you've got the answer you needed from the community. Do it!
Once I'm confident that I understand this stuff a wee bit better, I'll definately look into that.
EmericaSkater is offline  
Old 03-10-2009, 06:06 PM   #29
Hendricks266
Re: Help on melee fighting
I tried to completely recode all of the weapons for my old mod, but I never got to the swaying and bobbing. Your best bet is to port code out of the source. I do know that you have to do something with the hardcoded, constantly updated variables looking_angSR1 and gun_pos, as the game automatically changes them for the bobbing and swaying, and also disables it when the menu option for it is turned off.
Hendricks266 is offline  
Old 04-09-2009, 08:28 AM   #30
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
okay, I'm finally fed up trying to screw around with hardcoded crap in the player structure to get my melee stuff to work, so I took DT's suggestion and started working on a way to get it to work through my own variables. I got the first part knocked out by disabling the original function for WEAPKEY1 and setting one of my own varaibles to a particular value when that key is pressed, so the game will know it's armed. I used the DRAWWEAPON event to display the idle animation. I got that working the way I wanted it to, so now I'm trying to get the attacking animation to work when you press the fire button, and that brought me to the next level of confusion; I'm not sure how I should go about getting the tiles to play in the appropriate sequence. Should I just animate them through Dukeres, then try to find a way to make it stop once it hits the last tile? Or am I supposed to supposed to use ifcount commands in my gamevars so they'll work in tandem with what I've got in the display event? DT, you said that I'm supposed to use my own counters to get it to increment, so does that mean I'm just using addvar commands and if so, how do I control how fast it goes?
If I can just figure out how to get the attack to animate, I'm sure I can string the rest of this stuff together...
EmericaSkater is offline  
Old 04-09-2009, 09:00 AM   #31
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
I'm not sure how I should go about getting the tiles to play in the appropriate sequence. Should I just animate them through Dukeres, then try to find a way to make it stop once it hits the last tile?
I don't recommend that, because it helps to have total control of how the frames are displayed.

Quote:
Originally Posted by EmericaSkater View Post
Or am I supposed to supposed to use ifcount commands in my gamevars so they'll work in tandem with what I've got in the display event?
Something like that.

Quote:
Originally Posted by EmericaSkater View Post
DT, you said that I'm supposed to use my own counters to get it to increment, so does that mean I'm just using addvar commands and if so, how do I control how fast it goes?
If you addvar counter 1 in the player code, then the counter will increment once per game tic. There are 26 tics per second. Then you can make the desired frame display based on the counter. There are several ways to do that. One way would be to make a another variable (example):

gamevar counter 0 1
gamevar meleepic 0 1

Then, in the player code:

Code:
 
ifvarg counter 0 // counter got set to 1 when you started the attack
{
   switch counter
   case 1 case 2 setvar meleepic 3460 break // or whatever the first frame is
   case 3 case 4 setvar meleepic 3461 break
   // etc
   endswitch
   addvar counter 1
   ifvarg counter 26 setvar counter 0
}
Finally, in the display event, if the counter is nonzero you use rotatesprite and display the meleepic tile.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 04-10-2009, 07:40 AM   #32
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Alright, I'm that much closer to getting this figured out. First expiriment was largely following the example you gave, wherein I made two new gamevars, FISTPIC and COUNTER, then put this into the player code...
=
Code:
ifvare FISTARMED 1 
{
ifvarand bits 4 
{ setvar COUNTER 1 }


ifvarg COUNTER 0 
{ switch COUNTER
  case 1
  case 2
  setvar FISTPIC 3665
  break
  case 3 
  case 4 
  setvar FISTPIC 3666
  case 5
  case 6
  setvar FISTPIC 3667
  endswitch
 
 }
Since I'm gleaning that the case arguments mean game tics, I put the following code in my DRAWWEAPON event

Code:
ifvare FISTARMED 1
{
ifvarg COUNTER 0
{
ifvare COUNTER 2 { rotatesprite 166 195 65536 0 FISTPIC 0 0 0 0 0 xdim ydim }
ifvare COUNTER 4 { rotatesprite 166 195 65536 0 FISTPIC 0 0 0 0 0 xdim ydim }
...and so on so forth, for all of the animations I had in the attack. Unfortunately, it didn't appear to do anything. If anything I'm figuring it's something I messed up in the display event. So, I tried another method, since I was more familiar with weaponcount, I put in a switch command that still involved my own gamevar, put it into a state, then called that state from within my display event.

This was the state

Code:
state swingfist
switch COUNTER
case 0
setvar xweapon 165
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 195
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
ifvare hudtype 1 { addvarvar yweapon 31 }
setvar tilenumweapon 3664
addvar tilenumweapon 1
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 1
case 2
case 3
case 4
setvar xweapon 185
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 210
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
ifvare hudtype 1 { addvarvar yweapon 31 }
setvar tilenumweapon 3664
addvar tilenumweapon 2
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
case 5
case 6
case 7
case 8
setvar xweapon 200
addvarvar xweapon weapon_xoffset
subvarvar xweapon looking_angSR1
setvar yweapon 220
addvarvar yweapon looking_arc
subvarvar yweapon gun_pos
ifvare hudtype 1 { addvarvar yweapon 31 }
setvar tilenumweapon 3664
addvar tilenumweapon 3
myospal xweapon yweapon tilenumweapon gs orientationweapon palweapon
break
endswitch
addvar COUNTER 1
ifvarg COUNTER 26 setvar COUNTER 0
ends
the display code for it looked similiar to the other, only rather than have a rotate sprite command for each frame, I simply called the state if the counter variable was greater than zero. This worked insofar as getting something onto the screen, but it was only the first frame, it didn't animate and it kind of appeared to be stuck there. Any ideas on where I could of gone wrong with this?
EmericaSkater is offline  
Old 04-16-2009, 10:24 PM   #33
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
Well, it looks really nice now. I even threw in some extra variables to keep track of what sequence it's pressed in so it will display an extra attack when the button is pressed a second or third time. One question though, is there any hard-coded way to tell the game whether or not the button is being held or pressed? Because I've noticed that if the attack button is held it stays on the first tile, and if it's pressed too rapidly, it'll skip the other animations based on what sequence the button is pressed in...
Last edited by EmericaSkater; 04-17-2009 at 01:32 PM.
EmericaSkater is offline  
Old 04-16-2009, 11:50 PM   #34
DeeperThought

DeeperThought's Avatar
Re: Help on melee fighting
Quote:
Originally Posted by EmericaSkater View Post
One question though, is there any hard-coded way to keep tell the game whether or not the button is being held or pressed?
You can tell whether a button is being pressed at any particular moment by checking the relevant input bit, as I showed you earlier. If you want to know whether a button is being held down (i.e. whether the pressed button was also pressed during the previous tic) then you need to add some more code to make that determination. The way I do it is like this: when the player presses the button, I mark the time of the press by putting the elapsed game time (player_par) into a variable, then add 1 to it. On the next button detection (i.e. every button detection), if the button is pressed and the time stored in the variable (prior to the variable being updated) is equal to the current elapsed time, then the button is being held.
__________________
DUKE PLUS
New map effects and various optional extras for Duke 3D.

DUKE NUKEM: ATTRITION
XP based weapon upgrades, progressive difficulty, and more.
DeeperThought is offline  
Old 04-17-2009, 03:41 PM   #35
EmericaSkater

EmericaSkater's Avatar
Re: Help on melee fighting
I can't possibly thank you enough, DT. It's friggen gorgeous now!
EmericaSkater is offline  
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 12:22 PM.

Page generated in 0.21984601 seconds (100.00% PHP - 0% MySQL) with 18 queries

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

Website is ©1987-2014 Apogee Software, Ltd.
Ideas and messages posted here become property of Apogee Software Ltd.