Full Version : Things that are only for playerselves
xmlspawner >>Scripting Support >>Things that are only for playerselves


<< Prev | Next >>

Galfaroth- 02-11-2006
Hello all (esp. Arte wink.gif ). Here is my Armor script. All I want to do is: disable moving it to world, transfer with players so it should be simply chained to player - he can't remove it or sell, but still can wear. I saw in your questholder script there were OnMoveToWorld class or sth like that. Can you point me on this?

CODE

using System;
using Server.Items;
using Server.Network;
using Server.Mobiles;

namespace Server.Items
{
public class ZbrojaObozowaLekka : BaseArmor
{
 public override int BasePhysicalResistance{ get{ return 10; } }
 public override int BaseFireResistance{ get{ return 10; } }
 public override int BaseColdResistance{ get{ return 10; } }
 public override int BasePoisonResistance{ get{ return 10; } }
 public override int BaseEnergyResistance{ get{ return 10; } }

 public override int InitMinHits{ get{ return 60; } }
 public override int InitMaxHits{ get{ return 60; } }

 public override int AosStrReq{ get{ return 10; } }

 public override int OldStrReq{ get{ return 10; } }
 public override int OldDexBonus{ get{ return 10; } }

 public override int ArmorBase{ get{ return 10; } }

 public override ArmorMaterialType MaterialType{ get{ return ArmorMaterialType.Studded; } }

 [Constructable]
 public ZbrojaObozowaLekka( int hue, int itemid, string name ) : base( itemid )
 {
  Name = name;
  Hue = hue;
  Weight = 1;
  DexRequirement = 0;
  StrRequirement = 0;
  IntRequirement = 0;
 }


 public ZbrojaObozowaLekka( Serial serial ) : base( serial )
 {
 }
 public override void Serialize( GenericWriter writer )
 {
  base.Serialize( writer );
  writer.Write( (int) 0 ); // version
 }
 public override void Deserialize( GenericReader reader )
 {
  base.Deserialize( reader );
  int version = reader.ReadInt();
 }
}
}


ArteGordon- 02-11-2006
just add these overrides

CODE

 public override bool OnDragDrop( Mobile from, Item dropped )
 {
  return false;
 }

 public override bool OnDragDropInto( Mobile from, Item item, Point3D p )
 {
  return false;
 }

 public override bool OnDroppedToWorld(Mobile from,Point3D point)
 {

  return false;
 }

Galfaroth- 02-11-2006
Two errors:
CODE
 - Error: Scripts\WOG\Testin\Przynaleznosci.cs: CS0115: (line 41, column 24) 'Se
rver.Items.ZbrojaObozowaLekka.OnDragDropInto(Server.Mobile, Server.Item)': no su
itable method found to override
- Error: Scripts\WOG\Testin\Przynaleznosci.cs: CS0115: (line 42, column 24) 'Se
rver.Items.ZbrojaObozowaLekka.OnDroppedToWorld(Server.Mobile, Server.Item)': no
suitable method found to override

ArteGordon- 02-11-2006
try using these

CODE

 public override bool OnDragDrop(Mobile from, Item dropped)
 {
  return false;
 }

 public override bool OnDroppedOnto(Mobile from, Item target)
 {
  return false;
 }

 public override bool OnDroppedInto(Mobile from, Container target, Point3D p)
 {
  return false;
 }

 public override bool OnDroppedToWorld(Mobile from, Point3D point)
 {

  return false;
 }

 public override bool OnDroppedToMobile(Mobile from, Mobile target)
 {
  return false;
 }

Galfaroth- 02-11-2006
Okay now works but when I want to disarmor this armor (move it from player to backpack) It doesn't work wink.gif The only thing to move it to backpack is kill myself. Any ideas?

ArteGordon- 02-11-2006
checks for the owner of the container, it will allow the item to drop to the backpack of the owner. I added a bankbox check, but you could take that out if you wanted them to be able to put it in their bankbox.

If you also want them to be able to drop the item back onto themselves, then add the modified OnDroppedToMobile as well.

CODE

  public override bool OnDroppedInto(Mobile from, Container target, Point3D p)
 {
  if (target.Parent == from && !(target is BankBox))
  {
   return base.OnDroppedInto(from, target, p);
  }

  return false;
 }

 public override bool OnDroppedToMobile(Mobile from, Mobile target)
 {
  if (from == target)
  {
   return base.OnDroppedToMobile(from, target);
  }

  return false;
 }


Galfaroth- 02-12-2006
Okay Arte works great! And one question - is it possible that if player wears this armor, he can't wear shoes and gloves? And if he is wearing shoes and gloves he can't wear this?

ArteGordon- 02-12-2006
add a check for things on other layers if you want to prevent this from being equipped when other things are already being worn.
That would go in the CanEquip override.

To prevent other things from being equipped when it is worn, you could either have it equip invisible items on those layers, or you could make a modification to the basearmor and baseclothing classes CanEquip that checked for your special armor whenever anything was equipped and then specifically blocked equipping shoes and gloves.