|
||
|
|||||||
| Custom Script Releases This forum is where you can release your custom scripts for other users to use. Please note: By releasing your scripts here you are submitting them to the public and as such agree to make them public domain. The RunUO Team has made its software GPL for you to use and enjoy you should do the same for anything based off of RunUO. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Novice
|
here is script 2 replace original one:
Code:
using Server;
using Server.Mobiles;
using Server.RateDef;
namespace Server.Misc
{
public class SkillCheck
{
private static readonly bool AntiMacroCode = false; //Change this to true to enable anti-macro code
public static TimeSpan AntiMacroExpire = TimeSpan.FromMinutes( 5.0 ); //How long do we remember targets/locations?
public const int Allowance = 3; //How many times may we use the same location/target for gain
private const int LocationSize = 5; //The size of eeach location, make this smaller so players dont have to move as far
private static bool[] UseAntiMacro = new bool[]
{
// true if this skill uses the anti-macro code, false if it does not
false,// Alchemy = 0,
true,// Anatomy = 1,
true,// AnimalLore = 2,
true,// ItemID = 3,
true,// ArmsLore = 4,
false,// Parry = 5,
true,// Begging = 6,
false,// Blacksmith = 7,
false,// Fletching = 8,
true,// Peacemaking = 9,
true,// Camping = 10,
false,// Carpentry = 11,
false,// Cartography = 12,
false,// Cooking = 13,
true,// DetectHidden = 14,
true,// Discordance = 15,
true,// EvalInt = 16,
true,// Healing = 17,
true,// Fishing = 18,
true,// Forensics = 19,
true,// Herding = 20,
true,// Hiding = 21,
true,// Provocation = 22,
false,// Inscribe = 23,
true,// Lockpicking = 24,
true,// Magery = 25,
true,// MagicResist = 26,
false,// Tactics = 27,
true,// Snooping = 28,
true,// Musicianship = 29,
true,// Poisoning = 30,
false,// Archery = 31,
true,// SpiritSpeak = 32,
true,// Stealing = 33,
false,// Tailoring = 34,
true,// AnimalTaming = 35,
true,// TasteID = 36,
false,// Tinkering = 37,
true,// Tracking = 38,
true,// Veterinary = 39,
false,// Swords = 40,
false,// Macing = 41,
false,// Fencing = 42,
false,// Wrestling = 43,
true,// Lumberjacking = 44,
true,// Mining = 45,
true,// Meditation = 46,
true,// Stealth = 47,
true,// RemoveTrap = 48,
true,// Necromancy = 49,
false,// Focus = 50,
true,// Chivalry = 51
true,// Bushido = 52
true,//Ninjitsu = 53
true // Spellweaving
};
public static void Initialize()
{
Mobile.SkillCheckLocationHandler = new SkillCheckLocationHandler( Mobile_SkillCheckLocation );
Mobile.SkillCheckDirectLocationHandler = new SkillCheckDirectLocationHandler( Mobile_SkillCheckDirectLocation );
Mobile.SkillCheckTargetHandler = new SkillCheckTargetHandler( Mobile_SkillCheckTarget );
Mobile.SkillCheckDirectTargetHandler = new SkillCheckDirectTargetHandler( Mobile_SkillCheckDirectTarget );
//here is gainrates 4 each skill
//for instance .15 would be a 15% chance to gain in the particular skill
SkillInfo.Table[0].GainFactor = .12;// Alchemy = 0,
SkillInfo.Table[1].GainFactor = .12;// Anatomy = 1,
SkillInfo.Table[2].GainFactor = .12;// AnimalLore = 2,
SkillInfo.Table[3].GainFactor = .10;// ItemID = 3,
SkillInfo.Table[4].GainFactor = .10;// ArmsLore = 4,
SkillInfo.Table[5].GainFactor = .11;// Parry = 5,
SkillInfo.Table[6].GainFactor = .12;// Begging = 6,
SkillInfo.Table[7].GainFactor = .12;// Blacksmith = 7,
SkillInfo.Table[8].GainFactor = .12;// Fletching = 8,
SkillInfo.Table[9].GainFactor = .11;// Peacemaking = 9,
SkillInfo.Table[10].GainFactor = .15;// Camping = 10,
SkillInfo.Table[11].GainFactor = .12;// Carpentry = 11,
SkillInfo.Table[12].GainFactor = .12;// Cartography = 12,
SkillInfo.Table[13].GainFactor = .12;// Cooking = 13,
SkillInfo.Table[14].GainFactor = .10;// DetectHidden = 14,
SkillInfo.Table[15].GainFactor = .12;// Discordance = 15,
SkillInfo.Table[16].GainFactor = .10;// EvalInt = 16,
SkillInfo.Table[17].GainFactor = .12;// Healing = 17,
SkillInfo.Table[18].GainFactor = .10;// Fishing = 18,
SkillInfo.Table[19].GainFactor = .12;// Forensics = 19,
SkillInfo.Table[20].GainFactor = .15;// Herding = 20,
SkillInfo.Table[21].GainFactor = .15;// Hiding = 21,
SkillInfo.Table[22].GainFactor = .12;// Provocation = 22,
SkillInfo.Table[23].GainFactor = .15;// Inscribe = 23,
SkillInfo.Table[24].GainFactor = .15;// Lockpicking = 24,
SkillInfo.Table[25].GainFactor = .10;// Magery = 25,
SkillInfo.Table[26].GainFactor = .15;// MagicResist = 26,
SkillInfo.Table[27].GainFactor = .10;// Tactics = 27,
SkillInfo.Table[28].GainFactor = .10;// Snooping = 28,
SkillInfo.Table[29].GainFactor = .11;// Musicianship = 29,
SkillInfo.Table[30].GainFactor = .15;// Poisoning = 30
SkillInfo.Table[31].GainFactor = .10;// Archery = 31
SkillInfo.Table[32].GainFactor = .15;// SpiritSpeak = 32
SkillInfo.Table[33].GainFactor = .10;// Stealing = 33
SkillInfo.Table[34].GainFactor = .12;// Tailoring = 34
SkillInfo.Table[35].GainFactor = .15;// AnimalTaming = 35
SkillInfo.Table[36].GainFactor = .10;// TasteID = 36
SkillInfo.Table[37].GainFactor = .12;// Tinkering = 37
SkillInfo.Table[38].GainFactor = .15;// Tracking = 38
SkillInfo.Table[39].GainFactor = .15;// Veterinary = 39
SkillInfo.Table[40].GainFactor = .10;// Swords = 40
SkillInfo.Table[41].GainFactor = .10;// Macing = 41
SkillInfo.Table[42].GainFactor = .10;// Fencing = 42
SkillInfo.Table[43].GainFactor = .10;// Wrestling = 43
SkillInfo.Table[44].GainFactor = .10;// Lumberjacking = 44
SkillInfo.Table[45].GainFactor = .10;// Mining = 45
SkillInfo.Table[46].GainFactor = .09;// Meditation = 46
SkillInfo.Table[47].GainFactor = .15;// Stealth = 47
SkillInfo.Table[48].GainFactor = .15;// RemoveTrap = 48
SkillInfo.Table[49].GainFactor = .10;// Necromancy = 49
SkillInfo.Table[50].GainFactor = .09;// Focus = 50
SkillInfo.Table[51].GainFactor = .12;// Chivalry = 51
}
public static bool Mobile_SkillCheckLocation( Mobile from, SkillName skillName, double minSkill, double maxSkill )
{
Skill skill = from.Skills[skillName];
if ( skill == null )
return false;
double value = skill.Value;
if ( value < minSkill )
return false; // Too difficult
else if ( value >= maxSkill )
return true; // No challenge
double chance = (value - minSkill) / (maxSkill - minSkill);
Point2D loc = new Point2D( from.Location.X / LocationSize, from.Location.Y / LocationSize );
return CheckSkill( from, skill, loc, chance );
}
public static bool Mobile_SkillCheckDirectLocation( Mobile from, SkillName skillName, double chance )
{
Skill skill = from.Skills[skillName];
if ( skill == null )
return false;
if ( chance < 0.0 )
return false; // Too difficult
else if ( chance >= 1.0 )
return true; // No challenge
Point2D loc = new Point2D( from.Location.X / LocationSize, from.Location.Y / LocationSize );
return CheckSkill( from, skill, loc, chance );
}
public static bool CheckSkill( Mobile from, Skill skill, object amObj, double chance )
{
if ( from.Skills.Cap == 0 )
return false;
bool success = ( chance >= Utility.RandomDouble() );
//here is modifications 2 skillgains
double BaseSkillGain = skill.Info.GainFactor;
double LowSkillMod = .10;
double aSkillMod = .03;
double bSkillMod = .05;
double cSkillMod = .06;
double dSkillMod = .07;
double eSkillMod = .08;
double fSkillMod = .085;
double gSkillMod = .09;
double hSkillMod = .095;
double iSkillMod = .096;
double jSkillMod = .097;
double kSkillMod = .098;
//Example: Player Skill is 85.3 - We would take the 12% base chance and subtract 8% - Player now has a 4% chance to gain.
//*****************************************************************************************************************//
double ComputedSkillMod = 0; // holds the percent chance to gain after checking players skill
//here is modding gainrates. i.c. under lv 20% lowskillmod added 2 gain rate. from 20 to 40 askillmod substracted from it
if ( skill.Base < 20.0 )
ComputedSkillMod = BaseSkillGain + LowSkillMod;
else if ( skill.Base < 40.0 )
ComputedSkillMod = BaseSkillGain - aSkillMod;
else if ( skill.Base < 60.0 )
ComputedSkillMod = BaseSkillGain - bSkillMod;
else if ( skill.Base < 80.0 )
ComputedSkillMod = BaseSkillGain - cSkillMod;
else if ( skill.Base < 90.0 )
ComputedSkillMod = BaseSkillGain - dSkillMod;
else if ( skill.Base < 100.0 )
ComputedSkillMod = BaseSkillGain - eSkillMod;
else if ( skill.Base < 110.0 )
ComputedSkillMod = BaseSkillGain - fSkillMod;
else if ( skill.Base < 120.0 )
ComputedSkillMod = BaseSkillGain - gSkillMod;
else if ( skill.Base < 130.0 )
ComputedSkillMod = BaseSkillGain - hSkillMod;
else if ( skill.Base < 140.0 )
ComputedSkillMod = BaseSkillGain - iSkillMod;
else if ( skill.Base < 145.0 )
ComputedSkillMod = BaseSkillGain - jSkillMod;
else if ( skill.Base >= 145.0 )
ComputedSkillMod = BaseSkillGain - kSkillMod;
//if u make substraction larger than skill gain rate
if ( ComputedSkillMod < 0.001 )
ComputedSkillMod = 0.001;
//following line used to see chance to gain ingame
//from.SendMessage( "Your chance to gain {0} is {1}",skill.Name, ComputedSkillMod );
if ( from is BaseCreature && ((BaseCreature)from).Controlled )
ComputedSkillMod *= 2;
ComputedSkillMod *= RateDefinitions.ratebonus;
if ( from.Alive && ( ( ComputedSkillMod >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) )
Gain( from, skill );
return success;
}
public static bool Mobile_SkillCheckTarget( Mobile from, SkillName skillName, object target, double minSkill, double maxSkill )
{
Skill skill = from.Skills[skillName];
if ( skill == null )
return false;
double value = skill.Value;
if ( value < minSkill )
return false; // Too difficult
else if ( value >= maxSkill )
return true; // No challenge
double chance = (value - minSkill) / (maxSkill - minSkill);
return CheckSkill( from, skill, target, chance );
}
public static bool Mobile_SkillCheckDirectTarget( Mobile from, SkillName skillName, object target, double chance )
{
Skill skill = from.Skills[skillName];
if ( skill == null )
return false;
if ( chance < 0.0 )
return false; // Too difficult
else if ( chance >= 1.0 )
return true; // No challenge
return CheckSkill( from, skill, target, chance );
}
private static bool AllowGain( Mobile from, Skill skill, object obj )
{
if ( from is PlayerMobile && AntiMacroCode && UseAntiMacro[skill.Info.SkillID] )
return ((PlayerMobile)from).AntiMacroCheck( skill, obj );
else
return true;
}
public enum Stat { Str, Dex, Int }
public static void Gain( Mobile from, Skill skill )
{
if ( from.Region is Regions.Jail )
return;
if ( from is BaseCreature && ((BaseCreature)from).IsDeadPet )
return;
if ( skill.SkillName == SkillName.Focus && from is BaseCreature )
return;
if ( skill.Base < skill.Cap && skill.Lock == SkillLock.Up )
{
int toGain = 1;
if ( skill.Base < 20.0 )
toGain = Utility.Random( 6 ) + 5;
else if ( skill.Base < 40.0 )
toGain = Utility.Random( 5 ) + 4;
else if ( skill.Base < 60.0 )
toGain = Utility.Random( 4 ) + 3;
else if ( skill.Base < 80.0 )
toGain = Utility.Random( 3 ) + 2;
else if ( skill.Base < 90.0 )
toGain = Utility.Random( 2 ) + 1;
toGain *= RateDefinitions.gainbonus;
Skills skills = from.Skills;
if ( ( skills.Total / skills.Cap ) >= Utility.RandomDouble() )//( skills.Total >= skills.Cap )
{
for ( int i = 0; i < skills.Length; ++i )
{
Skill toLower = skills[i];
if ( toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain )
{
toLower.BaseFixedPoint -= toGain;
break;
}
}
}
if ( (skills.Total + toGain) <= skills.Cap )
{
skill.BaseFixedPoint += toGain;
}
}
if ( skill.Lock == SkillLock.Up )
{
SkillInfo info = skill.Info;
if ( from.StrLock == StatLockType.Up && ((info.StrGain / 33.3) + RateDefinitions.StatGainBonus) > Utility.RandomDouble() )
{
if( info.StrGain != 0 )
GainStat( from, Stat.Str );
}
else if ( from.DexLock == StatLockType.Up && ((info.DexGain / 33.3) + RateDefinitions.StatGainBonus) > Utility.RandomDouble() )
{
if( info.DexGain != 0 )
GainStat( from, Stat.Dex );
}
else if ( from.IntLock == StatLockType.Up && ((info.IntGain / 33.3) + RateDefinitions.StatGainBonus) > Utility.RandomDouble() )
{
if( info.IntGain != 0 )
GainStat( from, Stat.Int );
}
//following line used to show chance to gain stats ingame
//from.SendMessage( "Str: {0} Dex: {1} Int: {2}",((info.StrGain / 33.3) + RateDefinitions.StatGainBonus),((info.DexGain / 33.3) + RateDefinitions.StatGainBonus),((info.IntGain / 33.3) + RateDefinitions.StatGainBonus) );
}
}
public static bool CanLower( Mobile from, Stat stat )
{
switch ( stat )
{
case Stat.Str: return ( from.StrLock == StatLockType.Down && from.RawStr > 10 );
case Stat.Dex: return ( from.DexLock == StatLockType.Down && from.RawDex > 10 );
case Stat.Int: return ( from.IntLock == StatLockType.Down && from.RawInt > 10 );
}
return false;
}
public static bool CanRaise( Mobile from, Stat stat )
{
if ( !(from is BaseCreature && ((BaseCreature)from).Controlled) )
{
if ( from.RawStatTotal >= from.StatCap )
return false;
}
switch ( stat )
{
case Stat.Str: return ( from.StrLock == StatLockType.Up && from.RawStr < 100 );
case Stat.Dex: return ( from.DexLock == StatLockType.Up && from.RawDex < 100 );
case Stat.Int: return ( from.IntLock == StatLockType.Up && from.RawInt < 100 );
}
return false;
}
public static void IncreaseStat( Mobile from, Stat stat, bool atrophy )
{
atrophy = atrophy || (from.RawStatTotal >= from.StatCap);
switch ( stat )
{
case Stat.Str:
{
if ( atrophy )
{
if ( CanLower( from, Stat.Dex ) && (from.RawDex < from.RawInt || !CanLower( from, Stat.Int )) )
--from.RawDex;
else if ( CanLower( from, Stat.Int ) )
--from.RawInt;
}
if ( CanRaise( from, Stat.Str ) )
++from.RawStr;
break;
}
case Stat.Dex:
{
if ( atrophy )
{
if ( CanLower( from, Stat.Str ) && (from.RawStr < from.RawInt || !CanLower( from, Stat.Int )) )
--from.RawStr;
else if ( CanLower( from, Stat.Int ) )
--from.RawInt;
}
if ( CanRaise( from, Stat.Dex ) )
++from.RawDex;
break;
}
case Stat.Int:
{
if ( atrophy )
{
if ( CanLower( from, Stat.Str ) && (from.RawStr < from.RawDex || !CanLower( from, Stat.Dex )) )
--from.RawStr;
else if ( CanLower( from, Stat.Dex ) )
--from.RawDex;
}
if ( CanRaise( from, Stat.Int ) )
++from.RawInt;
break;
}
}
}
private static TimeSpan m_StatGainDelay = TimeSpan.FromMinutes( RateDefinitions.statgaindelay );
public static void GainStat( Mobile from, Stat stat )
{
switch( stat )
{
case Stat.Str:
{
if( (from.LastStrGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastStrGain = DateTime.Now;
break;
}
case Stat.Dex:
{
if( (from.LastDexGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastDexGain = DateTime.Now;
break;
}
case Stat.Int:
{
if( (from.LastIntGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastIntGain = DateTime.Now;
break;
}
}
}
}
}
also u need 2 make new namespace Server.RateDef nd public a class RateDefinitions with public variables ratebonus, gainbonus, statgaindelay and StatGainBonus. or just use this one: Code:
using System;
using Server;
namespace Server.RateDef
{
public class RateDefinitions
{
public static double ratebonus = 1.0; // skillgain rate increase
public static int gainbonus = 1; // gain rate increment
public static double statgaindelay = 60.0; // stat gain delay
public static double StatGainBonus = 0.0; // extra chance to gain in stats. 0.0 - 1.0
}
}
also ill be happy if u add some words about me if u uses this scripts on your shard |
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
|
What does it do? What's the difference from the original one. You should add this kind of info in your top post.
Oh, and i think asking for ratings and similar stuff is against forum policys. If not, then just ignore this last statement and call me an idiot But descriptions, more descriptions, and even more descriptions. Can't have enough of them ![]() |
|
|
|
|
|
#4 (permalink) |
|
Forum Expert
|
all the stuff you can change is described in the script. I guess that is why he didn't attach it but put it in his thread so you can browse through. It would be stupid to describe it extra. Just have a look at the script. Everything is written in there!
Thanks a lot for sharing it! I like the idea of customizable skillgaining! Great work! Lia
__________________
;)My C# Bookshelf (carpented by Soultaker);) BTW: Please ask questions in the adequat forum and not on a private message! Otherwise nobody can learn from it!
|
|
|
|
|
|
#6 (permalink) |
|
Forum Novice
Join Date: May 2005
Age: 36
Posts: 175
|
I can see the author's account is terminated so dont flame me for askin.
but I was wondering if anyone else tried this and fixed this error ? Code:
Errors:
+ @ Modified/SkillCheck.cs:
CS0246: Line 9: The type or namespace name 'TimeSpan' could not be found (ar
e you missing a using directive or an assembly reference?)
CS0246: Line 389: The type or namespace name 'TimeSpan' could not be found (
are you missing a using directive or an assembly reference?)
|
|
|
|
|
|
#7 (permalink) |
|
Forum Novice
Join Date: May 2005
Location: Canada
Age: 24
Posts: 543
|
I think you just need to add a
Code:
using System;
__________________
A sense of community is the lifeblood of RunUO. http://www.runuo.com/forums/announcements/67400-something-all-you-chew.html Satire, man's greatest weapon (Flame Wars!) The darkness is patient and in the end it always wins...but even the smallest light can overcome the blackest shadow. |
|
|
|
|
|
#8 (permalink) |
|
Forum Newbie
Join Date: Nov 2006
Posts: 4
|
I got this script to work by creating a folder called RateDef in scripts folder and adding the second script given by the author and naming it Ratedefinitions.cs
I also added using Server; as suggested above and i added using Server.RateDef I done a little testing and it seems to function correctly, but I am a total noob to scripting and running a server at this point. This seems like a promising script for what I have in mind for skill gains. My thanks to the author. |
|
|
|
|
|
#10 (permalink) |
|
Forum Newbie
Join Date: Nov 2006
Posts: 4
|
I have noticed the same thing. No stat gains in about an hour of use with a new character.The stat script is a bit complex for me though.Any help with this would be greatly appreciated.
Last edited by war_bringer; 11-27-2006 at 05:07 AM. |
|
|
|
|
|
#11 (permalink) |
|
Forum Novice
Join Date: Mar 2004
Posts: 152
|
well with some tweaks the skill gains work quite effectively. and you can set how much % the skill gain shows when you actually gain skill. so for me I set 0.1% in the ratedef file. But having problems with the stat gain. been using this system for about 1 week and no stat gain recorded on any player.
|
|
|
|
|
|
#12 (permalink) |
|
Forum Novice
|
look here:
Code:
private static TimeSpan m_StatGainDelay = TimeSpan.FromMinutes( RateDefinitions.statgaindelay ); |
|
|
|
|
|
#13 (permalink) |
|
RunUO Forum Moderator
|
What about attaching the modified version as a *.cs file so people could just download it?
__________________
I always try to help
![]() Sometimes, I don't know how.... ![]() My Web Page Forum Rules ------------------------------------------------------------- Extensive OWLTR System | Token System | World Teleporters ------------------------------------------------------------- |
|
|
|
|
|
#16 (permalink) |
|
Forum Novice
Join Date: Mar 2004
Posts: 152
|
Here is what I got so far, skill gains work but stat gains are non exsistant.
here is skillcheck.cs C:\RUNUO\Scripts\Misc Code:
using System;
using Server;
using Server.Mobiles;
using Server.RateDef;
namespace Server.Misc
{
public class SkillCheck
{
private static readonly bool AntiMacroCode = true; //Change this to true to enable anti-macro code
public static TimeSpan AntiMacroExpire = TimeSpan.FromMinutes(0.1); //How long do we remember targets/locations?
public const int Allowance = 3; //How many times may we use the same location/target for gain
private const int LocationSize = 5; //The size of eeach location, make this smaller so players dont have to move as far
private static bool[] UseAntiMacro = new bool[]
{
// true if this skill uses the anti-macro code, false if it does not
false,// Alchemy = 0,
true,// Anatomy = 1,
true,// AnimalLore = 2,
true,// ItemID = 3,
true,// ArmsLore = 4,
false,// Parry = 5,
true,// Begging = 6,
false,// Blacksmith = 7,
false,// Fletching = 8,
true,// Peacemaking = 9,
true,// Camping = 10,
false,// Carpentry = 11,
false,// Cartography = 12,
false,// Cooking = 13,
true,// DetectHidden = 14,
true,// Discordance = 15,
true,// EvalInt = 16,
true,// Healing = 17,
true,// Fishing = 18,
true,// Forensics = 19,
true,// Herding = 20,
true,// Hiding = 21,
true,// Provocation = 22,
false,// Inscribe = 23,
true,// Lockpicking = 24,
true,// Magery = 25,
true,// MagicResist = 26,
false,// Tactics = 27,
true,// Snooping = 28,
true,// Musicianship = 29,
true,// Poisoning = 30,
false,// Archery = 31,
true,// SpiritSpeak = 32,
true,// Stealing = 33,
false,// Tailoring = 34,
true,// AnimalTaming = 35,
true,// TasteID = 36,
false,// Tinkering = 37,
true,// Tracking = 38,
true,// Veterinary = 39,
false,// Swords = 40,
false,// Macing = 41,
false,// Fencing = 42,
false,// Wrestling = 43,
true,// Lumberjacking = 44,
true,// Mining = 45,
true,// Meditation = 46,
true,// Stealth = 47,
true,// RemoveTrap = 48,
true,// Necromancy = 49,
false,// Focus = 50,
true,// Chivalry = 51
true,// Bushido = 52
true,//Ninjitsu = 53
true // Spellweaving
};
public static void Initialize()
{
Mobile.SkillCheckLocationHandler = new SkillCheckLocationHandler(Mobile_SkillCheckLocation);
Mobile.SkillCheckDirectLocationHandler = new SkillCheckDirectLocationHandler(Mobile_SkillCheckDirectLocation);
Mobile.SkillCheckTargetHandler = new SkillCheckTargetHandler(Mobile_SkillCheckTarget);
Mobile.SkillCheckDirectTargetHandler = new SkillCheckDirectTargetHandler(Mobile_SkillCheckDirectTarget);
//here is gainrates 4 each skill
//for instance .15 would be a 15% chance to gain in the particular skill
SkillInfo.Table[0].GainFactor = .12;// Alchemy = 0,
SkillInfo.Table[1].GainFactor = .12;// Anatomy = 1,
SkillInfo.Table[2].GainFactor = .12;// AnimalLore = 2,
SkillInfo.Table[3].GainFactor = .10;// ItemID = 3,
SkillInfo.Table[4].GainFactor = .10;// ArmsLore = 4,
SkillInfo.Table[5].GainFactor = .11;// Parry = 5,
SkillInfo.Table[6].GainFactor = .12;// Begging = 6,
SkillInfo.Table[7].GainFactor = .12;// Blacksmith = 7,
SkillInfo.Table[8].GainFactor = .12;// Fletching = 8,
SkillInfo.Table[9].GainFactor = .11;// Peacemaking = 9,
SkillInfo.Table[10].GainFactor = .15;// Camping = 10,
SkillInfo.Table[11].GainFactor = .12;// Carpentry = 11,
SkillInfo.Table[12].GainFactor = .12;// Cartography = 12,
SkillInfo.Table[13].GainFactor = .12;// Cooking = 13,
SkillInfo.Table[14].GainFactor = .10;// DetectHidden = 14,
SkillInfo.Table[15].GainFactor = .12;// Discordance = 15,
SkillInfo.Table[16].GainFactor = .10;// EvalInt = 16,
SkillInfo.Table[17].GainFactor = .12;// Healing = 17,
SkillInfo.Table[18].GainFactor = .10;// Fishing = 18,
SkillInfo.Table[19].GainFactor = .12;// Forensics = 19,
SkillInfo.Table[20].GainFactor = .15;// Herding = 20,
SkillInfo.Table[21].GainFactor = .15;// Hiding = 21,
SkillInfo.Table[22].GainFactor = .12;// Provocation = 22,
SkillInfo.Table[23].GainFactor = .15;// Inscribe = 23,
SkillInfo.Table[24].GainFactor = .15;// Lockpicking = 24,
SkillInfo.Table[25].GainFactor = .10;// Magery = 25,
SkillInfo.Table[26].GainFactor = .15;// MagicResist = 26,
SkillInfo.Table[27].GainFactor = .10;// Tactics = 27,
SkillInfo.Table[28].GainFactor = .10;// Snooping = 28,
SkillInfo.Table[29].GainFactor = .11;// Musicianship = 29,
SkillInfo.Table[30].GainFactor = .15;// Poisoning = 30
SkillInfo.Table[31].GainFactor = .10;// Archery = 31
SkillInfo.Table[32].GainFactor = .15;// SpiritSpeak = 32
SkillInfo.Table[33].GainFactor = .10;// Stealing = 33
SkillInfo.Table[34].GainFactor = .12;// Tailoring = 34
SkillInfo.Table[35].GainFactor = .15;// AnimalTaming = 35
SkillInfo.Table[36].GainFactor = .10;// TasteID = 36
SkillInfo.Table[37].GainFactor = .12;// Tinkering = 37
SkillInfo.Table[38].GainFactor = .15;// Tracking = 38
SkillInfo.Table[39].GainFactor = .15;// Veterinary = 39
SkillInfo.Table[40].GainFactor = .10;// Swords = 40
SkillInfo.Table[41].GainFactor = .10;// Macing = 41
SkillInfo.Table[42].GainFactor = .10;// Fencing = 42
SkillInfo.Table[43].GainFactor = .10;// Wrestling = 43
SkillInfo.Table[44].GainFactor = .10;// Lumberjacking = 44
SkillInfo.Table[45].GainFactor = .10;// Mining = 45
SkillInfo.Table[46].GainFactor = .09;// Meditation = 46
SkillInfo.Table[47].GainFactor = .15;// Stealth = 47
SkillInfo.Table[48].GainFactor = .15;// RemoveTrap = 48
SkillInfo.Table[49].GainFactor = .10;// Necromancy = 49
SkillInfo.Table[50].GainFactor = .09;// Focus = 50
SkillInfo.Table[51].GainFactor = .12;// Chivalry = 51
}
public static bool Mobile_SkillCheckLocation(Mobile from, SkillName skillName, double minSkill, double maxSkill)
{
return Mobile_SkillCheckLocation(from, skillName, minSkill, maxSkill, maxSkill);
}
public static bool Mobile_SkillCheckLocation(Mobile from, SkillName skillName, double minSkill, double maxSkill, double maxSkillGain)
{
Skill skill = from.Skills[skillName];
if (skill == null)
return false;
double value = skill.Value;
if (value < minSkill)
return false; // Too difficult
else if (value >= maxSkill && maxSkill >= maxSkillGain)
return true; // No challenge
double chance = (value - minSkill) / (maxSkill - minSkill);
double chanceG = (value - minSkill) / (maxSkillGain - minSkill);
Point2D loc = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize);
CheckSkill(from, skill, loc, chanceG);
return chance >= Utility.RandomDouble();
}
public static bool Mobile_SkillCheckDirectLocation(Mobile from, SkillName skillName, double chance)
{
Skill skill = from.Skills[skillName];
if (skill == null)
return false;
if (chance < 0.0)
return false; // Too difficult
else if (chance >= 1.0)
return true; // No challenge
Point2D loc = new Point2D(from.Location.X / LocationSize, from.Location.Y / LocationSize);
return CheckSkill(from, skill, loc, chance);
}
public static bool CheckSkill(Mobile from, Skill skill, object amObj, double chance)
{
if (from.Skills.Cap == 0)
return false;
bool success = (chance >= Utility.RandomDouble());
//here is modifications 2 skillgains
double BaseSkillGain = skill.Info.GainFactor;
double LowSkillMod = .10;
double aSkillMod = .03;
double bSkillMod = .05;
double cSkillMod = .06;
double dSkillMod = .07;
double eSkillMod = .08;
double fSkillMod = .085;
double gSkillMod = .09;
double hSkillMod = .095;
double iSkillMod = .096;
double jSkillMod = .097;
double kSkillMod = .098;
//Example: Player Skill is 85.3 - We would take the 12% base chance and subtract 8% - Player now has a 4% chance to gain.
//*****************************************************************************************************************//
double ComputedSkillMod = 0; // holds the percent chance to gain after checking players skill
//here is modding gainrates. i.c. under lv 20% lowskillmod added 2 gain rate. from 20 to 40 askillmod substracted from it
if (skill.Base < 20.0)
ComputedSkillMod = BaseSkillGain + LowSkillMod;
else if (skill.Base < 40.0)
ComputedSkillMod = BaseSkillGain - aSkillMod;
else if (skill.Base < 80.0)
ComputedSkillMod = BaseSkillGain - bSkillMod;
else if (skill.Base < 90.0)
ComputedSkillMod = BaseSkillGain - cSkillMod;
else if (skill.Base < 100.0)
ComputedSkillMod = BaseSkillGain - dSkillMod;
else if (skill.Base < 110.0)
ComputedSkillMod = BaseSkillGain - eSkillMod;
else if (skill.Base < 120.0)
ComputedSkillMod = BaseSkillGain - fSkillMod;
else if (skill.Base < 130.0)
ComputedSkillMod = BaseSkillGain - gSkillMod;
else if (skill.Base < 140.0)
ComputedSkillMod = BaseSkillGain - hSkillMod;
else if (skill.Base < 160.0)
ComputedSkillMod = BaseSkillGain - iSkillMod;
else if (skill.Base < 180.0)
ComputedSkillMod = BaseSkillGain - jSkillMod;
else if (skill.Base >= 200.0)
ComputedSkillMod = BaseSkillGain - kSkillMod;
//if u make substraction larger than skill gain rate
if (ComputedSkillMod < 0.001)
ComputedSkillMod = 0.001;
//following line used to see chance to gain ingame
//from.SendMessage( "Your chance to gain {0} is {1}",skill.Name, ComputedSkillMod );
if (from is BaseCreature && ((BaseCreature)from).Controlled)
ComputedSkillMod *= 2;
ComputedSkillMod *= RateDefinitions.ratebonus;
if (from.Alive && ((ComputedSkillMod >= Utility.RandomDouble() && AllowGain(from, skill, amObj)) || skill.Base < 10.0))
Gain(from, skill);
return success;
}
public static bool Mobile_SkillCheckTarget(Mobile from, SkillName skillName, object target, double minSkill, double maxSkill)
{
Skill skill = from.Skills[skillName];
if (skill == null)
return false;
double value = skill.Value;
if (value < minSkill)
return false; // Too difficult
else if (value >= maxSkill)
return true; // No challenge
double chance = (value - minSkill) / (maxSkill - minSkill);
return CheckSkill(from, skill, target, chance);
}
public static bool Mobile_SkillCheckDirectTarget(Mobile from, SkillName skillName, object target, double chance)
{
Skill skill = from.Skills[skillName];
if (skill == null)
return false;
if (chance < 0.0)
return false; // Too difficult
else if (chance >= 1.0)
return true; // No challenge
return CheckSkill(from, skill, target, chance);
}
private static bool AllowGain(Mobile from, Skill skill, object obj)
{
if (from is PlayerMobile && AntiMacroCode && UseAntiMacro[skill.Info.SkillID])
return ((PlayerMobile)from).AntiMacroCheck(skill, obj);
else
return true;
}
public enum Stat { Str, Dex, Int }
public static void Gain(Mobile from, Skill skill)
{
if (from.Region is Regions.Jail)
return;
if (from is BaseCreature && ((BaseCreature)from).IsDeadPet)
return;
if (skill.SkillName == SkillName.Focus && from is BaseCreature)
return;
if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up)
{
int toGain = 1;
if (skill.Base < 20.0)
toGain = Utility.Random(8) + 7;
else if (skill.Base < 40.0)
toGain = Utility.Random(7) + 6;
else if (skill.Base < 60.0)
toGain = Utility.Random(6) + 5;
else if (skill.Base < 80.0)
toGain = Utility.Random(5) + 4;
else if (skill.Base < 100.0)
toGain = Utility.Random(4) + 3;
else if (skill.Base < 120.0)
toGain = Utility.Random(3) + 2;
else if (skill.Base < 150.0)
toGain = Utility.Random(2) + 1;
else if (skill.Base < 200.0)
toGain = Utility.Random(1) + 1;
toGain *= RateDefinitions.gainbonus;
Skills skills = from.Skills;
if ((skills.Total / skills.Cap) >= Utility.RandomDouble())//( skills.Total >= skills.Cap )
{
for (int i = 0; i < skills.Length; ++i)
{
Skill toLower = skills[i];
if (toLower != skill && toLower.Lock == SkillLock.Down && toLower.BaseFixedPoint >= toGain)
{
toLower.BaseFixedPoint -= toGain;
break;
}
}
}
if ((skills.Total + toGain) <= skills.Cap)
{
skill.BaseFixedPoint += toGain;
}
}
if (skill.Lock == SkillLock.Up)
{
SkillInfo info = skill.Info;
if (from.StrLock == StatLockType.Up && ((info.StrGain / 10.0) + RateDefinitions.StatGainBonus) > Utility.RandomDouble())
{
if (info.StrGain != 0)
GainStat(from, Stat.Str);
}
else if (from.DexLock == StatLockType.Up && ((info.DexGain / 8.0) + RateDefinitions.StatGainBonus) > Utility.RandomDouble())
{
if (info.DexGain != 0)
GainStat(from, Stat.Dex);
}
else if (from.IntLock == StatLockType.Up && ((info.IntGain / 13.0) + RateDefinitions.StatGainBonus) > Utility.RandomDouble())
{
if (info.IntGain != 0)
GainStat(from, Stat.Int);
}
//following line used to show chance to gain stats ingame
//from.SendMessage( "Str: {0} Dex: {1} Int: {2}",((info.StrGain / 33.3) + RateDefinitions.StatGainBonus),((info.DexGain / 33.3) + RateDefinitions.StatGainBonus),((info.IntGain / 33.3) + RateDefinitions.StatGainBonus) );
}
}
public static bool CanLower(Mobile from, Stat stat)
{
switch (stat)
{
case Stat.Str: return (from.StrLock == StatLockType.Down && from.RawStr > 10);
case Stat.Dex: return (from.DexLock == StatLockType.Down && from.RawDex > 10);
case Stat.Int: return (from.IntLock == StatLockType.Down && from.RawInt > 10);
}
return false;
}
public static bool CanRaise(Mobile from, Stat stat)
{
if (!(from is BaseCreature && ((BaseCreature)from).Controlled))
{
if (from.RawStatTotal >= from.StatCap)
return false;
}
switch (stat)
{
case Stat.Str: return (from.StrLock == StatLockType.Up && from.RawStr < 2000);
case Stat.Dex: return (from.DexLock == StatLockType.Up && from.RawDex < 2000);
case Stat.Int: return (from.IntLock == StatLockType.Up && from.RawInt < 2000);
}
return false;
}
public static void IncreaseStat(Mobile from, Stat stat, bool atrophy)
{
atrophy = atrophy || (from.RawStatTotal >= from.StatCap);
switch (stat)
{
case Stat.Str:
{
if (atrophy)
{
if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int)))
--from.RawDex;
else if (CanLower(from, Stat.Int))
--from.RawInt;
}
if (CanRaise(from, Stat.Str))
++from.RawStr;
break;
}
case Stat.Dex:
{
if (atrophy)
{
if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int)))
--from.RawStr;
else if (CanLower(from, Stat.Int))
--from.RawInt;
}
if (CanRaise(from, Stat.Dex))
++from.RawDex;
break;
}
case Stat.Int:
{
if (atrophy)
{
if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex)))
--from.RawStr;
else if (CanLower(from, Stat.Dex))
--from.RawDex;
}
if (CanRaise(from, Stat.Int))
++from.RawInt;
break;
}
}
}
private static TimeSpan m_StatGainDelay = TimeSpan.FromMinutes(5.0);
public static void GainStat(Mobile from, Stat stat)
{
switch (stat)
{
case Stat.Str:
{
if ((from.LastStrGain + m_StatGainDelay) >= DateTime.Now)
return;
from.LastStrGain = DateTime.Now;
break;
}
case Stat.Dex:
{
if ((from.LastDexGain + m_StatGainDelay) >= DateTime.Now)
return;
from.LastDexGain = DateTime.Now;
break;
}
case Stat.Int:
{
if ((from.LastIntGain + m_StatGainDelay) >= DateTime.Now)
return;
from.LastIntGain = DateTime.Now;
break;
}
}
}
}
}
Code:
using System;
using Server;
namespace Server.RateDef
{
public class RateDefinitions
{
public static double ratebonus = 0.1; // skillgain rate increase
public static int gainbonus = 1; // gain rate increment
public static double statgaindelay = 2.0; // stat gain delay
public static double StatGainBonus = 0.2; // extra chance to gain in stats. 0.0 - 1.0
}
}
|
|
|
|
|
|
#17 (permalink) |
|
Forum Newbie
Join Date: Aug 2003
Posts: 12
|
I don't know if anybody's still interested in this, but I found the problem with stats not gaining. The GainStat() function was missing two lines. I haven't tested it extensively, but I was able to gain both skills and stats with a couple of different characters. Here is the corrected Gainstat() function:
Code:
public static void GainStat( Mobile from, Stat stat )
{
switch( stat )
{
case Stat.Str:
{
if( (from.LastStrGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastStrGain = DateTime.Now;
break;
}
case Stat.Dex:
{
if( (from.LastDexGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastDexGain = DateTime.Now;
break;
}
case Stat.Int:
{
if( (from.LastIntGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastIntGain = DateTime.Now;
break;
}
}
bool atrophy = ( (from.RawStatTotal / (double)from.StatCap) >= Utility.RandomDouble() );
IncreaseStat( from, stat, atrophy );
}
|
|
|
|
|
|
#19 (permalink) |
|
Forum Novice
|
here are my errors. it might be becouse i dont have an xml spawner system i have the megaspawner system Code:
RunUO - [www.runuo.com] Version 2.0, Build 2357.32527 Core: Running on .NET Framework Version 2.0.50727 Scripts: Compiling C# scripts...failed (1 errors, 0 warnings) Errors: + Mis |