public static void DoHeal ( Mobile creature )
{
DoHeal( creature, false, 10 );
}
public static void DoHeal ( Mobile creature, int percentToHeal )
{
DoHeal( creature, false, percentToHeal );
}
public static void DoHeal ( Mobile creature, bool checkBandages )
{
DoHeal( creature, checkBandages, 10 );
}
public static void DoHeal ( Mobile creature, bool checkBandages, int percentToHeal )
{
BaseCreature c = null;
if ( creature is BaseCreature )
c = (BaseCreature)creature;
if ( percentToHeal <= 0 || percentToHeal >= 100 ) //No weird percentages
{
percentToHeal = 10;
}
int percent = creature.HitsMax / percentToHeal; //We need to find the number of hits
if ( creature.Hits < creature.HitsMax - percent ) //If they're below that number
{
if ( BandageContext.GetContext( creature ) == null ) //Checks to see if healing
{
if ( !checkBandages ) //Do we need bandages?
{
if ( c != null )
c.DebugSay( "I'm healing without bandages" );
BandageContext.BeginHeal( creature, creature ); //Start the healing process
return;
}
if ( creature.FindItemOnLayer( Layer.Backpack ) != null) //Check for a backpack
{
Bandage bandage = (Bandage)creature.Backpack.FindItemByType( typeof( Bandage ) ); //Are there even bandages?
if ( bandage != null )
{
if ( c != null )
c.DebugSay( "I'm healing with bandages!" );
BandageContext.BeginHeal( creature, creature ); //Start the healing process
return;
}
if ( c != null )
c.DebugSay( "I'm out of bandages!" );
}
}
}
}
public static void suckBlood ( Mobile creature )
{
suckBlood( creature, 10, 20, 2 );
}
public static void suckBlood ( Mobile creature, int range )
{
suckBlood (creature, 10, 20, range);
}
public static void suckBlood ( Mobile creature, int min, int max )
{
suckBlood( creature, min, max, 2 );
}
public static void suckBlood ( Mobile creature, int min, int max, int range )
{
BaseCreature c = null;
if ( creature is BaseCreature )
c = (BaseCreature)creature;
ArrayList list = new ArrayList();
foreach ( Mobile m in creature.GetMobilesInRange( range ) )
{
if ( m == creature || !creature.CanBeHarmful( m ) )
continue;
if ( m is BaseCreature && ( ( (BaseCreature)m ).Controlled || ( (BaseCreature)m ).Summoned ) )
list.Add( m );
else if ( c != null && m is BaseCreature && ( (BaseCreature)m ).Team != c.Team )
list.Add( m );
else if ( m.Player )
list.Add( m );
}
foreach ( Mobile m in list )
{
creature.DoHarmful( m );
m.FixedParticles( 0x374A, 10, 15, 5013, 0x496, 0, EffectLayer.Waist );
m.PlaySound( 0x231 );
m.SendMessage( "You feel the life drain out of you!" );
int toDrain = Utility.RandomMinMax( min, max );
creature.Hits += toDrain;
m.Damage( toDrain, creature );
}
}
public static void equipWeapon ( Mobile creature )
{
equipWeapon( creature, false, false );
}
public static void equipWeapon ( Mobile creature, bool constantCheck )
{
equipWeapon( creature, false, constantCheck);
}
public static void equipWeapon ( Mobile creature, bool createWeapon, bool constantCheck )
{
BaseCreature c = null;
if ( creature is BaseCreature )
c = (BaseCreature)creature;
List<BaseWeapon> weps = new List<BaseWeapon>();
BaseWeapon wep = creature.Weapon as BaseWeapon;
if ( constantCheck || wep != null ) //Do we always check for a weapon? Do we even have a weapon?
{
float total = 0;//Which of the weapon skills is highest?
short holder = 0;//Hold the value
double[] skillz = new double[6];
skillz[0] = ( creature.Skills[SkillName.Wrestling].Value );//Value, because skill bonus items have an effect
skillz[1] = ( creature.Skills[SkillName.Archery].Value ); //Change to 0 for no archery support
skillz[2] = ( creature.Skills[SkillName.Swords].Value );
skillz[3] = ( creature.Skills[SkillName.Fencing].Value );
skillz[4] = ( creature.Skills[SkillName.Macing].Value );
for ( short i = 0; i < 5; i++ )
if ( skillz[i] > total )
{
total = (float)skillz[i];
holder = i;
}
if ( total == 0 || holder == 0 ) //Don't equip a weapon if every skill is at 0 or wrestling is highest
{
if ( c != null )
c.DebugSay( "My fists are my weapons!" );
return;
}
if ( creature.Backpack != null ) //Backpack check
{
foreach ( Item i in creature.Backpack.Items )
if ( i is BaseWeapon )
weps.Add( (BaseWeapon)i );
if ( weps.Count == 0 ) //No weapons, no need to waste CPU cycles
{
if ( c != null )
c.DebugSay( "I have no weapons!" );
return;
}
List<int> wepRanks = new List<int>();
for ( int i = 0; i < weps.Count; i++ )
{
if ( c != null )
wepRanks[i] = doRank( weps[i], c.AI, holder );
else
wepRanks[i] = doRank( weps[i], AIType.AI_Melee, holder );
}
total = 0; //Reset the total
for ( short i = 0; i < wepRanks.Count; i++ )
if ( wepRanks[i] > total )
{
total = wepRanks[i];
holder = i;
}
creature.EquipItem( weps[holder] );//And FINALLY equip it.
}
if ( c != null )
c.DebugSay( "I have no backpack!" );
return;
}
}