本文整理汇总了C#中Server.Item.Dupe方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Dupe方法的具体用法?C# Item.Dupe怎么用?C# Item.Dupe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Item
的用法示例。
在下文中一共展示了Item.Dupe方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lift
public virtual void Lift( Item item, int amount, out bool rejected, out LRReason reject )
{
rejected = true;
reject = LRReason.Inspecific;
if ( item == null )
return;
Mobile from = this;
NetState state = m_NetState;
if ( from.AccessLevel >= AccessLevel.GameMaster || Core.Now >= from.NextActionTime )
{
if ( from.CheckAlive() )
{
from.DisruptiveAction();
if ( from.Holding != null )
{
reject = LRReason.AreHolding;
}
else if ( from.AccessLevel < AccessLevel.GameMaster && !from.InRange( item.GetWorldLocation(), 2 ) )
{
reject = LRReason.OutOfRange;
}
else if ( !from.CanSee( item ) || !from.InLOS( item ) )
{
reject = LRReason.OutOfSight;
}
else if ( !item.VerifyMove( from ) )
{
reject = LRReason.CannotLift;
}
else if ( item.InSecureTrade || !item.IsAccessibleTo( from ) )
{
reject = LRReason.CannotLift;
}
else if ( !item.CheckLift( from, item ) )
{
reject = LRReason.Inspecific;
}
else
{
object root = item.RootParent;
if ( root != null && root is Mobile && !((Mobile)root).CheckNonlocalLift( from, item ) )
{
reject = LRReason.TryToSteal;
}
else if ( !from.OnDragLift( item ) || !item.OnDragLift( from ) )
{
reject = LRReason.Inspecific;
}
else if ( !from.CheckAlive() )
{
reject = LRReason.Inspecific;
}
else
{
item.SetLastMoved();
if ( amount == 0 )
amount = 1;
if ( amount > item.Amount )
amount = item.Amount;
int oldAmount = item.Amount;
item.Amount = amount;
if ( amount < oldAmount )
item.Dupe( oldAmount - amount );
Map map = from.Map;
if ( Mobile.DragEffects && map != null && (root == null || root is Item))
{
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
Packet p = null;
foreach ( NetState ns in eable )
{
if ( ns.Mobile != from && ns.Mobile.CanSee( from ) )
{
if ( p == null )
{
IEntity src;
if ( root == null )
src = new Entity( Serial.Zero, item.Location, map );
else
src = new Entity( ((Item)root).Serial, ((Item)root).Location, map );
p = new DragEffect( src, from, item.ItemID, item.Hue, amount );
}
ns.Send( p );
}
}
//.........这里部分代码省略.........
示例2: LoadWeapon
public virtual void LoadWeapon(Mobile from, Item projectile)
{
if (projectile == null) return;
// restrict allowed projectiles
if (!CheckAllowedProjectile(projectile))
{
from.SendMessage("That cannot be loaded into this weapon");
return;
}
if (m_Projectile != null && !m_Projectile.Deleted)
{
from.SendMessage("{0} unloaded", m_Projectile.Name);
from.AddToBackpack(m_Projectile);
}
if (projectile.Amount > 1)
{
projectile.Amount--;
Projectile = projectile.Dupe(1);
}
else
{
Projectile = projectile;
}
if (m_Projectile != null)
{
m_Projectile.Internalize();
from.SendMessage("{0} loaded", m_Projectile.Name);
}
}
示例3: TryStealItem
//.........这里部分代码省略.........
}
}
else
{
m_Thief.SendLocalizedMessage( 1005588 ); // You must join a faction to do that
}
}
#endregion
else if ( toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( Core.AOS && toSteal is Container )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
{
m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
}
else if ( toSteal.Parent is Mobile )
{
m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
}
else if ( root == m_Thief )
{
m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
}
else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
{
}
else if ( root is Corpse )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else
{
double w = toSteal.Weight + toSteal.TotalWeight;
if ( w > 10 )
{
m_Thief.SendMessage( "That is too heavy to steal." );
}
else
{
if ( toSteal.Stackable && toSteal.Amount > 1 )
{
int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);
if ( maxAmount < 1 )
maxAmount = 1;
else if ( maxAmount > toSteal.Amount )
maxAmount = toSteal.Amount;
int amount = Utility.RandomMinMax( 1, maxAmount );
if ( amount >= toSteal.Amount )
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
stolen = toSteal;
}
else
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
{
stolen = toSteal.Dupe( amount );
toSteal.Amount -= amount;
}
}
}
else
{
int iw = (int)Math.Ceiling( w );
iw *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
stolen = toSteal;
}
if ( stolen != null )
m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
else
m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
}
}
return stolen;
}
示例4: TryStealItem
//.........这里部分代码省略.........
double w = toSteal.Weight + toSteal.TotalWeight;
if ( w > 10 )
{
m_Thief.SendMessage( "That is too heavy to steal." );
}
else
{
if ( toSteal.Stackable && toSteal.Amount > 1 )
{
//ARTEGORDON
// fix for zero-weight stackables
int maxAmount = toSteal.Amount;
if(toSteal.Weight > 0)
maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);
if ( maxAmount < 1 )
maxAmount = 1;
else if ( maxAmount > toSteal.Amount )
maxAmount = toSteal.Amount;
int amount = Utility.RandomMinMax( 1, maxAmount );
if ( amount >= toSteal.Amount )
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
stolen = toSteal;
}
else
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
{
stolen = toSteal.Dupe( amount );
toSteal.Amount -= amount;
}
}
}
else
{
int iw = (int)Math.Ceiling( w );
iw *= 10;
// ARTEGORDONMOD
// Begin mod for ArtifactRarity difficulty scaling
// add in an additional difficulty factor for objects with ArtifactRarity
// with rarity=1 requiring a minimum of 100 stealing, and rarity 12 requiring a minimum of 118
// Note, this is completely independent of weight
Type ptype;
string value = BaseXmlSpawner.GetBasicPropertyValue(toSteal,"ArtifactRarity", out ptype);
if(ptype == typeof(int) && value != null)
{
int rarity = 0;
try{
rarity = int.Parse(value);
} catch{}
// rarity difficulty scaling
if(rarity > 0)
{
iw = (int)Math.Ceiling(120 + rarity*1.5);
}
}
// End mod for ArtifactRarity difficulty scaling
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
stolen = toSteal;
}
if ( stolen != null )
{
// ARTEGORDONMOD
// Begin mod for stealable rares and other locked down items
// set the taken flag to trigger release from any controlling spawner
ItemFlags.SetTaken(stolen, true);
// clear the stealable flag so that the item can only be stolen once if it is later locked down.
ItemFlags.SetStealable(stolen, false);
// release it if it was locked down
stolen.Movable = true;
// End mod for stealable rares and other locked down items
m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
}
else
m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
}
}
return stolen;
}
示例5: CheckGiveObjective
public static bool CheckGiveObjective(IXmlQuest quest, Mobile mob, Item item, string objectivestr, string statestr, out string newstatestr, out bool givestatus)
{
// format for the objective string will be GIVE,mobname,itemtype[,count][,proptest] or GIVENAMED,mobname,itemname[,type][,count][,proptest]
newstatestr = statestr;
givestatus = false;
if (objectivestr == null) return false;
if (mob == null || mob.Name == null) return false;
string[] arglist = BaseXmlSpawner.ParseString(objectivestr, 6, ",");
int targetcount = 1;
bool found = false;
bool checkprop = true;
string status_str = null;
string typestr = null;
CheckArgList(arglist, 3, item, out typestr, out targetcount, out checkprop, out status_str);
if (status_str != null) quest.Status = status_str;
if (arglist.Length > 1)
{
// the name of the mob must match the specified mobname
if (mob.Name != arglist[1]) return false;
}
if (arglist.Length > 2)
{
// collect task objective
if (arglist[0] == "GIVE")
{
//Type targettype = SpawnerType.GetType( arglist[2] );
// test the requirements against the the given item
if (item != null && !item.Deleted && BaseXmlSpawner.CheckType(item, arglist[2]) /*(item.GetType() == targettype)*/ && checkprop)
{
// found a match
found = true;
}
}
else
if (arglist[0] == "GIVENAMED")
{
if (item != null && !item.Deleted && (arglist[2] == item.Name) && checkprop &&
(typestr == null || BaseXmlSpawner.CheckType(item, typestr))
)
{
// found a match
found = true;
}
}
}
// update the objective state
if (found)
{
int current = 0;
try
{
current = int.Parse(statestr);
}
catch { }
// get the current given count and update it
int added = 0;
if (item.Stackable)
{
if (targetcount - current < item.Amount)
{
added = targetcount - current;
if (quest != null && quest.PlayerMade)
{
Item newitem = item.Dupe(added);
//if(newitem != null)
//newitem.Amount = added;
TakeGiven(mob, quest, newitem);
}
item.Amount -= added;
}
else
{
added = item.Amount;
TakeGiven(mob, quest, item);
//item.Delete();
}
}
else
{
if (targetcount - current > 0)
{
added = 1;
TakeGiven(mob, quest, item);
//item.Delete();
}
}
int collected = current + added;
//.........这里部分代码省略.........
示例6: CheckCollectObjective
public static bool CheckCollectObjective(IXmlQuest quest, Item item, string objectivestr, string statestr, out string newstatestr, out bool collectstatus)
{
// format for the objective string will be COLLECT,itemtype[,count][,proptest] or COLLECTNAMED,itemname[,itemtype][,count][,proptest]
newstatestr = statestr;
collectstatus = false;
if (objectivestr == null) return false;
string[] arglist = BaseXmlSpawner.ParseString(objectivestr, 5, ",");
int targetcount = 1;
bool found = false;
bool checkprop = true;
string status_str = null;
string typestr = null;
CheckArgList(arglist, 2, item, out typestr, out targetcount, out checkprop, out status_str);
if (status_str != null) quest.Status = status_str;
if (arglist.Length > 1)
{
// collect task objective
if (arglist[0] == "COLLECT")
{
//Type targettype = SpawnerType.GetType( arglist[1] );
// test the collect requirements against the the collected item
if (item != null && !item.Deleted && BaseXmlSpawner.CheckType(item, arglist[1])/*(item.GetType() == targettype)*/ && checkprop)
{
// found a match
found = true;
}
}
else
if (arglist[0] == "COLLECTNAMED")
{
if (item != null && !item.Deleted && (arglist[1] == item.Name) && checkprop &&
(typestr == null || BaseXmlSpawner.CheckType(item, typestr))
)
{
// found a match
found = true;
}
}
}
// update the objective state
if (found)
{
int current = 0;
try
{
current = int.Parse(statestr);
}
catch { }
// get the current collect count and update it
int added = 0;
if (item.Stackable)
{
if (targetcount - current < item.Amount)
{
added = targetcount - current;
if (quest != null && quest.PlayerMade)
{
Item newitem = item.Dupe(added);
//if(newitem != null)
//newitem.Amount = added;
ReturnCollected(quest, newitem);
}
item.Amount -= added;
}
else
{
added = item.Amount;
// if it is a playermade quest then give the item to the creator, otherwise just delete it
ReturnCollected(quest, item);
//item.Delete();
}
}
else
{
if (targetcount - current > 0)
{
added = 1;
ReturnCollected(quest, item);
//item.Delete();
}
}
int collected = current + added;
newstatestr = String.Format("{0}", collected);
if (collected >= targetcount)
{
// collecttask completed
collectstatus = true;
}
return true;
//.........这里部分代码省略.........
示例7: TryStealItem
private Item TryStealItem( Item toSteal, object root, int difficulty, ref bool ok, ref bool caught )
{
Item stolen = null;
//if ( toSteal is KeyRing )
// toSteal.Weight = toSteal.TotalWeight = 1;
if ( root is BaseVendor || root is PlayerVendor )
{
m_Thief.SendLocalizedMessage( 1005598 ); // You can't steal from shopkeepers.
}
else if ( !m_Thief.CanSee( toSteal ) || ( root != null && !m_Thief.CanSee( root ) ) )
{
m_Thief.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
{
m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
}
else if ( toSteal.Parent is Mobile )
{
m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
}
else if ( root == m_Thief )
{
m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
}
else if ( root is Mobile && ( ((Mobile)root).AccessLevel > AccessLevel.Player || !m_Thief.CanBeHarmful( (Mobile)root ) ) )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else
{
for(Item p = toSteal.Parent as Item;p != null;p=p.Parent as Item)
{
if ( p is LockableContainer && ((LockableContainer)p).Locked )
{
m_Thief.SendAsciiMessage( "That is not accessable." );
return null;
}
}
if ( toSteal.Weight + toSteal.TotalWeight > 10 )
{
m_Thief.SendAsciiMessage( "That is too heavy to steal from someone's backpack." );
}
else
{
ok = true;
double w = toSteal.PileWeight + toSteal.TotalWeight;
double check;
if ( w >= 10 )
{
check = 10 * 3.0 * difficulty + 10.0;
caught = CheckDetect( ( 10 * 5.0 * difficulty ) / ( m_Thief.Skills.Stealing.Value + 100.0 ), root as Mobile );
}
else
{
check = w * 3.0 * difficulty + 10.0;
if ( toSteal is Key || toSteal is Multis.Deeds.HouseDeed || toSteal is KeyRing )
w += 5;
caught = CheckDetect( ( w * 5.0 * difficulty ) / ( m_Thief.Skills.Stealing.Value + 100.0 ), root as Mobile );
}
if ( m_Thief.CheckSkill( SkillName.Stealing, check-25, check+25 ) )
{
m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
if ( toSteal.Stackable && toSteal.Amount > 1 )
{
int amount;
/*int maxAmount = (int)( (m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight );
if ( maxAmount < 1 )
maxAmount = 1;
else if ( maxAmount > toSteal.Amount )
maxAmount = toSteal.Amount;
amount = Utility.Random( maxAmount ) + 1;*/
amount = Utility.Random( 10 ) + 1;
if ( amount > w )
amount = toSteal.Amount;
else
amount = (toSteal.Amount * amount) / ( toSteal.PileWeight + toSteal.TotalWeight );
if ( amount < 1 )
amount = 1;
if ( amount >= toSteal.Amount )
{
stolen = toSteal;
}
else
{
stolen = toSteal.Dupe( amount );
//.........这里部分代码省略.........
示例8: TryStealItem
//.........这里部分代码省略.........
else if ( toSteal.Parent == null || !toSteal.Movable || toSteal.LootType == LootType.Newbied || toSteal.CheckBlessed( root ) )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( !m_Thief.InRange( toSteal.GetWorldLocation(), 1 ) )
{
m_Thief.SendLocalizedMessage( 502703 ); // You must be standing next to an item to steal it.
}
else if ( toSteal.Parent is Mobile )
{
m_Thief.SendLocalizedMessage( 1005585 ); // You cannot steal items which are equiped.
}
else if ( root == m_Thief )
{
m_Thief.SendLocalizedMessage( 502704 ); // You catch yourself red-handed.
}
else if ( root is Mobile && ((Mobile)root).AccessLevel > AccessLevel.Player )
{
m_Thief.SendLocalizedMessage( 502710 ); // You can't steal that!
}
else if ( root is Mobile && !m_Thief.CanBeHarmful( (Mobile)root ) )
{
m_Thief.SendMessage("You can't steal from them.");
}
else
{
double w = toSteal.Weight + toSteal.TotalWeight;
if ( w > 10 )
{
m_Thief.SendMessage( "That is too heavy to steal." );
}
else
{
if ( toSteal.Stackable && toSteal.Amount > 1 )
{
int minAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 25.0) / toSteal.Weight);
int maxAmount = (int)((m_Thief.Skills[SkillName.Stealing].Value / 10.0) / toSteal.Weight);
if ( minAmount < 1 )
minAmount = 1;
if ( maxAmount < 1 )
maxAmount = 1;
else if ( maxAmount > toSteal.Amount )
maxAmount = toSteal.Amount;
int amount = Utility.RandomMinMax( minAmount, maxAmount );
if ( amount >= toSteal.Amount )
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * toSteal.Amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
stolen = toSteal;
}
else
{
int pileWeight = (int)Math.Ceiling( toSteal.Weight * amount );
pileWeight *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, pileWeight - 22.5, pileWeight + 27.5 ) )
{
stolen = toSteal.Dupe( amount );
toSteal.Amount -= amount;
}
}
}
else
{
int iw = (int)Math.Ceiling( w );
iw *= 10;
if ( m_Thief.CheckTargetSkill( SkillName.Stealing, toSteal, iw - 22.5, iw + 27.5 ) )
stolen = toSteal;
}
if ( stolen != null )
m_Thief.SendLocalizedMessage( 502724 ); // You succesfully steal the item.
if (m_Thief.Player == true)
{
((PlayerMobile)m_Thief).LastStoleAt = DateTime.Now;
}
if ( stolen == null ) //change from else to if - Pigpen
m_Thief.SendLocalizedMessage( 502723 ); // You fail to steal the item.
caught = ( m_Thief.Skills[SkillName.Stealing].Value < Utility.Random( 150 ) );
}
}
// wea: reset next skill time
m_Thief.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(10.0);
// adam: reset the LootType.Special to LootType.Regular
if (stolen != null && stolen.LootType == LootType.Special)
stolen.LootType = LootType.Regular;
return stolen;
}