#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
#-------------------------------------------------------------------------------  
 | 
#  
 | 
##@package GM.Commands.SetNPCHP  
 | 
#  
 | 
# @todo:ÉèÖÃÆÁÄ»ÖÜΧNPCѪÁ¿  
 | 
# @author hxp  
 | 
# @date 2015-3-22  
 | 
# @version 1.0  
 | 
#  
 | 
# ÏêϸÃèÊö: ÉèÖÃÆÁÄ»ÖÜΧNPCѪÁ¿  
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
"""Version = 2015-03-22 23:00"""  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
  
 | 
import IPY_GameWorld  
 | 
import GameWorld  
 | 
import ChConfig  
 | 
import GameObj  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#Â߼ʵÏÖ  
 | 
  
 | 
## GMÃüÁîÖ´ÐÐÈë¿Ú  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param msgList ²ÎÊýÁÐ±í  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def OnExec(curPlayer, msgList):  
 | 
    if len(msgList) != 2:  
 | 
        GameWorld.DebugAnswer(curPlayer, "SetNPCHP NPCID HP")  
 | 
        return  
 | 
      
 | 
    npcID, setHP = msgList  
 | 
    setHP = max(1, setHP)  
 | 
      
 | 
    curNPC = GameWorld.GetObj(npcID, IPY_GameWorld.gotNPC)  
 | 
    if curNPC:  
 | 
        __GMSetNPCHP(curPlayer, curNPC, setHP)  
 | 
        return  
 | 
      
 | 
    gameMap = GameWorld.GetMap()  
 | 
      
 | 
    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.GetObj(curObj.GetID(), IPY_GameWorld.gotNPC)  
 | 
                if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie:  
 | 
                    continue  
 | 
                  
 | 
                #²»É±¹¦ÄÜNPC  
 | 
                if curNPC.GetType() == IPY_GameWorld.ntFunctionNPC:  
 | 
                    continue   
 | 
                  
 | 
                if curNPC.GetNPCID() != npcID:  
 | 
                    continue  
 | 
                  
 | 
                __GMSetNPCHP(curPlayer, curNPC, setHP)  
 | 
      
 | 
    return  
 | 
  
 | 
def __GMSetNPCHP(curPlayer, curNPC, setHP):  
 | 
    GameObj.SetHP(curNPC, setHP)  
 | 
    curNPC.Notify_HPEx()  
 | 
    GameWorld.DebugAnswer(curPlayer, "SetNPCHP ID=%s(%s),HP=%s" % (curNPC.GetID(), curNPC.GetNPCID(), setHP))  
 | 
    return  
 | 
  
 |