Page 2 of 2

Re: DECORATE Weapon Questions

PostPosted: Mon Dec 11, 2017 4:12 pm
by Exosphere
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.

Re: DECORATE Weapon Questions

PostPosted: Mon Dec 11, 2017 7:56 pm
by Blue Shadow
Could you post the whole code of the weapon?

Re: DECORATE Weapon Questions

PostPosted: Mon Dec 11, 2017 8:37 pm
by Exosphere
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");}
   }
}

Re: DECORATE Weapon Questions

PostPosted: Mon Dec 11, 2017 11:23 pm
by Blue Shadow
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.

Re: DECORATE Weapon Questions

PostPosted: Mon Dec 11, 2017 11:59 pm
by Exosphere
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.

Re: DECORATE Weapon Questions

PostPosted: Tue Dec 12, 2017 12:31 am
by jdredalert
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.

Re: DECORATE Weapon Questions

PostPosted: Tue Dec 12, 2017 3:24 pm
by Exosphere
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?