Quote:
Originally Posted by scottdavey
I'm making it so that CPs are like vps without creating a team, like players get a few cps per mob but I've made it so it adds all the CPs the player has earned up and them gives it to them eventually, but I don't know when to decide when to give them the CPs.
Any ideas would be greatly appreciated as I'm swamped:
Code:
public static void RewardCPSForHunting(Character User, short MobLevel)
{
uint CpsToGive = (uint)MobLevel;
User.PlayerTemporaryCPs += CpsToGive;
if (User.Alive && User.PlayerTemporaryCPs >= User.Level*2)
UpdatePlayerHuntingCPs(User);
}
public static void UpdatePlayerHuntingCPs(Character User)
{
User.CPs += User.PlayerTemporaryCPs;
User.MyClient.SendPacket(General.MyPackets.Vital(User.UID, 30, User.CPs));
User.MyClient.SendPacket(General.MyPackets.SendMsg(User.MyClient.MessageId, "SYSTEM", User.Name, "You got " + User.PlayerTemporaryCPs + " CPs from killing Monsters.", 2005));
User.PlayerTemporaryCPs = 0;
}
(Forget about the MobLevel stuff, I originally did MobLevel + 1.)
Currently I have it at players level times two, but I would rather have it some other way.
|
Few suggestions for you to consider... keep in mind it's just how I'd do it. Lots of others have different opinion on auto cps.
#1: You want to add up cps over time and give to the player eventually? I can think of a few options for that... A: Do it when temp cps reaches a certain amount (say 500... 1000... or whatever) or B: do it after a certain amount of time. Such as every 10 minutes award the player for the mobs they've killed during that time or whatever... Hell do it as a quest... Kill as many mobs as you can in 10 mins to collect cps. Can do it few times a day
#2: You can do CHANCE of getting cps from killing. Personally, my system uses the player level as well as mob level and drop rate to calculate how often the player receives cps from hunting. That way high levels hunting low level mobs will have a drastically lower chance of finding cps than a noob running around killing same mobs (reduces camping/ksing)
#3: You can do random amount of cps from killing... again based on all sorts of variables such as random chance, global drop rate, player level, mob level, mob type, etc
Here's some small pseudo code to give you a start/inspiration... hopefully I'm on the right track of what you wanna do.
On monster death do something like..
if(Calculation.PercentSuccess(GlobalCpDropRate))
{
Client.TemporaryCps += Rand.Next(1, Monster.Info.Level);
if(Client.TemporaryCps >= 1000)
{
AwardCps(Client);
}
}
Then have a function called Award Cps that goes ahead and awards the cps and prints out how much the user has gained (and obviously update db and reset the temp cps)
Or you could do something involving monster and player level... such as
double CpsChance = Monster.Info.Level / Client.Level * GlobalCpRate
if(Calculation.PercentSuccess(CpsChance))
{
award the cps, fixed, random, based on mob level... however you decide to do it.
}
note: Alot of these things like Rand.Next and Calculation.PercentSuccess are based off what CoEmu calls things but I can guarentee you that your source will have something almost IDENTICAL coded.
Actually for reference, random is just something like..
Random Rand = new Random();
You can then call it by doing Rand.Next(min, max) and it will give you an int. You can also do Rand.NextDouble or other types if you wanna use some other type of output.