|
You last visited: Today at 19:10
Advertisement
[Request] Auto Cps for World Conquer V2
Discussion on [Request] Auto Cps for World Conquer V2 within the CO2 Private Server forum part of the Conquer Online 2 category.
03/01/2023, 19:00
|
#1
|
elite*gold: 0
Join Date: May 2005
Posts: 89
Received Thanks: 2
|
[Request] Auto Cps for World Conquer V2
Greetings. I've been trying to setup a CO server and implement some ideas, but I'm a newbie to programming. At least I've managed to make it work 
Looking for help of a kind soul to teach me how to add auto cps on this source, based on monster level, like pheasants gives 1 cp and so on.
I'm willing to learn, and I've tried searching for threads/posts with this subject but none came up.
Thanks in advance.
|
|
|
03/01/2023, 20:59
|
#2
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
|
Don't you have a release on adding CPs to another source? Or was that not your work?
|
|
|
03/01/2023, 22:46
|
#3
|
elite*gold: 0
Join Date: May 2005
Posts: 89
Received Thanks: 2
|
Quote:
Originally Posted by Spirited
Don't you have a release on adding CPs to another source? Or was that not your work?
|
Honestly I don't remember, it's been a few years since I got involved with sources.
But if posted something about, it wasn't my work and I apologize if I didn't gave the credit for who did.
Edit: BTW, thanks for reminding me of this. I've dropped Albetros source years ago, and at that time, Pro4Never helped me on that code.
I'm trying again on another source.
|
|
|
03/01/2023, 23:46
|
#4
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
|
Quote:
Originally Posted by AngelusInkubus
Honestly I don't remember, it's been a few years since I got involved with sources.
But if posted something about, it wasn't my work and I apologize if I didn't gave the credit for who did.
Edit: BTW, thanks for reminding me of this. I've dropped Albetros source years ago, and at that time, Pro4Never helped me on that code.
I'm trying again on another source.
|
Ah, okay. Well, you could do something similar. There's gotta be a looting table in World Conquer v2 as well. You could add support for dropping CPs in that system.
|
|
|
03/01/2023, 23:59
|
#5
|
elite*gold: 0
Join Date: May 2005
Posts: 89
Received Thanks: 2
|
Quote:
Originally Posted by Spirited
Ah, okay. Well, you could do something similar. There's gotta be a looting table in World Conquer v2 as well. You could add support for dropping CPs in that system.
|
I'm trying to automatically send it to the owner/killer inventory instead of dropping cp items, like that code for Albetros.
I've tried this:
Quote:
#region CP Award
public Character(MsgUserInfo pMsg, DbUser dbUser, Client pClient)
public uint Emoney;
{
Emoney = m_dbUser.Emoney;
get { return m_dbUser.Emoney; }
set
{
m_dbUser.Emoney = m_dbMonster.Level;
UpdateClient(ClientUpdateType.CONQUER_POINTS, value);
Save();
}
}
#endregion
|
But hadn't succeeded. Albetros was simpler I guess...
Any ideas?
|
|
|
03/04/2023, 17:48
|
#6
|
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
|
Quote:
Originally Posted by AngelusInkubus
I'm trying to automatically send it to the owner/killer inventory instead of dropping cp items, like that code for Albetros.
I've tried this:
But hadn't succeeded. Albetros was simpler I guess...
Any ideas?
|
Dude, you can do this just by checking if the attacker is a Character on BeKill method of Monster
Code:
public void BeKill(IRole pRole)
{
// todo pet handle
if (m_tDisappear.IsActive()) return;
try
{
DetachAllStatus(this);
AttachStatus(this, FlagInt.DEAD, 0, 20, 0, 0);
AttachStatus(this, FlagInt.GHOST, 0, 20, 0, 0);
AttachStatus(this, FlagInt.FADE, 0, 20, 0, 0);
uint dieType = pRole is Character ? ((pRole as Character).KoCount * 65541) : 1;
var msg = new MsgInteract
{
Action = InteractionType.ACT_ITR_KILL,
EntityIdentity = pRole != null ? pRole.Identity : 0,
TargetIdentity = Identity,
CellX = MapX,
CellY = MapY,
MagicType = 0,
MagicLevel = 0,
Data = dieType
};
Map.SendToRange(msg, MapX, MapY);
}
catch (Exception e)
{
ServerKernel.Log.SaveLog(e.ToString());
}
m_tDisappear.Startup(5);
Character pActionUser = null;
if (pRole != null && pRole is Character)
pActionUser = pRole as Character;
Life = 0;
uint idMapItemOwner = 0;
if (pActionUser != null)
{
idMapItemOwner = pActionUser.Identity;
if (pActionUser.BattleSystem.IsActived())
pActionUser.BattleSystem.ResetBattle();
}
// do action
if (IsDieAction())
GameAction.ProcessAction(m_dbMonster.Action, pActionUser, this, null, null);
if (m_pDrop != null)
{
for (int i = 0; i < m_pDrop.DropNum; i++)
{
bool bExe = false;
foreach (var dropRule in m_pDrop.Actions.OrderBy(x => x.Value))
{
if (Calculations.ChanceCalc(dropRule.Value/100f))
{
GameAction.ProcessAction(dropRule.Key, pActionUser, this, null, null);
bExe = true;
break;
}
}
if (!bExe && m_pDrop.DefaultAction > 0)
GameAction.ProcessAction(m_pDrop.DefaultAction, pActionUser, this, null, null);
}
}
if (IsGuard())
return;
int nChanceAdjust = 30;
if (pActionUser != null && GetNameType(pRole.Level, Level) == BattleSystem.NAME_GREEN)
nChanceAdjust = 10;
if (Calculations.ChanceCalc(nChanceAdjust))
{
int dwMoneyMin = (int)(m_dbMonster.DropMoney * 0.85f);
int dwMoneyMax = (int)(m_dbMonster.DropMoney * 1.15f);
uint dwMoney = (uint)(dwMoneyMin + Calculations.Random.Next(dwMoneyMax - dwMoneyMin) + 1);
int nHeapNum = 1 + Calculations.Random.Next(3);
uint dwMoneyAve = (uint)(dwMoney / nHeapNum);
for (int i = 0; i < nHeapNum; i++)
{
uint dwMoneyTmp = (uint)Calculations.MulDiv((int)dwMoneyAve, 90 + Calculations.Random.Next(21), 100);
if (pActionUser != null)
{
switch (pActionUser.Owner.VipLevel)
{
case 1: dwMoneyTmp = (uint)(dwMoneyTmp * .7f); break;
case 2: dwMoneyTmp = (uint)(dwMoneyTmp * 1.0f); break;
case 3: dwMoneyTmp = (uint)(dwMoneyTmp * 1.25f); break;
case 4: dwMoneyTmp = (uint)(dwMoneyTmp * 1.5f); break;
case 5: dwMoneyTmp = (uint)(dwMoneyTmp * 1.75f); break;
case 6: dwMoneyTmp = (uint)(dwMoneyTmp * 2.25f); break;
}
}
if (pActionUser != null)// && pActionUser.Owner.VipLevel >= 3)
pActionUser.AwardMoney(dwMoneyTmp);
//else
// DropMoney(dwMoneyTmp, idMapItemOwner);
}
}
int nDropNum = 0;
int nAtkLev = Level;
if (pRole != null)
nAtkLev = pRole.Level;
int nRate = Calculations.Random.Next(1000);
float dropRate = .75f;
if (Calculations.ChanceCalc(dropRate))
{
DropItem(SpecialItem.TYPE_DRAGONBALL, idMapItemOwner, 0, 0, 0, 0);
if (pRole != null && pRole.IsPlayer())
(pRole as Character).Send(string.Format(ServerString.DRAGON_BALL_DROP, pRole.Name));
}
if (Calculations.ChanceCalc(.3f) && pRole.IsPlayer())
{
(pRole as Character).AwardBoundEmoney(10);
}
if (pRole is Character && Calculations.ChanceCalc(dropRate))
{
Character pUser = pRole as Character;
int nAmount = 215;
int nBonus = 0;
string szMsg = "You found {0} CPs while looting.";
if (pUser.Owner.VipLevel > 0)
{
switch (pUser.Owner.VipLevel)
{
case 1:
nBonus = 15;
break;
case 2:
nBonus = 30;
break;
case 3:
nBonus = 45;
break;
case 4:
nBonus = 90;
break;
case 5:
nBonus = 135;
break;
case 6:
nBonus = 180;
break;
}
szMsg = "You received {0} CPs while looting plus {1} CPs for being Vip level {2}.";
pUser.Send(string.Format(szMsg, nAmount, nBonus, pUser.Owner.VipLevel));
}
else
{
pUser.Send(string.Format(szMsg, nAmount));
}
pUser.AwardEmoney(nAmount + nBonus);
}
if (Calculations.ChanceCalc(0.005f)) // Fire of hell
DropItem(1060101, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(0.005f)) // BombScroll
DropItem(1060100, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(0.8f))
DropItem(SpecialItem.TYPE_METEOR, idMapItemOwner, 0, 0, 0, 0); // meteor
if (Calculations.ChanceCalc(.1f)) // DiligenceBook
DropItem(723340, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(.05f)) // EnduranceBook
DropItem(723341, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(.003f)) // Oblivion Dew
DropItem(711083, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(.03f)) // DragonPill
DropItem(720598, idMapItemOwner, 0, 0, 0, 0);
if (!IsPkKiller() && !IsGuard() && !IsEvilKiller() && !IsDynaMonster() && !IsDynaNpc())
{
if (Calculations.ChanceCalc(.1f))
{
uint dGem = m_pNormalGem[ThreadSafeRandom.RandGet(m_pNormalGem.Length) % m_pNormalGem.Length];
DropItem(dGem, idMapItemOwner, 0, 0, 0, 0); // normal gems
}
}
if ((m_dbMonster.Id == 15 || m_dbMonster.Id == 74) && Calculations.ChanceCalc(2f))
{
DropItem(1080001, idMapItemOwner, 0, 0, 0, 0); // emerald
}
int nChance = BattleSystem.AdjustDrop(200, nAtkLev, Level);
if (nRate < Math.Min(1000, nChance))
{
nDropNum = 1 + Calculations.Random.Next(1, 3); // drop 10-16 items
}
else
{
nChance += BattleSystem.AdjustDrop(1000, nAtkLev, Level);
if (nRate < Math.Min(1000, nChance))
nDropNum = 1; // drop 1 item
}
for (int i = 0; i < nDropNum; i++)
{
uint idItemtype = GetDropItem();
DbItemtype itemtype;
if (!ServerKernel.Itemtype.TryGetValue(idItemtype, out itemtype))
continue;
byte nDmg = 0;
byte nPlus = 0;
if (Calculations.ChanceCalc(.5f))
{
// bless
nDmg = (byte)(Calculations.ChanceCalc(10) ? 5 : 3);
}
if (Calculations.ChanceCalc(.3f))
{
// plus
nPlus = 1;
}
if (!DropItem(itemtype, idMapItemOwner, nPlus, nDmg, 0, (short)Calculations.Random.Next(-200, 300)))
break;
}
}
I just downloaded the code from the topic and it already have the CPs drop implemented
|
|
|
03/05/2023, 02:12
|
#7
|
elite*gold: 0
Join Date: May 2005
Posts: 89
Received Thanks: 2
|
Quote:
Originally Posted by pintinho12
Dude, you can do this just by checking if the attacker is a Character on BeKill method of Monster
Code:
public void BeKill(IRole pRole)
{
// todo pet handle
if (m_tDisappear.IsActive()) return;
try
{
DetachAllStatus(this);
AttachStatus(this, FlagInt.DEAD, 0, 20, 0, 0);
AttachStatus(this, FlagInt.GHOST, 0, 20, 0, 0);
AttachStatus(this, FlagInt.FADE, 0, 20, 0, 0);
uint dieType = pRole is Character ? ((pRole as Character).KoCount * 65541) : 1;
var msg = new MsgInteract
{
Action = InteractionType.ACT_ITR_KILL,
EntityIdentity = pRole != null ? pRole.Identity : 0,
TargetIdentity = Identity,
CellX = MapX,
CellY = MapY,
MagicType = 0,
MagicLevel = 0,
Data = dieType
};
Map.SendToRange(msg, MapX, MapY);
}
catch (Exception e)
{
ServerKernel.Log.SaveLog(e.ToString());
}
m_tDisappear.Startup(5);
Character pActionUser = null;
if (pRole != null && pRole is Character)
pActionUser = pRole as Character;
Life = 0;
uint idMapItemOwner = 0;
if (pActionUser != null)
{
idMapItemOwner = pActionUser.Identity;
if (pActionUser.BattleSystem.IsActived())
pActionUser.BattleSystem.ResetBattle();
}
// do action
if (IsDieAction())
GameAction.ProcessAction(m_dbMonster.Action, pActionUser, this, null, null);
if (m_pDrop != null)
{
for (int i = 0; i < m_pDrop.DropNum; i++)
{
bool bExe = false;
foreach (var dropRule in m_pDrop.Actions.OrderBy(x => x.Value))
{
if (Calculations.ChanceCalc(dropRule.Value/100f))
{
GameAction.ProcessAction(dropRule.Key, pActionUser, this, null, null);
bExe = true;
break;
}
}
if (!bExe && m_pDrop.DefaultAction > 0)
GameAction.ProcessAction(m_pDrop.DefaultAction, pActionUser, this, null, null);
}
}
if (IsGuard())
return;
int nChanceAdjust = 30;
if (pActionUser != null && GetNameType(pRole.Level, Level) == BattleSystem.NAME_GREEN)
nChanceAdjust = 10;
if (Calculations.ChanceCalc(nChanceAdjust))
{
int dwMoneyMin = (int)(m_dbMonster.DropMoney * 0.85f);
int dwMoneyMax = (int)(m_dbMonster.DropMoney * 1.15f);
uint dwMoney = (uint)(dwMoneyMin + Calculations.Random.Next(dwMoneyMax - dwMoneyMin) + 1);
int nHeapNum = 1 + Calculations.Random.Next(3);
uint dwMoneyAve = (uint)(dwMoney / nHeapNum);
for (int i = 0; i < nHeapNum; i++)
{
uint dwMoneyTmp = (uint)Calculations.MulDiv((int)dwMoneyAve, 90 + Calculations.Random.Next(21), 100);
if (pActionUser != null)
{
switch (pActionUser.Owner.VipLevel)
{
case 1: dwMoneyTmp = (uint)(dwMoneyTmp * .7f); break;
case 2: dwMoneyTmp = (uint)(dwMoneyTmp * 1.0f); break;
case 3: dwMoneyTmp = (uint)(dwMoneyTmp * 1.25f); break;
case 4: dwMoneyTmp = (uint)(dwMoneyTmp * 1.5f); break;
case 5: dwMoneyTmp = (uint)(dwMoneyTmp * 1.75f); break;
case 6: dwMoneyTmp = (uint)(dwMoneyTmp * 2.25f); break;
}
}
if (pActionUser != null)// && pActionUser.Owner.VipLevel >= 3)
pActionUser.AwardMoney(dwMoneyTmp);
//else
// DropMoney(dwMoneyTmp, idMapItemOwner);
}
}
int nDropNum = 0;
int nAtkLev = Level;
if (pRole != null)
nAtkLev = pRole.Level;
int nRate = Calculations.Random.Next(1000);
float dropRate = .75f;
if (Calculations.ChanceCalc(dropRate))
{
DropItem(SpecialItem.TYPE_DRAGONBALL, idMapItemOwner, 0, 0, 0, 0);
if (pRole != null && pRole.IsPlayer())
(pRole as Character).Send(string.Format(ServerString.DRAGON_BALL_DROP, pRole.Name));
}
if (Calculations.ChanceCalc(.3f) && pRole.IsPlayer())
{
(pRole as Character).AwardBoundEmoney(10);
}
if (pRole is Character && Calculations.ChanceCalc(dropRate))
{
Character pUser = pRole as Character;
int nAmount = 215;
int nBonus = 0;
string szMsg = "You found {0} CPs while looting.";
if (pUser.Owner.VipLevel > 0)
{
switch (pUser.Owner.VipLevel)
{
case 1:
nBonus = 15;
break;
case 2:
nBonus = 30;
break;
case 3:
nBonus = 45;
break;
case 4:
nBonus = 90;
break;
case 5:
nBonus = 135;
break;
case 6:
nBonus = 180;
break;
}
szMsg = "You received {0} CPs while looting plus {1} CPs for being Vip level {2}.";
pUser.Send(string.Format(szMsg, nAmount, nBonus, pUser.Owner.VipLevel));
}
else
{
pUser.Send(string.Format(szMsg, nAmount));
}
pUser.AwardEmoney(nAmount + nBonus);
}
if (Calculations.ChanceCalc(0.005f)) // Fire of hell
DropItem(1060101, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(0.005f)) // BombScroll
DropItem(1060100, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(0.8f))
DropItem(SpecialItem.TYPE_METEOR, idMapItemOwner, 0, 0, 0, 0); // meteor
if (Calculations.ChanceCalc(.1f)) // DiligenceBook
DropItem(723340, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(.05f)) // EnduranceBook
DropItem(723341, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(.003f)) // Oblivion Dew
DropItem(711083, idMapItemOwner, 0, 0, 0, 0);
if (Calculations.ChanceCalc(.03f)) // DragonPill
DropItem(720598, idMapItemOwner, 0, 0, 0, 0);
if (!IsPkKiller() && !IsGuard() && !IsEvilKiller() && !IsDynaMonster() && !IsDynaNpc())
{
if (Calculations.ChanceCalc(.1f))
{
uint dGem = m_pNormalGem[ThreadSafeRandom.RandGet(m_pNormalGem.Length) % m_pNormalGem.Length];
DropItem(dGem, idMapItemOwner, 0, 0, 0, 0); // normal gems
}
}
if ((m_dbMonster.Id == 15 || m_dbMonster.Id == 74) && Calculations.ChanceCalc(2f))
{
DropItem(1080001, idMapItemOwner, 0, 0, 0, 0); // emerald
}
int nChance = BattleSystem.AdjustDrop(200, nAtkLev, Level);
if (nRate < Math.Min(1000, nChance))
{
nDropNum = 1 + Calculations.Random.Next(1, 3); // drop 10-16 items
}
else
{
nChance += BattleSystem.AdjustDrop(1000, nAtkLev, Level);
if (nRate < Math.Min(1000, nChance))
nDropNum = 1; // drop 1 item
}
for (int i = 0; i < nDropNum; i++)
{
uint idItemtype = GetDropItem();
DbItemtype itemtype;
if (!ServerKernel.Itemtype.TryGetValue(idItemtype, out itemtype))
continue;
byte nDmg = 0;
byte nPlus = 0;
if (Calculations.ChanceCalc(.5f))
{
// bless
nDmg = (byte)(Calculations.ChanceCalc(10) ? 5 : 3);
}
if (Calculations.ChanceCalc(.3f))
{
// plus
nPlus = 1;
}
if (!DropItem(itemtype, idMapItemOwner, nPlus, nDmg, 0, (short)Calculations.Random.Next(-200, 300)))
break;
}
}
I just downloaded the code from the topic and it already have the CPs drop implemented
|
If i'm not mistaken, these cps given to character are based on vip level and has a drop chance while farming.
I was trying to implement for each kill, based on monster level, while vip level would give a bonus like it's already doing.
With this code you already gave me an answer to another question, 'bout drop chances, which I'd like to change a little bit. Thanks!
|
|
|
03/06/2023, 13:32
|
#8
|
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
|
Quote:
Originally Posted by AngelusInkubus
If i'm not mistaken, these cps given to character are based on vip level and has a drop chance while farming.
I was trying to implement for each kill, based on monster level, while vip level would give a bonus like it's already doing.
With this code you already gave me an answer to another question, 'bout drop chances, which I'd like to change a little bit. Thanks!
|
With that code you can already do what you need ^^, just change it to your desire
|
|
|
03/09/2023, 14:31
|
#9
|
dotCom
elite*gold: 9842
Join Date: Mar 2009
Posts: 16,846
Received Thanks: 4,675
|
CO2 Programming -> CO2 Private Server
#moved
|
|
|
03/10/2023, 03:01
|
#10
|
elite*gold: 0
Join Date: May 2005
Posts: 89
Received Thanks: 2
|
Thanks pintinho12 for the tips about the source,and the source itself (gr8 job), already managed to change what I've wanted. Btw, you're brazilian too, right?
Also, thanks to Devsome for moving the topic to the right section. =D
|
|
|
All times are GMT +1. The time now is 19:10.
|
|