本文整理汇总了C++中CItem::GetUID方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetUID方法的具体用法?C++ CItem::GetUID怎么用?C++ CItem::GetUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetUID方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateItem
void CItemSpawn::GenerateItem(CResourceDef *pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateItem");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
CItemContainer *pCont = dynamic_cast<CItemContainer *>(GetParent());
BYTE iCount = pCont ? static_cast<unsigned char>(pCont->ContentCount(rid)) : GetCount();
if ( iCount >= GetAmount() )
return;
CItem *pItem = CreateTemplate(id);
if ( pItem == NULL )
return;
WORD iAmountPile = static_cast<WORD>(minimum(USHRT_MAX,m_itSpawnItem.m_pile));
if ( iAmountPile > 1 )
{
CItemBase *pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType() )
pItem->SetAmount(Calc_GetRandVal(iAmountPile) + 1);
}
pItem->SetAttr(m_Attr & (ATTR_OWNED | ATTR_MOVE_ALWAYS));
pItem->SetDecayTime(g_Cfg.m_iDecay_Item); // it will decay eventually to be replaced later
pItem->MoveNearObj(this, m_itSpawnItem.m_DistMax);
AddObj(pItem->GetUID());
}
示例2: IsType
CItem * CItemMulti::Multi_GetSign()
{
// Get my sign or tiller link.
CItem * pTiller = m_uidLink.ItemFind();
if ( pTiller == NULL )
{
pTiller = Multi_FindItemType( IsType(IT_SHIP) ? IT_SHIP_TILLER : IT_SIGN_GUMP );
if ( pTiller == NULL )
return( this );
m_uidLink = pTiller->GetUID();
}
return( pTiller );
}
示例3: ContentAddPrivate
void CContainer::ContentAddPrivate( CItem * pItem )
{
ADDTOCALLSTACK("CContainer::ContentAddPrivate");
// We are adding to a CChar or a CItemContainer
ASSERT( pItem != NULL );
ASSERT( pItem->IsValidUID()); // it should be valid at this point.
if ( pItem->GetParent() == this )
return;
if (!CGObList::GetCount())
CGObList::InsertHead( pItem );
else
{
CItem* pTest = GetContentHead();
CItem *prevItem = pTest;
for (; pTest != NULL; pTest = pTest->GetNext())
{
if (pTest->GetUID() < prevItem->GetUID())
prevItem = pTest;
}
CGObList::InsertAfter(pItem,prevItem);
}
//CGObList::InsertTail( pItem );//Reversing the order in which things are added into a container
OnWeightChange( pItem->GetWeight());
}
示例4: GenerateItem
void CItemSpawn::GenerateItem(CResourceDef * pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateItem");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
int iDistMax = m_itSpawnItem.m_DistMax;
int iAmountPile = m_itSpawnItem.m_pile;
int iCount = 0;
CItemContainer * pCont = dynamic_cast <CItemContainer *>( GetParent());
if ( pCont != NULL )
iCount = pCont->ContentCount( rid );
else
iCount = GetCount();
if ( iCount >= GetAmount())
return;
CItem * pItem = CreateTemplate( id );
if ( pItem == NULL )
return;
pItem->SetAttr( m_Attr & ( ATTR_OWNED | ATTR_MOVE_ALWAYS ));
if ( iAmountPile > 1 )
{
CItemBase * pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType())
{
if ( iAmountPile == 0 || iAmountPile > GetAmount())
iAmountPile = GetAmount();
pItem->SetAmount( Calc_GetRandVal(iAmountPile) + 1 );
}
}
pItem->SetDecayTime( g_Cfg.m_iDecay_Item ); // It will decay eventually to be replaced later.
pItem->MoveNearObj( this, iDistMax );
AddObj(pItem->GetUID());
pItem->m_uidSpawnItem = GetUID();
}
示例5: Cmd_EditItem
void CClient::Cmd_EditItem( CObjBase *pObj, int iSelect )
{
ADDTOCALLSTACK("CClient::Cmd_EditItem");
// ARGS:
// iSelect == -1 = setup.
// m_Targ_Text = what are we doing to it ?
//
if ( !pObj )
return;
CContainer *pContainer = dynamic_cast<CContainer *>(pObj);
if ( !pContainer )
{
addGumpDialogProps(pObj->GetUID());
return;
}
if ( iSelect == 0 ) // cancelled
return;
if ( iSelect > 0 ) // we selected an item
{
if ( static_cast<size_t>(iSelect) >= COUNTOF(m_tmMenu.m_Item) )
return;
if ( m_Targ_Text.IsEmpty() )
addGumpDialogProps(m_tmMenu.m_Item[static_cast<size_t>(iSelect)]);
else
OnTarg_Obj_Set(CGrayUID(m_tmMenu.m_Item[static_cast<size_t>(iSelect)]).ObjFind());
return;
}
CMenuItem item[minimum(COUNTOF(m_tmMenu.m_Item), MAX_MENU_ITEMS)]; // Most as we want to display at one time.
item[0].m_sText.Format("Contents of %s", pObj->GetName());
size_t count = 0;
for ( CItem *pItem = pContainer->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
{
count++;
m_tmMenu.m_Item[count] = pItem->GetUID();
item[count].m_sText = pItem->GetName();
ITEMID_TYPE idi = pItem->GetDispID();
item[count].m_id = static_cast<WORD>(idi);
item[count].m_color = 0;
if ( !pItem->IsType(IT_EQ_MEMORY_OBJ) )
{
HUE_TYPE wHue = pItem->GetHue();
if ( wHue != 0 )
{
wHue = (wHue == 1 ? 0x7FF : wHue - 1);
item[count].m_color = wHue;
}
}
if ( count >= (COUNTOF(item) - 1) )
break;
}
ASSERT(count < COUNTOF(item));
addItemMenu(CLIMODE_MENU_EDIT, item, count, pObj);
}
示例6: r_Verb
//.........这里部分代码省略.........
}
#endif
}
break;
case CV_BADSPAWN:
{
// Loop the world searching for bad spawns
bool fFound = false;
for ( int m = 0; m < 256 && !fFound; m++ )
{
if ( !g_MapList.m_maps[m] ) continue;
for ( int d = 0; d < g_MapList.GetSectorQty(m) && !fFound; d++ )
{
CSector *pSector = g_World.GetSector(m, d);
if ( !pSector ) continue;
CItem *pNext;
CItem *pItem = STATIC_CAST <CItem*>(pSector->m_Items_Inert.GetHead());
for ( ; pItem != NULL && !fFound; pItem = pNext )
{
pNext = pItem->GetNext();
if ( pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR) )
{
CItemSpawn *pSpawn = static_cast<CItemSpawn*>(pItem);
CResourceDef *pDef = pSpawn->FixDef();
if ( !pDef )
{
RESOURCE_ID_BASE rid = ( pItem->IsType(IT_SPAWN_ITEM) ? pItem->m_itSpawnItem.m_ItemID : pItem->m_itSpawnChar.m_CharID);
CPointMap pt = pItem->GetTopPoint();
m_pChar->Spell_Teleport(pt, true, false);
m_pChar->m_Act_Targ = pItem->GetUID();
SysMessagef("Bad spawn (0%lx, id=%s). Set as ACT", (DWORD)pItem->GetUID(), g_Cfg.ResourceGetName(rid));
fFound = true;
}
}
}
}
}
if ( ! fFound )
SysMessage(g_Cfg.GetDefaultMsg( DEFMSG_NO_BAD_SPAWNS ));
}
break;
case CV_BANKSELF: // open my own bank
addBankOpen( m_pChar, static_cast<LAYER_TYPE>(s.GetArgVal()));
break;
case CV_CAST:
{
SPELL_TYPE spell = static_cast<SPELL_TYPE>(g_Cfg.ResourceGetIndexType(RES_SPELL, s.GetArgStr()));
const CSpellDef * pSpellDef = g_Cfg.GetSpellDef(spell);
if (pSpellDef == NULL)
return true;
CObjBase * pObjSrc = dynamic_cast<CObjBase *>(pSrc);
if ( IsSetMagicFlags( MAGICF_PRECAST ) && !pSpellDef->IsSpellType( SPELLFLAG_NOPRECAST ) )
{
int skill;
if (!pSpellDef->GetPrimarySkill(&skill, NULL))
return true;
m_tmSkillMagery.m_Spell = spell; // m_atMagery.m_Spell
m_pChar->m_atMagery.m_Spell = spell;
if (pObjSrc != NULL)
示例7: OnTick
//.........这里部分代码省略.........
// regen all creatures and do AI
ProfileTask charactersTask(PROFILE_CHARS);
//pChar = STATIC_CAST <CChar*>( m_Chars_Active.GetHead());
CChar * pCharNext = NULL;
CChar * pChar = dynamic_cast <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar != NULL; pChar = pCharNext )
{
EXC_TRYSUB("TickChar");
pCharNext = pChar->GetNext();
if (( fEnvironChange ) && ( IsTrigUsed(TRIGGER_ENVIRONCHANGE) ))
pChar->OnTrigger(CTRIG_EnvironChange, pChar);
if ( pChar->IsClient())
{
CClient * pClient = pChar->GetClient();
ASSERT( pClient );
if ( sound )
pClient->addSound(sound, pChar);
if ( fLightChange && ! pChar->IsStatFlag( STATF_DEAD | STATF_NightSight ))
pClient->addLight();
if ( fWeatherChange )
pClient->addWeather(GetWeather());
if ( iRegionPeriodic && pChar->m_pArea )
{
if (( iRegionPeriodic == 2 )&&( IsTrigUsed(TRIGGER_REGPERIODIC) ))
{
pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_REGPERIODIC );
iRegionPeriodic--;
}
if ( IsTrigUsed(TRIGGER_CLIPERIODIC) )
pChar->m_pArea->OnRegionTrigger( pChar, RTRIG_CLIPERIODIC );
}
}
// Can only die on your own tick.
if ( !pChar->OnTick() )
pChar->Delete();
EXC_CATCHSUB("Sector");
EXC_DEBUGSUB_START;
CPointMap pt = GetBasePoint();
g_Log.EventDebug("char 0%lx '%s'\n", static_cast<DWORD>(pChar->GetUID()), pChar->GetName());
g_Log.EventDebug("sector #%d [%d,%d,%d,%d]\n", GetIndex(), pt.m_x, pt.m_y, pt.m_z, pt.m_map);
EXC_DEBUGSUB_END;
}
// decay items on ground = time out spells / gates etc.. etc..
// No need to check these so often !
ProfileTask itemsTask(PROFILE_ITEMS);
CItem * pItemNext = NULL;
CItem * pItem = dynamic_cast <CItem*>( m_Items_Timer.GetHead());
for ( ; pItem != NULL; pItem = pItemNext )
{
EXC_TRYSUB("TickItem");
pItemNext = pItem->GetNext();
EXC_SETSUB("TimerExpired");
if ( pItem->IsTimerExpired() )
{
EXC_SETSUB("ItemTick");
if ( !pItem->OnTick() )
{
EXC_SETSUB("ItemDelete");
pItem->Delete();
}
else
{
EXC_SETSUB("TimerExpired2");
if ( pItem->IsTimerExpired() ) // forgot to clear the timer.? strange.
{
EXC_SETSUB("SetTimeout");
pItem->SetTimeout(-1);
}
}
}
EXC_SETSUB("UpdateFlags");
pItem->OnTickStatusUpdate();
#ifdef _WIN32
EXC_CATCHSUB("Sector");
EXC_DEBUGSUB_START;
CPointMap pt = GetBasePoint();
g_Log.EventError("item 0%lx '%s' [timer=%lld, type=%lld]\n", static_cast<DWORD>(pItem->GetUID()), pItem->GetName(), pItem->GetTimerAdjusted(), static_cast<int>(pItem->GetType()));
g_Log.EventError("sector #%d [%d,%d,%d,%d]\n", GetIndex(), pt.m_x, pt.m_y, pt.m_z, pt.m_map);
EXC_DEBUGSUB_END;
#else
}
#ifndef _DEBUG
catch ( const CGrayError& e )
示例8: NPC_OnHearPetCmdTarg
bool CChar::NPC_OnHearPetCmdTarg( int iCmd, CChar *pSrc, CObjBase *pObj, const CPointMap &pt, LPCTSTR pszArgs )
{
ADDTOCALLSTACK("CChar::NPC_OnHearPetCmdTarg");
// Pet commands that required a target.
if ( m_fIgnoreNextPetCmd )
{
m_fIgnoreNextPetCmd = false;
return false;
}
switch ( iCmd )
{
case PC_FOLLOW:
case PC_STAY:
case PC_STOP:
{
// Pet friends can use only these commands
if ( Memory_FindObjTypes(pSrc, MEMORY_FRIEND) )
break;
}
default:
{
// All others commands are avaible only to pet owner
if ( !NPC_IsOwnedBy(pSrc, true) )
return false;
}
}
if ( IsStatFlag(STATF_DEAD) )
{
// Bonded NPCs still placed on world even when dead.
// They can listen to commands, but not to these commands below
if ( iCmd == PC_GUARD || iCmd == PC_GUARD_ME || iCmd == PC_ATTACK || iCmd == PC_KILL || iCmd == PC_TRANSFER || iCmd == PC_DROP || iCmd == PC_DROP_ALL )
return true;
}
bool bSuccess = false;
CItem *pItemTarg = dynamic_cast<CItem *>(pObj);
CChar *pCharTarg = dynamic_cast<CChar *>(pObj);
switch ( iCmd )
{
case PC_ATTACK:
case PC_KILL:
{
if ( !pCharTarg || pCharTarg == pSrc )
break;
bSuccess = pCharTarg->OnAttackedBy(pSrc, 1, true); // we know who told them to do this.
if ( bSuccess )
bSuccess = Fight_Attack(pCharTarg, true);
break;
}
case PC_FOLLOW:
if ( !pCharTarg )
break;
m_Act_Targ = pCharTarg->GetUID();
bSuccess = Skill_Start(NPCACT_FOLLOW_TARG);
break;
case PC_FRIEND:
{
if ( !pCharTarg || !pCharTarg->m_pPlayer || pCharTarg == pSrc )
{
Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_CONFUSED));
break;
}
CItemMemory *pMemory = Memory_FindObjTypes(pCharTarg, MEMORY_FRIEND);
if ( pMemory )
{
pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_ALREADY));
break;
}
pSrc->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_SUCCESS1), GetName(), pCharTarg->GetName());
pCharTarg->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_SUCCESS2), pSrc->GetName(), GetName());
Memory_AddObjTypes(pCharTarg, MEMORY_FRIEND);
m_Act_Targ = pCharTarg->GetUID();
bSuccess = Skill_Start(NPCACT_FOLLOW_TARG);
break;
}
case PC_UNFRIEND:
{
if ( !pCharTarg || !pCharTarg->m_pPlayer )
{
Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_CONFUSED));
break;
}
CItemMemory *pMemory = Memory_FindObjTypes(pCharTarg, MEMORY_FRIEND);
if ( !pMemory )
{
pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND_NOTFRIEND));
break;
}
pSrc->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND_SUCCESS1), GetName(), pCharTarg->GetName());
pCharTarg->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND_SUCCESS2), pSrc->GetName(), GetName());
pMemory->Delete();
//.........这里部分代码省略.........
示例9: CanSeeLOS_New
//.........这里部分代码省略.........
if ( pItemDef->GetID() != pItem->GetDispID() ) //not a parent item
{
WARNLOS(("Not a parent item (DYNAMIC)\n"));
pDupeDef = CItemBaseDupe::GetDupeRef((ITEMID_TYPE)(pItem->GetDispID()));
if ( !pDupeDef )
{
// Not an error: i have changed the DISPID of the item.
CItemBase* pParentDef = CItemBase::FindItemBase(pItem->GetDispID());
if (pParentDef)
{
wTFlags = pParentDef->GetTFlags();
Height = pParentDef->GetHeight();
}
else
g_Log.EventDebug("AdvancedLoS: Failed to get reference (dynamic): non-dupe, baseless dispid (DispID 0%x) (X: %d Y: %d Z: %hhd M: %hhu)\n", pItem->GetDispID(), ptNow.m_x, ptNow.m_y, pItem->GetUnkZ(), ptNow.m_map);
}
else
{
// It's a dupe item
wTFlags = pDupeDef->GetTFlags();
Height = pDupeDef->GetHeight();
}
}
else
{
WARNLOS(("Parent item (DYNAMIC)\n"));
}
Height = (wTFlags & UFLAG2_CLIMBABLE) ? Height / 2 : Height;
if ( ((wTFlags & (UFLAG1_WALL|UFLAG1_BLOCK|UFLAG2_PLATFORM)) || pItem->Can(CAN_I_BLOCKLOS_HEIGHT)) && !((wTFlags & UFLAG2_WINDOW) && (flags & LOS_NB_WINDOWS)) )
{
WARNLOS(("pItem %0x(%0x) %d,%d,%d - %d\n", (dword)pItem->GetUID(), pItem->GetDispID(), pItem->GetUnkPoint().m_x, pItem->GetUnkPoint().m_y, pItem->GetUnkPoint().m_z, Height));
min_z = pItem->GetUnkPoint().m_z;
max_z = minimum(Height + min_z, UO_SIZE_Z);
WARNLOS(("wTFlags(0%x)\n", wTFlags));
WARNLOS(("pItem %0x(%0x) Z check: %d,%d (Now: %d) (Dest: %d).\n", (dword)pItem->GetUID(), pItem->GetDispID(), min_z, max_z, ptNow.m_z, ptDst.m_z));
if ( min_z <= ptNow.m_z && max_z >= ptNow.m_z )
{
if ( ptNow.m_x != ptDst.m_x || ptNow.m_y != ptDst.m_y || min_z > ptDst.m_z || max_z < ptDst.m_z )
{
WARNLOS(("pItem blocked - m:%d M:%d\n", min_z, max_z));
bPath = false;
break;
}
}
}
}
}
}
}
if ( !bPath )
break;
// ----------- Multis ---------------
if ( !(flags & LOS_NB_MULTI) )
{
if ( !((flags & LOS_NB_LOCAL_MULTI) && (pSrcRegion == pNowRegion)) )
{
size_t iQtyr = ptNow.GetRegions(REGION_TYPE_MULTI, &rlinks);
if ( iQtyr > 0 )
{
示例10: NPC_OnHearPetCmdTarg
bool CChar::NPC_OnHearPetCmdTarg(int iCmd, CChar *pSrc, CObjBase *pObj, const CPointMap &pt, LPCTSTR pszArgs)
{
ADDTOCALLSTACK("CChar::NPC_OnHearPetCmdTarg");
// Pet commands that required a target.
if ( m_fIgnoreNextPetCmd )
{
m_fIgnoreNextPetCmd = false;
return false;
}
if ( !NPC_PetCheckAccess(iCmd, pSrc) )
return true;
bool bSuccess = false;
CItem *pItemTarg = dynamic_cast<CItem *>(pObj);
CChar *pCharTarg = dynamic_cast<CChar *>(pObj);
switch ( iCmd )
{
case PC_ATTACK:
case PC_KILL:
{
if ( !pCharTarg || (pCharTarg == this) || (pCharTarg == pSrc) )
break;
bSuccess = pCharTarg->OnAttackedBy(pSrc, true);
if ( bSuccess )
bSuccess = Fight_Attack(pCharTarg, true);
break;
}
case PC_FOLLOW:
if ( !pCharTarg || (pCharTarg == this) )
break;
m_Act_Targ = pCharTarg->GetUID();
bSuccess = Skill_Start(NPCACT_FOLLOW_TARG);
break;
case PC_FRIEND:
{
if ( !pCharTarg || !pCharTarg->m_pPlayer || (pCharTarg == pSrc) )
{
Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_CONFUSED));
break;
}
CItemMemory *pMemory = Memory_FindObjTypes(pCharTarg, MEMORY_FRIEND);
if ( pMemory )
{
pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_ALREADY));
break;
}
pSrc->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_SUCCESS1), GetName(), pCharTarg->GetName());
pCharTarg->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_FRIEND_SUCCESS2), pSrc->GetName(), GetName());
Memory_AddObjTypes(pCharTarg, MEMORY_FRIEND);
m_Act_Targ = pCharTarg->GetUID();
bSuccess = Skill_Start(NPCACT_FOLLOW_TARG);
break;
}
case PC_UNFRIEND:
{
if ( !pCharTarg || !pCharTarg->m_pPlayer )
{
Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_CONFUSED));
break;
}
CItemMemory *pMemory = Memory_FindObjTypes(pCharTarg, MEMORY_FRIEND);
if ( !pMemory )
{
pSrc->SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND_NOTFRIEND));
break;
}
pSrc->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND_SUCCESS1), GetName(), pCharTarg->GetName());
pCharTarg->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_UNFRIEND_SUCCESS2), pSrc->GetName(), GetName());
pMemory->Delete();
m_Act_Targ = pSrc->GetUID();
bSuccess = Skill_Start(NPCACT_FOLLOW_TARG);
break;
}
case PC_GO:
if ( !pt.IsValidPoint() )
break;
m_Act_p = pt;
bSuccess = Skill_Start(NPCACT_GOTO);
break;
case PC_GUARD:
if ( !pCharTarg || (pCharTarg == this) )
break;
pCharTarg->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_TARG_GUARD_SUCCESS), GetName());
m_Act_Targ = pCharTarg->GetUID();
bSuccess = Skill_Start(NPCACT_GUARD_TARG);
break;
case PC_TRANSFER:
if ( !pCharTarg || !pCharTarg->m_pClient )
//.........这里部分代码省略.........
示例11: NPC_OnHearPetCmdTarg
bool CChar::NPC_OnHearPetCmdTarg( int iCmd, CChar * pSrc, CObjBase * pObj, const CPointMap & pt, LPCTSTR pszArgs )
{
ADDTOCALLSTACK("CChar::NPC_OnHearPetCmdTarg");
// Pet commands that required a target.
if ( iCmd == PC_FOLLOW || iCmd == PC_STAY || iCmd == PC_STOP )
{
// Pet friends can use only these commands
if ( ! NPC_IsOwnedBy( pSrc ) && Memory_FindObjTypes( pSrc, MEMORY_FRIEND ) == NULL )
return false;
}
else
{
// All others commands are avaible only to pet owner
if ( ! NPC_IsOwnedBy( pSrc, true ) )
return false;
}
if ( m_fIgnoreNextPetCmd == true )
{
m_fIgnoreNextPetCmd = false;
return(false);
}
bool fSuccess = false; // No they won't do it.
// Could be NULL
CItem * pItemTarg = dynamic_cast<CItem*>(pObj);
CChar * pCharTarg = dynamic_cast<CChar*>(pObj);
switch ( iCmd )
{
case PC_GO:
// Go to the location x,y
if ( ! pt.IsValidPoint())
break;
m_Act_p = pt;
fSuccess = Skill_Start( NPCACT_GOTO );
break;
case PC_GUARD:
if ( pObj == NULL )
break;
m_Act_Targ = pObj->GetUID();
fSuccess = Skill_Start( NPCACT_GUARD_TARG );
break;
case PC_TRANSFER:
// transfer ownership via the transfer command.
if ( pCharTarg == NULL )
break;
if ( pCharTarg->IsClient() )
{
if ( IsSetOF(OF_PetSlots) )
{
if ( !pCharTarg->FollowersUpdate(this, static_cast<short>(maximum(1, GetDefNum("FOLLOWERSLOTS", true, true))), true) )
{
pSrc->SysMessageDefault( DEFMSG_PETSLOTS_TRY_TRANSFER );
break;
}
}
fSuccess = NPC_PetSetOwner( pCharTarg );
}
break;
case PC_KILL:
case PC_ATTACK:
// Attack the target.
if ( pCharTarg == NULL )
break;
// refuse to attack friends.
if ( NPC_IsOwnedBy( pCharTarg, true ))
{
fSuccess = false; // take no commands
break;
}
fSuccess = pCharTarg->OnAttackedBy( pSrc, 1, true ); // we know who told them to do this.
if ( fSuccess )
{
fSuccess = Fight_Attack( pCharTarg, true );
}
break;
case PC_FOLLOW:
if ( pCharTarg == NULL )
break;
m_Act_Targ = pCharTarg->GetUID();
fSuccess = Skill_Start( NPCACT_FOLLOW_TARG );
break;
case PC_FRIEND:
// Not the same as owner,
if ( pCharTarg == NULL )
break;
Memory_AddObjTypes( pCharTarg, MEMORY_FRIEND );
break;
case PC_PRICE: // "PRICE" the vendor item.
if ( pItemTarg == NULL )
break;
if ( ! NPC_IsVendor())
//.........这里部分代码省略.........
示例12: r_Verb
//.........这里部分代码省略.........
INT64 piVal[3];
Str_ParseCmds(s.GetArgRaw(), piVal, COUNTOF(piVal));
addArrowQuest(static_cast<WORD>(piVal[0]), static_cast<WORD>(piVal[1]), static_cast<DWORD>(piVal[2]));
break;
}
case CV_BADSPAWN:
{
// Loop the world searching for bad spawns
bool fFound = false;
CItem *pItem = NULL;
CSector *pSector = NULL;
CResourceDef *pSpawnDef = NULL;
for ( int m = 0; (m < 256) && !fFound; ++m )
{
if ( !g_MapList.m_maps[m] )
continue;
for ( int s = 0; (s < g_MapList.GetSectorQty(m)) && !fFound; ++s )
{
pSector = g_World.GetSector(m, s);
if ( !pSector )
continue;
for ( pItem = static_cast<CItem *>(pSector->m_Items_Timer.GetHead()); (pItem != NULL) && !fFound; pItem = pItem->GetNext() )
{
if ( pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR) )
{
pSpawnDef = static_cast<CItemSpawn *>(pItem)->FixDef();
if ( !pSpawnDef )
{
RESOURCE_ID_BASE rid = pItem->IsType(IT_SPAWN_ITEM) ? pItem->m_itSpawnItem.m_ItemID : pItem->m_itSpawnChar.m_CharID;
CPointMap pt = pItem->GetTopPoint();
m_pChar->Spell_Teleport(pt, true, false);
m_pChar->m_Act_Targ = pItem->GetUID();
SysMessagef("Bad spawn (0%lx, id=%s). Set as ACT", static_cast<DWORD>(pItem->GetUID()), g_Cfg.ResourceGetName(rid));
fFound = true;
}
}
}
}
}
if ( !fFound )
SysMessage(g_Cfg.GetDefaultMsg(DEFMSG_NO_BAD_SPAWNS));
break;
}
case CV_BANKSELF:
{
addBankOpen(m_pChar, LAYER_BANKBOX);
break;
}
case CV_CAST:
{
SPELL_TYPE spell = static_cast<SPELL_TYPE>(g_Cfg.ResourceGetIndexType(RES_SPELL, s.GetArgStr()));
const CSpellDef *pSpellDef = g_Cfg.GetSpellDef(spell);
if ( !pSpellDef )
return true;
CObjBase *pObjSrc = dynamic_cast<CObjBase *>(pSrc);
if ( IsSetMagicFlags(MAGICF_PRECAST) && !pSpellDef->IsSpellType(SPELLFLAG_NOPRECAST) )
{
int iSkill;
if ( !pSpellDef->GetPrimarySkill(&iSkill, NULL) )
return true;
m_tmSkillMagery.m_Spell = spell; // m_atMagery.m_Spell
m_pChar->m_atMagery.m_Spell = spell;
示例13: r_WriteVal
//.........这里部分代码省略.........
}
if (pMultiItem != NULL)
break;
}
}
if ( pMultiItem == NULL )
{
sVal.FormatHex(0);
return true;
}
SKIP_SEPARATORS( pszKey );
if ( !*pszKey )
pszKey = "ID";
ITEMID_TYPE idTile = pMultiItem->GetDispID();
if ( strnicmp( pszKey, "ID", 2 ) == 0 )
{
sVal.FormatHex( idTile );
return true;
}
else if ( strnicmp( pszKey, "MULTI", 5 ) == 0 )
{
pszKey += 5;
if (*pszKey != '\0')
{
SKIP_SEPARATORS(pszKey);
return pItem->r_WriteVal( pszKey, sVal, &g_Serv );
}
sVal.FormatHex( pItem->GetUID() );
return true;
}
else if ( strnicmp( pszKey, "Z", 1 ) == 0 )
{
sVal.FormatVal( pItem->GetTopZ() + pMultiItem->m_dz );
return true;
}
// Check the script def for the item.
CItemBase * pItemDef = CItemBase::FindItemBase( idTile );
if ( pItemDef == NULL )
{
DEBUG_ERR(("Must have ITEMDEF section for item ID 0%x\n", idTile ));
return false;
}
return pItemDef->r_WriteVal( pszKey, sVal, &g_Serv );
}
int index = FindTableHeadSorted( pszKey, sm_szLoadKeys, COUNTOF(sm_szLoadKeys)-1 );
if ( index < 0 )
return false;
switch ( index )
{
case PT_M:
case PT_MAP:
sVal.FormatVal(m_map);
break;
case PT_X:
sVal.FormatVal(m_x);
break;