K_Doom Posted October 14, 2022 (edited) My question today is simple: just as the "Fist" weapon is affected by the Berserk powerup, I also want the "Knife" weapon to be affected (increase damage after collecting Berserk). I tried two ways but got no result. How do I do that? Edited October 16, 2022 by K_Doom edit 0 Quote Share this post Link to post
jaeden Posted October 14, 2022 You could post what you tried, so we can see what went wrong there. 1 Quote Share this post Link to post
SMG_Man Posted October 14, 2022 The way that the Berserk powerup works in ZDoom is that it gives you a sort of token ("PowerStrength"), and whenever the A_Punch function is called, if it's present it multiplies the damage by 10. Note that A_Punch has no parameters (unlike A_CustomPunch or other options), since it's the exact action special that the original fist uses. So you have a few choices here: • call A_Punch multiple times and let its inherent "PowerStrength" check do the work for you (your knife attacks will sound exactly like the fist though). This takes the least work. • mimic the original Berserk's behavior by manually putting in a check for "PowerStrength" and modify the behavior of the weapon accordingly. This takes a bit more work. • Rework the Berserk powerup to instead be a damage-amplifying powerup that only affects a specific type of damage ("Melee" for example). This would take the most work. For example, in one of my WADs I put in a knife and an axe that are affected by the Berserk powerup using the second option. Here's the relevant code from the knife: Fire: KNFG A 2 KNFG B 2 TNT1 A 0 A_JumpIfInventory("PowerStrength", 1, "Berserked") Normal: KNFG C 4 A_CustomPunch (random(15,25),1,0,"KnifePuff", 72) Goto FireEnd Berserked: KNFG C 4 A_CustomPunch (random(35,70),1,CPF_PULLIN,"KnifePuff", 72) FireEnd: KNFG D 2 KNFG E 2 KNFG F 2 KNFG E 2 KNFG A 2 A_ReFire("Fire") goto Ready When you attack with the knife, the first two frames of animation play as normal. Before going to the third frame (where the attack actually deals damage), the game checks whether you have the "PowerStrength" token from a Berserk pack - if you do, it will perform the more powerful "berserked" attack; if not, it will continue to the "normal" attack. After that point, both are directed to the FireEnd sequence, which is just the rest of the attack animation. Hopefully this helps with your endeavors. 1 Quote Share this post Link to post
K_Doom Posted October 15, 2022 On 10/14/2022 at 5:12 AM, jaeden said: You could post what you tried, so we can see what went wrong there. First I thought of adding this code that is commenting, just below the knife code. It didn't work, obviously haha Then I tried adding this new line in the knife code, but it doesn't work. 0 Quote Share this post Link to post
jaeden Posted October 15, 2022 It should be A_JumpIfInventory function, not A_JumpIfInTargetInventory (the latter checks inventory of your target, not your inventory). If you want to alter the custom punch, then you should probably call that before the actual punch. Also I dont see any "SmoothBerserk" state there. The "KnifeBerserk" actor seems right to me. 0 Quote Share this post Link to post
K_Doom Posted October 15, 2022 8 minutes ago, jaeden said: It should be A_JumpIfInventory function, not A_JumpIfInTargetInventory (the latter checks inventory of your target, not your inventory). If you want to alter the custom punch, then you should probably call that before the actual punch. Also I dont see any "SmoothBerserk" state there. The "KnifeBerserk" actor seems right to me. The "smoothberserk" refers to a new sprite that replaces the normal berserk and was assigned to the smooththfist first. So I used the same actor to also assign the knife. It is identical to the original berserk, the only difference being its attribution to the new fist actor. 0 Quote Share this post Link to post
K_Doom Posted October 16, 2022 On 10/14/2022 at 1:31 PM, SMG_Man said: The way that the Berserk powerup works in ZDoom is that it gives you a sort of token ("PowerStrength"), and whenever the A_Punch function is called, if it's present it multiplies the damage by 10. Note that A_Punch has no parameters (unlike A_CustomPunch or other options), since it's the exact action special that the original fist uses. So you have a few choices here: • call A_Punch multiple times and let its inherent "PowerStrength" check do the work for you (your knife attacks will sound exactly like the fist though). This takes the least work. • mimic the original Berserk's behavior by manually putting in a check for "PowerStrength" and modify the behavior of the weapon accordingly. This takes a bit more work. • Rework the Berserk powerup to instead be a damage-amplifying powerup that only affects a specific type of damage ("Melee" for example). This would take the most work. For example, in one of my WADs I put in a knife and an axe that are affected by the Berserk powerup using the second option. Here's the relevant code from the knife: Fire: KNFG A 2 KNFG B 2 TNT1 A 0 A_JumpIfInventory("PowerStrength", 1, "Berserked") Normal: KNFG C 4 A_CustomPunch (random(15,25),1,0,"KnifePuff", 72) Goto FireEnd Berserked: KNFG C 4 A_CustomPunch (random(35,70),1,CPF_PULLIN,"KnifePuff", 72) FireEnd: KNFG D 2 KNFG E 2 KNFG F 2 KNFG E 2 KNFG A 2 A_ReFire("Fire") goto Ready When you attack with the knife, the first two frames of animation play as normal. Before going to the third frame (where the attack actually deals damage), the game checks whether you have the "PowerStrength" token from a Berserk pack - if you do, it will perform the more powerful "berserked" attack; if not, it will continue to the "normal" attack. After that point, both are directed to the FireEnd sequence, which is just the rest of the attack animation. Hopefully this helps with your endeavors. I tried this second method you mentioned, but I'm not sure if it worked as at no time was the Imp (test monster) gibbed with knife blows. Not to mention that the knife is much more powerful than the fist, killing imps with 2 or 3 attacks, while fists need 6. But in berserk mode both have the same effectiveness.here is the code 0 Quote Share this post Link to post
SMG_Man Posted October 16, 2022 (edited) Okay, so it's good to know what the parameters for the function (A_CustomPunch) do. The first one is of course the damage value, and the second one is the "NoRandom" boolean. When set to 1, the "NoRandom" parameter tells the game to not apply the default randomizing spread for melee damage to the damage dealt by the attack (in this case, a value between 1 and 8); when it's set to 0, this random spread is applied. So let's quickly compare the actual damage ranges for the two different strengths of the knife attack: • In the "Normal" state, the attack has a base damage value of 6, and it uses the default random spread, so it will deal between 6 and 48 damage, in multiples of 6. • In the "Berserked" state, the attack has a base damage value of any integer between 35 and 70, and the default random spread is not applied. Therefore, at current there is an overall increase in the damage, but not by much. And also, in order to reliably gib Imps, the knife would need to be able to deal around 90 or so damage in a single hit. If you want the Berserk pack to confer the same 10x damage multiplier to the knife that it does to the fists, then you'll need to change the "Berserked" state's CustomPunch parameters to something more like this: KNFG C 4 A_CustomPunch (60, 0, CPF_PULLIN, "KnifePuff", 72) With the above replacement made to the Berserked state, the attack will deal between 60 and 480 damage, in multiples of 60. This will allow the berserked knife to potentially OHKO any enemy with less health than a Hell Knight, and it will always OHKO Imps and weaker enemies. Edited October 16, 2022 by SMG_Man 1 Quote Share this post Link to post
K_Doom Posted October 16, 2022 1 hour ago, SMG_Man said: Okay, so it's good to know what the parameters for the function (A_CustomPunch) do. The first one is of course the damage value, and the second one is the "NoRandom" boolean. When set to 1, the "NoRandom" parameter tells the game to not apply the default randomizing spread for melee damage to the damage dealt by the attack (in this case, a value between 1 and 8); when it's set to 0, this random spread is applied. So let's quickly compare the actual damage ranges for the two different strengths of the knife attack: • In the "Normal" state, the attack has a base damage value of 6, and it uses the default random spread, so it will deal between 6 and 48 damage, in multiples of 6. • In the "Berserked" state, the attack has a base damage value of any integer between 35 and 70, and the default random spread is not applied. Therefore, at current there is an overall increase in the damage, but not by much. And also, in order to reliably gib Imps, the knife would need to be able to deal around 90 or so damage in a single hit. If you want the Berserk pack to confer the same 10x damage multiplier to the knife that it does to the fists, then you'll need to change the "Berserked" state's CustomPunch parameters to something more like this: KNFG C 4 A_CustomPunch (60, 0, CPF_PULLIN, "KnifePuff", 72) With the above replacement made to the Berserked state, the attack will deal between 60 and 480 damage, in multiples of 60. This will allow the berserked knife to potentially OHKO any enemy with less health than a Hell Knight, and it will always OHKO Imps and weaker enemies. I tested this solution and it really works, now monsters like imp die in a single hit. The strange thing is that they are never "gibbed", even in berserk mode. I turned the Berserked mode damage to 1480, and all that happens is the Imp flying away (standard high kickback when taking too much damage), but it's never gibbed. 1 Quote Share this post Link to post
SMG_Man Posted October 16, 2022 If imps and other weaklings still aren't gibbing to the berserked knife, check the "Knifepuff" actor. If it looks mostly like this: ACTOR KnifePuff { +NOBLOCKMAP +NOGRAVITY +NOEXTREMEDEATH +PUFFONACTORS RenderStyle Translucent Alpha 0.6 SeeSound "KnifeHitThing" AttackSound "KnifeHitWall" ActiveSound "KnifeMiss" VSpeed 1 States { Spawn: PUFF ABCD 4 Stop } } Delete the "+NOEXTREMEDEATH" flag. That should take care of the problem. 1 Quote Share this post Link to post
K_Doom Posted October 16, 2022 4 minutes ago, SMG_Man said: If imps and other weaklings still aren't gibbing to the berserked knife, check the "Knifepuff" actor. If it looks mostly like this: ACTOR KnifePuff { +NOBLOCKMAP +NOGRAVITY +NOEXTREMEDEATH +PUFFONACTORS RenderStyle Translucent Alpha 0.6 SeeSound "KnifeHitThing" AttackSound "KnifeHitWall" ActiveSound "KnifeMiss" VSpeed 1 States { Spawn: PUFF ABCD 4 Stop } } Delete the "+NOEXTREMEDEATH" flag. That should take care of the problem. Oh yes, it was so obvious. I commented out this line at the top of the code but I didn't notice this one, thanks and sorry haha 1 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.