[Code] NS's Random Code Stuff

Post your example zscripts/ACS scripts/etc here.

[Code] NS's Random Code Stuff

Postby NeuralStunner » Wed Apr 11, 2012 12:51 am

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 allExpand view
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
NeuralStunner
I'll Get By
 
 
 
Joined: 21 Jul 2009
Location: Indiana, USA
Discord: NeuralStunner#1293
Operating System: Windows Vista/7/2008 64-bit

Re: [Code] NS's Random Code Stuff

Postby Xtyfe » Wed Apr 11, 2012 10:26 am

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
Xtyfe
Neque Deos, Neque Dominos
 
Joined: 15 Dec 2007
Location: The Intertubes

Re: [Code] NS's Random Code Stuff

Postby wildweasel » Wed Apr 11, 2012 12:25 pm

Oooh. I could make the Force-A-Nature actually behave properly with this.
User avatar
wildweasel
change o' pace.
Moderator Team Lead
 
Joined: 16 Jul 2003

Re: [Code] NS's Random Code Stuff

Postby XutaWoo » Wed Apr 11, 2012 2:56 pm

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
XutaWoo
one day when going to see the rabbit, there was a previous visitor ...
 
Joined: 30 Dec 2006
Location: beautiful hills of those who are friends

Re: [Code] NS's Random Code Stuff

Postby Xtyfe » Thu Apr 12, 2012 12:47 am

Could this be used to give monsters recoil? Holy balls that would be crazy
User avatar
Xtyfe
Neque Deos, Neque Dominos
 
Joined: 15 Dec 2007
Location: The Intertubes

Re: [Code] NS's Random Code Stuff

Postby Snarboo » Thu Apr 12, 2012 3:23 pm

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
Snarboo
Bacon doesn't know it's not dogs
 
Joined: 29 Nov 2005

Re: [Code] NS's Random Code Stuff

Postby NeuralStunner » Thu Apr 12, 2012 8:12 pm

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
NeuralStunner
I'll Get By
 
 
 
Joined: 21 Jul 2009
Location: Indiana, USA
Discord: NeuralStunner#1293
Operating System: Windows Vista/7/2008 64-bit

Re: [Code] NS's Random Code Stuff

Postby Xtyfe » Thu Apr 12, 2012 9:22 pm

Well of course, it's very useful :D

I wish to see more
User avatar
Xtyfe
Neque Deos, Neque Dominos
 
Joined: 15 Dec 2007
Location: The Intertubes

Re: [Code] NS's Random Code Stuff

Postby NeuralStunner » Thu Apr 12, 2012 11:01 pm

Added code for a missile spawner. Hope it's clear enough!
User avatar
NeuralStunner
I'll Get By
 
 
 
Joined: 21 Jul 2009
Location: Indiana, USA
Discord: NeuralStunner#1293
Operating System: Windows Vista/7/2008 64-bit

Re: [Code] NS's Random Code Stuff

Postby Gez » Fri Apr 13, 2012 2:20 am

Note that randomspawners work with projectiles now.
Gez
 
 
 
Joined: 06 Jul 2007

Re: [Code] NS's Random Code Stuff

Postby NeuralStunner » Fri Apr 13, 2012 2:41 pm

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
NeuralStunner
I'll Get By
 
 
 
Joined: 21 Jul 2009
Location: Indiana, USA
Discord: NeuralStunner#1293
Operating System: Windows Vista/7/2008 64-bit

Re: [Code] NS's Random Code Stuff

Postby Minigunner » Sat Apr 14, 2012 6:09 pm

Here's what I used for enhanced A_Recoil:
Code: Select allExpand view
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
Minigunner
 
Joined: 28 Dec 2009
Discord: Minigunner#5418

Re: [Code] NS's Random Code Stuff

Postby Matt » Sun Aug 05, 2012 9:13 pm

I just discovered this.

Every awful pun you have made or will make is forgiven.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [Code] NS's Random Code Stuff

Postby Xtyfe » Tue Aug 21, 2012 6:41 pm

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
Xtyfe
Neque Deos, Neque Dominos
 
Joined: 15 Dec 2007
Location: The Intertubes

Re: [Code] NS's Random Code Stuff

Postby RV-007 » Fri Aug 24, 2012 6:32 am

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.
User avatar
RV-007
anti-13ashar_society, lol
Banned User
 
Joined: 03 Sep 2011
Location: Dying w/ civilization or living after it

Next

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests