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!

NPC's + Words of power

Hello all, I'm stumped on this... I got words of power to show for NPC's like my original plan, however I decided to only do it for human bodyvalues (400 + 401), but I don't know how to change it for those specific values. Here is what I did to make all NPC's show them:


Code:
public virtual void SayMantra()
		{
			if ( m_Scroll is BaseWand )
				return;

			if ( m_Info.Mantra != null && m_Info.Mantra.Length > 0 && m_Caster.BodyValue > 0 )
			//m_Caster.Player ) if i dont want npc text
				m_Caster.PublicOverheadMessage( MessageType.Spell, m_Caster.SpeechHue, true, m_Info.Mantra, false );
		}

I tried using = and having another line of code for the second bodyvalue, but = can't be used instead of > apparently (yes, I'm pretty new to this).
 

daat99

Moderator
Staff member
Take a look at this:
Code:
if ( m_Info.Mantra != null && m_Info.Mantra.Length > 0 && m_Caster.BodyValue > 0])

Can you explain to me in English what this line checks?
 

daat99

Moderator
Staff member
Ok, lets start fixing it then.
How would you change it to make it that only body value of 400 displays the words of power?
 
I tried :
Code:
public virtual void SayMantra()
		{
			if ( m_Scroll is BaseWand )
				return;

			if ( m_Info.Mantra != null )
			{
				if ( m_Info.Mantra.Length > 0 )
				{
					if ( m_Caster.BodyValue ) 400;
					{
				m_Caster.PublicOverheadMessage( MessageType.Spell, m_Caster.SpeechHue, true, m_Info.Mantra, false );
					}
				}
			}	
		}

and a few other variations... however I haven't had to set a value like that before in anything I've scripted, so I don't know where I'm going with it.
 

daat99

Moderator
Staff member
You are making this a bit too hard on yourself.
Look at this line again:
Code:
if ( m_Info.Mantra != null && m_Info.Mantra.Length > 0 && m_Caster.BodyValue > 0])
You already told me correctly that:
It makes it so anything with a bodyvalue greater than 0 (all NPC's) display words of power when casting spells.
Now I give you the following limitations (hints):
1. You are not allowed to change anything in the script except this line.
2. You are not allowed to add new lines to the script at all.
3. You are not allowed to touch more than 2 keys on the keyboard (not really, but if you need to use more than 2 keys than you are doing something wrong again - it can still work though).


How would you make it so it'll allow only body value of 400 instead of "all bodyvalue greater than 0"?
 
Ahhhh!!! I did it! Apparently when using equal signs, you have to use two, hehe.

Code:
if ( m_Info.Mantra != null && m_Info.Mantra.Length > 0 && m_Caster.BodyValue == 400 )
m_Caster.PublicOverheadMessage( MessageType.Spell, m_Caster.SpeechHue, true, m_Info.Mantra, false );

So now if I just duplicate that and put another one under it for bodyvalue 401, it will display it for either, correct?! I guess I'll go try it. Thanks for helping a huge noob :D
 

Pure Insanity

Sorceror
Try this:

C#:
if ( m_Info.Mantra != null && m_Info.Mantra.Length > 0 && (m_Caster.BodyValue == 400 || m_Caster.BodyValue == 401) )
m_Caster.PublicOverheadMessage( MessageType.Spell, m_Caster.SpeechHue, true, m_Info.Mantra, false );
 
Top