/// <summary> /// Equip a char with an object. /// </summary> /// <param name="obj">The object.</param> /// <param name="iWear">The equipment slot to place the object on.</param> public void EquipObject( ref Object obj, ObjTemplate.WearLocation iWear ) { int aff; if( obj == null ) return; if( Object.GetEquipmentOnCharacter( this, iWear ) ) { string buf = String.Format( "CharData.EquipObject(): {0} already equipped at slot {1}.", Name, iWear ); Log.Error( buf, 0 ); return; } if( ( obj.HasFlag( ObjTemplate.ITEM_ANTI_EVIL ) && IsEvil() ) || ( obj.HasFlag( ObjTemplate.ITEM_ANTI_GOOD ) && IsGood() ) || ( obj.HasFlag( ObjTemplate.ITEM_ANTI_NEUTRAL ) && IsNeutral() ) ) { SocketConnection.Act( "You are zapped by $p&n and drop it.", this, obj, null, SocketConnection.MessageTarget.character ); SocketConnection.Act( "$n&n is zapped by $p&n and drops it.", this, obj, null, SocketConnection.MessageTarget.room ); obj.RemoveFromChar(); obj.AddToRoom( InRoom ); return; } ArmorPoints -= Object.GetArmorClassModifer( obj, iWear ); obj.WearLocation = iWear; CarryNumber--; foreach (Affect affect in obj.ObjIndexData.Affected) { ApplyAffectModifiers(affect, true); } foreach (Affect affect in obj.Affected) { ApplyAffectModifiers(affect, true); } if (obj.ItemType == ObjTemplate.ObjectType.light && obj.Values[2] != 0 && InRoom) { ++InRoom.Light; } for( aff = 0; aff < Limits.NUM_AFFECT_VECTORS; aff++ ) AffectedBy[ aff ] = AffectedBy[ aff ] | obj.AffectedBy[ aff ]; if (!IsNPC() && Socket.Terminal == SocketConnection.TerminalType.TERMINAL_ENHANCED) { Command.Equipment(this, new string[] { "" } ); } return; }
public static void GetObject(CharData ch, Object obj, Object container) { if (!obj.HasWearFlag(ObjTemplate.WEARABLE_CARRY)) { ch.SendText("You can't pick that up.\r\n"); return; } if (obj._itemType != ObjTemplate.ObjectType.money) { if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight()) { SocketConnection.Act("$p&n is quite literally the &+Ystraw&n that would break the &n&+ycamel&n's back.", ch, obj, null, SocketConnection.MessageTarget.character); return; } } if (container != null) { SocketConnection.Act("You get $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n retrieves $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.room); obj.RemoveFromObject(); // Fix for corpse EQ dupe on crash if (container._itemType == ObjTemplate.ObjectType.pc_corpse) { Database.CorpseList.Save(); } } else { SocketConnection.Act("You get $p&n.", ch, obj, container, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&n picks up $p&n.", ch, obj, container, SocketConnection.MessageTarget.room); obj.RemoveFromRoom(); } if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil()) { SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L. Ouch!&n", ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room); Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic); obj.AddToRoom(ch.InRoom); return; } if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil()) { SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L. Ouch!&n", ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room); Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic); obj.AddToRoom(ch.InRoom); return; } if (obj.HasFlag(ObjTemplate.ITEM_ANTI_GOOD) && ch.IsGood()) { SocketConnection.Act("&+LYou are &n&+rconsumed&+L by &+Rfire&+L and &+Ldespair&n from $p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.character); SocketConnection.Act("$n&+L is &n&+rengulfed&+L by an abundancy of &+Rflames&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room); Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic); obj.AddToRoom(ch.InRoom); return; } if (obj._itemType == ObjTemplate.ObjectType.money) { int amount = obj._values[0] + obj._values[1] + obj._values[2] + obj._values[3]; ch.ReceiveCopper(obj._values[0]); ch.ReceiveSilver(obj._values[1]); ch.ReceiveGold(obj._values[2]); ch.ReceivePlatinum(obj._values[3]); if (amount > 1) { string text = String.Format("You pick up"); string text2; if (obj._values[3] > 0) { text2 = String.Format(" {0} &+Wplatinum&n", obj._values[3]); if (obj._values[0] > 0 || obj._values[1] > 0 || obj._values[2] > 0) { text2 += ","; } text += text2; } if (obj._values[2] > 0) { text2 = String.Format(" {0} &+Ygold&n", obj._values[2]); if (obj._values[0] > 0 || obj._values[1] > 0) { text2 += ","; } text += text2; } if (obj._values[1] > 0) { text2 = String.Format(" {0} &n&+wsilver&n", obj._values[1]); if (obj._values[0] > 0) { text2 += ","; } text += text2; } if (obj._values[0] > 0) { text2 = String.Format(" {0} &n&+ycopper&n", obj._values[0]); text += text2; } text += " coins.\r\n"; ch.SendText(text); } obj.RemoveFromWorld(); } else { obj.ObjToChar(ch); // Prevent item duplication. CharData.SavePlayer(ch); } return; }