Ok, so here's my problem i have made a few bows for my server but i want it so they do not require ammo...

i set them with the LowerAmmo Attribute BUT they still need arrows/bolts....

How do i make it so they dont require ammo full stop?
 
Change to this in BaseRanged.cs, line 224:

// consume ammo
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
{
quiver.InvalidateWeight();
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return true;
}
}
 
Change to this in BaseRanged.cs, line 224:

// consume ammo
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
{
quiver.InvalidateWeight();
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return true;
}
}


that would set it for every bow right? i only want certain ones to not require ammo.
 
ive not used this in a long time and i dont know if it will work with Servuo anyways but you need something like.

Add this script to your scripts no need to edit anything

Code:
using System;
using Server.Items;
using Server.Network;
namespace Server.Items
{
public abstract class noammoBaseRanged : BaseMeleeWeapon
{
  public abstract int EffectID{ get; }
  public abstract Type AmmoType{ get; }
  public abstract Item Ammo{ get; }
  public override int DefHitSound{ get{ return 0x234; } }
  public override int DefMissSound{ get{ return 0x238; } }
  public override SkillName DefSkill{ get{ return SkillName.Archery; } }
  public override WeaponType DefType{ get{ return WeaponType.Ranged; } }
  public override WeaponAnimation DefAnimation{ get{ return WeaponAnimation.ShootXBow; } }
  public noammoBaseRanged( int itemID ) : base( itemID )
  {
  }
  public noammoBaseRanged( Serial serial ) : base( serial )
  {
  }
  public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
  {
   // Make sure we've been standing still for one second
   {
    if ( attacker.HarmfulCheck( defender ) )
    {
     attacker.DisruptiveAction();
     attacker.Send( new Swing( 0, attacker, defender ) );
     if ( OnFired( attacker, defender ) )
     {
      if ( CheckHit( attacker, defender ) )
       OnHit( attacker, defender );
      else
       OnMiss( attacker, defender );
     }
    }
    return GetDelay( attacker );
   }
  
  }
  public virtual void OnHit( Mobile attacker, Mobile defender )
  {
   if ( attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble() )
    defender.AddToBackpack( Ammo );
   base.OnHit( attacker, defender );
  }
  public override void OnMiss( Mobile attacker, Mobile defender )
  {
   if ( attacker.Player && 0.4 >= Utility.RandomDouble() )
    Ammo.MoveToWorld( new Point3D( defender.X + Utility.RandomMinMax( -1, 1 ), defender.Y + Utility.RandomMinMax( -1, 1 ), defender.Z ), defender.Map );
   base.OnMiss( attacker, defender );
  }
  public virtual bool OnFired( Mobile attacker, Mobile defender )
  {
   Container pack = attacker.Backpack;
   if ( attacker.Player && (pack == null || !pack.ConsumeTotal( AmmoType, 1 )) )
    return true;
   attacker.MovingEffect( defender, EffectID, 18, 1, false, false );
   return true;
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.Write( (int) 2 ); // version
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadInt();
   switch ( version )
   {
    case 2:
    case 1:
    {
     break;
    }
    case 0:
    {
     /*m_EffectID =*/ reader.ReadInt();
     break;
    }
   }
   if ( version < 2 )
   {
    WeaponAttributes.MageWeapon = 0;
    WeaponAttributes.UseBestSkill = 0;
   }
  }
}
}

then in the bow you dont want to use ammo

Code:
public class CustomXBow: RepeatingCrossbow

Change to

Code:
public class CustomXBow: noammoBaseRanged

As mentioned above this used to work on Runuo ive not tried on Servuo
 
has changed since i used it i downloaded sahisahi version and was getting some errors i am guessing they was for a older version of servuo..

I have fixed the errors so it should work now
 

Attachments

  • Ammoless Bows.rar
    1.8 KB · Views: 75
Not that the previous solution isn't fine but there's another solution which I think was a lot simpler. Sorry I didn't get back to this thread earlier. All you need to do is in the script for your new weapon(s) enter:

public override Type AmmoType
{
get
{
return null;
}
}
public override Item Ammo
{
get
{
return null;
}
}

And add one null reference check in BaseRanged.cs:

public virtual bool OnFired(Mobile attacker, IDamageable damageable)
{
WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

// Respect special moves that use no ammo
if (ability != null && ability.ConsumeAmmo == false)
{
return true;
}

if (AmmoType != null)
{

if (attacker.Player)
{
 
Not that the previous solution isn't fine but there's another solution which I think was a lot simpler. Sorry I didn't get back to this thread earlier. All you need to do is in the script for your new weapon(s) enter:

public override Type AmmoType
{
get
{
return null;
}
}
public override Item Ammo
{
get
{
return null;
}
}

And add one null reference check in BaseRanged.cs:

public virtual bool OnFired(Mobile attacker, IDamageable damageable)
{
WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

// Respect special moves that use no ammo
if (ability != null && ability.ConsumeAmmo == false)
{
return true;
}

if (AmmoType != null)
{

if (attacker.Player)
{

that also is a nice fix :p
 
Back