hxp
5 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package Item_Add_HPMP
# @todo: Ò©¼ÁÎïÆ·Ê¹ÓÃ
#
# @author: panwei
# @date 2010-04-23
# @version 2.5
#
# @change: "2010-08-09 16:00" panwei ÐÂÔö¶à´Î»Ø¸´Ò©¼ÁÂß¼­
# @change: "2010-08-18 14:25" panwei ³ÖÐø²¹ºìºÍ³ÖÐø²¹ÀºÐ§¹û·Ö¿ª
# @change: "2011-02-23 17:30" panwei É¾³ýÍâ²ãͳһÁ÷Ïò¼Ç¼, µ¥¸öÎïÆ·µ÷ÓÃͳһÁ÷Ïò¼Ç¼
# @change: "2011-04-13 18:00" Alee Ìí¼Ó³èÎï¶à´Î²¹¸øÎïÆ·
# @change: "2011-04-18 13:30" Alee Ìí¼ÓϵͳÌáʾ²ÎÊý
# @change: "2012-06-18 18:00" jiang ÐÞ¸ÄItemCommon.DelItemº¯ÊýµÄ²ÎÊýÓÃÓÚOssʼþ¼Ç¼
# @change: "2012-07-18 17:40" Alee ¾«¼òÁ÷ÏòÊä³ö
# @change: "2013-07-17 20:10" Alee ÐÞ¸ÄϵͳÌáʾ
# @change: "2014-07-03 21:00" hxp Ôö¼ÓѪ°ü/À¶°ü²¹³äÁ¿ÎïÆ·
# @change: "2015-03-23 03:30" ljd Ò©¼Á²¹ÑªÔö¼ÓÖÎÁÆ(Ôö¼Ó¼õÉÙ»ØÑªÐ§¹û)Ч¹û
# @change: "2015-05-07 11:00" hxp ÐÞ¸ÄÌáʾ
# @change: "2015-05-22 20:30" hxp Ôö¼Ó³èÎï»ØÑªÑª°ü
# @change: "2016-11-03 20:30" xdh ËÀÍö²»»ØÑª
# @change: "2016-11-16 20:00" hxp Ôö¼Ó½ûÁÆ×´Ì¬ÏÂÏÞÖÆ
# @change: "2016-11-24 16:30" hxp Ôö¼Ó²»¿É»ØÑªµÄµØÍ¼É趨
#---------------------------------------------------------------------
#"""Version = 2016-11-24 16:30"""
#---------------------------------------------------------------------
#µ¼Èë
import ChConfig
import PlayerControl
import GameWorld
import ItemCommon
import Item_Txt_Skill_ByItemList
import PetControl
import SkillCommon
import BuffSkill
import IPY_GameWorld
import GameObj
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
#---------------------------------------------------------------------
 
#---------------------------------------------------------------------
## Âß¼­ÊµÏÖ //·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param curRoleItem µ±Ç°Ö÷½ÇʹÓõÄÎïÆ·
#  @param tick µ±Ç°Ê±¼ä
#  @return True or False ·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def UseItem(curPlayer, curRoleItem, tick):
    if GameObj.GetHP(curPlayer) <= 0 or curPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
        #ËÀÍö²»»ØÑª
        return
    
    if curPlayer.GetMapID() in ChConfig.CanNotRecoverMapIDList:
        #GameWorld.DebugLog("¸ÃµØÍ¼ÎÞ·¨Ê¹Óûָ´ÎïÆ·!")
        return
    
    if GameObj.GetPyPlayerState(curPlayer, ChConfig.Def_PlayerState_LimitAddHP):
        # ÔÝʱºìÀ¶¶¼½ûµô
        #GameWorld.DebugLog("µ±Ç°½ûÁÆ×´Ì¬Ï£¬ÎÞ·¨Ê¹ÓûØÑªÎïÆ·!")
        return
    
    useItemEff = curRoleItem.GetEffectByIndex(0)
    curEffID = useItemEff.GetEffectID()
    curEffValueA = useItemEff.GetEffectValue(0)
    curEffValueB = useItemEff.GetEffectValue(1)
 
    # HP»Ö¸´Ð§¹û±ä»¯
    if curEffID in [ChConfig.Def_Effect_AddHP_Once, ChConfig.Def_Effect_AddHP_More,
                    ChConfig.Def_Effect_AddHP_Package, ChConfig.Def_Effect_AddPetHP_More]:
        # ÑªÆ¿»Ö¸´Ð§¹û¼Ó³É
        curEffValueB += PlayerControl.GetHPCureEnhance(curPlayer)
 
    #²¹ºì(µ¥´Î)
    if curEffID == ChConfig.Def_Effect_AddHP_Once:
        return __DoLogic_AddHP_Once(curPlayer, curRoleItem, curEffValueA, curEffValueB)
    
    #²¹À¶(µ¥´Î)
    if curEffID == ChConfig.Def_Effect_AddMP_Once:
        return __DoLogic_AddMP_Once(curPlayer, curRoleItem, curEffValueA, curEffValueB)
    
    #===========================================================================
    # #²¹ºì(¶à´Î)
    # if curEffID == ChConfig.Def_Effect_AddHP_More:
    #    return __DoLogic_AddHP_More(curPlayer, curRoleItem, curEffValueA)
    # 
    # #²¹À¶(¶à´Î)
    # if curEffID == ChConfig.Def_Effect_AddMP_More:
    #    return __DoLogic_AddMP_More(curPlayer, curRoleItem, curEffValueA)
    #===========================================================================
    
    #³ÖÐø»Ø¸´Ñª»òÀ¶
    if curEffID in [ChConfig.Def_Effect_AddHP_Last, ChConfig.Def_Effect_AddMP_Last]:
        #µ÷ÓÃÎïÆ·´¥·¢¼¼ÄÜ
        return Item_Txt_Skill_ByItemList.UseItem(curPlayer, curRoleItem, tick)
    
    #Ѫ°ü»òÀ¶°üÈÝÁ¿
    if curEffID in [ChConfig.Def_Effect_AddHP_Package, ChConfig.Def_Effect_AddMP_Package, 
                    ChConfig.Def_Effect_AddPetHP_Package]:
        return __DoLogic_AddHPMP_Package(curPlayer, curRoleItem, curEffValueA, tick)
    
    if curEffID == ChConfig.Def_Effect_AddPetHP_More:
        return __DoLogic_AddPetHP_More(curPlayer, curRoleItem, curEffValueA)
    
    #ʹÓÃʧ°Ü
    GameWorld.ErrLog('Item_Add_HPMP effID = %s NoFind'%(curEffID))
    return False
 
#===============================================================================
#---µ¥´Î»Ø¸´Âß¼­--- »Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Íæ¼Ò×î´óÉúÃü(ħ·¨)ÉÏÏÞ * Ð§¹ûAÖµ + Ð§¹ûBÖµ
#===============================================================================
#---------------------------------------------------------------------
##Ò»´ÎÐÔ»ØÑªÎïÆ·Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @param effValueA Ð§¹ûAÖµ
# @param effValueB Ð§¹ûBÖµ
# @return ²¼¶ûÖµ
# @remarks Ò»´ÎÐÔ»ØÑªÎïÆ·Âß¼­´¦Àí
def __DoLogic_AddHP_Once(curPlayer, curItem, effValueA, effValueB):
    curValue = GameObj.GetHP(curPlayer)
    curMaxValue = GameObj.GetMaxHP(curPlayer)
    setFunc = "SetHP"
    sysMsgStr = 'GeRen_chenxin_21675'
    
    return __Add_HPorMP_Once(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, effValueB, sysMsgStr)
#---------------------------------------------------------------------
##Ò»´ÎÐÔ»ØÀ¶ÎïÆ·Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @param effValueA Ð§¹ûAÖµ
# @param effValueB Ð§¹ûBÖµ
# @return ²¼¶ûÖµ
# @remarks Ò»´ÎÐÔ»ØÀ¶ÎïÆ·Âß¼­´¦Àí
def __DoLogic_AddMP_Once(curPlayer, curItem, effValueA, effValueB):
    curValue = curPlayer.GetMP()
    curMaxValue = curPlayer.GetMaxMP()
    setFunc = curPlayer.SetMP
    sysMsgStr = 'GeRen_chenxin_295695'
    
    return __Add_HPorMP_Once(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, effValueB, sysMsgStr)
#---------------------------------------------------------------------
##µ¥´Î»Ø¸´Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @param curValue µ±Ç°Öµ
# @param curMaxValue µ±Ç°×î´óÖµ
# @param setFunc µ÷ÓÃÉèÖú¯Êý
# @param addPer °Ù·Ö±È¼Ó³É
# @param addValue ¹Ì¶¨Öµ
# @param sysMsgStr ÏµÍ³ÌáʾÏûÏ¢×Ö·û´®
# @return ²¼¶ûÖµ
# @remarks µ¥´Î²¹HP»òÕß²¹MP
def __Add_HPorMP_Once(curPlayer, curItem, curValue, curMaxValue, setFunc, addPer, addValue, sysMsgStr):
    if curValue == curMaxValue:
        PlayerControl.NotifyCode(curPlayer, sysMsgStr)
        return False
    
    #»Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Íæ¼Ò×î´óÉúÃü(ħ·¨)ÉÏÏÞ * Ð§¹ûAÖµ + Ð§¹ûBÖµ
    addTotalValue = int(curMaxValue * addPer / ChConfig.Def_MaxRateValue + addValue)
    #»Ø¸´ÊýÖµ
    if setFunc == "SetHP":
        GameObj.SetHP(curPlayer, min(curMaxValue, curValue + addTotalValue))
    else:
        setFunc(min(curMaxValue, curValue + addTotalValue))
    #¿Û³ýÎïÆ·
    ItemCommon.DelItem(curPlayer, curItem, 1, True)
    return True
 
#===============================================================================
#--¶à´Î»Ø¸´Âß¼­--- »Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Ð§¹ûAÖµ
#===============================================================================
#---------------------------------------------------------------------
##¶à´Î»ØÑªÎïÆ·Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @param effValueA Ð§¹ûAÖµ
# @return ²¼¶ûÖµ
# @remarks ¶à´Î»ØÑªÎïÆ·Âß¼­´¦Àí
def __DoLogic_AddHP_More(curPlayer, curItem, effValueA):
    curValue = GameObj.GetHP(curPlayer)
    curMaxValue = GameObj.GetMaxHP(curPlayer)
    setFunc = curPlayer.SetHP
    sysMsgStr = 'GeRen_chenxin_21675'
    
    return __Add_HPorMP_More(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, sysMsgStr)
#---------------------------------------------------------------------
##¶à´Î»ØÀ¶ÎïÆ·Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @param effValueA Ð§¹ûAÖµ
# @return ²¼¶ûÖµ
# @remarks ¶à´Î»ØÀ¶ÎïÆ·Âß¼­´¦Àí
def __DoLogic_AddMP_More(curPlayer, curItem, effValueA):
    curValue = curPlayer.GetMP()
    curMaxValue = curPlayer.GetMaxMP()
    setFunc = curPlayer.SetMP
    sysMsgStr = 'GeRen_chenxin_295695'
    
    return __Add_HPorMP_More(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, sysMsgStr)
#---------------------------------------------------------------------
##¶à´Î»Ö¸´Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curItem ÎïÆ·ÊµÀý
# @param curValue µ±Ç°Öµ
# @param curMaxValue µ±Ç°×î´óÖµ
# @param setFunc ÉèÖú¯Êý
# @param addValue Ìí¼ÓÖµ
# @param sysMsgStr ÏµÍ³ÌáʾÏûÏ¢×Ö·û´®
# @return ²¼¶ûÖµ
# @remarks ¶à´Î²¹HP»òÕß²¹MP
def __Add_HPorMP_More(curPlayer, curItem, curValue, curMaxValue, setFunc, addValue, sysMsgStr):
    #===========================================================================
    # #ÒѾ­ÂúÖµ
    # if curValue == curMaxValue:
    #    PlayerControl.NotifyCode(curPlayer, sysMsgStr)
    #    return False
    # 
    # curItemDurg = curItem.GetCurDurg()
    # 
    # #»Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Ð§¹ûAÖµ (×îºóÒ»´Î²»Ò»¶¨×ã¹»)
    # setFunc(min(curMaxValue, curValue + min(addValue, curItemDurg)))
    # 
    # #---ÎïÆ·Ä;üõÉÙ---
    # if curItemDurg > addValue:
    #    curItem.SetCurDurg(curItemDurg - addValue)
    # else:
    #    ItemCommon.DelItem(curPlayer, curItem, 1, True)
    #===========================================================================
        
    return True
 
 
##³èÎï¶à´Î»ØÑªÎïÆ·Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param curRoleItem ÎïÆ·ÊµÀý
# @param curEffValueA Ð§¹ûAÖµ
# @return ²¼¶ûÖµ
def __DoLogic_AddPetHP_More(curPlayer, curRoleItem, curEffValueA):
#===============================================================================
#    fightPetObj = curPlayer.GetPetMgr().GetFightPet()  # ³öÕ½µÄ³èÎï¶ÔÏó
#    
#    if fightPetObj == None:
#        PlayerControl.NotifyCode(curPlayer, "Pet_liubo_381601", [curRoleItem.GetItemTypeID()])
#        return False
#    
#    curValue = GameObj.GetHP(fightPetObj)
#    curMaxValue = GameObj.GetMaxHP(fightPetObj)
#    #ÒѾ­ÂúÖµ
#    if curValue == curMaxValue:
#        PlayerControl.NotifyCode(curPlayer, "Pet_liubo_493922")
#        return False
#    
#    curItemDurg = curRoleItem.GetCurDurg()
#    #»Ø¸´Ð§¹û = µ±Ç°ÉúÃü + Ð§¹ûAÖµ(×îºóÒ»´Î²»Ò»¶¨¹»)
#    PetControl.AddPetHP(fightPetObj, min(curEffValueA, curItemDurg))
#    
#    #---ÎïÆ·Ä;üõÉÙ---
#    if curItemDurg > curEffValueA:
#        curRoleItem.SetCurDurg(curItemDurg - curEffValueA)
#    else:
#        ItemCommon.DelItem(curPlayer, curRoleItem, 1, True)
#        
#===============================================================================
    return True
 
 
##Ѫ°ü/À¶°ü²¹³ä°ü
# @param curPlayer Íæ¼ÒʵÀý
# @param curRoleItem ÎïÆ·ÊµÀý
# @param curEffValueA Ð§¹ûAÖµ
# @return ²¼¶ûÖµ
def __DoLogic_AddHPMP_Package(curPlayer, curRoleItem, curEffValueA, tick):
    # Ê¹Óõȼ¶
    if curPlayer.GetLV() < curRoleItem.GetUseLV():
        return False
    
    if curRoleItem.GetAddSkillCount() <= 0:
        return False
    
    addSkillID = curRoleItem.GetAddSkill(0)
    
    if not addSkillID:
        return False
    
    addSkill = GameWorld.GetGameData().GetSkillBySkillID(addSkillID)
 
    buffType = SkillCommon.GetBuffType(addSkill)
    BuffSkill.AddBuffNoRefreshState(curPlayer, buffType, addSkill, tick, [curEffValueA], curPlayer)
    # ¼¤»îÍæ¼Ò(±£Ö¤³ÖÐøÐÔBuff´¦Àí¼ä¸ô)
    PlayerControl.SetIsNeedProcess(curPlayer, True)
    # ¿Û³ýÎïÆ·
    ItemCommon.DelItem(curPlayer, curRoleItem, 1, True)
    return True