Diesel
Member
So I am trying to get ammo for bows and crossbows to subtract from Daat's MAsterstorage. I look at the Daat's baseranged.cs and the current baseranged.cs and I can see where it goes. But the variables in the code sections don't align. They are different. That moves it beyond my poor code snippet insertion skills into coding which I am unskilled.
So here is the Daat's Baseranged.cs snippet
public virtual bool OnFired(Mobile attacker, Mobile defender)
{
if (attacker.Player)
{
BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
Container pack = attacker.Backpack;
if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost)
{
// consume ammo
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
{
quiver.InvalidateWeight();
}
else if (TryFireFromMasterStorage(attacker)) // Vii add
{
// fired arrow from MasterStorage, do nothing else
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return false;
}
}
else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null))
{
// lower ammo cost should not work when we have no ammo at all
if (!TryFireFromMasterStorage(attacker)) // Vii add
return false;
}
}
And here is the actual 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 (attacker.Player)
{
BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
Container pack = attacker.Backpack;
int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost);
if (quiver == null || Utility.Random(100) >= lowerAmmo)
{
// consume ammo
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
{
quiver.InvalidateWeight();
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return false;
}
}
else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null))
{
// lower ammo cost should not work when we have no ammo at all
return false;
}
}
I am posting both of the entire BaseRanged.cs files as attachments. But I would be glad to hear any ideas.
So here is the Daat's Baseranged.cs snippet
public virtual bool OnFired(Mobile attacker, Mobile defender)
{
if (attacker.Player)
{
BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
Container pack = attacker.Backpack;
if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost)
{
// consume ammo
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
{
quiver.InvalidateWeight();
}
else if (TryFireFromMasterStorage(attacker)) // Vii add
{
// fired arrow from MasterStorage, do nothing else
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return false;
}
}
else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null))
{
// lower ammo cost should not work when we have no ammo at all
if (!TryFireFromMasterStorage(attacker)) // Vii add
return false;
}
}
And here is the actual 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 (attacker.Player)
{
BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
Container pack = attacker.Backpack;
int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost);
if (quiver == null || Utility.Random(100) >= lowerAmmo)
{
// consume ammo
if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
{
quiver.InvalidateWeight();
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return false;
}
}
else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null))
{
// lower ammo cost should not work when we have no ammo at all
return false;
}
}
I am posting both of the entire BaseRanged.cs files as attachments. But I would be glad to hear any ideas.