吾爱尚玩资源基地
标题:
魔兽变态sf中的PVP从玩家身上掉落的代码
[打印本页]
作者:
admin
时间:
2016-4-18 22:49
标题:
魔兽变态sf中的PVP从玩家身上掉落的代码
玩家PVP随机从包里面掉落某个物品给胜利者(自己先设置conf)貌似是M端的代码?不记得了
if (sWorld.getPvpLoot(PLAYER_LOOT_ENABLE)) {
if (looterPlr->getLevel() - getLevel() < sWorld.getPvpLoot(PLAYER_LOOT_LEVEL_DIFF))
{
uint32 gold = (uint32)( urand(50, 150) * 0.016f * pow( ((float)bones->loot.gold)/5.76f, 2.5f) * sWorld.getRate(RATE_DROP_MONEY) * sWorld.getPvpLoot(PLAYER_LOOT_MONEY) );
if (GetMoney() >= gold)
{
SetMoney(GetMoney()-gold);
bones->loot.gold = gold;
ChatHandler(this).PSendSysMessage( LANG_PVP_LOSS_MONEY_MESSAGE, UTF8Cn::GetNameLink(looterPlr->GetName()).c_str(), gold/10000 );
ChatHandler(looterPlr).PSendSysMessage( LANG_PVP_WIN_MONEY_MESSAGE, UTF8Cn::GetNameLink(this->GetName()).c_str(), gold/10000 );
}
else
bones->loot.gold = 0;
if ( sWorld.getPvpLoot(PLAYER_LOOT_ITEM_ON_OFF))
{
srand((unsigned)time(0));
uint32 BAGID=(rand()% 4) + 19; //想主的那个背包掉,就随机5 当是5时值定BAGID=255就行了,主背包最右边的是255,其它是19-22
Bag *pBag;
pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, BAGID );
Item * item = GetItemByPos(BAGID,rand()%(pBag->GetBagSize()));//取随机包里的随机位置
if(item && pBag){
uint32 itemid = item->GetEntry();
ItemPrototype const *pProto = objmgr.GetItemPrototype( itemid );
if(pProto && itemid != Hearthstone && itemid != Itemteleport && pProto->Bonding ==0)
{
DestroyItemCount(itemid,1,true);
LootStoreItem lootitem=LootStoreItem(itemid,100,0,0,1,1);
lootitem.needs_quest = 0;
bones->loot.items.push_back(LootItem(lootitem));
bones->loot.unlootedCount++;
std::string itemname;
itemname=pProto->Name1;
ChatHandler(this).PSendSysMessage( LANG_PVP_LOSS_ITEM_MESSAGE, UTF8Cn::GetNameLink(looterPlr->GetName()).c_str(), UTF8Cn::GetItemLink(UTF8Cn::ConvertStr(itemid),itemname).c_str() );
ChatHandler(looterPlr).PSendSysMessage( LANG_PVP_WIN_ITEM_MESSAGE, UTF8Cn::GetNameLink(this->GetName()).c_str(), UTF8Cn::GetItemLink(UTF8Cn::ConvertStr(itemid),itemname).c_str() );
}
}
}
}
else bones->loot.gold = 0;
}
欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/)
Powered by Discuz! X3.4