Here is the quest giver script I am using. Currently when you turn in a completed quest you get a random piece of armor and some gold. I would like to add a random piece of specific armor like ranger armor to randomly drop as a reward sometimes also. I cant seem to get it right. I have tried adding something like this
But it always appears on the NPC and not in the players pack.
Please help! LOL
Code:
switch (Utility.Random(5))
case 0: AddItem(new RangerArms() ); break;
case 1: AddItem(new RangerChest() ); break;
case 2: AddItem(new RangerGloves() ); break;
case 3: AddItem(new RangerGorget() ); break;
case 4: AddItem(new RangerLegs() ); break;
But it always appears on the NPC and not in the players pack.
Code:
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Targeting;
using Server.Gumps;
using Server.Misc;
using Server.Network;
using Server.Spells;
using Server.Commands;
using Server.Mobiles;
namespace Server.Mobiles
{
[CorpseName( "quest master corpse" )]
public class QuestGiver : Mobile
{
public virtual bool IsInvulnerable{ get{ return false; } }//Invulnerable 1
[Constructable]
public QuestGiver()
{
//Change NPC characteristics, gear and stats in this section
InitStats(100, 100, 100);
Karma = 1000;
Fame = 1000;
Hue = Utility.RandomSkinHue();
Body = 0x190;
Blessed = true;//Invulnerable 2
AddItem( new QuarterStaff() );
AddItem( new StuddedArms() );
AddItem( new StuddedLegs() );
AddItem( new StuddedChest() );
AddItem( new StuddedGloves() );
AddItem( new StuddedGorget() );
AddItem( new Sandals( Utility.RandomNeutralHue() ) );
AddItem( new BodySash( Utility.RandomNeutralHue() ) );
AddItem( new Cloak( Utility.RandomNeutralHue() ) );
//AddItem( new Robe( Utility.RandomNeutralHue() ) );
Direction = Direction.South;
Name = NameList.RandomName( "male" );
Title = "The Quest Master";
CantWalk = true;
//Utility.AssignRandomHair( this );
Item hair = new Item( 0x203C );
hair.Hue = Utility.RandomHairHue();
hair.Layer = Layer.Hair;
hair.Movable = false;
AddItem( hair );
//End of section
}
public QuestGiver( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
public override void OnDoubleClick( Mobile from )
{
DisplayPaperdollTo( from );
Say(String.Format("Hello {0}, just say 'quest' if thou wouldst like to embark on a quest for me.", from.Name));
}
private static void GetRandomAOSStats( out int attributeCount, out int min, out int max, int level )
{
int rnd = Utility.Random( 15 );
if ( level == 6 )
{
attributeCount = Utility.RandomMinMax( 2, 6 );
min = 50; max = 100;
}
else if ( level == 5 )
{
attributeCount = Utility.RandomMinMax( 2, 4 );
min = 40; max = 90;
}
else if ( level == 4 )
{
attributeCount = Utility.RandomMinMax( 2, 3 );
min = 30; max = 80;
}
else if ( level == 3 )
{
attributeCount = Utility.RandomMinMax( 1, 3 );
min = 20; max = 70;
}
else if ( level == 2 )
{
attributeCount = Utility.RandomMinMax( 1, 2 );
min = 10; max = 60;
}
else
{
attributeCount = 10;
min = 10; max = 20;
}
}
public override bool HandlesOnSpeech( Mobile from )
{
if ( from.InRange( this.Location, 12 ) )
return true;
return base.HandlesOnSpeech( from );
}
public override void OnSpeech(SpeechEventArgs e )
{
if ( !e.Handled && e.Mobile.InRange( this.Location, 12 ) )
{
if (e.Speech == "quest")
{
e.Mobile.SendGump( new QuestGiver_gump( e.Mobile ) );
}
}
base.OnSpeech( e );
}
public override bool OnDragDrop(Mobile from, Item dropped)
{
Mobile m = from;
PlayerMobile mobile = m as PlayerMobile;
if ( mobile != null)
{
if(dropped is Gold && dropped.Amount==100)//Change the amount of gold per lvl quest here
{
mobile.AddToBackpack ( new QuestScroll(1) );
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
return true;
}
else if(dropped is Gold && dropped.Amount==200)//Change the amount of gold per lvl quest here
{
mobile.AddToBackpack ( new QuestScroll(2) );
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
return true;
}
else if(dropped is Gold && dropped.Amount==300)//Change the amount of gold per lvl quest here
{
mobile.AddToBackpack ( new QuestScroll(3) );
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
return true;
}
else if(dropped is Gold && dropped.Amount==400)//Change the amount of gold per lvl quest here
{
mobile.AddToBackpack ( new QuestScroll(4) );
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
return true;
}
else if(dropped is Gold && dropped.Amount==500)//Change the amount of gold per lvl quest here
{
mobile.AddToBackpack ( new QuestScroll(5) );
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
return true;
}
else if(dropped is Gold && dropped.Amount==600)//Change the amount of gold per lvl quest here
{
mobile.AddToBackpack ( new QuestScroll(6) );
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Return the Quest parchment to me when you are done...for your reward.", mobile.NetState );
return true;
}
else if(dropped is Gold)//Customize message when wrong amount of gold is given below
{
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "That is not the amount I am looking for.", mobile.NetState );
return false;
}
else if( dropped is QuestScroll )
{
QuestScroll m_Quest = (QuestScroll)dropped;
if(m_Quest.NNeed > m_Quest.NGot)
{
mobile.AddToBackpack ( dropped );//Customize message when quest scroll is incomplete below
this.PrivateOverheadMessage( MessageType.Regular, 89, false, "Thou hast not completed thy quest.", mobile.NetState );
return false;
}
string sMessage = "";//Customize message when valid quest scroll is complete and turned in below
if (m_Quest.NType == 1){ sMessage = "I see thou art victorious. Here is thy reward."; }
else { sMessage = "Ahh...you have found " + m_Quest.NItemName + "! Here is thy reward"; }
if ( Utility.RandomMinMax( 1, 4 ) == 1 )
{
mobile.AddToBackpack ( new Gold( m_Quest.NLevel * Utility.RandomMinMax( 250, 400 ) ) );
}
else
{
mobile.AddToBackpack ( new Gold( m_Quest.NLevel * Utility.RandomMinMax( 150, 300 ) ) );
Item item;
item = Loot.RandomArmorOrShieldOrWeapon();
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)item;
weapon.DamageLevel = (WeaponDamageLevel)Utility.Random( 6 );
weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random( 6 );
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
mobile.AddToBackpack ( item );
}
else if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor)item;
armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random( 6 );
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
mobile.AddToBackpack ( item );
}
else if( item is BaseHat )
{
BaseHat hat = (BaseHat)item;
mobile.AddToBackpack ( item );
}
else if( item is BaseJewel )
{
int attributeCount;
int min, max;
GetRandomAOSStats( out attributeCount, out min, out max, m_Quest.NLevel );
mobile.AddToBackpack ( item );
}
}
this.PrivateOverheadMessage(MessageType.Regular, 89, false, sMessage, mobile.NetState);
dropped.Delete();
return true;
}
else
{
mobile.AddToBackpack ( dropped );
this.PrivateOverheadMessage(MessageType.Regular, 89, false, "I have no need for this...", mobile.NetState); return true;
}
}
return false;
}
}
}
namespace Server.Gumps
{
public class QuestGiver_gump : Gump
{
public static void Initialize()
{
CommandSystem.Register( "QuestGiver_gump", AccessLevel.GameMaster, new CommandEventHandler( QuestGiver_gump_OnCommand ) );
//CommandSystem.Register( "Quest", AccessLevel.Player, new CommandEventHandler( QuestGiver_gump_OnCommand ) );//Allows players to use command instead of context menu to activate gump
}
private static void QuestGiver_gump_OnCommand( CommandEventArgs e )
{
e.Mobile.SendGump( new QuestGiver_gump( e.Mobile ) );
}
public QuestGiver_gump( Mobile owner ) : base( 50,50 )
{
AddPage( 0 );
AddImageTiled( 54, 33, 369, 400, 2624 );
AddAlphaRegion( 54, 33, 369, 400 );
AddImageTiled( 416, 39, 44, 389, 203 );
AddImage( 97, 49, 9005 );
AddImageTiled( 58, 39, 29, 390, 10460 );
AddImageTiled( 412, 37, 31, 389, 10460 );
AddLabel( 140, 60, 0x34, "The Quest Master" );
AddHtml( 107, 140, 300, 230, " < BODY > " +
////////////////////// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx THIS IS THE LENGTH OF THE TEXT ALLOWED //
"<BASEFONT COLOR=YELLOW>Hail brave adventurer. I am the local<BR>" +
"<BASEFONT COLOR=YELLOW>quest master. If anything needs to be<BR>" +
"<BASEFONT COLOR=YELLOW>done around here...I am the one to see.<BR>" +
"<BASEFONT COLOR=YELLOW>Although I am not supposed to hire any<BR>" +
"<BASEFONT COLOR=YELLOW>citizens, you look like you can handle<BR>" +
"<BASEFONT COLOR=YELLOW>yourself. Of course, I could get in<BR>" +
"<BASEFONT COLOR=YELLOW>much trouble if they find out that I<BR>" +
"<BASEFONT COLOR=YELLOW>let slip what needs to be done, as gold<BR>" +
"<BASEFONT COLOR=YELLOW>is rare and usually the nobles want to<BR>" +
"<BASEFONT COLOR=YELLOW>get the riches for themselves.<BR>" +
"<BASEFONT COLOR=YELLOW><BR>" +
"<BASEFONT COLOR=YELLOW>I'll tell you what, you slip a few gold<BR>" +
"<BASEFONT COLOR=YELLOW>coins my way, and I will be a little<BR>" +
"<BASEFONT COLOR=YELLOW>careless about what I say. The more<BR>" +
"<BASEFONT COLOR=YELLOW>gold I get...the more careless I will<BR>" +
"<BASEFONT COLOR=YELLOW>speak.<BR>" +
"<BASEFONT COLOR=YELLOW><BR>" +
"<BASEFONT COLOR=YELLOW>100 Gold - Level 1 Quest<BR>" +//List amount of gold required in gump for lvl quest
"<BASEFONT COLOR=YELLOW>200 Gold - Level 2 Quest<BR>" +//List amount of gold required in gump for lvl quest
"<BASEFONT COLOR=YELLOW>300 Gold - Level 3 Quest<BR>" +//List amount of gold required in gump for lvl quest
"<BASEFONT COLOR=YELLOW>400 Gold - Level 4 Quest<BR>" +//List amount of gold required in gump for lvl quest
"<BASEFONT COLOR=YELLOW>500 Gold - Level 5 Quest<BR>" +//List amount of gold required in gump for lvl quest
"<BASEFONT COLOR=YELLOW>600 Gold - Level 6 Quest<BR>" +//List amount of gold required in gump for lvl quest
"<BASEFONT COLOR=YELLOW><BR>" +
"<BASEFONT COLOR=YELLOW>Simply follow the quest by targeting a<BR>" +
"<BASEFONT COLOR=YELLOW>corpse of a slain creature. The corpse<BR>" +
"<BASEFONT COLOR=YELLOW>must be a creature you are in a<BR>" +
"<BASEFONT COLOR=YELLOW>quest to slay.<BR>" +
"<BASEFONT COLOR=YELLOW><BR>" +
"<BASEFONT COLOR=YELLOW><BR>" +
"<BASEFONT COLOR=YELLOW>Rewards very from much gold or some<BR>" +
"<BASEFONT COLOR=YELLOW>gold and a magical item.<BR>" +
"</BODY>", false, true);
AddImage( 430, 9, 10441);
AddImageTiled( 40, 38, 17, 391, 9263 );
AddImage( 6, 25, 10421 );
AddImage( 34, 12, 10420 );
AddImageTiled( 94, 25, 342, 15, 10304 );
AddImageTiled( 40, 427, 415, 16, 10304 );
AddImage( -10, 314, 10402 );
AddImage( 56, 150, 10411 );
AddImage( 155, 120, 2103 );
AddImage( 136, 84, 96 );
AddButton( 225, 390, 0xF7, 0xF8, 0, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 0:{ break; }
}
}
}
}
Please help! LOL