Go Back   RunUO - Ultima Online Emulation > RunUO > RunUO Post Archive

RunUO Post Archive The Archvie

Reply
 
Thread Tools Display Modes
Old 09-04-2003, 04:26 PM   #1 (permalink)
Moderate
 
David's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 6,598
Default How do I add individual Stat Caps?

(edit: valid for Beta 35)

This is an advanced topic. The tutorial assumes some ability to interpret and adjust scripts written in C#. If you apply these changes incorrectly, all players on your shard could be lost. Make appropriate backups.

This tutorial edits the PlayerMobile script included with the RunUO distribution. This is done simply because that is the lowest common denominator. I do not recommend editing the PlayerMobile class, instead I strongly suggest you use a class derived from PlayerMobile and use that (many already use dovPlayerMobile.) However, that is beyond the scope of this post. If you do already use a derived class, simply change each occurrence of PlayerMobile to the appropriate class name.

One final note, adding individual Stat Caps does not remove the overall Stat Cap. If that is not the behavior you want, simply set the overall cap greater than the sum of the individual caps.

First you will need to add some Properties to your PlayerMobile.cs script to hold the Stat Cap values. They can be added anywhere in this class,
[code:1] public class PlayerMobile : Mobile
{
[/code:1]
I would put them around line 75 where you find similar statements. Here is what you need to add.
[code:1]private int m_maxSTR;
private int m_maxDEX;
private int m_maxINT;

[CommandProperty( AccessLevel.GameMaster )]
public int MaxSTR // Maximum value of STR stat
{
get {return m_maxSTR;}
set {m_maxSTR = value;}
}

[CommandProperty( AccessLevel.GameMaster )]
public int MaxINT // Maximum value of INT stat
{
get {return m_maxINT;}
set {m_maxINT = value;}
}

[CommandProperty( AccessLevel.GameMaster )]
public int MaxDEX // Maximum value of DEX stat
{
get {return m_maxDEX;}
set {m_maxDEX = value;}
}[/code:1]

Now the hard part, and the basis of why you need to use a class derived from PlayerMobile. We need to seralize the variables. In other words we need to include them in the world saves. Note that this assumes the Beta 34 version of the PlayerMobile, if it changes with subsequent versions you need to adjust what you are told here. You also need to understand Seralize/Deseralize, and you will need to fix this each and every time the distribution PlayerMobile changes. Please, please, please use a derived class! That will avoid constant updates.

Near the bottom of the script you will find a Serialize method. In there will be this line.
[code:1]writer.Write( (int) 12 ); // version[/code:1]
change it to
[code:1]writer.Write( (int) 13 ); // version

writer.Write( (int) m_maxSTR );
writer.Write( (int) m_maxDEX );
writer.Write( (int) m_maxINT ); [/code:1]

Now, a little above the Serialize method you will find a Deseralize method. In it, just below this
[code:1]switch ( version )
{
[/code:1]
Add this
[code:1]case 13:
{
m_maxSTR = reader.ReadInt();
m_maxDEX = reader.ReadInt();
m_maxINT = reader.ReadInt();

goto case 12;
}
[/code:1]

The players should now have a property in which to store the Stat Caps.

In order to make them have some effect, we need to edit the SkillCheck.cs file. Open it and find the CanRaise method about 4/5 of the way down, at line 240.

It looks like this
[code:1]public static bool CanRaise( Mobile from, Stat stat )
{
if ( from.RawStatTotal >= from.StatCap )
return false;

switch ( stat )
{
case Stat.Str: return ( from.StrLock == StatLockType.Up && from.RawStr < 125 );
case Stat.Dex: return ( from.DexLock == StatLockType.Up && from.RawDex < 125 );
case Stat.Int: return ( from.IntLock == StatLockType.Up && from.RawInt < 125 );
}

return false;
}[/code:1]

Change it to this, again assuming that you are editing the PlayerMobile. For your derived class, you will need to make adjustments here.
[code:1]public static bool CanRaise( Mobile from, Stat stat )
{
if ( from.RawStatTotal >= from.StatCap )
return false;

if ( from.Player && ( from is PlayerMobile ) )
{
PlayerMobile pm = from as PlayerMobile;
switch ( stat )
{
case Stat.Str: return ( from.StrLock == StatLockType.Up && from.RawStr < pm.MaxSTR );
case Stat.Dex: return ( from.DexLock == StatLockType.Up && from.RawDex < pm.MaxDEX );
case Stat.Int: return ( from.IntLock == StatLockType.Up && from.RawInt < pm.MaxINT );
}

}
else
{
switch ( stat )
{
case Stat.Str: return ( from.StrLock == StatLockType.Up && from.RawStr < 125 );
case Stat.Dex: return ( from.DexLock == StatLockType.Up && from.RawDex < 125 );
case Stat.Int: return ( from.IntLock == StatLockType.Up && from.RawInt < 125 );
}
}

return false;
}[/code:1]

Now you simply need to set the properties of the Player’s characters. CharacterCreation.cs would be a good place to do this. The SetStats method is a good choice, although there are lots of valid places to do it. Add the following, seasoned to taste...
[code:1]m.MaxSTR = 100;
m.MaxDEX = 100;
m.MaxINT = 100;
[/code:1]

Comments or corrections are welcome, PM me and I will adjust this post as necessary.

enjoy!
__________________
David Forum Moderator
The RunUO.com Forum Moderator Team

Forum Rules and Guidelines
RunUO Forum Search Engine
Download RunUO 2.0 RC2
David is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5