📄 op_inv.cpp
字号:
#include "..\stdafx.h"
#include "DefaultHeader.h"
#include "CItem.h"
#include "Op_Magic.h"
#include "WeatherControl.h"
extern CItem_List Item_Ref ;
extern t_connection connections[DRAGON_MAX_CONNECTIONS_+1];
void getItemIndex(int, int &, int &) ;
const char const equip_able[9]={2, 3, 4, 5, 6, 7, 8, 8, 9 } ;
//////////////////////////////////////////////////////////////////////////
//
// 窃荐汲疙: 秦寸困摹俊 item捞 沥富肺 乐绰瘤 魄喊窍绰 窃荐(摹泼捞唱 俊矾
// 俊 措厚茄 贸府)
// 颇扼固磐: item_no; 酒捞袍 锅龋
// char_id; 青困甫 茄 某腐磐狼 id(index)
// source; 酒捞袍捞 困摹茄 厘家 沥焊
//
// 府畔蔼: 酒捞袍 粮犁 咯何
//
//////////////////////////////////////////////////////////////////////////
bool exist(int item_no, int char_id, POS &source)
{
if( item_no == IN_COINS || item_no == IN_COIN ) // 0222 YGI
{
ItemAttr *temp = GetItemByPOS( char_id, source );
if( !temp ) return NOT;
if( temp->item_no == IN_COINS && temp->attr[IATTR_MUCH] <= 5 ) temp->item_no = IN_COIN;
else if( temp->item_no == IN_COIN && temp->attr[IATTR_MUCH] > 5 ) temp->item_no = IN_COINS;
}
// 010210 YGI
if( item_no == IN_NEW_COINS || item_no == IN_NEW_COIN ) // 0222 YGI
{
ItemAttr *temp = GetItemByPOS( char_id, source );
if( !temp ) return NOT;
if( temp->item_no == IN_NEW_COINS && temp->attr[IATTR_MUCH] <= 5 ) temp->item_no = IN_NEW_COIN;
else if( temp->item_no == IN_NEW_COIN && temp->attr[IATTR_MUCH] > 5 ) temp->item_no = IN_NEW_COINS;
}
switch(source.type) {
case INV: // inventory
//connections[char_id].chrlst.
if(connections[char_id].chrlst.inv[source.p1][source.p2][source.p3].item_no == item_no) return OK ;
return NOT ;
case HAND:
if(connections[char_id].chrlst.handheld.item_no == item_no) return OK ;
else return NOT ;
case EQUIP:
if(connections[char_id].chrlst.equip[source.p3].item_no == item_no) return OK ;
else return NOT ;
case QUICK:
if(connections[char_id].chrlst.quick[source.p3].item_no == item_no) return OK ;
else return NOT ;
case BANK : //1225
if(connections[char_id].chrlst.bank[source.p1][source.p2][source.p3].item_no == item_no) return OK ;
else return NOT ;
case BOX://冠胶绰 公炼扒 绝绢//021030 lsw
return NOT ;
case GROUND:
// check the existence by item_index
if(ItemList[source.p3].bAlive) {
if(ItemList[source.p3].x == source.p1 && ItemList[source.p3].y == source.p2 &&
ItemList[source.p3].item_no == item_no) return OK ;
else return NOT ;
}
else return NOT ;
case OTHER_CH : { //0105
//<soto-tai
CHARLIST *ch;
if( source.p3 < 10000 ) ch = &connections[source.p3].chrlst;
else ch = &NPCList[ source.p3-10000 ];
int a, b, c;
for( a=0; a<3; a++ )
for( b=0; b<3; b++ )
for( c=0; c<8; c++ )
if( ch->inv[a][b][c].item_no == item_no )
{
source.p1 = INV;
source.p2 = a*100+b*10+c;
return OK;
}
/* for( c=0; c<8; c++)
if( ch->equip[c].item_no == item_no )
{
source.p1 = EQUIP;
source.p2 = c;
return OK;
}
for( c=0; c<6; c++)//020530 lsw
if( ch->quick[c].item_no == item_no )
{
source.p1 = QUICK;
source.p2 = c;
return OK;
}
*/
return NOT;
}
//>soto-tai
default:
return NOT ;
}
}
//////////////////////////////////////////////////////////////////////////////
//
// 窃荐汲疙: 牢亥配府俊俊辑 后磊府甫 茫酒 弊 搬苞甫 舅妨林绰 窃荐
//
// 颇扼固磐: chr; 秦寸 某腐磐狼 *
// p1, p2, p3; 牢亥配府 硅凯狼 霉锅掳, 滴锅掳 付瘤阜 index
//
// 府畔蔼: 后磊府狼 粮犁 咯何(粮犁矫俊绰 p1,p2,p3俊 悸泼)
//
//////////////////////////////////////////////////////////////////////////////
void SendRareDisplayEffect(CHARLIST *ch, const int iDyRareType)
{
if(0 > iDyRareType || MAX_ITEM_FUNCTION <=iDyRareType )
{
return;
}
const int iSendDisplayNo = ItemFunction[iDyRareType].iEffectNo;
const int iSendDisplayTime = 5;
if(iSendDisplayTime && iSendDisplayNo)//捞棋飘 焊郴淋//烙矫肺 阜酒躇澜 抛胶飘甫 困秦辑
{//捞棋飘 抛捞喉 祈笼 秦辑 荤侩 窍磊
t_packet p;
const short cn = ch->GetServerID();
p.h.header.type = CMD_ADD_EFFECT;
p.h.header.size = sizeof( t_AddEffect );
p.u.AddEffect.wEffectNo =iSendDisplayNo;
p.u.AddEffect.idTarget =cn;
p.u.AddEffect.wDuration =iSendDisplayTime;
QueuePacket( connections, cn, &p, 1);
CastMe2Other( ch->GetServerID(), &p );
}
return;
}
void SendRareDisplayEffect(CHARLIST *ch)
{
const int iSendDisplayNo = RareEM.GetRareDisplayEffectNo(DYNAMICRARE,ch->DynamicRare); // 荤侩等 付过狼 锅龋
const int iSendDisplayTime = RareEM.GetRareDisplayEffectTime(ch->DynamicRare);
if(iSendDisplayTime && iSendDisplayNo)//捞棋飘 焊郴淋//烙矫肺 阜酒躇澜 抛胶飘甫 困秦辑
{//捞棋飘 抛捞喉 祈笼 秦辑 荤侩 窍磊
t_packet p;
const short cn = ch->GetServerID();
p.h.header.type = CMD_ADD_EFFECT;
p.h.header.size = sizeof( t_AddEffect );
p.u.AddEffect.wEffectNo =iSendDisplayNo;
// p.u.AddEffect.wEffectNo =474;//TEST
p.u.AddEffect.idTarget =cn;
p.u.AddEffect.wDuration =iSendDisplayTime;
// p.u.AddEffect.wDuration =10;//TEST
QueuePacket( connections, cn, &p, 1);
CastMe2Other( ch->GetServerID(), &p );
}
return;
}
//////////////////////////////////////////////////////////////////////////
//
// 窃荐汲疙: 酒捞袍狼 困摹甫 官槽促. NULL酒捞袍 俺充阑 眠啊窍咯 酒捞袍狼
// 困摹捞悼 棺 磊府官厕, 荤侩, 厘馒殿 阿辆 酒捞袍 捞悼俊
// 包拌等 葛电 楷魂俊 荤侩.(窜 泅犁, 牢亥配府郴俊辑父)
//
// 颇扼固磐: char_id ; 青困甫 茄 某腐磐 id(index)
// cstauts ; 某腐磐狼 惑怕函拳甫 努扼捞攫飘俊 舅妨林扁 困秦
// packet俊 器窃瞪 structure. 窜鉴洒, equip捞唱
// use窃荐俊 颇扼固磐肺 逞绢埃促.
// source, dest ; 盔/格钎 厘家 沥焊(POS STRUCTURE汲疙 曼炼)
//
// 府畔蔼: 秦寸 楷魂(捞悼/厘馒/荤侩殿狼)狼 啊瓷 咯何
//
//////////////////////////////////////////////////////////////////////////
// *************************************************************************************
//
// 某腐磐埃狼 捞悼 酒流 瘤盔 救凳. 甘苞狼 捞悼 瘤盔 救凳.
//
// ************************************************************************************
// 某腐磐埃狼 酒捞袍 捞悼阑 瘤盔窍扁 困秦辑绰 dest狼 p1俊 charlist俊辑狼 index啊 逞绢客具 茄促.
// 甘苞狼 酒捞袍 捞悼阑 瘤盔窍扁 困秦辑绰 dest狼 p1, p2俊 x,y啊 甸绢客具 茄促.
int exchangePOS_of_Item(const int char_id, t_chr_status_info *cstatus, const POS SourcePos, const POS DestPos) // 0624 YGI
{
CHARLIST *hero = CheckServerId( char_id );
if( !hero )
{
return 0;
}
ItemAttr tu = {0,}, *pSourceItem=NULL;
int item_id ;
POS other_pos;
bool iSendDyRareDisplayEffect =0;
switch(SourcePos.type)
{
case INV:
{
pSourceItem= &hero->inv[SourcePos.p1][SourcePos.p2][SourcePos.p3];
}break ;
case EQUIP:
{
pSourceItem= &hero->equip[SourcePos.p3] ;
}break ;
case QUICK:
{
pSourceItem= &hero->quick[SourcePos.p3] ;
}break ;
case BANK :
{
pSourceItem= &hero->bank[SourcePos.p1][SourcePos.p2][SourcePos.p3] ;
}break ;
case HAND:
{
pSourceItem= &hero->handheld;
}break ;//021030 lsw 冠胶 绝嚼聪促.
case GROUND:
{
tu.item_no = ItemList[SourcePos.p3].item_no;
::memcpy( &tu, &ItemList[SourcePos.p3], sizeof( DWORD )*6 );
pSourceItem = NULL;
}break;
//<soto-tai
case OTHER_CH : // 0105
{
CHARLIST *ch = NULL;
if( SourcePos.p3 < 10000 )
{
ch = ::CheckServerId(SourcePos.p3);
}
else
{
ch = ::NPC_ReturnCharListPoint(SourcePos.p3);
}
if(!ch)//措惑捞 绝促
{
return 0;
}
switch( SourcePos.p1 )
{
case INV :
{
const int a= SourcePos.p2 /100;
const int b = (SourcePos.p2 - a*100)/10;
const int c = SourcePos.p2 % 10;
pSourceItem= &ch->inv[a][b][c] ;
::SetItemPos( INV, a, b, c, &other_pos );
break;
}
/*
case EQUIP :
{
pSourceItem= &ch->equip[SourcePos.p2] ;
::SetItemPos( EQUIP, SourcePos.p2, &other_pos );
}break;
case QUICK :
{
pSourceItem= &ch->quick[SourcePos.p2] ;
SetItemPos( QUICK, SourcePos.p2, &other_pos );
}break;
*/
default :
{
return 0 ;
}break;
}
break;
}
//>soto-tai
default:
return 0 ;
}
if( pSourceItem )
{
tu = *pSourceItem;
}
CItem *ii = ItemUnit( tu.item_no );
if( NULL == ii ) return 0;
switch(DestPos.type)
{
case INV:
{
ItemAttr &DestItem = hero->inv[DestPos.p1][DestPos.p2][DestPos.p3];
if( SourcePos.type == HAND && ii->GetRbutton() == DIVIDE_ITEM )
{
int sum_able = 0 ;
if( tu.item_no == DestItem.item_no //酒捞袍 逞滚啊 老摹窍绊
&& tu.attr[IATTR_RARE_MAIN] == DestItem.attr[IATTR_RARE_MAIN] ) //饭绢 加己捞 鞍栏搁
{
sum_able = 1; // 010522 YGI
}
CItem *t = ItemUnit( DestItem );
if( ( t && t->GetItemKind() == IK_MONEY && ii->GetItemKind() == IK_MONEY ) //鞍篮 悼傈
|| ( t && t->GetItemKind() == IK_NEW_MONEY && ii->GetItemKind() == IK_NEW_MONEY ) )
{
sum_able = 1; // 010210 YGI
}
if( DestItem.item_no == 0 )
{
DestItem = tu;
DestItem.attr[IATTR_MUCH] = 0;
sum_able = 1;
}
if( sum_able )
{
DestItem.attr[IATTR_MUCH]+=tu.attr[IATTR_MUCH]; // 酒捞袍 荐樊 钦摹扁
::CheckAutoDivideMoney( &DestItem, char_id ); // 0415_2 YGI
::SendServerItemAttr( char_id, IATTR_DURATION, DestPos, &DestItem );
::DeleteItem( pSourceItem );
goto OK_;
}
}
// 器记 林赣聪 备泅
else if( SourcePos.type == HAND && ii->GetRbutton() == USE_ITEM ) // 甸绊 乐绰 酒捞袍捞 器记捞绊
{
CItem *t = ItemUnit( DestItem );
if( t && ii->GetItemKind() != IK_POTION_BOX && t->GetItemKind() == IK_POTION_BOX ) // 措惑捞 林赣聪捞搁
{
// 器记 历厘
CPotionBox potion_box( hero );
if(potion_box.PutItem( pSourceItem ))
{
goto OK_;
}
}
}
else if(SourcePos.type == EQUIP) // 010604 YGI
{
if( DestItem.item_no )
{
::MoveEmptyInv( &DestItem, hero );
}
ii->ReleaseItem( hero );
}
*pSourceItem= DestItem ; // 001030 YGI
DestItem = tu ;
goto OK_;
}break;
case EQUIP: // case EQUIP
{
ItemAttr &DestItem = hero->equip[DestPos.p3];
int dest_type, dest_index;
::getItemIndex( DestItem.item_no, dest_type, dest_index );
CItem *t = ItemUnit( dest_type, dest_index ); // 酒公巴档 绝阑 荐 乐促.
if( t ) // 010604 YGI
{
t->ReleaseItem( hero );
::MoveEmptyInv( &DestItem, hero );
// acer4
// 劝阑 颗板阑 版快 拳混档 颗变促.
if( DestPos.p3 == WT_WEAPON && t->GetSkill_Ability() == TACTICS_Archery )
{
ItemAttr *arrow_item = &hero->equip[WT_SHIELD];
if( arrow_item->item_no )
{
CItem *tt = ::ItemUnit( arrow_item->item_no );
if( tt ) tt->ReleaseItem( hero );
::MoveEmptyInv( arrow_item, hero );
POS pos;
::SetItemPos( EQUIP, WT_SHIELD , &pos );
::SendServerEachItem( &pos, arrow_item, char_id );
}
}
}
if( ii->is_equipable(char_id, cstatus, SourcePos, DestPos) )
{
*pSourceItem= hero->equip[DestPos.p3] ;
hero->equip[DestPos.p3]= tu ;
ii->EquipItem( hero ); //
goto OK_;
}
else return 0 ;
}break;
case QUICK : //1214
{
if( ii->GetWearAble() == WEAR_BELT )
{
*pSourceItem= hero->quick[DestPos.p3] ;
hero->quick[DestPos.p3]= tu ;
goto OK_;
}
else return 0;
}break;
case BANK : //1225
{
ItemAttr &DestItem = hero->bank[DestPos.p1][DestPos.p2][DestPos.p3];
if( DestItem.item_no )
{
// 篮青俊辑 啊廉吭促.
::SendItemEventLog( &DestItem, char_id, SN_NOT_USER, SILT_GET_BANK, 2 ); //YGI acer
::MoveEmptyInv( &DestItem, hero );
}
if( SourcePos.type == HAND && tu.item_no == DestItem.item_no && ii->GetRbutton() == DIVIDE_ITEM
&& tu.attr[IATTR_RARE_MAIN] == DestItem.attr[IATTR_RARE_MAIN])//010604//鞍篮加己父 钦摹扁
{
DestItem.attr[IATTR_MUCH]+=tu.attr[IATTR_MUCH]; // 酒捞袍 荐樊 钦摹扁
::DeleteItem( pSourceItem );
goto OK_;
}
*pSourceItem= DestItem;
DestItem = tu;
if(SourcePos.type == EQUIP)
{
ii->ReleaseItem( hero );
}
::SendItemEventLog( &DestItem, char_id, SN_NOT_USER, SILT_PUT_BANK, 2 ); //YGI acer
goto OK_;
}break;
//soto-tai
case HAND:
{
ItemAttr &DestItem = hero->handheld;
if( DestItem.item_no ) // 颊俊 购啊甫 甸绊 乐栏搁 厚绢乐绰 牢亥栏肺 焊郴滚赴促.
::MoveEmptyInv( &DestItem, hero );
int release = false;
switch( SourcePos.type )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -