aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot
diff options
context:
space:
mode:
authorSean Dague2009-02-26 21:29:25 +0000
committerSean Dague2009-02-26 21:29:25 +0000
commitc89a4d9eb64fd641516860321d0b15beeba09d9f (patch)
tree66660a06a500025d383188a049afc66af1556e1f /OpenSim/Tools/pCampBot
parent* Update ScenePresenceTests to reflect current REST communication workflow. (diff)
downloadopensim-SC_OLD-c89a4d9eb64fd641516860321d0b15beeba09d9f.zip
opensim-SC_OLD-c89a4d9eb64fd641516860321d0b15beeba09d9f.tar.gz
opensim-SC_OLD-c89a4d9eb64fd641516860321d0b15beeba09d9f.tar.bz2
opensim-SC_OLD-c89a4d9eb64fd641516860321d0b15beeba09d9f.tar.xz
* 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>
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs61
1 files changed, 37 insertions, 24 deletions
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 8e43670..0ded0c0 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -53,7 +53,7 @@ namespace pCampBot
53 53
54 protected Timer m_action; // Action Timer 54 protected Timer m_action; // Action Timer
55 protected List<uint> objectIDs = new List<uint>(); 55 protected List<uint> objectIDs = new List<uint>();
56 56
57 57
58 protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here 58 protected Random somthing = new Random(Environment.TickCount);// We do stuff randomly here
59 59
@@ -77,35 +77,46 @@ namespace pCampBot
77 77
78 void m_action_Elapsed(object sender, ElapsedEventArgs e) 78 void m_action_Elapsed(object sender, ElapsedEventArgs e)
79 { 79 {
80 //client.Throttle.Task = 500000f; 80 while(true)
81 //client.Throttle.Set();
82 int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number,
83 // the greater the bot's chances to walk instead of run.
84 if (walkorrun == 0)
85 {
86 client.Self.Movement.AlwaysRun = true;
87 }
88 else
89 { 81 {
90 client.Self.Movement.AlwaysRun = false; 82 //client.Appearance.ForceRebakeAvatarTextures();
91 } 83 //client.Appearance.SetPreviousAppearance();
92 84
93 // TODO: unused: Vector3 pos = client.Self.SimPosition; 85 int walkorrun = somthing.Next(4); // Randomize between walking and running. The greater this number,
94 Vector3 newpos = new Vector3(somthing.Next(255), somthing.Next(255), somthing.Next(255)); 86 // the greater the bot's chances to walk instead of run.
95 client.Self.Movement.TurnToward(newpos); 87 client.Self.Jump(false);
88 if (walkorrun == 0)
89 {
90 client.Self.Movement.AlwaysRun = true;
91 }
92 else
93 {
94 client.Self.Movement.AlwaysRun = false;
95 }
96 96
97 for (int i = 0; i < 2000; i++) 97 // TODO: unused: Vector3 pos = client.Self.SimPosition;
98 { 98 Vector3 newpos = new Vector3(somthing.Next(255), somthing.Next(255), somthing.Next(255));
99 client.Self.Movement.TurnToward(newpos);
100
101 /*
102 // Why does it need to keep setting it true? Changing to just let it walk =)
103 for (int i = 0; i < 2000; i++)
104 {
105 client.Self.Movement.AtPos = true;
106 Thread.Sleep(somthing.Next(25, 75)); // Makes sure the bots keep walking for this time.
107 }
108 */
99 client.Self.Movement.AtPos = true; 109 client.Self.Movement.AtPos = true;
100 Thread.Sleep(somthing.Next(25, 75)); // Makes sure the bots keep walking for this time. 110 Thread.Sleep(somthing.Next(3000,13000));
101 } 111 client.Self.Movement.AtPos = false;
102 client.Self.Jump(true); 112 client.Self.Jump(true);
103 113
104 string randomf = talkarray[somthing.Next(talkarray.Length)]; 114 string randomf = talkarray[somthing.Next(talkarray.Length)];
105 if (talkarray.Length > 1 && randomf.Length > 1) 115 if (talkarray.Length > 1 && randomf.Length > 1)
106 client.Self.Chat(randomf, 0, ChatType.Normal); 116 client.Self.Chat(randomf, 0, ChatType.Normal);
107 117
108 //Thread.Sleep(somthing.Next(1, 10)); // Apparently its better without it right now. 118 Thread.Sleep(somthing.Next(1000, 10000));
119 }
109 } 120 }
110 121
111 /// <summary> 122 /// <summary>
@@ -157,6 +168,8 @@ namespace pCampBot
157 if (OnConnected != null) 168 if (OnConnected != null)
158 { 169 {
159 m_action = new Timer(somthing.Next(1000, 10000)); 170 m_action = new Timer(somthing.Next(1000, 10000));
171 m_action.Enabled = true;
172 m_action.AutoReset = false;
160 m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed); 173 m_action.Elapsed += new ElapsedEventHandler(m_action_Elapsed);
161 m_action.Start(); 174 m_action.Start();
162 OnConnected(this, EventType.CONNECTED); 175 OnConnected(this, EventType.CONNECTED);