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;
}
}