RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Weapon script

MentalSteel

Wanderer
Weapon script

Well im creating a scipt called "Wolf Fang". Basicly a mod of Serp Fang. I want to make it so when you hit a creature Wolfs appear but only once. So if this can b done then can someone please tell me what to add. Thanks.
 

V1RTU4L

Page
copy the serp fang script, rename it ... rename every "serpfang" or whatever to "wolffang"
post your script and how u tried to realise the things you want and we will help you
 

MentalSteel

Wanderer
here is the script

Code:
using System;
using Server;

namespace Server.Items
{
	public class WolfFang : BaseSword
	{	
		public override int ArtifactRarity{ get{ return 100; } }

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

		[Constructable]
		public WolfFang() : base( 0x1401 )
		{
			Name = "Wolf Fang";
			ItemID = 0x1400;
			Hue = 1153;
			WeaponAttributes.HitDispel = 100;
			WeaponAttributes.HitLeechHits = 50;
			WeaponAttributes.SelfRepair = 1;
			Attributes.Luck = 16000;
			Attributes.WeaponDamage = 70;		}


		public WolfFang( 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();
		}
	}
}
 

Lancelot

Wanderer
i think you have to make it so it makes a wolf like this

*removed..look down*

If it dont work im sorry, im a new scripter too :)
 

MentalSteel

Wanderer
Error: Scripts\Items\Weapons\Artifacts\WolfFang.cs: CS0115: (line 33, column 38) 'Server.Items.WolfFang.OnDamage(int, Server.Mobile)': no suitable method found Override
 

Lancelot

Wanderer
oh i forgot to add a check to see if its already summoned

try this

Code:
using System;
using Server;

namespace Server.Items
{
	public class WolfFang : BaseSword
	{	
		public override int ArtifactRarity{ get{ return 100; } }

		public override int InitMinHits{ get{ return 255; } }
		public override int InitMaxHits{ get{ return 255; } }
               
                public bool Used;
                [CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
                public bool wolf_created
                {
                    get{return Used;}
                    set{Used = value;}
                }

		[Constructable]
		public WolfFang() : base( 0x1401 )
		{
			Name = "Wolf Fang";
			ItemID = 0x1400;
			Hue = 1153;
			WeaponAttributes.HitDispel = 100;
			WeaponAttributes.HitLeechHits = 50;
			WeaponAttributes.SelfRepair = 1;
			Attributes.Luck = 16000;
			Attributes.WeaponDamage = 70;		}

		public void MakeWolf( Mobile from )
                {
                        Wolf newwolf;
                        newwolf = new Wolf();
                        newwolf.Map = from.Map;
                        newwolf.Location = from.Location;
	        }
		
                public override void OnHit( Mobile attacker, Mobile defender )
		{
			base.OnHit( attacker, defender );
		     
            	         if ( this.wolf_created == false ) //Create Wolf
            	         {
            	                MakeWolf( from );
                	        this.wolf_created = true;
            		        this.Status = false;
              	         }

                         else if ( this.wolf_created == true)
                         {
                               return;
                         }


                }
		
		public WolfFang( 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();
		}
	}
}
 

MentalSteel

Wanderer
Error: Scripts\Items\Weapons\Artifacts\WolfFang.cs: CS0115: (line 41, column 38) 'Server.Items.WolfFang.OnDamage(int, Server.Mobile)': no suitable method found Override
 

V1RTU4L

Page
u base your item on the "basesword" ...
now you say runuo you want to override the basesword-method for "OnDamage".
Due to the fact, that basesword has no method for OnDamage, there is nothing you can override. to get rid of the error you could simply delete the "override" in that line and wont
get the error ... but that is not the solution for your problem.
 

Lancelot

Wanderer
the reason why it was working cuz there is no such thing as Wolf only timber wolf , white wolf, etc.. its set at white wolf ATM

Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;

namespace Server.Items
{
	public class WolfFang : BaseSword
	{	
		public override int ArtifactRarity{ get{ return 100; } }
		public override int InitMinHits{ get{ return 255; } }
		public override int InitMaxHits{ get{ return 255; } }
               
	
        [CommandProperty( AccessLevel.Counselor, AccessLevel.GameMaster )]
        public bool wolf_created
        {
             get{return wolf_created;}
             set{wolf_created = value;}
        }

		[Constructable]
		public WolfFang() : base( 0x1401 )
		{
			Name = "Wolf Fang";
			ItemID = 0x1400;
			Hue = 1153;
			WeaponAttributes.HitDispel = 100;
			WeaponAttributes.HitLeechHits = 50;
			WeaponAttributes.SelfRepair = 1;
			Attributes.Luck = 16000;
			Attributes.WeaponDamage = 70;
		}
		
		#region Make Wolf
		public void MakeWolf( Mobile from )
        {
      	  WhiteWolf newwolf;
          newwolf = new WhiteWolf();
          newwolf.Map = from.Map;
          newwolf.Location = from.Location;
		  newwolf.Controled = true;
          newwolf.ControlMaster = from;
          newwolf.ControlOrder = OrderType.Attack;
		  from.BoltEffect( 0 );
	    }
		
		 #endregion
		
        public override void OnHit( Mobile attacker, Mobile defender )
		{
		 	base.OnHit( attacker, defender );
		     
            	         if ( this.wolf_created == false ) //Create Wolf
            	         {
            	            MakeWolf( attacker );
                	        this.wolf_created = true;
              	         }
			return;
		}
		
		public WolfFang( 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();
		}
	}
}
 

ArteGordon

Wanderer
Code:
public bool wolf_created
        {
             get{return wolf_created;}
             set{wolf_created = value;}
        }

This is a circular definition. You need to do something like this

Code:
private bool m_wolf_created;

public bool wolf_created
        {
             get{return m_wolf_created;}
             set{m_wolf_created = value;}
        }

You will also need to serialize/deserialize it otherwise it will be reset on every server restart.
 

V1RTU4L

Page
MentalSteel said:
well it doesnt even do anything i just stand there.
he he just like i thought ...
there is no OnHit-method in basesword afaik...
you could create a OnDoubleClick method though, which would spawn the wolf once you doubleclick the weapon ...
 

V1RTU4L

Page
just replace the "OnHit" from the other guys script with "OnDoubleClick"
like
Code:
    public override void OnDoubleClick( )
		{
		 			     
            	         if ( this.wolf_created == false ) //Create Wolf
            	         {
            	            MakeWolf( attacker );
                	        this.wolf_created = true;
              	         }
			return;
		}

don't know if you have to use the override keyword or not .. that's the thing u gotta test.
 
Top