[Code] NS's Random Code Stuff

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
NeuralStunner
 
 
Posts: 12325
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

[Code] NS's Random Code Stuff

Post by NeuralStunner »

Note: I highly doubt most of these methods will work in Skulltag. If I've tried it in ST and it works, I'll mark it as such.

Full 3D Recoil (Decorate)
A_Recoil rather sucks because it applies horizontal force only. You can use this Pitch-aware method instead. Great for powerful weapons!

Code: Select all

A_ChangeVelocity (Cos(Pitch) * -force, 0, Sin(Pitch) * force, CVF_Relative)
Replace each force with your desired velocity. If you want to push forward rather than back, switch the negative sign (-) from first force to the second.


Projectile Spawners (Decorate)
This has two uses: One, it helps keep FastProjectiles from spawning inside walls. Two, it can be used to fire a random projectile while keeping the weapon itself simple.
Spoiler: Details Inside!
Melee Attack "Arc Scans" (Decorate)
This somewhat replicates the melee weapons from Hexen. The scan will span outward in an arc, trying to find an enemy to hit. This has a couple interesting quirks:
  1. Instead of turning to face the enemy dead-center, you'll only turn as far as needed to strike its hitbox.
  2. Near the max range of the attack (based on the target's radius), the distance check and thus the scan will fail. This isn't so bad in practice.
Spoiler: Code!
Dynamic Projectile Damage (Decorate)
Want to change a projectile's damage "on the fly"? You can!
Spoiler: omg code!!1
Last edited by NeuralStunner on Thu Jan 08, 2015 9:29 pm, edited 7 times in total.
User avatar
Xtyfe
Posts: 1480
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: [Code] NS's Random Code Stuff

Post by Xtyfe »

Very nice, I noticed A_Recoil did that and opted not to use it because of that. But this solves that nicely :D
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: [Code] NS's Random Code Stuff

Post by wildweasel »

Oooh. I could make the Force-A-Nature actually behave properly with this.
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: [Code] NS's Random Code Stuff

Post by XutaWoo »

Heh, I had this in my old Rifle Instagib mod. Except it was donein ACS because A_ChangeVelocity didn't even exist in ZDoom back then, but still. :P
User avatar
Xtyfe
Posts: 1480
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: [Code] NS's Random Code Stuff

Post by Xtyfe »

Could this be used to give monsters recoil? Holy balls that would be crazy
User avatar
Snarboo
Posts: 2599
Joined: Tue Nov 29, 2005 4:37 am

Re: [Code] NS's Random Code Stuff

Post by Snarboo »

I just tested your code, NeuralStunner, and it seems you have the x-velocity backwards: it needs to be a negative value to thrust the player backwards. The z-velocity is correct though! You can pull off some interesting effects with this.
User avatar
NeuralStunner
 
 
Posts: 12325
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [Code] NS's Random Code Stuff

Post by NeuralStunner »

Actually no, I got both backwards. Whoops! Fixed now.

Also, I didn't expect so much response to my first code snippet. Thanks guys. =:)
User avatar
Xtyfe
Posts: 1480
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: [Code] NS's Random Code Stuff

Post by Xtyfe »

Well of course, it's very useful :D

I wish to see more
User avatar
NeuralStunner
 
 
Posts: 12325
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [Code] NS's Random Code Stuff

Post by NeuralStunner »

Added code for a missile spawner. Hope it's clear enough!
Gez
 
 
Posts: 17833
Joined: Fri Jul 06, 2007 3:22 pm

Re: [Code] NS's Random Code Stuff

Post by Gez »

Note that randomspawners work with projectiles now.
User avatar
NeuralStunner
 
 
Posts: 12325
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [Code] NS's Random Code Stuff

Post by NeuralStunner »

Bah.

Technology becomes obsolete moments after it's released, isn't that how it works? :P

Edit: Heh, so I tried that method and the chosen projectiles are being fired horizontally (rather than inheriting the direction of the RandomSpawner). So I'm not dead yet! :P
User avatar
Minigunner
Posts: 754
Joined: Mon Dec 28, 2009 5:13 pm

Re: [Code] NS's Random Code Stuff

Post by Minigunner »

Here's what I used for enhanced A_Recoil:

Code: Select all

ThrustThingZ(0,([force]*4)*sin(pitch),0,1) and
A_Recoil([force]*cos(pitch))
If you do not want vertical recoil, then use only the second line.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [Code] NS's Random Code Stuff

Post by Matt »

I just discovered this.

Every awful pun you have made or will make is forgiven.
User avatar
Xtyfe
Posts: 1480
Joined: Fri Dec 14, 2007 6:29 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

Re: [Code] NS's Random Code Stuff

Post by Xtyfe »

This fast projectile spawner, I'm not sure I understand the need for the multiplication of velocity, I assume that works into the speed of the projectile it spawns, so I want to make sure my projectiles are going at the speeds I want them to :D
User avatar
RV-007
Posts: 1501
Joined: Fri Sep 02, 2011 9:00 pm
Location: Dying w/ civilization or living after it
Contact:

Re: [Code] NS's Random Code Stuff

Post by RV-007 »

Is this the equivalent of A_SkullAttack w/o the damage (may include A_FaceTarget)? If so, I can finally make a rampaging stampede of demons to (eventually) climb over ledges w/o infighting each other.
Post Reply

Return to “Script Library”