Pserver arena
I made this little arena system, atm only supports 1 player at a time, might add that feature later on.
Commands are /arena join and then /arena start
Arena contains 20 rounds, each round theres 1 monster ++, starting at 4, winner of the arena gets 2000 fame


How-to
Go to wServer -> realm -> entities -> player - > Player.Chat.cs and add this command
Also add this at top of the File
Then create a new class at your wServer called BattleArena.cs and add this
To edit the monsters that appear on each round just edit this part of the BattleArena.cs
case number: means the round number and name means the monster name.
To edit the total rounds just edit
where the number = the max rounds
To edit the fame earned just edit
Where 2000 is the fame earned
Important
Current map used is beachzone if you want to change it you will need to edit a few things ( use a map with no monsters on it !!! )
Where it says ( on BattleArena.cs )
Change GameId = World.YOURMAP,
Where it says ( on Player.Chat.cs )
Change -13 for the id of the world you want.
And thats it, if Im missing something just say ( was a long thread ).
Commands are /arena join and then /arena start
Arena contains 20 rounds, each round theres 1 monster ++, starting at 4, winner of the arena gets 2000 fame


How-to
Go to wServer -> realm -> entities -> player - > Player.Chat.cs and add this command
Code:
else if (cmd.Equals("arena", StringComparison.OrdinalIgnoreCase))
{
if (args[0] == "join")
{
var check = BattleArena.CheckArena();
if (!check)
{
psr.SendPacket(new NotificationPacket()
{
ObjectId = Id,
Color = new ARGB(0xFF00FF00),
Text = "Arena alredy in use!"
});
}
else
{
BattleArena.Init(psr, Id);
}
}
else if (args[0] == "start")
{
World world = RealmManager.GetWorld(Owner.Id);
if (world.Id == -13)
{
var start = BattleArena.ArenaUpdate(psr, Id, X, Y, Owner);
if (!start)
{
psr.SendPacket(new NotificationPacket()
{
ObjectId = Id,
Color = new ARGB(0xFF00FF00),
Text = "Arena alredy started!"
});
}
else
{
psr.SendPacket(new NotificationPacket()
{
ObjectId = Id,
Color = new ARGB(0xFF00FF00),
Text = "Starting arena, good luck!"
});
new Thread(BattleArena.ArenaGame).Start();
}
}
else
{
psr.SendPacket(new NotificationPacket()
{
ObjectId = Id,
Color = new ARGB(0xFF00FF00),
Text = "You should first /arena join"
});
}
}
}
Code:
using System.Threading;
Code:
using System.Text;
using wServer.svrPackets;
using wServer.realm;
using System.Threading;
using db;
namespace wServer
{
class BattleArena
{
public static bool on;
public static bool start;
public static ClientProcessor psr;
public static int Id;
public static int count = 0;
public static int monsters = 2;
public static float X;
public static float Y;
public static World Owner;
public static bool running;
public static string name;
public static void Init(ClientProcessor newPsr, int newId)
{
on = true;
Id = newId;
psr = newPsr;
running = true;
foreach (var e in RealmManager.Clients.Values.ToArray())
{
e.SendPacket(new TextPacket()
{
BubbleTime = 0,
Stars = -1,
Name = "@Arena",
Text = "Player : " + psr.Account.Name + " entered the arena!"
});
}
psr.Reconnect(new ReconnectPacket()
{
Host = "",
Port = 2050,
GameId = World.BEACHZONE_ID,
Name = "Arena",
Key = Empty<byte>.Array,
});
psr.SendPacket(new TextPacket()
{
BubbleTime = 0,
Stars = -1,
Name = "@Arena",
Text = "You entered the arena"
});
}
public static bool ArenaUpdate(ClientProcessor newPsr, int newId, float newX, float newY, World newOwner)
{
if (start)
{
return false;
}
else
{
X = newX;
Y = newY;
Owner = newOwner;
psr = newPsr;
Id = newId;
start = true;
return true;
}
}
public static bool CheckArena()
{
if (on)
{
return false;
}
else
{
on = true;
return true;
}
}
public static void ArenaGame()
{
while (running)
{
if (Owner.Enemies.Count == 0)
{
if (count == 20)
{
foreach (var i in RealmManager.Clients.Values.ToArray())
{
i.SendPacket(new TextPacket()
{
Name = "@Arena",
Stars = -1,
BubbleTime = 0,
Recipient = "",
Text = "Player : " + psr.Account.Name + " won the arena! 2000 fame earned",
CleanText = "Player : " + psr.Account.Name + " won the arena! 2000 fame earned"
});
}
using (var dbx = new Database())
{
dbx.UpdateFame(psr.Account, 2000);
}
running = false;
}
count = count + 1;
monsters = monsters + 1;
psr.SendPacket(new NotificationPacket()
{
ObjectId = Id,
Color = new ARGB(0xFF00FF00),
Text = "Starting round : " + count
});
switch (count)
{
case 1:
name = "Tawny Warg";
break;
case 2:
name = "Demon Warg";
break;
case 3:
name = "Orc Mage";
break;
case 4:
name = "Orc Warrior";
break;
case 5:
name = "Orc King";
break;
default:
name = "Sheep";
break;
}
short objType;
if (!XmlDatas.IdToType.TryGetValue(name, out objType) || !XmlDatas.ObjectDescs.ContainsKey(objType))
{
psr.SendPacket(new TextPacket()
{
BubbleTime = 0,
Stars = -1,
Name = "",
Text = "Unknown entity!"
});
}
else
{
for (int i = 0; i <= monsters; i++)
{
var entity = Entity.Resolve(objType);
entity.Move(X, Y);
Owner.EnterWorld(entity);
}
}
}
if (Owner.Players.Count == 0)
{
foreach (var i in RealmManager.Clients.Values.ToArray())
{
i.SendPacket(new TextPacket()
{
Name = "@Arena",
Stars = -1,
BubbleTime = 0,
Recipient = "",
Text = "Player : " + psr.Account.Name + " failed at the arena!",
CleanText = "Player : " + psr.Account.Name + " failed at the arena!"
});
}
running = false;
}
Thread.Sleep(4000);
}
foreach (var i in Owner.Enemies)
{
Owner.LeaveWorld(i.Value);
}
on = false;
start = false;
count = 0;
monsters = 4;
psr.Reconnect(new ReconnectPacket()
{
Host = "",
Port = 2050,
GameId = World.NEXUS_ID,
Name = "Nexus",
Key = Empty<byte>.Array,
});
}
}
}
case number: means the round number and name means the monster name.
Code:
switch (count)
{
case 1:
name = "Tawny Warg";
break;
case 2:
name = "Demon Warg";
break;
case 3:
name = "Orc Mage";
break;
case 4:
name = "Orc Warrior";
break;
case 5:
name = "Orc King";
break;
default:
name = "Sheep";
break;
}
where the number = the max rounds
Code:
if (count == 20)
Where 2000 is the fame earned
Code:
dbx.UpdateFame(psr.Account, 2000);
Current map used is beachzone if you want to change it you will need to edit a few things ( use a map with no monsters on it !!! )
Where it says ( on BattleArena.cs )
Code:
psr.Reconnect(new ReconnectPacket()
{
Host = "",
Port = 2050,
GameId = World.BEACHZONE_ID,
Name = "Arena",
Key = Empty<byte>.Array,
});
Where it says ( on Player.Chat.cs )
Code:
if (world.Id == -13)
And thats it, if Im missing something just say ( was a long thread ).




