[wpdev-commits] wolfpack/ai ai_humans.cpp,1.26,1.27 ai_monsters.cpp,1.28,1.29
Brought to you by:
rip,
thiagocorrea
From: Sebastian H. <dar...@us...> - 2004-10-27 14:07:17
|
Update of /cvsroot/wpdev/wolfpack/ai In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5590/ai Modified Files: ai_humans.cpp ai_monsters.cpp Log Message: Implemented onCheckVictim and onDoDamage Index: ai_humans.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/ai/ai_humans.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ai_humans.cpp 27 Oct 2004 10:56:12 -0000 1.26 --- ai_humans.cpp 27 Oct 2004 14:06:54 -0000 1.27 *************** *** 402,424 **** P_NPC pNpc = dynamic_cast<P_NPC>(pChar); ! // NPCs owned by innocent players aren't attacked ! if (pNpc) { ! if (pNpc->isTamed() && pNpc->owner()) { ! if (pNpc->owner()->isInnocent()) { ! continue; } } else { ! // Check for the AI, guards only attack other npcs if they ! // are monsters. ! Monster_Aggressive *npcai = dynamic_cast<Monster_Aggressive*>(pNpc->ai()); ! if (!npcai) { continue; - } } - } else { - // Innocent players aren't attacked - P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( pChar ); - if ( pPlayer && (pPlayer->isInnocent() || pPlayer->isGMorCounselor()) ) - continue; } --- 402,439 ---- P_NPC pNpc = dynamic_cast<P_NPC>(pChar); ! // If the character has a checkvictim processing function, use that instead ! if (m_npc->canHandleEvent(EVENT_CHECKVICTIM)) { ! if (pNpc && pNpc->owner()) { ! pChar = pNpc->owner(); ! } ! ! PyObject *args = Py_BuildValue("(NNi)", m_npc->getPyObject(), pChar->getPyObject(), pChar->dist(m_npc)); ! bool result = m_npc->callEventHandler(EVENT_CHECKVICTIM, args); ! Py_DECREF(args); ! ! if (!result) { ! continue; ! } ! } else { ! // NPCs owned by innocent players aren't attacked ! if (pNpc) { ! if (pNpc->isTamed() && pNpc->owner()) { ! if ((pNpc->owner()->isInnocent() || pNpc->owner()->isGMorCounselor())) { ! continue; ! } ! } else { ! // Check for the AI, guards only attack other npcs if they ! // are monsters. ! Monster_Aggressive *npcai = dynamic_cast<Monster_Aggressive*>(pNpc->ai()); ! if (!npcai) { ! continue; ! } } } else { ! // Innocent players aren't attacked ! P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( pChar ); ! if ( pPlayer && (pPlayer->isInnocent() || pPlayer->isGMorCounselor()) ) continue; } } *************** *** 454,458 **** P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); ! if ( !pTarget || pTarget->isDead() || pTarget->isInnocent() ) return 0.0f; --- 469,473 ---- P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); ! if ( !pTarget || pTarget->isDead() || pTarget->isHidden() || pTarget->isInvisible() ) return 0.0f; *************** *** 495,499 **** P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); ! if ( !pTarget || pTarget->isDead() || pTarget->isInnocent() ) return 0.0f; --- 510,514 ---- P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); ! if ( !pTarget || pTarget->isDead() || pTarget->isHidden() || pTarget->isInvisible() ) return 0.0f; *************** *** 514,518 **** P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); ! if ( !pTarget || pTarget->isDead() || pTarget->isInnocent() ) return 1.0f; --- 529,533 ---- P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); ! if ( !pTarget || pTarget->isDead() || pTarget->isHidden() || pTarget->isInvisible() ) return 1.0f; Index: ai_monsters.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/ai/ai_monsters.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ai_monsters.cpp 16 Oct 2004 18:19:41 -0000 1.28 --- ai_monsters.cpp 27 Oct 2004 14:07:08 -0000 1.29 *************** *** 78,82 **** } ! return true; } --- 78,91 ---- } ! bool result = true; ! ! // Check if the NPC has a script for target validation ! if (npc->canHandleEvent(EVENT_CHECKVICTIM)) { ! PyObject *args = Py_BuildValue("(NNi)", npc->getPyObject(), victim->getPyObject(), dist); ! result = npc->callEventHandler(EVENT_CHECKVICTIM, args); ! Py_DECREF(args); ! } ! ! return result; } *************** *** 99,103 **** if (victim != target && (!npc->isTamed() || victim->attackTarget() == npc)) { // See if it's a target we want ! unsigned int dist = npc->dist(victim); if (dist < distance && validTarget(npc, victim, dist)) { target = victim; --- 108,112 ---- if (victim != target && (!npc->isTamed() || victim->attackTarget() == npc)) { // See if it's a target we want ! unsigned int dist = npc->dist(victim); if (dist < distance && validTarget(npc, victim, dist)) { target = victim; *************** *** 111,116 **** RegionIterator4Chars ri(npc->pos(), VISRANGE); for ( ri.Begin(); !ri.atEnd(); ri++ ) { ! // We limit ourself to players here ! P_PLAYER victim= dynamic_cast<P_PLAYER>( ri.GetData() ); // We don't already attack the target, right? --- 120,126 ---- RegionIterator4Chars ri(npc->pos(), VISRANGE); for ( ri.Begin(); !ri.atEnd(); ri++ ) { ! // We limit ourself to players and pets owned by players. ! P_PLAYER victim = dynamic_cast<P_PLAYER>( ri.GetData() ); ! P_NPC npcVictim = dynamic_cast<P_NPC>( ri.GetData() ); // We don't already attack the target, right? *************** *** 122,125 **** --- 132,142 ---- distance = dist; } + } else if (npcVictim && npcVictim->owner() && npcVictim != target) { + // See if it's a target we want + unsigned int dist = npc->dist(victim); + if (dist < distance && validTarget(npc, victim, dist)) { + target = victim; + distance = dist; + } } } *************** *** 147,151 **** if (!m_currentVictim || m_currentVictim->dist(m_npc) > 1) { P_CHAR target = findBestTarget(m_npc); - if (target) { m_currentVictim = target; --- 164,167 ---- |