static PyObject *wpParty_getAttr(wpParty *self, char *name) { cParty *party = self->party; if (!strcmp(name, "leader")) { return party->leader()->getPyObject(); } else if (!strcmp(name, "members")) { QPtrList<cPlayer> members = party->members(); PyObject *list = PyList_New(0); for (P_PLAYER member = members.first(); member; member = members.next()) PyList_Append(list, member->getPyObject()); return list; } else if (!strcmp(name, "canidates")) { QPtrList<cPlayer> canidates = party->canidates(); PyObject *list = PyList_New(0); for (P_PLAYER canidate = canidates.first(); canidate; canidate = canidates.next()) PyList_Append(list, canidate->getPyObject()); return list; } else if (!strcmp(name, "lootingallowed")) { QPtrList<cPlayer> lootlist = party->lootingAllowed(); PyObject *list = PyList_New(0); for (P_PLAYER member = lootlist.first(); member; member = lootlist.next()) PyList_Append(list, member->getPyObject()); return list; } return Py_FindMethod(wpPartyMethods, (PyObject*)self, name); }
static PyObject* wpParty_getAttr( wpParty* self, char* name ) { cParty* party = self->party; /* \rproperty party.leader A <object id="char">char</object> object for the leader of this party. */ if ( !strcmp( name, "leader" ) ) { return party->leader()->getPyObject(); } /* \rproperty party.members A list of <object id="char">char</object> objects for the members in this party. */ else if ( !strcmp( name, "members" ) ) { QPtrList<cPlayer> members = party->members(); PyObject* list = PyList_New( 0 ); for ( P_PLAYER member = members.first(); member; member = members.next() ) PyList_Append( list, member->getPyObject() ); return list; } /* \rproperty party.canidates A list of <object id="char">char</object> objects for the canidates in this party. */ else if ( !strcmp( name, "canidates" ) ) { QPtrList<cPlayer> canidates = party->canidates(); PyObject* list = PyList_New( 0 ); for ( P_PLAYER canidate = canidates.first(); canidate; canidate = canidates.next() ) PyList_Append( list, canidate->getPyObject() ); return list; } /* \rproperty party.lootingallowed A list of <object id="char">char</object> objects for the members of this party who allowed looting their corpse. */ else if ( !strcmp( name, "lootingallowed" ) ) { QPtrList<cPlayer> lootlist = party->lootingAllowed(); PyObject* list = PyList_New( 0 ); for ( P_PLAYER member = lootlist.first(); member; member = lootlist.next() ) PyList_Append( list, member->getPyObject() ); return list; } return Py_FindMethod( wpPartyMethods, ( PyObject * ) self, name ); }
///////////////// // 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; }
void cSkills::Snooping( P_PLAYER player, P_ITEM container ) { P_CHAR owner = container->getOutmostChar(); if ( !owner ) return; // Snooping into something thats not equipped?! PyObject *args = Py_BuildValue( "(NNN)", owner->getPyObject(), container->getPyObject(), player->getPyObject() ); // Event prfen if ( player->canHandleEvent( EVENT_SNOOPING ) ) { if ( player->callEventHandler( EVENT_SNOOPING, args ) ) { Py_DECREF( args ); return; } } if ( owner->canHandleEvent( EVENT_SNOOPING ) ) { if ( owner->callEventHandler( EVENT_SNOOPING, args ) ) { Py_DECREF( args ); return; } } Py_DECREF( args ); cUOSocket* socket = player->socket(); if ( !socket ) return; P_CHAR pc_owner = container->getOutmostChar(); P_PLAYER pp_owner = dynamic_cast<P_PLAYER>( pc_owner ); if ( pp_owner && pp_owner->isGMorCounselor() ) { pp_owner->message( tr( "%1 is trying to snoop in your pack" ).arg( player->name() ) ); socket->sysMessage( 500209 ); // You can not peek into the container. return; } else if ( player->checkSkill( SNOOPING, 0, 1000 ) ) { socket->sendContainer( container ); socket->sysMessage( tr( "You successfully peek into that container." ) ); } else { socket->sysMessage( 500210 ); // You failed to peek into the container. if ( !pp_owner ) // is NPC ? { if ( pc_owner ) { pc_owner->talk( tr( "Art thou attempting to disturb my privacy?" ) ); } } else { pp_owner->message( tr( "You notice %1 trying to peek into your pack!" ).arg( player->name() ) ); } } // SetTimerSec(player->objectdelay(), Config::instance()->objectDelay()+Config::instance()->snoopdelay()); player->setObjectDelay( Server::instance()->time() + ( Config::instance()->objectDelay() + Config::instance()->snoopdelay() ) * MY_CLOCKS_PER_SEC ); }