C# Scripting

Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Nov 6, 2004
Messages
3,055
Best answers
0
Location
Round Rock, TX
Ok, this was scripted BY HAND, and took me awhile. But I'm curious to know if it's clean code or not, so I'm gonna post the source here for examination. The reason I'm doing so is because I've lost my compiler, and until I can contact the one who gave it to me, I'm stuck without one.

Code:
using System;
using System.Collections;
using Server.Items;
namespace Server.Mobiles
{
   [CorpseName( "A Vampiric corpse" )]
   public class Akasha : BaseCreature
   {
    private static bool m_Talked;
 
    string[] kfcsay = new string[]
    {
     "Let my cries chill the living!",
     "My children shall destroy you!",
     "Die, *****!",
     "Your blood shall course through my veins!"
    };
 
    [Constructable]
    public Akasha() : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4 )
    {
     Name = "Akasha";
     Title = "Queen of the Damned";
     Body = 401;
     Hue = 1150;
     Female = true;
     BaseSoundID = 1154;
 
     SetStr( 500, 800 );
     SetDex( 500, 800 );
     SetInt( 10000, 13000 );
 
     SetHits( 10000, 15000 );
 
     SetDamage( 50, 70 );
 
     SetDamageType( ResistanceType.Physical, 20 );
     SetDamageType( ResistanceType.Cold, 40 );
     SetDamageType( ResistanceType.Energy, 40 );
 
     SetResistance( ResistanceType.Physical, 55, 65 );
     SetResistance( ResistanceType.Fire, 25, 30 );
     SetResistance( ResistanceType.Cold, 50, 60 );
     SetResistance( ResistanceType.Poison, 50, 60 );
     SetResistance( ResistanceType.Energy, 25, 30 );
 
     SetSkill( SkillName.EvalInt, 120.1, 130.0 );
     SetSkill( SkillName.Magery, 120.1, 130.0 );
     SetSkill( SkillName.Meditation, 100.1, 101.0 );
     SetSkill( SkillName.Poisoning, 100.1, 101.0 );
     SetSkill( SkillName.MagicResist, 175.2, 200.0 );
     SetSkill( SkillName.Tactics, 90.1, 100.0 );
     SetSkill( SkillName.Macing, 120.1, 130.0 );
 
     Nightmare mare = new Nightmare();
     mare.Hue = 2118;
     mare.Rider = this;
 
     Fame = 23000;
     Karma = -23000;
 
     VirtualArmor = 60;
 
     AddItem( new FloppyHat ( 1153 ) );
     AddItem( new Skirt ( 1153 ) );
     AddItem( new Sandals ( 2118 ) );
     AddItem( new FemaleTunicofBlood ( ) );
     AddItem( new ArmsofBlood ( ) );
     AddItem( new GlovesofBlood ( ) );
     AddItem( new LeggingsofBlood ( ) );
     AddItem( new GorgetofBlood ( ) );
 
     LongHair hair = new LongHair();
     hair.Hue = 2118;
     hair.Layer = Layer.Hair;
     hair.Movable = false;
     AddItem( hair );
     StaffOfTheMagi weapon = new StaffOfTheMagi();
 
     weapon.Movable = false;
 
     AddItem( weapon );
 
     PackItem( new AkashasHeart());
     PackGold( 2000,3050 );
 
     switch ( Utility.Random( 50 ))
     {
      case 0: PackItem( new VampireSlayer() ); break;
      case 1: PackItem( new VampireRobe() ); break;
      default: break;
     }
    }
 
    public override bool AutoDispel{ get{ return true; } }
    public override bool AlwaysMurderer{ get{ return true; } }
    public override Poison PoisonImmune{ get{ return Poison.Deadly; } }
    public override int TreasureMapLevel{ get{ return 5; } }
    public override bool BardImmune{ get{ return true; } }
    public override bool CanRummageCorpses{ get{ return true; } }
    public override Poison HitPoison{ get{ return Poison.Lethal; } }
 
    public Akasha( Serial serial ) : base( serial )
    {
    }
 
    public override void Serialize( GenericWriter writer )
    {
     base.Serialize( writer );
     writer.Write( (int) 0 );
    }
 
    public override void Deserialize( GenericReader reader )
    {
     base.Deserialize( reader );
     int version = reader.ReadInt();
    }
    public void Spawnavampire( Mobile m )
    {
     Map map = this.Map;
 
     if ( map == null )
     return;
 
     avampire spawned = new avampire();
 
     spawned.Team = this.Team;
     spawned.Map = map;
 
     bool validLocation = false;
 
     for ( int j = 0; !validLocation && j < 10; ++j )
     {
      int x = X + Utility.Random( 3 ) - 1;
      int y = Y + Utility.Random( 3 ) - 1;
      int z = map.GetAverageZ( x, y );
 
      if ( validLocation = map.CanFit( x, y, this.Z, 16, false, false ) )
      spawned.Location = new Point3D( x, y, Z );
      else if ( validLocation = map.CanFit( x, y, z, 16, false, false ) )
      spawned.Location = new Point3D( x, y, z );
     }
 
     if ( !validLocation )
     spawned.Location = this.Location;
 
     spawned.Combatant = m;
    }
 
    public void Eatavampire()
    {
     Map map = this.Map;
 
     if ( map == null )
     return;
 
     ArrayList toEat = new ArrayList();
 
     IPooledEnumerable eable = map.GetMobilesInRange( this.Location, 2 );
 
     foreach ( Mobile m in eable )
     {
      if ( m is avampire )
      toEat.Add( m );
     }
 
     eable.Free();
 
     if ( toEat.Count > 0 )
     {
      PlaySound( Utility.Random( 0x3B, 2 ) );
 
      foreach ( Mobile m in toEat )
      {
       Hits += (m.Hits / 2);
       m.Delete();
      }
     }
    }
 
    public override void OnGotMeleeAttack( Mobile attacker )
    {
     base.OnGotMeleeAttack( attacker );
 
     if ( this.Hits > (this.HitsMax / 4) )
     {
      if ( 0.25 >= Utility.RandomDouble() )
      Spawnavampire( attacker );
     }
     else if ( 0.25 >= Utility.RandomDouble() )
     {
      Eatavampire();
     }
    }
   }
}
 
Lost in space
Banned
Joined
Oct 21, 2003
Messages
814
Best answers
0
You do realize C# isn't a scripting language right?

Also, any code posted onto forums is never clean, due to tab raping. If you need to post code somewhere, http://pastebin.com then just link it.
 
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Nov 6, 2004
Messages
3,055
Best answers
0
Location
Round Rock, TX
Kurt` said:
You do realize C# isn't a scripting language right?
Yeah it is. Anyways, I've found my compiler so it's all good. Thread can be closed.
 
Lost in space
Banned
💻 Oldtimer
Joined
Dec 1, 2002
Messages
2,725
Best answers
0
Ugh, C#, the ugly Microsoft-interbred monstrosity of C++ and .NET...

Anyway, mind telling us what it... is? Some kind of MUD? All I see is a superficial class implementation.

Spunky said:
Yeah it is.
No. It isn't.
A scripting language is parsed by an interpreter, whereas a compiled language is compiled into an exectuable format. You mention yourself that you lost your compiler. I find it hard to believe you actually coded that yourself if you not only didn't know that, but defiantly argue against those who do. -_-
 
New Member
💻 Oldtimer
Joined
May 14, 2003
Messages
1,929
Best answers
0
Spunky said:
Yeah it is. Anyways, I've found my compiler so it's all good. Thread can be closed.
Of course, my dear.
 

Users who are viewing this thread

Top Bottom