[ACS] Way For Player To Fire Projectile?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

[ACS] Way For Player To Fire Projectile?

Postby Chubbs » Sat May 21, 2022 12:13 pm

Hi all. I'm trying to get a universal subweapon system to work and I did through Decorate, but I wasn't satisfied with it and wanted something that could be done at any time. I implemented the graphics through ACS with no problem, but now I'm trying to figure out a way to actually get the player to fire the projectiles.

I see that there is SpawnProjectile but it doesn't seem to work for me when being activated by the player and also even if I did get it to work I'm not sure it would account for the player's angle and pitch. Any ideas? Thanks!
Chubbs
 
Joined: 08 Mar 2017

Re: [ACS] Way For Player To Fire Projectile?

Postby Blue Shadow » Sat May 21, 2022 6:54 pm

Probably the easiest solution is to give the player a CustomInventory item that calls A_FireProjectile in its Pickup state.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: [ACS] Way For Player To Fire Projectile?

Postby Chubbs » Sun May 22, 2022 12:54 am

Blue Shadow wrote:Probably the easiest solution is to give the player a CustomInventory item that calls A_FireProjectile in its Pickup state.


This worked PERFECTLY! I didn't know that you could use CustomInventory in such a way. Thank you!
Chubbs
 
Joined: 08 Mar 2017

Re: [ACS] Way For Player To Fire Projectile?

Postby Chubbs » Sun May 22, 2022 12:57 am

Just in case anyone is looking at this later and wondering:

Here's the Decorate
Code: Select allExpand view
actor SubWeaponFire: CustomInventory // Credit to Blue Shadow on Zdoom forums for answering my question with this solution!
{
  states
  {
   Spawn:
      TNT1 A -1
   stop
   Pickup:
    TNT1 A 0 A_FireCustomMissile ("Subweapon",Frandom(-0.25,0.25),0,-4,16,0,Frandom(-0.15,0.15))
    stop
  }
}


And this is what's in the ACS Script

Code: Select allExpand view
If(GetPlayerInput(-1, INPUT_BUTTONS) & BT_USER1)
{
GiveInventory("SubWeaponFire",1);
TakeInventory("SubWeaponAmmo",2);
}
Chubbs
 
Joined: 08 Mar 2017


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests