本文整理汇总了C++中P_NPC::callEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ P_NPC::callEventHandler方法的具体用法?C++ P_NPC::callEventHandler怎么用?C++ P_NPC::callEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_NPC
的用法示例。
在下文中一共展示了P_NPC::callEventHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: response
/////////////////
// name: response
// purpose: tries to get a response from an npc standing around
// history: heavily revamped/rewritten by Duke, Oct 2001
// remark: The new logic tries to minimize the # of strstr() calls by *first* checking
// what kind of npcs are standing around and then checking only those keywords
// that they might be interested in.
// This is especially usefull in crowded places.
bool Speech::response( cUOSocket* socket, P_PLAYER pPlayer, const QString& comm, QValueVector<Q_UINT16>& keywords )
{
if ( !pPlayer->socket() || pPlayer->isDead() )
{
return false;
}
QString speechUpr = comm.upper();
MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( pPlayer->pos(), 18 );
for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
{
P_NPC pNpc = dynamic_cast<P_NPC>( pChar );
// We will only process NPCs here
if ( !pNpc )
continue;
// at least they should be on the screen
if ( pPlayer->dist( pNpc ) > 16 )
continue;
if ( pNpc->canHandleEvent( EVENT_SPEECH ) )
{
PyObject* pkeywords = PyTuple_New( keywords.size() );
// Set Items
for ( unsigned int i = 0; i < keywords.size(); ++i )
PyTuple_SetItem( pkeywords, i, PyInt_FromLong( keywords[i] ) );
PyObject* args = Py_BuildValue( "(NNNO)", pNpc->getPyObject(), pPlayer->getPyObject(), QString2Python( comm ), pkeywords );
bool result = pNpc->callEventHandler( EVENT_SPEECH, args );
Py_DECREF( args );
Py_DECREF( pkeywords );
if ( result )
return true;
}
if ( pNpc->ai() )
{
pNpc->ai()->onSpeechInput( pPlayer, speechUpr );
}
if ( QuestionSpeech( socket, pPlayer, pNpc, speechUpr ) )
return true;
}
return false;
}