* This patch reduces the excessive number of threads opened by the Timer event. Also simplifies the walking around method.
From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>GenericGridServerConcept
parent
57ab79e331
commit
c89a4d9eb6
|
@ -77,10 +77,14 @@ namespace pCampBot
|
|||
|
||||
void m_action_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
//client.Throttle.Task = 500000f;
|
||||
//client.Throttle.Set();
|
||||
while(true)
|
||||
{
|
||||
//client.Appearance.ForceRebakeAvatarTextures();
|
||||
//client.Appearance.SetPreviousAppearance();
|
||||
|
||||
int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number,
|
||||
// the greater the bot's chances to walk instead of run.
|
||||
client.Self.Jump(false);
|
||||
if (walkorrun == 0)
|
||||
{
|
||||
client.Self.Movement.AlwaysRun = true;
|
||||
|
@ -94,18 +98,25 @@ namespace pCampBot
|
|||
Vector3 newpos = new Vector3(somthing.Next(255), somthing.Next(255), somthing.Next(255));
|
||||
client.Self.Movement.TurnToward(newpos);
|
||||
|
||||
/*
|
||||
// Why does it need to keep setting it true? Changing to just let it walk =)
|
||||
for (int i = 0; i < 2000; i++)
|
||||
{
|
||||
client.Self.Movement.AtPos = true;
|
||||
Thread.Sleep(somthing.Next(25, 75)); // Makes sure the bots keep walking for this time.
|
||||
}
|
||||
*/
|
||||
client.Self.Movement.AtPos = true;
|
||||
Thread.Sleep(somthing.Next(3000,13000));
|
||||
client.Self.Movement.AtPos = false;
|
||||
client.Self.Jump(true);
|
||||
|
||||
string randomf = talkarray[somthing.Next(talkarray.Length)];
|
||||
if (talkarray.Length > 1 && randomf.Length > 1)
|
||||
client.Self.Chat(randomf, 0, ChatType.Normal);
|
||||
|
||||
//Thread.Sleep(somthing.Next(1, 10)); // Apparently its better without it right now.
|
||||
Thread.Sleep(somthing.Next(1000, 10000));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -157,6 +168,8 @@ namespace pCampBot
|
|||
if (OnConnected != null)
|
||||
{
|
||||
m_action = new Timer(somthing.Next(1000, 10000));
|
||||
m_action.Enabled = true;
|
||||
m_action.AutoReset = false;
|
||||
m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed);
|
||||
m_action.Start();
|
||||
OnConnected(this, EventType.CONNECTED);
|
||||
|
|
Loading…
Reference in New Issue