本文整理汇总了C#中MUDEngine.CharData.CanDropObject方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.CanDropObject方法的具体用法?C# CharData.CanDropObject怎么用?C# CharData.CanDropObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUDEngine.CharData
的用法示例。
在下文中一共展示了CharData.CanDropObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Give
//.........这里部分代码省略.........
if (!ch.CheckQuest(victim, null, (amount * 1000)))
{
victim.ReceivePlatinum(amount);
}
// Prevent money duping
CharData.SavePlayer(ch);
CharData.SavePlayer(victim);
return;
}
ch.SendText("You don't have any of _that_ type of coin yet.\r\n");
return;
}
Object obj = ch.GetObjCarrying(arg1);
if (!obj)
{
ch.SendText("You do not have that item.\r\n");
return;
}
if (obj.WearLocation != ObjTemplate.WearLocation.none)
{
ch.SendText("You must remove it first.\r\n");
return;
}
victim = ch.GetCharRoom(arg2);
if (victim == null)
{
ch.SendText("They aren't here.\r\n");
return;
}
if (!ch.CanDropObject(obj))
{
ch.SendText("You couldn't possibly part with it.\r\n");
return;
}
/*
* How silly of shopkeepers to refuse blessed items... previously vampires would
* refuse blessed items... now all undead types refuse blessed items.
*/
if (obj.HasFlag(ObjTemplate.ITEM_BLESS) && victim.IsUndead())
{
SocketConnection.Act("$N&n refuses to touch the blessed $p&n.", ch, obj, victim, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n tries to give $N&n a $p&n but $E refuses.", ch, obj, victim, SocketConnection.MessageTarget.room);
SocketConnection.Act("You refuse to accept the blessed $p&n from $n&n.", ch, obj, victim, SocketConnection.MessageTarget.victim);
return;
}
if (victim.CarryNumber + 1 > Limits.MAX_CARRY)
{
SocketConnection.Act("$N&n has $S hands full.", ch, null, victim, SocketConnection.MessageTarget.character);
return;
}
if (victim.CarryWeight + obj.GetWeight() > victim.MaxCarryWeight())
{
SocketConnection.Act("$N&n cannot carry that much weight.", ch, null, victim, SocketConnection.MessageTarget.character);
return;
}
if (!CharData.CanSeeObj(victim, obj))
{
SocketConnection.Act("$N&n can't see it.", ch, null, victim, SocketConnection.MessageTarget.character);
示例2: Drop
//.........这里部分代码省略.........
for ( obj = ch.in_room.contents; obj; obj = obj_next )
{
obj_next = obj.next_content;
switch ( obj.pIndexData.vnum )
{
case StaticObjects.OBJECT_NUMBER_MONEY_ONE:
amount += 1;
obj.ExtractFromWorld();;
break;
case StaticObjects.OBJECT_NUMBER_MONEY_SOME:
amount += obj.value[0];
obj.ExtractFromWorld();;
break;
}
}
*/
ch.SendText("Done.\r\n");
SocketConnection.Act("$n&n drops some &n&+wcoins&n.", ch, null, null, SocketConnection.MessageTarget.room);
return;
}
if (str[0] != "all" && MUDString.IsPrefixOf("all.", str[0]))
{
/* 'drop iobj' */
Object iobj = ch.GetObjCarrying(str[0]);
if (!iobj)
{
ch.SendText("You do not have that item.\r\n");
return;
}
if (!ch.CanDropObject(iobj))
{
ch.SendText("You can't release your grip on it.\r\n");
return;
}
iobj.RemoveFromChar();
iobj.AddToRoom(ch.InRoom);
// Prevent item duping - Xangis
CharData.SavePlayer(ch);
iobj.FlyLevel = ch.FlightLevel;
SocketConnection.Act("You drop $p&n.", ch, iobj, null, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n discards $p&n.", ch, iobj, null, SocketConnection.MessageTarget.room);
if (iobj.HasFlag(ObjTemplate.ITEM_TRANSIENT))
{
SocketConnection.Act("$p&n crumbles to dust.", ch, iobj, null, SocketConnection.MessageTarget.all);
iobj.RemoveFromWorld();
}
else if (ch.InRoom.TerrainType == TerrainType.lava && !iobj.HasFlag(ObjTemplate.ITEM_NOBURN))
{
SocketConnection.Act("$p&n melts as it sinks into the &+RLava&n.", ch, iobj, null, SocketConnection.MessageTarget.all);
if (!ch.IsNPC())
{
((PC)ch).Destroyed.AddItem(iobj);
}
iobj.RemoveFromWorld();
}
}
else
{
/* 'drop all' or 'drop all.obj' */
示例3: Value
/// <summary>
/// Value: Find out how much a shopkeeper will pay for an item.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Value(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
CharData keeper;
int cost;
if (str.Length == 0)
{
ch.SendText("Value what?\r\n");
return;
}
if (!(keeper = ch.FindShopkeeper("")))
return;
if (!(obj = ch.GetObjCarrying(str[0])))
{
SocketConnection.Act("$n&n tells you 'You don't have that item'.",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if (!ch.CanDropObject(obj))
{
ch.SendText("That's not something you can sell.\r\n");
return;
}
if (!CharData.CanSeeObj(keeper, obj))
{
SocketConnection.Act("$n&+W tells you 'You are offering me an imaginary object!?!?'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if ((cost = Object.GetCost(ch, keeper, obj, false)) <= 0)
{
SocketConnection.Act("$n&n looks uninterested in $p&n.", keeper, obj, ch, SocketConnection.MessageTarget.victim);
return;
}
if (obj.HasFlag(ObjTemplate.ITEM_POISONED))
{
SocketConnection.Act("$n&+W tells you 'I won't buy that! It's poisoned!'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
string buf = String.Format("$n&+W tells you 'I'll give you {0} &n&+ycopper&+W coins for $p&n.'", cost);
SocketConnection.Act(buf, keeper, obj, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
示例4: Steal
//.........这里部分代码省略.........
if (!sleeping && !victim.IsBlind())
{
CommandType.Interpret(victim, "kill " + ch.Name);
}
}
else
{
if (!victim.IsBlind() && !sleeping && victim.IsAffected(Affect.AFFECT_BERZERK))
{
victim.SendText("In your &+Rblood rage&n, you lash out in anger!\r\n");
CommandType.Interpret(victim, "kill " + ch.Name);
}
}
/*
if ( !Macros.IS_SET( ch.actflags, PC.PLAYER_THIEF ) )
{
Macros.SET_BIT( ref ch.actflags, PC.PLAYER_THIEF );
buf = String.Format( "{0} became a THIEF by stealing from {1}",
ch._name, victim._name );
Immtalk.Immtalk( ch, Immtalk.IMMTALK_CRIME, ch.GetTrust(), buf );
CharData.SavePlayer( ch );
}
*/
// }
if (sleeping)
{
if (MUDMath.NumberPercent() < victim.GetCurrLuck())
{
CommandType.Interpret(victim, "wake");
}
}
return;
} //end failure
if (!MUDString.IsPrefixOf(arg1, "coins"))
{
int amount = victim.GetGold() * MUDMath.NumberRange(1, 20) / 100;
int amount2 = victim.GetSilver() * MUDMath.NumberRange(1, 20) / 100;
int amount3 = victim.GetCopper() * MUDMath.NumberRange(1, 20) / 100;
int amount4 = victim.GetPlatinum() * MUDMath.NumberRange(1, 20) / 100;
if ((amount + amount2 + amount3 + amount4) <= 0)
{
ch.SendText("You couldn't get any &n&+wcoins&n.\r\n");
return;
}
ch.ReceiveGold(amount);
ch.ReceiveSilver(amount2);
ch.ReceiveCopper(amount3);
ch.ReceivePlatinum(amount4);
victim.SpendGold(amount);
victim.SpendSilver(amount2);
victim.SpendCopper(amount3);
victim.SpendPlatinum(amount4);
string text = String.Format("Success! You got {0} &+Wplatinum&n, {1} &+Ygold&n, {2} silver, and {3} &+ycopper&n.\r\n",
amount2, amount3, amount, amount4);
ch.SendText(text);
return;
}
if (!ch.CanDropObject(obj) || obj.HasFlag(ObjTemplate.ITEM_INVENTORY))
{
ch.SendText("You can't pry it away.\r\n");
return;
}
if (ch.CarryNumber + 1 > Limits.MAX_CARRY)
{
ch.SendText("You have your hands full.\r\n");
return;
}
if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight())
{
ch.SendText("You cannot carry that much weight.\r\n");
return;
}
if (obj.WearLocation != ObjTemplate.WearLocation.none)
{
ch.SendText("Very daring, and you got it!\r\n");
victim.UnequipObject(obj);
}
obj.RemoveFromChar();
obj.ObjToChar(ch);
ch.SendText("Nice work.\r\n");
if (obj.Trap != null && obj.Trap.CheckTrigger( Trap.TriggerType.steal))
{
ch.SetOffTrap(obj);
if (ch.CurrentPosition == Position.dead)
{
return;
}
}
return;
}
示例5: Sell
/// <summary>
/// Sell an item.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Sell(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
CharData keeper;
string arg2 = String.Empty;
int cost;
if (str.Length == 0)
{
ch.SendText("Sell what?\r\n");
return;
}
if (!(keeper = ch.FindShopkeeper(arg2)))
{
return;
}
if (!ch.IsNPC())
{
// Won't buy from bottom 25% of faction range.
if (((PC)ch).GetFaction(keeper) < (Limits.MIN_FACTION / 2))
{
SocketConnection.Act("$n&+W tells you 'I won't do business with scum like you.'&n", keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
}
if (!(obj = ch.GetObjCarrying(str[0])))
{
SocketConnection.Act("$n&+W tells you 'You don't have that item.'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if (!ch.CanDropObject(obj))
{
ch.SendText("You couldn't possibly part with that.\r\n");
return;
}
if (!CharData.CanSeeObj(keeper, obj))
{
SocketConnection.Act("$n&+W tells you 'I can't see that item.'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
if ((cost = Object.GetCost(ch, keeper, obj, false)) <= 0 || obj.HasFlag(ObjTemplate.ITEM_NOSELL))
{
SocketConnection.Act("$n&n looks uninterested in $p&n.", keeper, obj, ch, SocketConnection.MessageTarget.victim);
return;
}
if (cost > obj.Cost)
{
Log.Error("Shopkeeper with index number {0} buys for more than 100 percent of value.\r\n",
keeper.MobileTemplate.IndexNumber);
cost = obj.Cost;
}
if (cost < 1)
cost = 1;
if (obj.HasFlag(ObjTemplate.ITEM_POISONED))
{
SocketConnection.Act("$n&+W tells you 'I won't buy that! It's poisoned!'&n",
keeper, null, ch, SocketConnection.MessageTarget.victim);
ch.ReplyTo = keeper;
return;
}
string buf = String.Format("You sell $p&n for {0}.", StringConversion.CoinString(cost));
SocketConnection.Act(buf, ch, obj, null, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n sells $p&n.", ch, obj, null, SocketConnection.MessageTarget.room);
ch.ReceiveCash(cost);
if (obj.ItemType == ObjTemplate.ObjectType.trash)
{
obj.RemoveFromWorld();
}
else
{
obj.RemoveFromChar();
obj.ObjToChar(keeper);
// Selling an object decreases its scarcity.
--obj.ObjIndexData.Scarcity;
}
return;
//.........这里部分代码省略.........
示例6: Put
/// <summary>
/// Put an object into another object.
/// </summary>
/// <param name="ch"></param>
/// <param name="str"></param>
public static void Put(CharData ch, string[] str)
{
if( ch == null ) return;
Object obj;
if (str.Length < 2)
{
ch.SendText("Put what into what?\r\n");
return;
}
if (!MUDString.StringsNotEqual(str[1], "all") || !MUDString.IsPrefixOf("all.", str[1]))
{
ch.SendText("You can't do that.\r\n");
return;
}
Object container = ch.GetObjHere(str[1]);
if (!container)
{
SocketConnection.Act("You see no $T&n here.", ch, null, str[1], SocketConnection.MessageTarget.character);
return;
}
/* Added put <missileweap> <quiver> */
if (container.ItemType != ObjTemplate.ObjectType.container &&
container.ItemType != ObjTemplate.ObjectType.quiver)
{
ch.SendText("That's not a container.\r\n");
return;
}
if (Macros.IsSet(container.Values[1], ObjTemplate.CONTAINER_CLOSED.Vector))
{
SocketConnection.Act("The $d&n is &n&+ystrapped&n shut.", ch, null, container.Name, SocketConnection.MessageTarget.character);
return;
}
if (str[0] != "all" && MUDString.IsPrefixOf("all.", str[0]))
{
/* 'put obj container' */
obj = ch.GetObjCarrying(str[0]);
if (!obj)
{
ch.SendText("You do not have that item.\r\n");
return;
}
if (obj == container)
{
ch.SendText("You can't fold it into itself.\r\n");
return;
}
if (!ch.CanDropObject(obj))
{
ch.SendText("You can't seem to let go of it.\r\n");
return;
}
if (obj.GetWeight() + container.GetWeight() - container.Weight > container.Values[0])
{
ch.SendText("It won't fit.\r\n");
return;
}
/* Added put <missileweap> <quiver> */
if (container.ItemType == ObjTemplate.ObjectType.quiver
&& obj.ItemType != ObjTemplate.ObjectType.missile_weapon)
{
SocketConnection.Act("$p&n doesn't belong in $P&n.", ch, obj, container, SocketConnection.MessageTarget.character);
return;
}
obj.RemoveFromChar();
container.AddToObject(obj);
SocketConnection.Act("You put $p&n in $P&n.", ch, obj, container, SocketConnection.MessageTarget.character);
SocketConnection.Act("$n&n slips $p&n into $P&n.", ch, obj, container, SocketConnection.MessageTarget.room);
if (obj.Trap != null && obj.Trap.CheckTrigger(Trap.TriggerType.get_put))
{
ch.SetOffTrap(obj);
}
}
else
{
/* 'put all container' or 'put all.obj container' */
bool stuff = false;
foreach (Object iobj in ch.Carrying)
{
if (iobj.WearLocation != ObjTemplate.WearLocation.none)
{
continue;
}
//.........这里部分代码省略.........