hxp
2018-08-10 bf6eb250654cbb2b11284ef7642f7ca1f1826b20
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
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package NormalNPC_Attack_SummonNPC
# ÆÕͨNPC¹¥»÷ÕÙ»½NPC
#
# @author eggxp
# @date 2010-4-20
# @version 1.5
#
# @change: "2010-09-06 17:30" panwei GetBattleTypeº¯ÊýÐÞ¸Ä, ÐÂÔö²ÎÊý:¹¥»÷·½
# @change: "2010-11-17 19:00" adaws ¼ÓÈëNPCÕóÈÝÅж¨
# @change: "2010-11-18 11:00" adaws NPCÕóÈÝÅж¨´íÐÞ¸Ä
# @change: "2011-05-05 17:30" Alee ¹¥»÷¹ØÏµÅжÏ
# @change: "2012-02-10 20:20" Alee Ìí¼Ó¼¼Äܱط¢Éú״̬
#------------------------------------------------------------------------------ 
"""Version = 2012-02-10 20:20"""
#---------------------------------------------------------------------
import NPCCommon
import AttackCommon
import ChConfig
import IPY_GameWorld
import GameWorld
import SkillShell
import GameObj
#---------------------------------------------------------------------
 
#---------------------------------------------------------------------
 
## ÊÇ·ñ¿ÉÒÔ¹¥»÷ 
#  @param curNormalNPC ¹¥»÷·½:ÆÕͨNPC
#  @param curTagPlayer ·ÀÊØ·½:ÕÙ»½ÊÞ
#  @param skill ¼¼ÄÜ(ÎÞ->None)
#  @param tick µ±Ç°Ê±¼ä
#  @return True or False
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def GetCanAttack(curNormalNPC, curTagSummon, skill, tick):
    if not AttackCommon.CheckNPCCanAttackTag(curNormalNPC, curTagSummon, skill):
        return False
    
    return True
 
## »ñµÃ¹ØÏµ
#  @param curNormalNPC ¹¥»÷·½:ÆÕͨNPC
#  @param curTagPlayer ·ÀÊØ·½:ÕÙ»½ÊÞ
#  @param skill ¼¼ÄÜ(ÎÞ->None)
#  @param tick µ±Ç°Ê±¼ä
#  @return È磺ChConfig.Type_Relation_Enemy , ChConfig.Def_PASysMessage_None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def GetTagRelation(curNormalNPC, curTagSummon, skill, tick):
    #1.²»¹¥»÷¾«Áé
    if curTagSummon.GetType() == IPY_GameWorld.ntFairy:
        return ChConfig.Type_Relation_None , ChConfig.Def_PASysMessage_None
    
    #ÅжÏÕóÓª
    attackerCampType = NPCCommon.GetFaction(curNormalNPC)
    defenderCampType = NPCCommon.GetFaction(curTagSummon)
    
    #2.²»¹¥»÷ÕóÓªÏàͬ£¨²»°üÀ¨¶þÕß¶¼ÎªÖÐÁ¢£©
    if not (attackerCampType == ChConfig.CampType_Neutral and defenderCampType == ChConfig.CampType_Neutral): 
        if attackerCampType == defenderCampType:
            return ChConfig.Type_Relation_Friend , ChConfig.Def_PASysMessage_None
        
    #ÕÙ»½ÊÞµÄÖ÷ÈË
    curSummonOwner =  NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curTagSummon)    
    if curSummonOwner == None:
        curSummonOwner = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotNPC, curTagSummon)
    
    if curSummonOwner != None:
        if GameWorld.IsSameObj(curSummonOwner, curNormalNPC) :
            #3.²»¹¥»÷×Ô¼ºµÄÕÙ»½ÊÞ
            return ChConfig.Type_Relation_Friend , ChConfig.Def_PASysMessage_None
    
        #4.²»¹¥»÷NPCÕÙ»½ÊÞ
        if curSummonOwner.GetGameObjType() == IPY_GameWorld.gotNPC:
            return ChConfig.Type_Relation_Friend , ChConfig.Def_PASysMessage_None
            
    return ChConfig.Type_Relation_Enemy , ChConfig.Def_PASysMessage_None
 
## ¹¥»÷
#  @param curNormalNPC ¹¥»÷·½:ÆÕͨNPC
#  @param curTagPlayer ·ÀÊØ·½:ÕÙ»½ÊÞ
#  @param skill ¼¼ÄÜ(ÎÞ->None)
#  @param skillValue ¼¼ÄÜÔöÇ¿
#  @param skillPercent ¼¼ÄÜÔöÇ¿°Ù·Ö±È
#  @param skillHurtList ¼¼ÄÜÉËѪÁбí(C++½Ó¿Ú)
#  @param tick µ±Ç°Ê±¼ä
#  @return hurtType £º HurtType É˺¦½á¹¹ÌåÀà 
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoAttack(curNormalNPC, curTagSummonNPC, skill, skillValue, skillPercent, skillHurtList, tick):
    #¼ÆËã·´µ¯,Ìí¼ÓÉËѪ
    curNPCBeHP = GameObj.GetHP(curNormalNPC)
    hurtType = AttackCommon.GetHurtHP(curNormalNPC, curTagSummonNPC, skill, skillValue, skillPercent, tick)
    hurtHP = hurtType.HurtHP
    
    #Ìí¼Ó³ðºÞ
    summonControl = NPCCommon.NPCControl(curTagSummonNPC)
    summonControl.AddObjDetelToAngryList_ByAttack(curNormalNPC, hurtHP, skill)
    
    #ÅжÏNPCÊÇ·ñÉËѪ,Èç¹ûÉËѪ,˵Ã÷·´µ¯É˺¦,Òª¼ÓÉËѪÁбí
    lastHP = curNPCBeHP - GameObj.GetHP(curNormalNPC)
    
    curTagPlayer = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curTagSummonNPC)
    
    if curTagPlayer != None :
        if lastHP > 0 :
            #Ìí¼ÓÉËѪÁбí
            AttackCommon.NPCAddObjInHurtList(curTagPlayer, curNormalNPC, curNPCBeHP, lastHP)
        
        #¸øÕâ¸öÍæ¼ÒµÄÆäËûÕÙ»½ÊÞÔö¼Ó³ðºÞ(´òÖ÷ÈËÓÅÏÈ->ÕâÀïÖ»Ìí¼Ó1µã³ðºÞ)
        AttackCommon.SummonAddAngryByOwner(curNormalNPC, curTagPlayer, 1)
    
    #Ìí¼Ó¼¼ÄÜÉ˺¦Í¨ÖªÁбí,(ÓÃÓÚ¹¥»÷½áÊø,ͳһ֪ͨ¿Í»§¶Ë)
    AttackCommon.AddHurt(curTagSummonNPC, skillHurtList, hurtType.HurtType, hurtHP)
    return hurtType
 
## ´¦Àí¹¥»÷ºóµÄ½á¹û
#  @param curNormalNPC ¹¥»÷·½:ÆÕͨNPC
#  @param curTagPlayer ·ÀÊØ·½:ÕÙ»½ÊÞ
#  @param skill ¼¼ÄÜ(ÎÞ->None)
#  @param tick µ±Ç°Ê±¼ä
#  @return True
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def AttackResult(curNormalNPC, curTagSummonNPC, skill, tick):
    #»ñÈ¡ÕÙ»½ÊÞµÄÖ÷ÈË
    curTagPlayer = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curTagSummonNPC)
    if curTagPlayer != None and curTagPlayer.GetHP() > 0 :
        #½øÈëÕ½¶·×´Ì¬
        AttackCommon.SetPlayerBattleState(curTagPlayer, tick)
    
    #ÕÙ»½ÊÞËÀÍö
    if GameObj.GetHP(curTagSummonNPC) <= 0:
        curTagSummonNPCControl = NPCCommon.NPCControl(curTagSummonNPC)
        #ÕÙ»½ÊÞËÀÍö
        curTagSummonNPCControl.SetKilled()
    
    return True