Hey guys, since I don't waste any time on this I'm sharing a small part of my work.
If you want to use this you must complete the missing things, I also have bootybox, cargobox and CTBbeacon classes but not going to share them.
The luck factor (what you will earn) is predefined on creating or recreation, the amount you will receive is defined on collection, you can make it like first luck factor so that will make the collection faster.
Note that sql parts are outdated and not fit your database.
If you are going to use this, you can throw me some credits at least.
Code:
using System;
using System.Data;
using System.Threading.Tasks;
using Game.Managers;
namespace Game.Collectables
{
class BonusBox : ICollectable
{
private enum Rewards
{
Uridium = 75,
//%25 chance
Ammunition = 20,
// %20
//Energy = 49, todo
//Jackpott = 40,
todo
Credits = 75
//%55
}
public string RemovePacket { get; set; }
public int X { get; set; }
public int Y { get; set; }
public bool Collected { get; set; }
private readonly string _id;
private readonly int _type;
private const string Uri = "uridium";
private const string Cre = "credits";
private const string Gg = "energy";
private const string Jpt = "jackpott";
private const string Ammo = "ammo";
private readonly int[] _boxUri = { 150, 300, 250, 200 };
private readonly int[] _boxCre = { 1000, 2500, 5000, 10000 };
private readonly int[] _boxAmmo = { 25, 50, 100, 10 };
private readonly Random _random;
private readonly Map _currentMap;
private int _luck;
public BonusBox(string id, ushort mapid, int type, Map map)
{
_id = id;
_type = type;
_random = new Random(int.Parse(Program.Random.Next(100) + id + mapid));//omg so pro preventing not to be same Randoms LOL
X = _random.Next(5, 180) * 100;
Y = _random.Next(5, 128) * 100;
_currentMap = map;
_luck = _random.Next(0, 100);
RemovePacket = "0|2|" + _id;
}
private async void Recreate()
{
foreach( var pair in _currentMap.GetUsersByBox(_id))
{
pair.Send("0|2|" + _id);
}
await Task.Delay(500);
_luck = _random.Next(0, 100);
X = _random.Next(5, 180) * 100;
Y = _random.Next(5, 128) * 100;
Collected = false;
}
public void Collect(uint userId)
{
var user = _currentMap.GetUser(userId);
if (!user.BoxesInRange.Contains(_id) || Collected || Distance.Get(X, user.Ship.X, Y, user.Ship.Y) > 200) return;
Collected = true;
if (_luck >= (int) Rewards.Uridium)
{
Update(Uri, userId);
}
//else if (_luck >= (int) Rewards.Ammunition)
//{
// Update(Ammo, userId); // disabled
//}
else if (_luck <= (int) Rewards.Credits)
{
Update(Cre, userId);
}
Recreate();
}
public string CreatePacket()
{
return "0|c|" + _id + "| " + _type + "|" + X + "|" + Y;
}
private void Update(string type, uint userId)
{
var randomyz = _random.Next(0, 4);
var user = _currentMap.GetUser(userId);
switch (type)
{
case Uri:
using (var dbClient = Program.QueryManager.Get())
{
var data = (DataTable)dbClient.query("SELECT uri FROM server_1_players WHERE playerID=" + userId);
if (data.Rows.Count != 1) return;
var uri = Convert.ToInt32(data.Rows[0]["uri"]);
var reward = _boxUri[randomyz];
uri += reward;
dbClient.query("UPDATE server_1_players SET uri = '" + uri + "' WHERE playerID = '" + userId +
"'");
user.Ship.Uri = uri;
user.Send("0|LM|ST|URI|" + reward + "|" + uri);
}
break;
case Cre:
using (var dbClient = Program.QueryManager.Get())
{
var data =
(DataTable)dbClient.query("SELECT credits FROM server_1_players WHERE playerID=" + userId);
if (data.Rows.Count != 1) return;
var cre = Convert.ToInt32(data.Rows[0]["credits"]);
var reward = _boxCre[randomyz];
cre += reward;
dbClient.query("UPDATE server_1_players SET credits = '" + cre + "' WHERE playerID = '" + userId + "'");
user.Ship.Credits = cre;
user.Send("0|LM|ST|CRE|" + reward + "|" + cre);
}
break;
//ammo needs a redo
}
}
public void Dispose()
{
//not need for bonusboxes, they are used again and again
}
}
}
Hey guys, since I don't waste any time on this I'm sharing a small part of my work.
If you want to use this you must complete the missing things, I also have bootybox, cargobox and CTBbeacon classes but not going to share them.
The luck factor (what you will earn) is predefined on creating or recreation, the amount you will receive is defined on collection, you can make it like first luck factor so that will make the collection faster.
Note that sql parts are outdated and not fit your database.
If you are going to use this, you can throw me some credits at least.
Code:
using System;
using System.Data;
using System.Threading.Tasks;
using Game.Managers;
namespace Game.Collectables
{
class BonusBox : ICollectable
{
private enum Rewards
{
Uridium = 75,
//%25 chance
Ammunition = 20,
// %20
//Energy = 49, todo
//Jackpott = 40,
todo
Credits = 75
//%55
}
public string RemovePacket { get; set; }
public int X { get; set; }
public int Y { get; set; }
public bool Collected { get; set; }
private readonly string _id;
private readonly int _type;
private const string Uri = "uridium";
private const string Cre = "credits";
private const string Gg = "energy";
private const string Jpt = "jackpott";
private const string Ammo = "ammo";
private readonly int[] _boxUri = { 150, 300, 250, 200 };
private readonly int[] _boxCre = { 1000, 2500, 5000, 10000 };
private readonly int[] _boxAmmo = { 25, 50, 100, 10 };
private readonly Random _random;
private readonly Map _currentMap;
private int _luck;
public BonusBox(string id, ushort mapid, int type, Map map)
{
_id = id;
_type = type;
_random = new Random(int.Parse(Program.Random.Next(100) + id + mapid));//omg so pro preventing not to be same Randoms LOL
X = _random.Next(5, 180) * 100;
Y = _random.Next(5, 128) * 100;
_currentMap = map;
_luck = _random.Next(0, 93);
RemovePacket = "0|2|" + _id;
}
private async void Recreate()
{
foreach( var pair in _currentMap.GetUsersByBox(_id))
{
pair.Send("0|2|" + _id);
}
await Task.Delay(500);
_luck = _random.Next(0, 93);
X = _random.Next(5, 180) * 100;
Y = _random.Next(5, 128) * 100;
Collected = false;
}
public void Collect(uint userId)
{
var user = _currentMap.GetUser(userId);
if (!user.BoxesInRange.Contains(_id) || Collected || Distance.Get(X, user.Ship.X, Y, user.Ship.Y) > 200) return;
Collected = true;
if (_luck >= (int) Rewards.Uridium)
{
Update(Uri, userId);
}
//else if (_luck >= (int) Rewards.Ammunition)
//{
// Update(Ammo, userId); // disabled
//}
else if (_luck <= (int) Rewards.Credits)
{
Update(Cre, userId);
}
Recreate();
}
public string CreatePacket()
{
return "0|c|" + _id + "| " + _type + "|" + X + "|" + Y;
}
private void Update(string type, uint userId)
{
var randomyz = _random.Next(0, 4);
var user = _currentMap.GetUser(userId);
switch (type)
{
case Uri:
using (var dbClient = Program.QueryManager.Get())
{
var data = (DataTable)dbClient.query("SELECT uri FROM server_1_players WHERE playerID=" + userId);
if (data.Rows.Count != 1) return;
var uri = Convert.ToInt32(data.Rows[0]["uri"]);
var reward = _boxUri[randomyz];
uri += reward;
dbClient.query("UPDATE server_1_players SET uri = '" + uri + "' WHERE playerID = '" + userId +
"'");
user.Ship.Uri = uri;
user.Send("0|LM|ST|URI|" + reward + "|" + uri);
}
break;
case Cre:
using (var dbClient = Program.QueryManager.Get())
{
var data =
(DataTable)dbClient.query("SELECT credits FROM server_1_players WHERE playerID=" + userId);
if (data.Rows.Count != 1) return;
var cre = Convert.ToInt32(data.Rows[0]["credits"]);
var reward = _boxCre[randomyz];
cre += reward;
dbClient.query("UPDATE server_1_players SET credits = '" + cre + "' WHERE playerID = '" + userId + "'");
user.Ship.Credits = cre;
user.Send("0|LM|ST|CRE|" + reward + "|" + cre);
}
break;
//ammo needs a redo
}
}
public void Dispose()
{
//not need for bonusboxes, they are used again and again
}
}
}
This is quite easy to do, however finding the correct packets for it is the hard part.
WTS my runescape with collectables 04/20/2014 - Runescape Trading - 2 Replies 78 att 83 str 75 def 80 ranged 60 prayer 77 magic 66 runecrafting 60 construction 67 dungoneering 82 constition 60 agility 55 herb 58 thieving 65 crafting 83 fletching 60 slayer 63 hunter 1 divination 68 mining 70 smithing 73 fishing 99 cooking 75 firemakeing 92 woodcutting 55 farming 52 summoning rare iteams deathcont t-shirt jester hat tri jester hat woolly hat bobble hat christmas ghost hood top and bottoms squirrel ears reindeer hat grim reaper hood jester scarf tri jester scarf woolly...
[Buying] Buying all RS03 collectables! 01/31/2014 - Runescape Trading - 0 Replies Hello.
Through my years of playing RuneScape I have always collected things, so I thought why not look into buying some from here.
Things I will pay extra for:
Burnt food
Buckets
Pots
Needles