Charbomber Posted June 12 Does anybody know how I would go about making a projectile that slows the player in DECORATE? I already tried coding it myself, but it didn't work out very well and I feel like I'm not really knowledgeable enough to do this on my own. If it helps (which it probably doesn't very much), here's the code I tried using to achieve this: actor SpitProjectile { Radius 3 Height 8 Speed 30 FastSpeed 50 Damage (1) Projectile +RANDOMIZE States { Spawn: SPIT AB 4 Bright Loop Death: SPIT CDE 6 Bright A_RadiusGive("PlayerSlow", 16, RGF_PLAYERS, 1) Stop } } (and then of course PlayerSlow) actor PlayerSlow : CustomInventory { Inventory.MaxAmount 3 +INVENTORY.QUIET +INVENTORY.UNCLEARABLE +INVENTORY.PERSISTENTPOWER States { Spawn: TNT1 A 0 stop Pickup: TNT1 A 0 A_JumpIfInventory("PlayerSlow", 3, "Slowdown3") TNT1 A 0 A_JumpIfInventory("PlayerSlow", 2, "Slowdown2") TNT1 A 0 A_JumpIfInventory("PlayerSlow", 1, "Slowdown1") stop ResetSpeed: TNT1 A 0 A_SetSpeed(1) stop Slowdown1: TNT1 A 0 A_SetSpeed(0.75) goto Remove Slowdown2: TNT1 A 0 A_SetSpeed(0.5) goto Remove Slowdown3: TNT1 A 0 A_SetSpeed(0.25) goto Remove Remove: TNT1 A 1024 TNT1 A 0 A_TakeInventory("PlayerSlow", 1) TNT1 A 0 { if (CountInv("PlayerSlow") < 1) { ResolveState("ResetSpeed"); } } stop } } 0 Quote Share this post Link to post
1 Gez Posted June 12 I think the Pickup state will probably fail as I believe it technically runs before the item in question is added to the player's inventory, so these A_JumpIf will not be run, you'll reach Stop, and fail to give anything. Otherwise, as jaeden said, the tic lengths of states is ignored when a CustomInventory is picked up -- everything happens instantly; you can't use CustomInventory items as parallel state machines for the player. So you should be giving PowerSpeed items, which should handle their own removals. I think (but haven't checked) that different PowerSpeed items are multiplicative, so if you have a SlowDown1 with speed 0.75, a SlowDown2 with speed 0.67, and a SlowDown3 with speed 0.5, you should get the final values you want (0.67x0.75 is 0.5, 0.5x0.5=0.25). 0 Quote Share this post Link to post
1 jaeden Posted June 12 Why I think your solution does not work: You cannot have delayed states in CustomInventory. The removal is instant. Also I don't know if A_SetSpeed can work like this on players, maybe it does. Best approach I can come up with is use inventory items derived from PowerSpeed as both slower and timer. I think the A_RadiusGive part in the projectile class is probably the correct way of doing this without using ZScript (though is it intentional that it is called 3 times?). 0 Quote Share this post Link to post
0 Charbomber Posted June 12 Thank you! I wasn't able to figure out how to have it additive with multiple SlowDown PowerSpeed items, but I'm even just happy with a projectile that slows you down in general and it wasn't too important of a feature to me. Once again, thanks! (Also, knowing that's how CustomInventory works is pretty useful too... I didn't know that's how it worked.) 0 Quote Share this post Link to post
Question
Charbomber
Does anybody know how I would go about making a projectile that slows the player in DECORATE?
I already tried coding it myself, but it didn't work out very well and I feel like I'm not really knowledgeable enough to do this on my own.
If it helps (which it probably doesn't very much), here's the code I tried using to achieve this:
actor SpitProjectile { Radius 3 Height 8 Speed 30 FastSpeed 50 Damage (1) Projectile +RANDOMIZE States { Spawn: SPIT AB 4 Bright Loop Death: SPIT CDE 6 Bright A_RadiusGive("PlayerSlow", 16, RGF_PLAYERS, 1) Stop } }
(and then of course PlayerSlow)
actor PlayerSlow : CustomInventory { Inventory.MaxAmount 3 +INVENTORY.QUIET +INVENTORY.UNCLEARABLE +INVENTORY.PERSISTENTPOWER States { Spawn: TNT1 A 0 stop Pickup: TNT1 A 0 A_JumpIfInventory("PlayerSlow", 3, "Slowdown3") TNT1 A 0 A_JumpIfInventory("PlayerSlow", 2, "Slowdown2") TNT1 A 0 A_JumpIfInventory("PlayerSlow", 1, "Slowdown1") stop ResetSpeed: TNT1 A 0 A_SetSpeed(1) stop Slowdown1: TNT1 A 0 A_SetSpeed(0.75) goto Remove Slowdown2: TNT1 A 0 A_SetSpeed(0.5) goto Remove Slowdown3: TNT1 A 0 A_SetSpeed(0.25) goto Remove Remove: TNT1 A 1024 TNT1 A 0 A_TakeInventory("PlayerSlow", 1) TNT1 A 0 { if (CountInv("PlayerSlow") < 1) { ResolveState("ResetSpeed"); } } stop } }
Share this post
Link to post
3 answers to this question
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.