Go Back   RunUO - Ultima Online Emulation > RunUO > New Join Forum

New Join Forum So your new to RunUO and looking to work with people that are new, this is the place.

Reply
 
Thread Tools Display Modes
Old 06-10-2005, 06:40 AM   #1 (permalink)
Forum Expert
 
Join Date: Feb 2005
Location: Fife,Scotland
Age: 40
Posts: 258
Default a little help pls

i got this script from the archives, i cant get it to work, i have done everything correctly to no avail, other ppl seem to get it going and others have problems too here is the script

Code:
//
// Story Teller v0.5
// jm (aka x-ray aka ¢¥¤ìŒ›˜) 
// jm99[at]mail333.com
//
using System; 
using System.IO;
using System.Text;
using System.Collections; 
using Server; 
using Server.Items; 
using Server.Misc;
namespace Server.Mobiles
{
 [CorpseName( "story teller corpse" )]
 public class StoryTeller : BaseCreature
 {
  public bool active;
  public static string path = "Data/story.txt";
  private DateTime nextAbilityTime;
  private StreamReader text;
  private string curspeech;
  public override bool InitialInnocent{ get{ return true; } }
  [CommandProperty( AccessLevel.GameMaster )]
  public bool Active
  {
   get
   {
	return active;
   }
   set
   {
	if ( !value )
	{
	 CloseStream();
	}
	active = value;
   }
  }
  [Constructable]
  public StoryTeller() : base( AIType.AI_Mage, FightMode.Agressor, 10, 1, 0.2, 0.4 )
  {
   InitBody();
   InitProps();
   InitOutfit();
   active = true;
  }
  public void InitProps()
  {
   SetHits( 13, 18 );
   SetDamage( 9, 15 );
   SetDamageType( ResistanceType.Physical, 100 );
   SetResistance( ResistanceType.Physical, 80, 90 );
   SetResistance( ResistanceType.Fire, 40, 50 );
   SetResistance( ResistanceType.Cold, 40, 50 );
   SetResistance( ResistanceType.Poison, 40, 50 );
   SetResistance( ResistanceType.Energy, 40, 50 );
   SetSkill( SkillName.EvalInt, 90.1, 100.0 );
   SetSkill( SkillName.Magery, 90.1, 100.0 );
   SetSkill( SkillName.Meditation, 90.1, 100.0 );
   SetSkill( SkillName.MagicResist, 100.5, 150.0 );
   SetSkill( SkillName.Tactics, 10.1, 20.0 );
   SetSkill( SkillName.Wrestling, 10.1, 12.5 );
   Fame = 2000;
   Karma = 2000;
   VirtualArmor = 100;
   Tamable = false;
  }
  public void InitBody()
  {
   SetStr( 80, 100 );
   SetDex( 80, 100 );
   SetInt( 80, 100 );
   Hue = Utility.RandomSkinHue();
   if ( Female = Utility.RandomBool() )
   {
	Body = 401;
	Name = NameList.RandomName( "female" );
   }
   else
   {
	Body = 400;
	Name = NameList.RandomName( "male" );
   }
  }
  public void InitOutfit()
  {
   if ( Female )
	AddItem( new FancyDress() );
   else
	AddItem( new FancyShirt( GetRandomHue() ) );
   int lowHue = GetRandomHue();
   AddItem( new ShortPants( lowHue ) );
   if ( Female )
	AddItem( new ThighBoots( lowHue ) );
   else
	AddItem( new Boots( lowHue ) );
   if ( !Female )
	AddItem( new BodySash( lowHue ) );
   AddItem( new Cloak( GetRandomHue() ) );
   switch ( Utility.Random( 4 ) )
   {
	case 0: AddItem( new ShortHair( Utility.RandomHairHue() ) ); break;
	case 1: AddItem( new TwoPigTails( Utility.RandomHairHue() ) ); break;
	case 2: AddItem( new ReceedingHair( Utility.RandomHairHue() ) ); break;
	case 3: AddItem( new KrisnaHair( Utility.RandomHairHue() ) ); break;
   }
   PackGold( 200, 250 );
  }
  private static int GetRandomHue()
  {
   switch ( Utility.Random( 6 ) )
   {
	default:
	case 0: return 0;
	case 1: return Utility.RandomBlueHue();
	case 2: return Utility.RandomGreenHue();
	case 3: return Utility.RandomRedHue();
	case 4: return Utility.RandomYellowHue();
	case 5: return Utility.RandomNeutralHue();
   }
  }
  public override bool BardImmune{ get{ return true; } }
  public override void GenerateLoot()
  {
   AddLoot( LootPack.LowScrolls );
   AddLoot( LootPack.Gems, 2 );
  }
  public StoryTeller( Serial serial ) : base( serial )
  {
  }
  public void Emote()
  {
   switch(Utility.Random( 85 ))
   {
   case 1:
	PlaySound( Female ? 785 : 1056 );
	Say( "*cough!*" );	 
	break;
   case 2:
	PlaySound( Female ? 818 : 1092 );
	Say( "*sniff*" );
	break;
   default:
	break;
   }
  }
  public void CloseStream()
  {
   if (text != null)
   {
	try { text.Close(); text = null; } catch {};
   }
  }
  public void Talk()
  {
   if (text == null) return;
   try
   {
	curspeech = text.ReadLine();
	if (curspeech == null) throw (new ArgumentNullException());
	Say( curspeech );	 
   }
   catch
   {
	CloseStream();
   }
  }
  public override void OnThink()
  {
   if ( DateTime.Now >= nextAbilityTime && Combatant == null && active == true )
   {
	nextAbilityTime = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 4, 6 ) );
	if (text == null)
	{
	 try 
	 {
	  text = new StreamReader ( path, System.Text.Encoding.Default, false );
	 }
	 catch {}
	}
	Talk();
	
	Emote();
   }
  }
  public override void OnDeath( Container c )
  {
   CloseStream();
   base.OnDeath( c );
  }
  public override void OnDelete()
  {
   CloseStream();
   base.OnDelete();
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.Write( (int) 0 );
   writer.Write( (bool) active );
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadInt();
   active = reader.ReadBool();
  }
 }
}
a text file is placed in data/story teller with what you want guy to say, then edit his props to direct him to text file, then you just [add storyteller, i get the story teller adjust his props etc
and all he says is *cough*

any help appreciated maybe im missing something?
orgis is offline   Reply With Quote
Old 06-10-2005, 07:25 AM   #2 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Don't use this class, the class isn't even complete, there is no code to read the entire file.

There is one line, you cannot read a text file only using StreamReader, you have to loop through the text.

I really hope this isn't a script you found in the submission thread, for somebody to post a script that doesn't even work, is just lame...

Don't use scripts from the Archives, they are not supported, they are in the Archives for a reaason. I hope you understand...
Phantom is offline   Reply With Quote
Old 06-10-2005, 05:40 PM   #3 (permalink)
Forum Expert
 
Join Date: Feb 2005
Location: Fife,Scotland
Age: 40
Posts: 258
Default

Quote:
Originally Posted by Phantom
Don't use this class, the class isn't even complete, there is no code to read the entire file.

There is one line, you cannot read a text file only using StreamReader, you have to loop through the text.

I really hope this isn't a script you found in the submission thread, for somebody to post a script that doesn't even work, is just lame...

Don't use scripts from the Archives, they are not supported, they are in the Archives for a reaason. I hope you understand...
yes i got from archives some ppl seem to have it working ok and others including me cant get it to work, i now know why

thanks for advice and info
orgis is offline   Reply With Quote
Old 06-10-2005, 05:50 PM   #4 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Quote:
Originally Posted by orgis
yes i got from archives some ppl seem to have it working ok and others including me cant get it to work, i now know why

thanks for advice and info
Don't care what other people claim, the script isn't complete, it doesn't and never did work.
Phantom is offline   Reply With Quote
Old 06-10-2005, 06:09 PM   #5 (permalink)
Forum Expert
 
Join Date: Feb 2005
Location: Fife,Scotland
Age: 40
Posts: 258
Default

Quote:
Originally Posted by Phantom
Don't care what other people claim, the script isn't complete, it doesn't and never did work.
i believe you dont worry about that, thanks for support you saved me a lot of trouble, thanks again mate

im looking to create that type of thing so its just forcing me to do it myself which is a good thing, i did start do it my self but some things are still beyond me but im getting there slowly
orgis is offline   Reply With Quote
Old 06-14-2005, 06:44 PM   #6 (permalink)
Master of the Internet
 
Join Date: Aug 2003
Posts: 5,688
Default

Quote:
Originally Posted by orgis
i got this script from the archives, i cant get it to work, i have done everything correctly to no avail, other ppl seem to get it going and others have problems too here is the script

Code:
//
// Story Teller v0.5
// jm (aka x-ray aka ¢¥¤ìŒ›˜) 
// jm99[at]mail333.com
//
using System; 
using System.IO;
using System.Text;
using System.Collections; 
using Server; 
using Server.Items; 
using Server.Misc;
namespace Server.Mobiles
{
 [CorpseName( "story teller corpse" )]
 public class StoryTeller : BaseCreature
 {
  public bool active;
  public static string path = "Data/story.txt";
  private DateTime nextAbilityTime;
  private StreamReader text;
  private string curspeech;
  public override bool InitialInnocent{ get{ return true; } }
  [CommandProperty( AccessLevel.GameMaster )]
  public bool Active
  {
   get
   {
	return active;
   }
   set
   {
	if ( !value )
	{
	 CloseStream();
	}
	active = value;
   }
  }
  [Constructable]
  public StoryTeller() : base( AIType.AI_Mage, FightMode.Agressor, 10, 1, 0.2, 0.4 )
  {
   InitBody();
   InitProps();
   InitOutfit();
   active = true;
  }
  public void InitProps()
  {
   SetHits( 13, 18 );
   SetDamage( 9, 15 );
   SetDamageType( ResistanceType.Physical, 100 );
   SetResistance( ResistanceType.Physical, 80, 90 );
   SetResistance( ResistanceType.Fire, 40, 50 );
   SetResistance( ResistanceType.Cold, 40, 50 );
   SetResistance( ResistanceType.Poison, 40, 50 );
   SetResistance( ResistanceType.Energy, 40, 50 );
   SetSkill( SkillName.EvalInt, 90.1, 100.0 );
   SetSkill( SkillName.Magery, 90.1, 100.0 );
   SetSkill( SkillName.Meditation, 90.1, 100.0 );
   SetSkill( SkillName.MagicResist, 100.5, 150.0 );
   SetSkill( SkillName.Tactics, 10.1, 20.0 );
   SetSkill( SkillName.Wrestling, 10.1, 12.5 );
   Fame = 2000;
   Karma = 2000;
   VirtualArmor = 100;
   Tamable = false;
  }
  public void InitBody()
  {
   SetStr( 80, 100 );
   SetDex( 80, 100 );
   SetInt( 80, 100 );
   Hue = Utility.RandomSkinHue();
   if ( Female = Utility.RandomBool() )
   {
	Body = 401;
	Name = NameList.RandomName( "female" );
   }
   else
   {
	Body = 400;
	Name = NameList.RandomName( "male" );
   }
  }
  public void InitOutfit()
  {
   if ( Female )
	AddItem( new FancyDress() );
   else
	AddItem( new FancyShirt( GetRandomHue() ) );
   int lowHue = GetRandomHue();
   AddItem( new ShortPants( lowHue ) );
   if ( Female )
	AddItem( new ThighBoots( lowHue ) );
   else
	AddItem( new Boots( lowHue ) );
   if ( !Female )
	AddItem( new BodySash( lowHue ) );
   AddItem( new Cloak( GetRandomHue() ) );
   switch ( Utility.Random( 4 ) )
   {
	case 0: AddItem( new ShortHair( Utility.RandomHairHue() ) ); break;
	case 1: AddItem( new TwoPigTails( Utility.RandomHairHue() ) ); break;
	case 2: AddItem( new ReceedingHair( Utility.RandomHairHue() ) ); break;
	case 3: AddItem( new KrisnaHair( Utility.RandomHairHue() ) ); break;
   }
   PackGold( 200, 250 );
  }
  private static int GetRandomHue()
  {
   switch ( Utility.Random( 6 ) )
   {
	default:
	case 0: return 0;
	case 1: return Utility.RandomBlueHue();
	case 2: return Utility.RandomGreenHue();
	case 3: return Utility.RandomRedHue();
	case 4: return Utility.RandomYellowHue();
	case 5: return Utility.RandomNeutralHue();
   }
  }
  public override bool BardImmune{ get{ return true; } }
  public override void GenerateLoot()
  {
   AddLoot( LootPack.LowScrolls );
   AddLoot( LootPack.Gems, 2 );
  }
  public StoryTeller( Serial serial ) : base( serial )
  {
  }
  public void Emote()
  {
   switch(Utility.Random( 85 ))
   {
   case 1:
	PlaySound( Female ? 785 : 1056 );
	Say( "*cough!*" );	 
	break;
   case 2:
	PlaySound( Female ? 818 : 1092 );
	Say( "*sniff*" );
	break;
   default:
	break;
   }
  }
  public void CloseStream()
  {
   if (text != null)
   {
	try { text.Close(); text = null; } catch {};
   }
  }
  public void Talk()
  {
   if (text == null) return;
   try
   {
	curspeech = text.ReadLine();
	if (curspeech == null) throw (new ArgumentNullException());
	Say( curspeech );	 
   }
   catch
   {
	CloseStream();
   }
  }
  public override void OnThink()
  {
   if ( DateTime.Now >= nextAbilityTime && Combatant == null && active == true )
   {
	nextAbilityTime = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 4, 6 ) );
	if (text == null)
	{
	 try 
	 {
	  text = new StreamReader ( path, System.Text.Encoding.Default, false );
	 }
	 catch {}
	}
	Talk();
	
	Emote();
   }
  }
  public override void OnDeath( Container c )
  {
   CloseStream();
   base.OnDeath( c );
  }
  public override void OnDelete()
  {
   CloseStream();
   base.OnDelete();
  }
  public override void Serialize( GenericWriter writer )
  {
   base.Serialize( writer );
   writer.Write( (int) 0 );
   writer.Write( (bool) active );
  }
  public override void Deserialize( GenericReader reader )
  {
   base.Deserialize( reader );
   int version = reader.ReadInt();
   active = reader.ReadBool();
  }
 }
}
a text file is placed in data/story teller with what you want guy to say, then edit his props to direct him to text file, then you just [add storyteller, i get the story teller adjust his props etc
and all he says is *cough*

any help appreciated maybe im missing something?

It will work just fine if you place your text file in the Data folder as "story.txt" as defined here

Code:
public static string path = "Data/story.txt";
__________________
The first line of the first rule in the forum rules and guidelines "Be respectful of others. "

For questions, information, and support for XmlSpawner and its addons, visit the
XmlSpawner Support Forum
ArteGordon is offline   Reply With Quote
Old 06-14-2005, 08:42 PM   #7 (permalink)
Forum Expert
 
Join Date: Feb 2005
Location: Fife,Scotland
Age: 40
Posts: 258
Default

Quote:
Originally Posted by ArteGordon
It will work just fine if you place your text file in the Data folder as "story.txt" as defined here

Code:
public static string path = "Data/story.txt";

i have just noticed that in my first post i posted wrong script, i must of confused them they are the same file name ,sorry

StoryTeller.cs
Code:
//
// Story Teller v0.5
// jm (aka x-ray aka ¢¥¤ìŒ›˜) 
// jm99[at]mail333.com
//
using System; 
using System.IO;
using System.Text;
using System.Collections; 
using Server; 
using Server.Items; 
using Server.Misc;
namespace Server.Mobiles
{
[CorpseName( "story teller corpse" )]
public class StoryTeller : BaseCreature
{
public bool active;
private string path;
[CommandProperty( AccessLevel.GameMaster )]
public string Path
{
get { return path; }
set { path = value; }
}
private DateTime nextAbilityTime;
private StreamReader text;
private string curspeech;
public override bool InitialInnocent{ get{ return true; } }
[CommandProperty( AccessLevel.GameMaster )]
public bool Active
{
get
{
	return active;
}
set
{
	if ( !value )
	{
	 CloseStream();
	}
	active = value;
}
}
[Constructable]
public StoryTeller() : base( AIType.AI_Mage, FightMode.Agressor, 10, 1, 0.2, 0.4 )
{
InitBody();
InitProps();
InitOutfit();
active = true;
}
public void InitProps()
{
SetHits( 13, 18 );
SetDamage( 9, 15 );
SetDamageType( ResistanceType.Physical, 100 );
SetResistance( ResistanceType.Physical, 80, 90 );
SetResistance( ResistanceType.Fire, 40, 50 );
SetResistance( ResistanceType.Cold, 40, 50 );
SetResistance( ResistanceType.Poison, 40, 50 );
SetResistance( ResistanceType.Energy, 40, 50 );
SetSkill( SkillName.EvalInt, 90.1, 100.0 );
SetSkill( SkillName.Magery, 90.1, 100.0 );
SetSkill( SkillName.Meditation, 90.1, 100.0 );
SetSkill( SkillName.MagicResist, 100.5, 150.0 );
SetSkill( SkillName.Tactics, 10.1, 20.0 );
SetSkill( SkillName.Wrestling, 10.1, 12.5 );
Fame = 2000;
Karma = 2000;
VirtualArmor = 100;
Tamable = false;
}
public void InitBody()
{
SetStr( 80, 100 );
SetDex( 80, 100 );
SetInt( 80, 100 );
Hue = Utility.RandomSkinHue();
if ( Female = Utility.RandomBool() )
{
	Body = 401;
	Name = NameList.RandomName( "female" );
}
else
{
	Body = 400;
	Name = NameList.RandomName( "male" );
}
}
public void InitOutfit()
{
if ( Female )
	AddItem( new FancyDress() );
else
	AddItem( new FancyShirt( GetRandomHue() ) );
int lowHue = GetRandomHue();
AddItem( new ShortPants( lowHue ) );
if ( Female )
	AddItem( new ThighBoots( lowHue ) );
else
	AddItem( new Boots( lowHue ) );
if ( !Female )
	AddItem( new BodySash( lowHue ) );
AddItem( new Cloak( GetRandomHue() ) );
switch ( Utility.Random( 4 ) )
{
	case 0: AddItem( new ShortHair( Utility.RandomHairHue() ) ); break;
	case 1: AddItem( new TwoPigTails( Utility.RandomHairHue() ) ); break;
	case 2: AddItem( new ReceedingHair( Utility.RandomHairHue() ) ); break;
	case 3: AddItem( new KrisnaHair( Utility.RandomHairHue() ) ); break;
}
PackGold( 200, 250 );
}
private static int GetRandomHue()
{
switch ( Utility.Random( 6 ) )
{
	default:
	case 0: return 0;
	case 1: return Utility.RandomBlueHue();
	case 2: return Utility.RandomGreenHue();
	case 3: return Utility.RandomRedHue();
	case 4: return Utility.RandomYellowHue();
	case 5: return Utility.RandomNeutralHue();
}
}
public override bool BardImmune{ get{ return true; } }
public override void GenerateLoot()
{
AddLoot( LootPack.LowScrolls );
AddLoot( LootPack.Gems, 2 );
}
public StoryTeller( Serial serial ) : base( serial )
{
}
public void Emote()
{
switch(Utility.Random( 85 ))
{
case 1:
	PlaySound( Female ? 785 : 1056 );
	Say( "*cough!*" );	 
	break;
case 2:
	PlaySound( Female ? 818 : 1092 );
	Say( "*sniff*" );
	break;
default:
	break;
}
}
public void CloseStream()
{
if (text != null)
{
	try { text.Close(); text = null; } catch {};
}
}
public void Talk()
{
if (text == null) return;
try
{
	curspeech = text.ReadLine();
	if (curspeech == null) throw (new ArgumentNullException());
	Say( curspeech );	 
}
catch
{
	CloseStream();
}
}
public override void OnThink()
{
if ( DateTime.Now >= nextAbilityTime && Combatant == null && active == true )
{
	nextAbilityTime = DateTime.Now + TimeSpan.FromSeconds( Utility.RandomMinMax( 4, 6 ) );
	if (text == null)
	{
	 try 
	 {
	 text = new StreamReader ( "Data/StoryTeller/" + path, System.Text.Encoding.Default, false );
	 }
	 catch {}
	}
	Talk();
 
	Emote();
}
}
public override void OnDeath( Container c )
{
CloseStream();
base.OnDeath( c );
}
public override void OnDelete()
{
CloseStream();
base.OnDelete();
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 );
writer.Write( (bool) active );
writer.Write( (string) path );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
active = reader.ReadBool();
path = reader.ReadString();
}
}
}
this is the one i should of posted, sorry

and yes i stil need help on it same question as first post, and can i ask does it really need these two lines surely just the one will do the lines highlighted in red
orgis 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