Xegethra Posted March 12, 2017 Hello, So I've had this set up for a while now, and never managed to overcome it. For my melee weapons I use the A_Jump set up, to give the appearance of varied health on the weapon before it breaks and you drop it, however it happens when you use it in mid air. I can't figure out how to have A_Jump only trigger when you hit another monster with the weapon. Is there a way I can do this, or do I have to go another route? I feel like it is halfway there but I just need it to activate on enemy contact as opposed to weapon use at all, because it is no good having the weapon break when it hits mid air. 0 Share this post Link to post
Blue Shadow Posted March 13, 2017 Assuming you're using A_CustomPunch as the means to do damage with the weapon, that function allows you to set a puff. Depending on the thing you hit with melee attacks, the puff enters a specific state:Bleeding actor -> XDeath Non-bleeding actor -> Melee Wall/Ceiling/Floor -> Crash (if Crash doesn't exist, Melee is entered)So set up your puff with Melee and XDeath states, and in them, give the player a counter item (for weapon durability). Here is an example of such a puff: actor KnucklesPuff : BulletPuff { +PUFFGETSOWNER // So the puff knows what or who shot it. States { Melee: XDeath: // Give the item to the puff's "target", which is the thing that shot it. // This relationship is established by setting the PUFFGETSOWNER flag. PUFF C 4 A_GiveInventory("DurabilityCounter", 1, AAPTR_TARGET) PUFF D 4 Stop } }What's left to do is check for the durability item in the weapon after each attack. 0 Share this post Link to post
Xegethra Posted March 13, 2017 I am using A_CustomPunch yeah. I'm a little lost on this, I have made an item out of the new puff and I have tried to connect it to the weapon, but nothing seems to happen. It seems this way would do the jump if it were in my inventory, so putting in AAPTR_TARGET or a name of an enemy doesn't seem to work either. Spoiler BOXP B 2 A_CustomPunch(1, 0, 0, "KnucklesPuff", 0, 0, 0, 0, "PFIST/PLGHHIT") BOXP B 2 A_JumpIfInventory("DurabilityCounter", 1, "Death") 0 Share this post Link to post
Blue Shadow Posted March 14, 2017 The durability item is something you need to make: actor DurabilityCounter : Inventory { Inventory.MaxAmount 10 // ... or whatever the value you want. } 0 Share this post Link to post
Xegethra Posted March 15, 2017 Ahh yes, thank you. O.K, I have managed to get it partly work. The durability item works when it hits an enemy, like it'll take a handful of hits before it gets broken, and due to the fluctuation of the damage dealt you may get an extra hit, or not....which is how I want it. Even if I have the probability of the A_Jump to always go to the jump, on an enemy the varied attacks make it fluctuate. The problem is, I could not get it working at all, until I put in the A_Jump chance. But doing this still makes it break in mid air, I'll explain it in the code. I'll stick in the whole code for the weapon. Spoiler // Cardboard Box 1 Weapon 1 --------------------------------------------------------------- ACTOR CardboardBox1 : weapon { Game Doom Radius 30 Height 30 Weapon.SlotNumber 1 Weapon.SelectionOrder 1900 +FLOORCLIP +WEAPON.MELEEWEAPON +INVENTORY.QUIET States { Ready: BOXH A 1 A_WeaponReady(WRF_DISABLESWITCH) Loop Select: BOXH A 1 A_Raise Loop Deselect: BOXH A 1 A_Lower Loop Fire: BOXT A 2 A_PlaySound("PFIST/PSWNG1") BOXT B 2 BOXP A 2 BOXP B 2 A_CustomPunch(1, 0, 0, "KnucklesPuff", 0, 0, 0, 0, "PFIST/PLGHHIT") BOXP B 2 A_Jump(256, "DurabilityCounter == 0", "Death") *This jump chance, if it has a number will make it happen but still in mid air, it gives me an error along the lines of -"DurabilityCounter == 0", "Death" Not found it CarboardBox1-. Whether it hits an enemy or not. Setting it to 0 makes it not work at all, as I thought but tried it anyway. When it has a number, say 256 which will guarantee the jump, it only does so in mid air, one use and it jumps, but on an enemy the durability seems to kick in and I get a few hits. But in mid air, one hit every time. If I change it to A_JumpIf, then it doesn't jump at all, ever no matter the chance number.* BOXP A 2 BOXT B 2 BOXT A 2 GoTo Ready ALTFire: BOXT A 0 A_Jump(256, "Fire2") Fire2: BOXT A 2 A_PlaySound("PFIST/PSWNG2") BOXT B 2 BOXT C 3 A_FireCustomMissile("CardboardBoxThrown1") BOXT D 3 BOXT E 3 BOXT F 3 A_Takeinventory("CardboardBox1") Goto Ready Death: BOXH B 4 A_PlaySound("WOODSMASH/WOODSMH1") BOXH C 4 A_SpawnItem("CardboardBoxSmashed1") BOXH D 4 BOXH D 1 A_Takeinventory("CardboardBox1") Goto Ready } } // CardboardBox1UP--------------------------------------------------------------- ACTOR CardboardBox1PU1 15030 { Game Doom SpawnID 162 Radius 13 Height 16 +USESPECIAL States { Spawn: CBX1 A -1 Loop } } // Hurt Puff actor KnucklesPuff : BulletPuff { +PUFFGETSOWNER States { Melee: XDeath: PUFF C 4 A_GiveInventory("DurabilityCounter", 1, AAPTR_TARGET) PUFF D 4 Stop } } // Durability box actor DurabilityCounter : Inventory { Inventory.MaxAmount 10 } So, I think I got it partially working? 0 Share this post Link to post
Arctangent Posted March 15, 2017 A_Jump only jumps at random chance - if you give it multiple arguments after the first, those're states it can jump to, not added logic. So, basically you're making code that that does an attack, then has a 100% chance to jump to either the Death state ... or the DurabilityCounter == 0 state, which obviously doesn't exist because you haven't defined it, so it just continues with the rest of Fire states. What you want is either A_JumpIfInventory or A_JumpIf with CountInv. Additionally, you'll want to put +PUFFONACTORS on the puff, because otherwise it won't actually be spawned when you hit something that bleeds. 0 Share this post Link to post
Xegethra Posted March 15, 2017 (edited) By Jove that fixed it! Thanks a bunch the both of you. I went the A_JumpIfInventory route, and now the cardboard box will crumble on an opponent instantly! *Edit* How do I alter the item durability? I have figured out how to make separately working durabilities for each of the weapons all named after their respective weapons, one for the bat, one for the box and so on. But I want the bat to have more durability, but when I set the item to give an amount, lets say 100, and then the weapon to use 10 each hit, I should have have 10 hits before it breaks? But, I always get one hit, which is indeed fine for the weaker weapons. Edited March 16, 2017 by Xegethra 0 Share this post Link to post