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!

Step Count during Magery Cast

creat a new variable in playermobile that is an intiger (int) called magersteps or what ever you want to call it
make sure you serialize/deserialize it properly (i believe there is a sticky for that to show you how that works)

then in the onmove section - add in a part for checking for the steps, and if there decrease them
then put in your check for if circel of magery and number of steps left to cancle the spell if true
(check to see how disturb works to cancel spells and use same method - i believe that is either in the "onhit" call in playermobile or in the spell system base directory)
 

Ventania

Wanderer
Right, here is what i did.

Code:
			int MageSteps = 10;
			if( running && mounted )
				MageSteps = MageSteps - 4;
			else if (!running && !mounted)
				MageSteps = MageSteps -1;
			else
				MageSteps = MageSteps - 2;

How could i possibly link this on the mage script, and, how can i involve the spell circles in the mage steps ? Wouldnt i need what i call a "function" to get this function from the magery system ? Still kinda lost, but im tryng :p Thanx for the help.

[]´s Ventania

EDIT: This was added in the protected override bool OnMove( Direction d )

Question: Why is it protected ? :D I mean, what does it means ?
 
you need to set up a MAIN variable in the playermobile, not one in the little section
with what you did - each move they start with 10 magerysteps

have you read yet how to serial/deserialze thread yet, like i said?

it shows you how to do a lot of that stuff, and what needs to be added

look at the other variables in playermobile, like hunger, thirst, next bod times, etc

you have to set up one like that

and like i said - you do not call the magery from here, you cancel the magery from here


this is not a simple procedure, and you need to read up on the other areas we have suggestd for you to read
 

Ventania

Wanderer
I Did a search about serial/deserialze in the forum, couldnt see any thread explaining about that. Ur now talkin in a language that is becoming hard for me to understand, if you could link the topics i must read, i would apreciate alot, and of course, read, study, then post my new questions. []´s

Ventania
 
look in the FAQ section and read all the stickies in there
read all the stickies in this section also
and i also seuggest the stickies in the server support section also

thoase are all good places to read and understand before attempting this script changes

then can start looking at a lot of the other ones in the faq section that pertain for what you might want to be doing with scripting

C# scripting is not something you are going to learn over nite, and it is very very easy to mess things up and have a wipe of items/mobiles/players on your shard
 

Ventania

Wanderer
I know is hard, ill do my best, gonna read em all =P Thanx for the help, ill come back with questions.

[]´s Ventania
 

Ventania

Wanderer
Ive read the treads, sorry bout my ignorance in scripting, im having trouble understanding the serialization. Could you help me doing the script ? Would be much easyer for me to learn if i see how the script should looks like, then modify it, try to understand how it works.

[]´s Ventania
 
sorry, but can not do that

1) it is against the rules to request that
2) i would be having to mod my scripts to do it, and my playermobile is no where close to being like yours (it is heavely modified all ready), and i do not have a use for the magery steps on my shard
also out versions could be highly different

but what you can do is look at some of the script reale scripts, ones with charges on them (like a container rename, etc)
and see how they set up the charges all through it
from setting the variable up, to the serial & deserializing on it

below is a smaple of the engraver i have that does that

if you can not figure it out from there (plus with what we have told you in other spots), then you need to do a lot more studying of C#

Code:
using System;
using Server;
using Server.Multis;
using Server.Targeting;
using Server.Items;
using Server.Prompts;

namespace Server.Items
{
	[FlipableAttribute( 0x0FBF, 0x0FC0 )]
	public class Engraver : Item
	{
		private int m_Charges;

		[CommandProperty( AccessLevel.GameMaster )]
		public int Charges
		{
			get { return m_Charges; }
			set { m_Charges = value; InvalidateProperties(); }
		}

		[Constructable]
		public Engraver() : this(10) { }

		[Constructable]
		public Engraver(int charges) : base( 0x0FBF )
		{
			Name = "Container Engraver";
			m_Charges = charges;
		}

		public override void GetProperties( ObjectPropertyList list )
		{
			base.GetProperties( list );
			list.Add("{0} Charges Left", Charges);
		}

		public override void OnDoubleClick( Mobile from )
		{
			if(!IsChildOf(from.Backpack)) from.SendMessage( "This must be in your backpack to use it." );
			else if ( m_Charges > 0)
			{
				if ( from.InRange( this.GetWorldLocation(), 2 ) )
				{
					from.SendMessage( "Target the container you wish to name." );
					from.Target = new InternalTarget( this );
				}
				else from.SendMessage( "That is too far away." );
			}
			else
			{
				from.SendMessage( "You are out of charges." );
				this.Delete();
			}
		}
		private class InternalTarget : Target
		{
			private Engraver m_Engraver;
			private BaseContainer m_engtarg;

			public InternalTarget( Engraver engrave ) : base( 1, false, TargetFlags.None )
			{
				m_Engraver = engrave;
			}
			protected override void OnTarget( Mobile from, object targeted )
			{
				if ( targeted is BaseContainer )
				{
					m_engtarg = (BaseContainer)targeted;
					if ( !from.InRange( m_Engraver.GetWorldLocation(), 2 ) || !from.InRange( m_engtarg.GetWorldLocation(), 2 ) ) from.SendLocalizedMessage( 500446 );
					else if ( m_engtarg.Parent == null )
					{
						BaseHouse house = BaseHouse.FindHouseAt( m_engtarg );
						if ( house == null || !house.IsSecure( m_engtarg ) ) from.SendMessage( "You must Secure your container before you can Engrave it." );
						else if ( !house.IsCoOwner( from ) ) from.SendLocalizedMessage( 501023 );
						else
						{
							from.SendMessage( "What would you like to engrave on the container ?" );
							m_Engraver.Charges -= 1 ;
							m_Engraver.InvalidateProperties();
							from.Prompt = new RenameContPrompt( m_engtarg );

						}
					}
				}
				else if ( targeted == m_Engraver ) from.SendMessage( "it can not engrave itself ?" );
				else if ( targeted is Engraver )
				{
					Engraver knife = targeted as Engraver;
					if (knife != null)
					{
						int knifeuses = knife.Charges;
						m_Engraver.Charges += knifeuses;
						knife.Delete();
					}
				}
				else from.SendMessage( "You cannot engrave that." );
			}
		}

		public Engraver( Serial serial ) : base( serial ) { }

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 );
			writer.Write( (int) m_Charges );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			m_Charges = reader.ReadInt();
		}
	}
}

namespace Server.Prompts
{
	public class RenameContPrompt : Prompt
	{
		private BaseContainer m_engtarg;

		public RenameContPrompt( BaseContainer rcont )
		{
			m_engtarg = rcont;
		}
		public override void OnResponse( Mobile from, string text )
		{
			m_engtarg.Name = text;
			from.SendMessage( "You have engraved the container." );
		}
	}
}
 

Ventania

Wanderer
Well.... i got no deal with C# then, i need to study. I still havent got what uve posted, im sorry i think i need more study, but, im not filled with it with the posts in the forum. Could you explain how could be done in a very kind way, like a mini tutoria ? If you dont there is no problem, since that would take a little time and effort, but i would apreciate. Im not a big fan o reading for learning, since i cant get things straight when i read. Ill read all threads again, but i dont think it will work for me. Starting to think i should give up on RunUO, cause i have no skills for it, even having will to learn.

EDIT: the languages in the tutorials are too complex for my english vocabulary, and i havent found no portuguese c# good tutorial.
 
i would be explaining it the same way and the other threads would

but you can try miscrosoft.com for tutorials on C#, they may have your translation up there
their msdn library is very good for that
 

Ventania

Wanderer
I undersand quite much of the C# logic, my problem is understanding the runuo commands. Letz take an example of the MagerySteps...

I know ill have to find a script controlling the movement of the character, that detects each step it takes, so ill just create the magerysteps int, then ill add 1 to it each tile the characters move. Ill need then, to go to the spells.cs and verify that magery steps everytime a spell is cast, and if steps is higher then it can be, i call the class DoFizzle() do miss the spell. The logic i got as far as i know, my problem is with the RunUO commands. I dont know where to start the script, if no one can post how could a script should be, its hard for me to learn since the tutorials are or for total dummies that doesnt know anything about programming, or for expert programers who already have a vast knowlege of RunUO C# programming.
 

Greystar

Wanderer
Ventania;745127 said:
I undersand quite much of the C# logic, my problem is understanding the runuo commands. Letz take an example of the MagerySteps...

I know ill have to find a script controlling the movement of the character, that detects each step it takes, so ill just create the magerysteps int, then ill add 1 to it each tile the characters move. Ill need then, to go to the spells.cs and verify that magery steps everytime a spell is cast, and if steps is higher then it can be, i call the class DoFizzle() do miss the spell. The logic i got as far as i know, my problem is with the RunUO commands. I dont know where to start the script, if no one can post how could a script should be, its hard for me to learn since the tutorials are or for total dummies that doesnt know anything about programming, or for expert programers who already have a vast knowlege of RunUO C# programming.

The only big issue is Serialization of the step count and that's not difficult just follow the logic already provided in the Serialization/Deserialization area. What you are trying to do is create an int variable to store a value. You said you found the declaration of StealthSteps in Mobile... So essentially copy that info into PlayerMobile and rename it to MagerySteps, add in the stuff for ser/deser then add the code to the section of OnMove I mentioned... Then from there you'll have to figure out the parts in Spell.cs... I think you have an Idea of what you need to do, you seem to have experience from another Emu community... the LOGIC is the same the structure is similiar, the "Commands" are default C# nothing special. They are similair to C/C++ and similair to VB (actually you can use VB scripts in the server). You have to TRY to do things before people will actively tell you where they think you can change somethng. LGW is correct in order to do what you are asking We'd have to add the stuff to our code to make it work to show you what you need to do and I really don't know of anyone who is willing to do that much work. Especially since it's harder to UNDO something once it's been serialized (tends to want to delete things). So just try and when it doesnt work you post what you did (using the # (code tags)) and people can see what you did and offer suggestions on how to fix it.
 

Ventania

Wanderer
Heres what i got in Mobiles.cs from the runuo.exe source.

Code:
protected override bool OnMove( Direction d )
		{
			if( !Core.SE )
				return base.OnMove( d );

			if( AccessLevel != AccessLevel.Player )
				return true;

			if( Hidden && DesignContext.Find( this ) == null )	//Hidden & NOT customizing a house
			{
				if( !Mounted && Skills.Stealth.Value >= 25.0 )
				{
					bool running = (d & Direction.Running) != 0;

					if( running )
					{
						if( (AllowedStealthSteps -= 2) <= 0 )
							RevealingAction();
					}
					else if( AllowedStealthSteps-- <= 0 )
					{
						Server.SkillHandlers.Stealth.OnUse( this );
					}			
				}
				else
				{
					RevealingAction();
				}
			}

			return true;
		}

What could i understand from this OnMove ?
Everytime u move a tile, this 'function' (can i call it a function?) is activated. So if i create a bool iscasting, activate it during a spell cast in spells.cs and create an int MageSteps, i should calculate how many steps i did during the cast. Thats a theory.

So , as i posted b4, i tryed to add this.
Code:
protected override bool OnMove( Direction d )
		{
                                      [red]bool iscasting = false;[/red]
			if( !Core.SE )
				return base.OnMove( d );

			if( AccessLevel != AccessLevel.Player )
				return true;
                                    [red]  if (iscasting)
{
                                      int MageSteps = 10;
			if( running && mounted )
				MageSteps = MageSteps - 4;
			else if (!running && !mounted)
				MageSteps = MageSteps -1;
			else
				MageSteps = MageSteps - 2;
}[/red]


			if( Hidden && DesignContext.Find( this ) == null )	//Hidden & NOT customizing a house
			{
				if( !Mounted && Skills.Stealth.Value >= 25.0 )
				{
					bool running = (d & Direction.Running) != 0;

					if( running )
					{
						if( (AllowedStealthSteps -= 2) <= 0 )
							RevealingAction();
					}
					else if( AllowedStealthSteps-- <= 0 )
					{
						Server.SkillHandlers.Stealth.OnUse( this );
					}			
				}
				else
				{
					RevealingAction();
				}
			}

			return true;
		}

Now, how could i 'export' this magesteps variable to spells.cs, and how can i determine this bool iscasting in the magesteps, to be true, in the begining of a casting spell. OnMove.Iscasting ? Still tryng.

Thanx for the help. []´s Ventania

EDIT: The [red] quote doesnt work huh, how may i make in red what was changed? :p
 

Greystar

Wanderer
Ventania;745268 said:
Heres what i got in Mobiles.cs from the runuo.exe source.

Code:
protected override bool OnMove( Direction d )
		{
			if( !Core.SE )
				return base.OnMove( d );

			if( AccessLevel != AccessLevel.Player )
				return true;

			if( Hidden && DesignContext.Find( this ) == null )	//Hidden & NOT customizing a house
			{
				if( !Mounted && Skills.Stealth.Value >= 25.0 )
				{
					bool running = (d & Direction.Running) != 0;

					if( running )
					{
						if( (AllowedStealthSteps -= 2) <= 0 )
							RevealingAction();
					}
					else if( AllowedStealthSteps-- <= 0 )
					{
						Server.SkillHandlers.Stealth.OnUse( this );
					}			
				}
				else
				{
					RevealingAction();
				}
			}

			return true;
		}

What could i understand from this OnMove ?
Everytime u move a tile, this 'function' (can i call it a function?) is activated. So if i create a bool iscasting, activate it during a spell cast in spells.cs and create an int MageSteps, i should calculate how many steps i did during the cast. Thats a theory.

So , as i posted b4, i tryed to add this.
Code:
protected override bool OnMove( Direction d )
		{
                                      [red]bool iscasting = false;[/red]
			if( !Core.SE )
				return base.OnMove( d );

			if( AccessLevel != AccessLevel.Player )
				return true;
                                    [red]  if (iscasting)
{
                                      int MageSteps = 10;
			if( running && mounted )
				MageSteps = MageSteps - 4;
			else if (!running && !mounted)
				MageSteps = MageSteps -1;
			else
				MageSteps = MageSteps - 2;
}[/red]


			if( Hidden && DesignContext.Find( this ) == null )	//Hidden & NOT customizing a house
			{
				if( !Mounted && Skills.Stealth.Value >= 25.0 )
				{
					bool running = (d & Direction.Running) != 0;

					if( running )
					{
						if( (AllowedStealthSteps -= 2) <= 0 )
							RevealingAction();
					}
					else if( AllowedStealthSteps-- <= 0 )
					{
						Server.SkillHandlers.Stealth.OnUse( this );
					}			
				}
				else
				{
					RevealingAction();
				}
			}

			return true;
		}

Now, how could i 'export' this magesteps variable to spells.cs, and how can i determine this bool iscasting in the magesteps, to be true, in the begining of a casting spell. OnMove.Iscasting ? Still tryng.

Thanx for the help. []´s Ventania

EDIT: The [red] quote doesnt work huh, how may i make in red what was changed? :p

First off you'd have to define IsCasting as a property... becuase how you have it now it's a local variable. Look how the other properties are defined to see how you'd do that, you'd also need ANOTHER variable for IsCasting... also MageSteps needs to be a property as well...

so where is what you'd need to add to make those into properties

Code:
		private int m_MageSteps; //<< I'd put this near where the other m_ variables are.

		[CommandProperty( AccessLevel.GameMaster )]
		public int MageSteps
		{
			get
			{
				return m_MageSteps;
			}
			set
			{
				m_MageSteps = value;
			}
		}

		private int m_IsCasting; //<< I'd put this near where the other m_ variables are.

		[CommandProperty( AccessLevel.GameMaster )]
		public bool IsCasting
		{
			get
			{
				return m_IsCasting;
			}
			set
			{
				m_IsCasting = value;
			}
		}

Then you need to make sure they are serialized and deserialized properly otherwise those values won't save over server start... if it doesn't matter then don't worry about it. Now you can use them in other scripts (such as Spell.cs where the spells are cast from)... you'd still add the code to the playermobile's OnMove that subtracts from the value and I'm guessing you'll want the "Max" steps allowed defined somewhere which would probably be in each spell (that will be the difficult part since it would require modifying how they are read by the server... I can't go into more detail about that cause I don't know what would need to be changed). You'd probably want to call IsCasting from within the OnBeforeCast think that's it. I suggest you look at Stealth for how they used it for sneaking. Beyond that I don't have any other suggestions.
 
1st off - that will not work like i said before

int MageSteps = 10;

means each time they move it is reset to 10

magesteps needs to be set up with the other main variables
like the npocguildinfo, etc

and when a spell is casted -- it sets the steps allowed in the player mobile


same with your is casting variable - it will always be set to false this way, and never work right - again it needs to be set up with the main variables, and set when a spel is casted
 

Ventania

Wanderer
How could i apply this on the playermobile.cs at the onmove ?

If i do a MageSteps comand in the spells.cs it would read the comand following in this script ? Bu how should it looks like as a global variable in the end, im not figuring it out.
 
they have to be a "global" variable for playermobile
i.e. just like autorenewinsurance, glassblowing, sandmining, knownreciepies, etc are

then you can assign them, etc just like any of them

PlayerMobile pm = caster as PlayerMobile; (assuming caster is the term used in that spell or in spellhelper, etc where ever you place it at)
pm.magerysteps = 15- spellcircle; (or set up if/thens to set by circle)
pm.castspell = true;
etc
 

Ventania

Wanderer
I Still couldnt figure out how i would make it a global, and i still havent figured out whats the purpose of the code greystar has posted. I Dont think the magerysteps would need to be serialized, since it will aways reset with a new cast. (If thats for serialization)
 

Greystar

Wanderer
Ventania;745574 said:
I Still couldnt figure out how i would make it a global, and i still havent figured out whats the purpose of the code greystar has posted. I Dont think the magerysteps would need to be serialized, since it will aways reset with a new cast. (If thats for serialization)

I think this is the last time I'm going to post here. LGW mentioned that you need to make the variables global... that is what my code I posted does. If the code is NOT global you CANNOT access it from another script. There is Global variables, which are used throught a script, Properties used to make global variables accessibly through other scripts and local variables, usually created inside a function.


Have a nice day!

PS) Happy Easter!
 

Ventania

Wanderer
Hmm lets see if i got it. Sorry for the trouble im causing, i know, as i posted b4, answering noob questions isnt fun, so i apreciate all uve done Graystar.

Ive added this to the Spells.

Code:
private int m_MageSteps;
private bool m_IsCasting;
			
// if its casting, m_isCasting = true;

		[CommandProperty( AccessLevel.GameMaster )]
		public int MageSteps
		{
			get
			{
				return m_MageSteps;
			}
			set
			{
				m_MageSteps = value; // *
			}
		}

		

		[CommandProperty( AccessLevel.GameMaster )]
		public bool IsCasting
		{
			get
			{
				return m_IsCasting;
			}
			set
			{
				m_IsCasting = value;
			}
		}
		
// ends casting, m_IsCasting = false;

When i spell is casted, i should turn the public bool IsCasting = true; , then read in the OnMove i should get the function, verify if iscasting is on, calculate the steps while the bool is on, then trow back the value of steps into spells.cs. I Just dont know the command to get the global var. Should i simply use MageSteps and IsCasting on the onmove or is there another way to get the public var ?

Thanx
[]´s Ventania

* Is this let to be like this, or should i make the function of calculating steps on this ?
 
Top