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.
 

Attachments

  • Current Server BaseRanged.cs
    6.7 KB · Views: 0
  • OWLTR EXAMPLE BaseRanged.cs
    7.2 KB · Views: 2
if you read threw it carefully its getting from your masterstorage and its looking for a quiver if you make pack not -- null, != pack it'll probably lookin tha backpack as well
 
Well, I wish it was taking the arrows directly from my masterstorage but it doesn't. The current version will use them from my pack and probably a quiver but it won't use them directly from the Masterstorage. Which is what I am wanting to do. I want it to check backpack check quiver then go to the master storage.
 
you can try this
Code:
// fired arrow from MasterStorage, do nothing else
}
else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
{
return false;
}
}
to this
Code:
// fired arrow from MasterStorage, do nothing else
}
else if (pack == null || pack.ConsumeTotal(AmmoType, 1))
{
return false;
}
}
and see if this works
 
You must have an older version then. We got it working a while back. Fires both arrows & bolts from the MasterStorage pack when stored in Woodworking.
 

Attachments

  • BaseRanged.cs
    7.1 KB · Views: 7
Hmmm got an error for BaseThrown.cs


--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 6313.34321
Publish 54
Core: Optimizing for 1 64-bit processor
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 9 warnings (I removed them)

Errors:
+ Items/Equipment/Weapons/BaseThrown.cs:
CS0115: Line 111: 'Server.Items.BaseThrown.OnFired(Server.Mobile, Server.IDa
mageable)': no suitable method found to override
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.



When I tried to replace mine with yours I got a ton of error so I replaced the block of code with your block of code and got this error for BaseThrown.Cs

Hereis what I put in:


public virtual bool OnFired(Mobile attacker, Mobile defender)
{
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 (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;
}
}
attacker.MovingEffect(defender, EffectID, 18, 1, false, false);
return true;
}
// Vii added for firing the ammotype directly from a masterstorage bag

public bool TryFireFromMasterStorage(Mobile attacker)
{
MasterStorage bag = MasterStorageUtils.GetMasterStorage((PlayerMobile)attacker);

if (bag == null || !bag.TryConsume(AmmoType, 1))

return false;
return true;
}
 
Last edited:
Try this. In the script I posted change line 210
Code:
public virtual bool OnFired(Mobile attacker, Mobile defender)
to
Code:
public virtual bool OnFired(Mobile attacker, IDamageable damageable)
and then farther down line 251 change
Code:
attacker.MovingEffect(defender, EffectID, 18, 1, false, false);
to
Code:
attacker.MovingEffect(damageable, EffectID, 18, 1, false, false);
 
--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 6313.34321
Publish 54
Core: Optimizing for 1 64-bit processor
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 9 warnings
Warnings:
+ Custom/Scripts.LV2/Addons/Outdoor Furnishings/GraniteFurnessAddon.cs:
CS0105: Line 2: The using directive for 'System' appeared previously in this
namespace
+ Items/Tools/ProspectorsTool.cs:
CS0105: Line 4: The using directive for 'Server.Engines.Harvest' appeared pr
eviously in this namespace
+ Custom/Scripts.LV2/Systems/Addon Generator/AddOnEditor_Att.cs:
CS0108: Line 18: 'Server.Engines.XmlSpawner2.AddOnEditor_Att.Initialize()' h
ides inherited member 'Server.Engines.XmlSpawner2.XmlAttachment.Initialize()'. U
se the new keyword if hiding was intended.
+ Custom/Scripts.LV2/Systems/Hell/NagsTeleporter.cs:
CS0114: Line 21: 'Server.Items.NagsTeleporter.Location' hides inherited memb
er 'Server.Item.Location'. To make the current member override that implementati
on, add the override keyword. Otherwise add the new keyword.
CS0108: Line 28: 'Server.Items.NagsTeleporter.Map' hides inherited member 'S
erver.Item.Map'. Use the new keyword if hiding was intended.
+ Custom/Scripts.LV2/Systems/Hell/UnderworldTeleporter.cs:
CS0114: Line 21: 'Server.Items.UnderWorldTeleporter.Location' hides inherite
d member 'Server.Item.Location'. To make the current member override that implem
entation, add the override keyword. Otherwise add the new keyword.
CS0108: Line 28: 'Server.Items.UnderWorldTeleporter.Map' hides inherited mem
ber 'Server.Item.Map'. Use the new keyword if hiding was intended.
+ Custom/Scripts.LV2/Systems/Hell/UnderWorldTeleporterFirst.cs:
CS0114: Line 21: 'Server.Items.UnderWorldTeleporterFirst.Location' hides inh
erited member 'Server.Item.Location'. To make the current member override that i
mplementation, add the override keyword. Otherwise add the new keyword.
CS0108: Line 28: 'Server.Items.UnderWorldTeleporterFirst.Map' hides inherite
d member 'Server.Item.Map'. Use the new keyword if hiding was intended.
+ Custom/Scripts.LV2/Systems/Hell/XerxesTeleporter.cs:
CS0114: Line 21: 'Server.Items.XerxesTeleporter.Location' hides inherited me
mber 'Server.Item.Location'. To make the current member override that implementa
tion, add the override keyword. Otherwise add the new keyword.
CS0108: Line 28: 'Server.Items.XerxesTeleporter.Map' hides inherited member
'Server.Item.Map'. Use the new keyword if hiding was intended.
+ Custom/Scripts.LV4/Medival World Customs/New Backpacks.cs:
CS0108: Line 51: 'Server.Items.BloodyBackpack.Dye(Server.Mobile, Server.Item
s.DyeTub)' hides inherited member 'Server.Items.Backpack.Dye(Server.Mobile, Serv
er.Items.DyeTub)'. Use the new keyword if hiding was intended.
CS0108: Line 120: 'Server.Items.FurryBackpack.Dye(Server.Mobile, Server.Item
s.DyeTub)' hides inherited member 'Server.Items.Backpack.Dye(Server.Mobile, Serv
er.Items.DyeTub)'. Use the new keyword if hiding was intended.
CS0108: Line 189: 'Server.Items.StrapsBackpack.Dye(Server.Mobile, Server.Ite
ms.DyeTub)' hides inherited member 'Server.Items.Backpack.Dye(Server.Mobile, Ser
ver.Items.DyeTub)'. Use the new keyword if hiding was intended.
+ Services/Revamped Dungeons/Covetous Void Spawn/Creatures/CovetousCreature.cs:

CS0108: Line 13: 'Server.Mobiles.CovetousCreature.Level' hides inherited mem
ber 'Server.Mobiles.BaseCreature.Level'. Use the new keyword if hiding was inten
ded.
Errors:
+ Items/Equipment/Weapons/BaseRanged.cs:
CS0115: Line 71: 'Server.Items.BaseRanged.OnSwing(Server.Mobile, Server.Mobi
le)': no suitable method found to override
CS0115: Line 133: 'Server.Items.BaseRanged.OnHit(Server.Mobile, Server.Mobil
e, double)': no suitable method found to override
CS0115: Line 164: 'Server.Items.BaseRanged.OnMiss(Server.Mobile, Server.Mobi
le)': no suitable method found to override

Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
[doublepost=1492366041][/doublepost]The attached file is the one you posted with the corrections and the generated errors.
 

Attachments

  • [ServUO.com]-BaseRanged.cs
    7.1 KB · Views: 2
You'll need to change the (Mobile attacker, Mobile defender) to (Mobile attacker, IDamageable, damageable) for all 3 of those lines in the error. Sorry about that, should have said that in the 1st place.
 
Okay, I went and switched the variables for those lines. This makes it look like we are getting closer.


--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 6313.34321
Publish 54
Core: Optimizing for 1 64-bit processor
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 0 warnings
Errors:
+ Items/Equipment/Weapons/BaseRanged.cs:
CS1001: Line 71: Identifier expected
CS1001: Line 71: Identifier expected
CS1001: Line 133: Identifier expected
CS1001: Line 133: Identifier expected
CS1001: Line 164: Identifier expected
CS1001: Line 164: Identifier expected
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.


Attaching the latest amended script.
[doublepost=1492370155][/doublepost]71 public override TimeSpan OnSwing(Mobile attacker, IDamageable, damageable) <----indicator says identifier expected between Idamageable, and after the ) at the end of the line

133 public override void OnHi(Mobile attacker, IDamageable, damageable, double damageBonus) <--- indicator between the IDamgeable, and the damageable saying identifier expected


164 public override void OnMiss(Mobile attacker, IDamageable, damageable) <--- indicator between the IDamgeable, and the damageable saying identifier expected and at end of the line
 

Attachments

  • [ServUO.com]-BaseRanged.cs
    7.1 KB · Views: 1
Between cleaning the house and getting ready for a garage sale then slipping by the computer to work on this, it's a wonder I haven't broken it. 8) Just spent the last hour inside the bathtub scrubbing tile. I smell like a homeless man atm.
[doublepost=1492377557][/doublepost]--------------------------------------------------------------------------------

ServUO - [http://www.servuo.com] Version 0.5, Build 6313.34321
Publish 54
Core: Optimizing for 1 64-bit processor
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 9 warnings
Warnings:


Errors:
+ Items/Equipment/Weapons/BaseRanged.cs:
CS0115: Line 133: 'Server.Items.BaseRanged.OnHi(Server.Mobile, Server.IDamag
eable, double)': no suitable method found to override
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

This is my Line 133

public override void OnHi(Mobile attacker, IDamageable damageable, double damageBonus)
[doublepost=1492377843][/doublepost]This is sorta like the song that will never end....
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back