| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
|   | 
| ##@package KillScreenNPC  | 
| # µ±Ç°ÆÁÄ»NPCÈ«²¿ËÀÍö  | 
| #  | 
| # @author ifo  | 
| # @date 2010-4-23  | 
| # @version 1.2  | 
| #  | 
| # ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  | 
| # @change: "2014-01-27 15:00" hxp Ôö¼ÓnpcËÀÍöÖ´ÐÐDoLogic_AttackResult  | 
| #  | 
| # VER = "2014-01-27 15:00" zhengyang Ìí¼Ó×¢ÊÍ  | 
| # VER = "2016-08-22 14:00" hxp Ö»»÷ɱ¹ÖÎï  | 
| #  | 
| # Ä£¿éÏêϸ˵Ã÷  | 
|   | 
| import LogUI  | 
| import IPY_GameWorld  | 
| import GameWorld  | 
| import ChConfig  | 
| import BaseAttack  | 
| import AttackCommon  | 
| import GameObj  | 
| import NPCCommon  | 
| import GameLogic_SealDemon  | 
|   | 
| ## GMÃüÁîÖ´ÐÐÈë¿Ú  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param playerList ²ÎÊýÁбí []  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def OnExec(curPlayer, playerList):  | 
|     if curPlayer.GetMapID() == ChConfig.Def_FBMapID_SealDemon:  | 
|         #·âħ̳»÷ɱ¹Ö  | 
|         gameWorld = GameWorld.GetGameWorld()  | 
|         lineID = gameWorld.GetPropertyID() - 1  | 
|         gameWorld.SetGameWorldDict(GameLogic_SealDemon.FBDict_RemainHP % lineID, 1)  | 
|         return  | 
|       | 
|     isMapAllNPC = 0  | 
|     if len(playerList) > 0:  | 
|         isMapAllNPC = playerList[0]  | 
|           | 
|     if isMapAllNPC:  | 
|         __KillMapAllNPC(curPlayer)  | 
|     else:  | 
|         __KillScreenNPC(curPlayer)  | 
|     return  | 
|   | 
| def __KillScreenNPC(curPlayer):  | 
|     gameMap = GameWorld.GetMap()     | 
|     tick = GameWorld.GetGameWorld().GetTick()  | 
|     for i in range(curPlayer.GetPosX()-ChConfig.Def_Screen_Area,curPlayer.GetPosX()+ChConfig.Def_Screen_Area):  | 
|         for j in range(curPlayer.GetPosY()-ChConfig.Def_Screen_Area,curPlayer.GetPosY()+ChConfig.Def_Screen_Area):  | 
|             tempObj = gameMap.GetPosObj(i,j)  | 
|             if not tempObj:  | 
|                 continue  | 
|             for k in range(0,tempObj.GetObjCount()):  | 
|                 curObj = tempObj.GetObjByIndex(k)  | 
|                 if curObj == None:  | 
|                     continue  | 
|                 if curObj.GetGameObjType() != IPY_GameWorld.gotNPC:  | 
|                     continue  | 
|                 #curNPC = GameWorld.GetNPCManager().GetNPCByIndex(curObj.GetIndex())  | 
|                 curNPC = GameWorld.GetObj(curObj.GetID(), IPY_GameWorld.gotNPC)  | 
|                 __DoKillNPC(curPlayer, curNPC, tick)  | 
|     return  | 
|   | 
|   | 
| def __KillMapAllNPC(curPlayer):  | 
|     tick = GameWorld.GetGameWorld().GetTick()  | 
|     gameNPCManager = GameWorld.GetNPCManager()  | 
|     for index in range(gameNPCManager.GetNPCCount()):  | 
|         curNPC = gameNPCManager.GetNPCByIndex(index)  | 
|         __DoKillNPC(curPlayer, curNPC, tick)  | 
|     return  | 
|   | 
| def __DoKillNPC(curPlayer, curNPC, tick):  | 
|     if not curNPC or curNPC.GetID() == 0 or GameObj.GetHP(curNPC) <= 0:  | 
|         return  | 
|     if NPCCommon.GetFaction(curNPC) == ChConfig.CampType_Justice:  | 
|         return  | 
|     if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie:  | 
|         return  | 
|     if curNPC.GetType() not in [IPY_GameWorld.ntMonster]:  | 
|         return  | 
|       | 
|     curHP = GameObj.GetHP(curNPC)  | 
|     if curPlayer.GetTeamID() > 0:  | 
|         AttackCommon.AddHurtValue(curNPC, curPlayer.GetTeamID(), ChConfig.Def_NPCHurtTypeTeam, curHP)  | 
|         AttackCommon.AddTeamPlayerHurtValue(curNPC, curPlayer.GetTeamID(), curPlayer.GetPlayerID(), curHP)  | 
|     else:  | 
|         AttackCommon.AddHurtValue(curNPC, curPlayer.GetPlayerID(), ChConfig.Def_NPCHurtTypePlayer, curHP)  | 
|       | 
|     #ͳһµ÷Óù¥»÷½áÊø¶¯×÷  | 
|     GameObj.SetHP(curNPC, 0)  | 
|     curNPC.SetDict(ChConfig.Def_PlayerKey_LastHurt, curPlayer.GetPlayerID())  | 
|     BaseAttack.DoLogic_AttackResult(curPlayer, curNPC, None, tick)  | 
| #                    curNPCControl = NPCCommon.NPCControl(curNPC)  | 
| #                    curNPCControl.SetKilled()  | 
|     return  |