:: RunUo.Korean.Forum > Script Support
¹®¼ÁÖ¼Ò : http://runuo.co.kr/forum/viewtopic.php?t=1461
¡Ø TOPIC TITLE : ½ºÅ³¿¡ °üÇØ Áú¹®µå¸³´Ï´Ù..
Á¦ ¸ñ : ½ºÅ³¿¡ °üÇØ Áú¹®µå¸³´Ï´Ù..
¾ÆÀ̵ð: jscj777 - 2006-08-17 ¸ñ 12:28 am
·±À¯¿À 1.0À» ¾²°íÀÖ½À´Ï´Ù¸¸..
ÀϹݰèÁ¤À¸·Î ½ÇÇèÀ» ÇØºÃ´Âµ¥ ½ºÅ³ÀÌ ´çÃé ¿À¸£Áú ¾Ê½À´Ï´Ù.
¿©±â¼ °Ë»öÇÑ´ë·Î ½ºÅ³Ã¼Å©.cs¸¦ ¾Æ¹«¸® ¼ÕºÁÁ൵
½ÇÇèÀÚµéÀº ¸ðµç ½ºÅ³ÀÌ ¾È¿À¸¥´Ù°í Çϳ׿ä.. Ȥ½Ã ¹» °Çµå·Á¼ ±×·±°É±î¿ä?
Á¦ ¸ñ : SkillCheck.cs ÆÄÀÏ ³»¿ë...
¾ÆÀ̵ð: GangPung - 2006-08-17 ¸ñ 7:00 pm
·±À¯¿À ¹öÁ¯ 2.0¿¡¼ ¸»¾¸µå¸³´Ï´Ù.
Misc/SkillCheck.cs ÆÄÀÏ ³»¿ëÁß...
¶óÀÎ 119ÀÌÇÏ
ÄÚµå : |
...Áß·«
public static bool CheckSkill( Mobile from, Skill skill, object amObj, double chance )
{
if ( from.Skills.Cap == 0 )
return false;
bool success = ( chance >= Utility.RandomDouble() );
double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;
gc += ( skill.Cap - skill.Base ) / skill.Cap;
gc /= 2; // ¾Æ·¡ÀÇ gc °ªÀ» º¯°æÇØÁÖ¼¼¿ä. 2¸¦ ±âÁØÀ¸·Î °ªÀÌ ³ôÀ»¼ö·Ï ¾î·Æ°Ô, ¾Õ¿¡ 0À» »« .25 ¶Ç´Â .5 ÀÌ·±½ÄÀ¸·Î ³·Àº°ªÀº ½ºÅ³ »ó½ÂÀÌ ½±°Ô Àû¿ëµË´Ï´Ù.
gc += ( 1.0 - chance ) * ( success ? 0.5 : (Core.AOS ? 0.0 : 0.2) );
gc /= 2; // À̺κР¿ª½Ã À§¿Í µ¿ÀÏÇÏ°Ô Àû¿ëÇØÁÖ¼¼¿ä.
gc *= skill.Info.GainFactor;
if ( gc < 0.01 )
gc = 0.01;
if ( from is BaseCreature && ((BaseCreature)from).Controlled )
gc *= 2;
if ( from.Alive && ( ( gc >= Utility.RandomDouble() && AllowGain( from, skill, amObj ) ) || skill.Base < 10.0 ) )
Gain( from, skill );
return success;
}
...Áß·«
|
À§ ÄÚµåÁß gc /= 2; °ªÀ» º¯°æÇØÁÖ¼¼¿ä. µÎ°÷ ¸ðµÎ ÇØÁÖ½Ã´Â°Ô ÆíÇϽǵíÇÕ´Ï´Ù.
2¸¦ ±âÁØÀ¸·Î °ªÀÌ ³ôÀ»¼ö·Ï ¾î·Æ°Ô, ¾Õ¿¡ 0À» »« .25 ¶Ç´Â .5 ÀÌ·±½ÄÀ¸·Î ³·Àº°ªÀº ½ºÅ³ »ó½ÂÀÌ ½±°Ô Àû¿ëµË´Ï´Ù.
Á¦ ¸ñ : Èì.. ´Ù¸¥ »ç¶÷¿¡°Ô
¾ÆÀ̵ð: jscj777 - 2006-08-17 ¸ñ 7:36 pm
´äº¯ °¨»çÇÕ´Ï´Ù.
±×·±µ¥ ´Ù¸¥ »ç¶÷¿¡°Ô ¼·¸¶ °èÁ¤À¸·Î Á¢¼ÓÇØ¼ ÇØº¸¶ó°í ÇÏ´Ï
¿À¸¥´Ù°í Çϳ׿ä.. óÀ½ ·±À¯¿À ±¸µ¿½Ãų¶§ ¸¸µç ¼·¸¶ °èÁ¤¸¸ ¿À¸£´Â°Å´Ï..
Ȥ½Ã ¹«½¼ ¹®Á¦°¡ ÀÖ³ª¿ä? skillcheck ÄÚµå ÷ºÎÇϰڽÀ´Ï´Ù.
¹«½¼ ¹®Á¦°¡ ÀÖ´ÂÁö ºÁÁÖ¼¼¿ä..
ÄÚµå : |
using System;
using Server;
using Server.Mobiles;
namespace Server.Misc
{
public class SkillCheck
{
private const bool AntiMacroCode = false; //Change this to false to disable 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
};
public static void Initialize()
{
// Begin mod to enable XmlSpawner skill triggering
Mobile.SkillCheckLocationHandler = new SkillCheckLocationHandler( XmlSpawnerSkillCheck.Mobile_SkillCheckLocation );
Mobile.SkillCheckDirectLocationHandler = new SkillCheckDirectLocationHandler( XmlSpawnerSkillCheck.Mobile_SkillCheckDirectLocation );
Mobile.SkillCheckTargetHandler = new SkillCheckTargetHandler( XmlSpawnerSkillCheck.Mobile_SkillCheckTarget );
Mobile.SkillCheckDirectTargetHandler = new SkillCheckDirectTargetHandler( XmlSpawnerSkillCheck.Mobile_SkillCheckDirectTarget );
// End mod to enable XmlSpawner skill triggering
SkillInfo.Table[0].GainFactor = 2;// Alchemy = 0,
SkillInfo.Table[1].GainFactor = 1.6;// Anatomy = 1,
SkillInfo.Table[2].GainFactor = 2;// AnimalLore = 2,
SkillInfo.Table[3].GainFactor = 2;// ItemID = 3,
SkillInfo.Table[4].GainFactor = 2;// ArmsLore = 4,
SkillInfo.Table[5].GainFactor = 1.6;// Parry = 5,
SkillInfo.Table[6].GainFactor = 0;// Begging = 6,
SkillInfo.Table[7].GainFactor = 2;// Blacksmith = 7,
SkillInfo.Table[8].GainFactor = 2;// Fletching = 8,
SkillInfo.Table[9].GainFactor = 2;// Peacemaking = 9,
SkillInfo.Table[10].GainFactor = 0;// Camping = 10,
SkillInfo.Table[11].GainFactor = 2;// Carpentry = 11,
SkillInfo.Table[12].GainFactor = 2;// Cartography = 12,
SkillInfo.Table[13].GainFactor = 1;// Cooking = 13,
SkillInfo.Table[14].GainFactor = 2;// DetectHidden = 14,
SkillInfo.Table[15].GainFactor = 2;// Discordance = 15,
SkillInfo.Table[16].GainFactor = 2;// EvalInt = 16,
SkillInfo.Table[17].GainFactor = 2;// Healing = 17,
SkillInfo.Table[18].GainFactor = 2;// Fishing = 18,
SkillInfo.Table[19].GainFactor = 0;// Forensics = 19,
SkillInfo.Table[20].GainFactor = 2;// Herding = 20,
SkillInfo.Table[21].GainFactor = 2.2;// Hiding = 21,
SkillInfo.Table[22].GainFactor = 2;// Provocation = 22,
SkillInfo.Table[23].GainFactor = 2;// Inscribe = 23,
SkillInfo.Table[24].GainFactor = 1;// Lockpicking = 24,
SkillInfo.Table[25].GainFactor = 1.5;// Magery = 25,
SkillInfo.Table[26].GainFactor = 0;// MagicResist = 26,
SkillInfo.Table[27].GainFactor = 1.7;// Tactics = 27,
SkillInfo.Table[28].GainFactor = 2;// Snooping = 28,
SkillInfo.Table[29].GainFactor = 2;// Musicianship = 29,
SkillInfo.Table[30].GainFactor = 2;// Poisoning = 30
SkillInfo.Table[31].GainFactor = 2;// Archery = 31
SkillInfo.Table[32].GainFactor = 2;// SpiritSpeak = 32
SkillInfo.Table[33].GainFactor = 2.2;// Stealing = 33
SkillInfo.Table[34].GainFactor = 2;// Tailoring = 34
SkillInfo.Table[35].GainFactor = 2.2;// AnimalTaming = 35
SkillInfo.Table[36].GainFactor = 2;// TasteID = 36
SkillInfo.Table[37].GainFactor = 2;// Tinkering = 37
SkillInfo.Table[38].GainFactor = 2;// Tracking = 38
SkillInfo.Table[39].GainFactor = 2;// Veterinary = 39
SkillInfo.Table[40].GainFactor = 1.6;// Swords = 40
SkillInfo.Table[41].GainFactor = 1.6;// Macing = 41
SkillInfo.Table[42].GainFactor = 1.5;// Fencing = 42
SkillInfo.Table[43].GainFactor = 1.6;// Wrestling = 43
SkillInfo.Table[44].GainFactor = 1;// Lumberjacking = 44
SkillInfo.Table[45].GainFactor = 1;// Mining = 45
SkillInfo.Table[46].GainFactor = 1;// Meditation = 46
SkillInfo.Table[47].GainFactor = 2;// Stealth = 47
SkillInfo.Table[48].GainFactor = 2;// RemoveTrap = 48
SkillInfo.Table[49].GainFactor = 2;// Necromancy = 49
SkillInfo.Table[50].GainFactor = 1.4;// Focus = 50
SkillInfo.Table[51].GainFactor = 2;// Chivalry = 51
SkillInfo.Table[52].GainFactor = 1.2;//Bushido = 52
SkillInfo.Table[53].GainFactor = 2;//Ninjitsu = 53
}
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() );
double gc = (double)(from.Skills.Cap - from.Skills.Total) / from.Skills.Cap;
gc += ( skill.Cap - skill.Base ) / skill.Cap;
gc /= 2;
gc += ( 1.0 - chance ) * ( success ? 0.5 : 0.2 );
gc /= 1;
gc *= skill.Info.GainFactor;
if ( gc < 0.01 )
gc = 0.01;
if ( from is BaseCreature && ((BaseCreature)from).Controled )
gc *= 2;
if ( from.Alive && ( ( gc >= 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 <= 10.0 )
toGain = Utility.Random( 4 ) + 1;
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;
double StatGainBonus = 0.5; //ÀÌ ºÎºÐÀ» 0.00 ¿¡¼ 1.00 °ªÀ¸·Î ¼öÁ¤Çϼ¼¿ä. ·±À¯¿À ±âº»°ªÀº 0À¸·Î ¼³Á¤µÇ¾îÀÖ½À´Ï´Ù. 1¿¡ °¡±î¿ï¼ö·Ï ½ºÅÈ ³À̵µ°¡ ½±´Ù°í »ý°¢ÇϽøéµË´Ï´Ù
if ( from.StrLock == StatLockType.Up && ((info.StrGain / 33.3) + StatGainBonus) > Utility.RandomDouble() )
{
if( info.StrGain != 0 )
GainStat( from, Stat.Str );
}
else if ( from.DexLock == StatLockType.Up && ((info.DexGain / 33.3) + StatGainBonus) > Utility.RandomDouble() )
{
if( info.DexGain != 0 )
GainStat( from, Stat.Dex );
}
else if ( from.IntLock == StatLockType.Up && ((info.IntGain / 33.3) + StatGainBonus) > Utility.RandomDouble() )
{
if( info.IntGain != 0 )
GainStat( from, Stat.Int );
}
}
}
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).Controled) )
{
if ( from.RawStatTotal >= from.StatCap )
return false;
}
if( from is PlayerMobile ) //Ç÷¹À̾ ½ºÅÝÀ» üũÇÑ´Ù.
{
PlayerMobile Pm =(PlayerMobile)from;
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( 0.0 );
public static void GainStat( Mobile from, Stat stat )
{
if ( (from.LastStatGain + m_StatGainDelay) >= DateTime.Now )
return;
from.LastStatGain = DateTime.Now;
bool atrophy = ( (from.RawStatTotal / (double)from.StatCap) >= Utility.RandomDouble() );
IncreaseStat( from, stat, atrophy );
}
}
}
|
|