DECORATE Weapon Questions

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.

Re: DECORATE Weapon Questions

Postby Exosphere » Mon Dec 11, 2017 3:12 pm

R4L wrote:Wouldn't be because your script is named "reload" and your calling "reloader" in your Reload state, would it?


Oops, thats a typo. Let me correct it.
User avatar
Exosphere
 
Joined: 11 Jun 2017
Location: New England, US

Re: DECORATE Weapon Questions

Postby Blue Shadow » Mon Dec 11, 2017 6:56 pm

Could you post the whole code of the weapon?
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: DECORATE Weapon Questions

Postby Exosphere » Mon Dec 11, 2017 7:37 pm

Blue Shadow wrote:Could you post the whole code of the weapon?


Code: Select allExpand view
ACTOR RifleMag : Ammo
{
   Inventory.Amount 25
   Inventory.MaxAmount 25
   +IGNORESKILL
}

ACTOR ShotgunTube : Ammo
{
   Inventory.Amount 8
   Inventory.MaxAmount 8
   +IGNORESKILL
}

ACTOR RocketMag : Ammo
{
   Inventory.Amount 3
   Inventory.MaxAmount 3
   +IGNORESKILL
}

ACTOR RifleMode : Inventory{}
ACTOR ShotgunMode : Inventory{}
ACTOR RocketMode : Inventory{}

ACTOR OICW : Weapon
{
   Tag "OICW"
   Inventory.PickupMessage ""
   Inventory.PickupSound ""
   Weapon.SlotNumber 2
   Weapon.SelectionOrder 2
   +NOAUTOFIRE
   
   States
   {
      Spawn:
         PLAS A -1
         Loop
      Ready:
         PLSG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
         Loop
      Deselect:
         PLSG A 1 A_Lower //PLSG A
         Loop
      Select:
         PLSG A 1 A_Raise //PLSG A
         Loop
      Fire:
         TNT1 A 0 A_JumpIfInventory("RifleMode", 1, "RifleFire")
         TNT1 A 0 A_JumpIfInventory("ShotgunMode", 1, "ShotgunFire")
         TNT1 A 0 A_JumpIfInventory("RocketMode", 1, "RocketFire")
         Goto Ready
         
      //------------------------------
      //   9.5x25mm Caseless Rifle Mode
      //------------------------------
      RifleFire:
         OICW A 1 A_JumpIfNoAmmo("Reload")
         OICW A 1 BRIGHT A_FireProjectile("ARBullet", frandom(-1.7, 1.7), 1, 0, 0, 0, frandom(-1.7, 1.7))
         OICW A 1 A_TakeInventory("RifleMag", 1)
         OICW A 1 A_Refire
         Goto Ready
         
      //-----------------------
      //   10 Gauge Shotgun Mode
      //-----------------------
      ShotgunFire:
         OICW A 1 A_JumpIfNoAmmo("Reload")
         OICW A 15 A_FireShotgun2
         OICW A 1 A_TakeInventory("ShotgunTube", 1)
         Goto Ready
         
      //---------------------------------
      //   20mm Smart Rocket Launcher Mode
      //---------------------------------
      RocketFire:
         OICW A 1 A_JumpIfNoAmmo("Reload")
         OICW A 20 A_FireMissile
         OICW A 1 A_TakeInventory("RocketMag", 1)
         Goto Ready
         
      AltFire:
         OICW A 1 ACS_NamedExecute("Cycler", 0, 0, 0, 0)
         TNT1 A 0 A_PlaySound("weapons/shotgr", CHAN_AUTO, 50.0)
         Goto Ready
         
      Reload:
         OICW A 1 ACS_NamedExecute("Reloader", 0, 0, 0, 0)
         TNT1 A 0 A_PlaySound("weapons/shotgr", CHAN_AUTO, 50.0)
         Goto Ready
   }
}


Here is also the ACS code for Reloader and Cycler. Also, for the Cycler to work, you must give the player "RifleMode" first.
Code: Select allExpand view
#library "cyclr"
script "Cycler" (void)
{

   if (CheckWeapon("OICW") == 1)
   {
      if(CheckInventory("RocketMode")==1 && CheckInventory("RifleMode")==0)
      //If Rocket Mode is ACTIVE and RifleMode is INACTIVE
      {
         TakeInventory("RocketMode", 1);
         GiveInventory("RifleMode", 1);
         Print(s:"9.5x25mm Caseless Rifle Mode: ACTIVE.");
      }
      else if(CheckInventory("RifleMode")==1 && CheckInventory("ShotgunMode")==0)
      //If Rifle Mode is ACTIVE and Shotgun Mode is INACTIVE
      {
         TakeInventory("RifleMode", 1);
         GiveInventory("ShotgunMode", 1);
         Print(s:"10ga Shotgun Mode: ACTIVE.");
      }
      else if(CheckInventory("ShotgunMode")==1 && CheckInventory("RocketMode")==0)
      //If Shotgun Mode is ACTIVE and RocketMode is INACTIVE
      {
         TakeInventory("ShotgunMode", 1);
         GiveInventory("RocketMode", 1);
         Print(s:"20mm Smart Rocket Mode: ACTIVE.");
      }
   }
}

#library "rldr"
script "Reloader" (void)
{
   if (CheckWeapon("OICW") == 1)
   {
      if(CheckInventory("RifleMode")==1)
      { GiveInventory("RifleMag", 25); Print(s:"Rifle Reloaded"); }
      
      else if(CheckInventory("ShotgunMode")==1)
      { GiveInventory("ShotgunTube", 8); Print(s:"Shotgun Reloaded"); }
      
      else if(CheckInventory("RocketMode")==1)
      { GiveInventory("RocketMag", 3); Print(s:"Smart Rocket Reloaded");}
   }
}
User avatar
Exosphere
 
Joined: 11 Jun 2017
Location: New England, US

Re: DECORATE Weapon Questions

Postby Blue Shadow » Mon Dec 11, 2017 10:23 pm

Your weapon is ammo-less (it lacks Weapon.AmmoType). This is why A_JumpIfNoAmmo doesn't work as expected. You may want to use A_JumpIfInventory instead of A_JumpIfNoAmmo.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: DECORATE Weapon Questions

Postby Exosphere » Mon Dec 11, 2017 10:59 pm

Blue Shadow wrote:Your weapon is ammo-less (it lacks Weapon.AmmoType). This is why A_JumpIfNoAmmo doesn't work as expected. You may want to use A_JumpIfInventory instead of A_JumpIfNoAmmo.


I do understand that the weapon doesn't have an ammo type, since I would've ideally like to have three different ammo types. Also, after changing the A_JumpIfNoAmmo to A_JumpIfInventory (and putting it at the end of the state before "Goto Ready" since it would do nothing but reload), still continues to fire projectiles even after the magazine is empty.
User avatar
Exosphere
 
Joined: 11 Jun 2017
Location: New England, US

Re: DECORATE Weapon Questions

Postby jdredalert » Mon Dec 11, 2017 11:31 pm

I made a weapon that could cycle through three different kinds of ammo, it was all made on DECORATE. Maybe you should take a look:

Click me.

Just keep in mind that i'm not actually using real ammo types, but inventory items instead.
User avatar
jdredalert
State of badass art.
 
Joined: 14 Jul 2013

Re: DECORATE Weapon Questions

Postby Exosphere » Tue Dec 12, 2017 2:24 pm

jdredalert wrote:I made a weapon that could cycle through three different kinds of ammo, it was all made on DECORATE. Maybe you should take a look:

Click me.

Just keep in mind that i'm not actually using real ammo types, but inventory items instead.


Funny you mentioning that weapon you made. Back in the summer, I had originally looked through that to get a sense of how use more than three ammo types could work, but went with making three separate weapons. Now returning to the one weapon & multiple ammo types, I remembered your weapon.

Could you look through my code, to see what is missing or needs to be fixed? My intent is to have it so that it can switch between bullets, shotgun, and rockets (obviously), while each having its own magazine size. I've also wanted to have it so that the weapon has unlimited ammo, but still needs to be reloaded. Think of the combat rifle from Lithium. If you need it, would you also need to see the Cycler code?
User avatar
Exosphere
 
Joined: 11 Jun 2017
Location: New England, US

Previous

Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests