hxp
2020-03-14 ad66d3a18003f0451e5620c4cc39bd6dfa63d66b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/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 IpyGameDataPY
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):
    npcID = curNPC.GetNPCID()
    isByTime = True if IpyGameDataPY.GetIpyGameDataNotLog("NPCTimeLostHP", npcID) else False
    GameObj.SetHP(curNPC, setHP, isByTime=isByTime)
    curNPC.Notify_HPEx()
    GameWorld.DebugAnswer(curPlayer, "SetNPCHP ID=%s(%s),HP=%s" % (curNPC.GetID(), curNPC.GetNPCID(), setHP))
    return