RedBeard

Member
Im trying to implement Begging as per Broadsword shards

This section doesn't seem to get recognized
else if (m_From.CheckTargetSkill(SkillName.Begging, m_Target, 0.0, 100.0))

{

if (m_Target is Darius && (0.75 > Utility.RandomDouble()))

if (m_From.Region.Name == "Heartwood" && (0.75 > Utility.RandomDouble()))

{

Item item = null;

item = new BeggingItem();

switch (Utility.Random(2))

{

case 0: item = new WaterPitcher(); break;

case 1: item = new WaterPitcherReversed(); break;

case 2: item = new FrenchBread(); break;

}

if (item != null)

m_From.AddToBackpack(item);

}

if (m_Target is Darius && (0.24 > Utility.RandomDouble()))

if (m_From.Region.Name == "Heartwood" && (0.24 > Utility.RandomDouble()))

{

Item item = null;

item = new BeggingItem();

switch (Utility.Random(5))

{

case 0: item = new Lantern(); break;

case 1: item = new CheesePizza(); break;

case 2: item = new WoodenBowlOfStew(); break;

case 3: item = new CheeseWedge(); break;

case 4: item = new Shirt(); break;

case 5: item = new BunchOfDates(); break;

case 6: item = new LiquorPitcher(); break;

case 7: item = new LiquorPitcherReversed(); break;

}

if (item != null)

m_From.AddToBackpack(item);

}

if (m_Target is Darius && (0.01 > Utility.RandomDouble()))

if (m_From.Region.Name == "Heartwood" && (0.01 > Utility.RandomDouble()))

{

Item item = null;

item = new BeggingItem();

switch (Utility.Random(11))

{

case 0: item = new Bedroll(); break;

case 1: item = new WinePitcher(); break;

case 2: item = new WinePitcherReversed(); break;

case 3: item = new BottleWineEmpty(); break;

case 4: item = new FlowerGarland(); break;

case 5: item = new FlowerGarlandReversed(); break;

case 6: item = new PlateOfCookies(); break;

case 7: item = new FishingPole(); break;

case 8: item = new FishSteak(); break;

case 9: item = new Sake(); break;

case 10: item = new Turnip(); break;

}

if (item != null)

m_From.AddToBackpack(item);

if (m_From.Karma > -3000)

{

int toLose = m_From.Karma + 3000;

if (toLose > 40)

toLose = 40;

Titles.AwardKarma(m_From, -toLose, true);

}

}
Here is my begging.cs
Code:
using System;

using Server;

using Server.Misc;

using Server.Targeting;

using Server.Items;

using Server.Regions;

using Server.Network;

using Server.Mobiles;

using Server.Engines.Quests;

using Server.Engines.Quests.Collector;

using System.Collections.Generic;

using System.Collections;

using Server.Engines.Craft;

using CustomsFramework;

using CustomsFramework.Systems.FoodEffects;

namespace Server.SkillHandlers

{

public class Begging

{

public static void Initialize()

{

SkillInfo.Table[(int)SkillName.Begging].Callback = new SkillUseCallback(OnUse);

}

public static TimeSpan OnUse(Mobile m)

{

m.RevealingAction();

m.Target = new InternalTarget();

m.RevealingAction();

m.SendLocalizedMessage(500397); // To whom do you wish to grovel?

return TimeSpan.FromHours(6.0);

}

private class InternalTarget : Target

{

private bool m_SetSkillTime = true;

public InternalTarget()

: base(12, false, TargetFlags.None)

{

}

protected override void OnTargetFinish(Mobile from)

{

if (m_SetSkillTime)

from.NextSkillTime = Core.TickCount;//DateTime.Now;

}

protected override void OnTarget(Mobile from, object targeted)

{

from.RevealingAction();

int number = -1;

if (targeted is Mobile)

{

Mobile targ = (Mobile)targeted;

if (targ.Player) // We can't beg from players

{

number = 500398; // Perhaps just asking would work better.

}

/* else if (!targ.Body.IsHuman) // Make sure the NPC is human

{

number = 500399; // There is little chance of getting money from that!

}*/

else if (!from.InRange(targ, 2))

{

if (!targ.Female)

number = 500401; // You are too far away to beg from him.

else

number = 500402; // You are too far away to beg from her.

}

else if (from.Mounted) // If we're on a mount, who would give us money?

{

number = 500404; // They seem unwilling to give you any money.

}

else

{

// Face eachother

from.Direction = from.GetDirectionTo(targ);

targ.Direction = targ.GetDirectionTo(from);

from.Animate(32, 5, 1, true, false, 0); // Bow

new InternalTimer(from, targ).Start();

m_SetSkillTime = false;

}

}

else // Not a Mobile

{

number = 500399; // There is little chance of getting money from that!

}

if (number != -1)

from.SendLocalizedMessage(number);

}

private class InternalTimer : Timer

{

private Mobile m_From, m_Target;

public InternalTimer(Mobile from, Mobile target)

: base(TimeSpan.FromSeconds(2.0))

{

m_From = from;

m_Target = target;

Priority = TimerPriority.TwoFiftyMS;

}

protected override void OnTick()

{

Container theirPack = m_Target.Backpack;

double badKarmaChance = 0.5 - ((double)m_From.Karma / 8570);

if (theirPack == null)

{

m_From.SendLocalizedMessage(500404); // They seem unwilling to give you any money.

}

else if (m_From.Karma < 0 && badKarmaChance > Utility.RandomDouble())

{

m_Target.PublicOverheadMessage(MessageType.Regular, m_Target.SpeechHue, 500406); // Thou dost not look trustworthy... no gold for thee today!

}

else if (m_From.CheckTargetSkill(SkillName.Begging, m_Target, 0.0, 100.0))

{


int toConsume = theirPack.GetAmount(typeof(Gold)) / 10;

int max = 10 + (m_From.Fame / 2500);

if (max > 14)

max = 14;

else if (max < 10)

max = 10;

if (toConsume > max)

toConsume = max;

if (toConsume > 0)

{

int consumed = theirPack.ConsumeUpTo(typeof(Gold), toConsume);

if (consumed > 0)

{

m_Target.PublicOverheadMessage(MessageType.Regular, m_Target.SpeechHue, 500405); // I feel sorry for thee...

Gold gold = new Gold(consumed);

m_From.AddToBackpack(gold);

m_From.PlaySound(gold.GetDropSound());

if (m_From.Karma > -3000)

{

int toLose = m_From.Karma + 3000;

if (toLose > 40)

toLose = 40;

Titles.AwardKarma(m_From, -toLose, true);

}

}

///////////////

else if (m_From.CheckTargetSkill(SkillName.Begging, m_Target, 0.0, 100.0))

{

if (m_Target is Darius && (0.75 > Utility.RandomDouble()))

if (m_From.Region.Name == "Heartwood" && (0.75 > Utility.RandomDouble()))

{

Item item = null;

item = new BeggingItem();

switch (Utility.Random(2))

{

case 0: item = new WaterPitcher(); break;

case 1: item = new WaterPitcherReversed(); break;

case 2: item = new FrenchBread(); break;

}

if (item != null)

m_From.AddToBackpack(item);

}

if (m_Target is Darius && (0.24 > Utility.RandomDouble()))

if (m_From.Region.Name == "Heartwood" && (0.24 > Utility.RandomDouble()))

{

Item item = null;

item = new BeggingItem();

switch (Utility.Random(5))

{

case 0: item = new Lantern(); break;

case 1: item = new CheesePizza(); break;

case 2: item = new WoodenBowlOfStew(); break;

case 3: item = new CheeseWedge(); break;

case 4: item = new Shirt(); break;

case 5: item = new BunchOfDates(); break;

case 6: item = new LiquorPitcher(); break;

case 7: item = new LiquorPitcherReversed(); break;

}

if (item != null)

m_From.AddToBackpack(item);

}

if (m_Target is Darius && (0.01 > Utility.RandomDouble()))

if (m_From.Region.Name == "Heartwood" && (0.01 > Utility.RandomDouble()))

{

Item item = null;

item = new BeggingItem();

switch (Utility.Random(11))

{

case 0: item = new Bedroll(); break;

case 1: item = new WinePitcher(); break;

case 2: item = new WinePitcherReversed(); break;

case 3: item = new BottleWineEmpty(); break;

case 4: item = new FlowerGarland(); break;

case 5: item = new FlowerGarlandReversed(); break;

case 6: item = new PlateOfCookies(); break;

case 7: item = new FishingPole(); break;

case 8: item = new FishSteak(); break;

case 9: item = new Sake(); break;

case 10: item = new Turnip(); break;

}

if (item != null)

m_From.AddToBackpack(item);

if (m_From.Karma > -3000)

{

int toLose = m_From.Karma + 3000;

if (toLose > 40)

toLose = 40;

Titles.AwardKarma(m_From, -toLose, true);

}

}

/////////////////////

else

{

m_Target.PublicOverheadMessage(MessageType.Regular, m_Target.SpeechHue, 500407); // I have not enough money to give thee any!

}

}

else

{

m_Target.PublicOverheadMessage(MessageType.Regular, m_Target.SpeechHue, 500407); // I have not enough money to give thee any!

}

}

else

{

m_Target.SendLocalizedMessage(500404); // They seem unwilling to give you any money.

}

m_From.NextSkillTime = Core.TickCount;/*DateTime.Now*/ //+TimeSpan.FromSeconds(10.0);

}

}

}

}

}

}


Any pointers appreciated.
 

Attachments

  • Begging.cs
    15.6 KB · Views: 1
  • BeggingItem.cs
    1.9 KB · Views: 0
  • BeggingItems.cs
    10.7 KB · Views: 0
I updated begging a while back to be up to date with OSI. If you beg from elfs then you get items instead of gold.

Is there still something missing?
 
wasn't aware of any update sorry ill check yours out

Looks good but it should be empty bottle of wine no biggie

thanx
 
Last edited:

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back