home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyc (Python 1.5) import Bladex import whrandom import AuxTran import ScorerActions import Actions import Reference import Basic_Funcs import Combat import CharStats import copy import whrandom import Damage import Stars import DMusic import GameStateAux import pdb DEBUG_SOUNDS = 0 TwinkleObjs = [ 'Gema'] THROWNHURTTIME_GAP = 45 BM_IDC = 0 BM_NONE = 1 BM_XYZ = 2 BM_XZ = 3 BM_2ANM = 4 BM_SCRIPT = 5 HEADF_ENG = 0 HEADF_ANM = 1 HEADF_ANM2SEE = 2 HEADF_ANM2ENG = 3 ASTAR_THINKING = 0 ASTAR_NOSOLVED = 1 ASTAR_SOLVED = 2 ASTAR_RECALCULATING = 3 TRUE = 1 == 1 FALSE = not TRUE WUEA_NONE = 0 WUEA_WAIT = 1 WUEA_ENDED = 2 ROUTE_WATCH = 0 ROUTE_BAY = 1 ROUTE_CHASE = 2 ROUTE_SINGLE = 3 ROUTE_BOWING = 4 CHOOSE_FIRST = -1 CHOOSE_SECOND = 1 CHOOSE_EITHER = 0 new_key_sound = Bladex.CreateSound('..\\..\\Sounds\\Manipulado-llave2.wav', 'NewKeySound') new_key_sound.Volume = 1 new_key_sound.MinDistance = 10000 new_key_sound.MaxDistance = 20000 def ChooseNearest(entity1name, entity2name): p1 = Bladex.GetEntity(entity1name) p2 = Bladex.GetEntity(entity2name) if not p1 and not p2: return CHOOSE_EITHER elif not p1: return CHOOSE_SECOND elif not p2: return CHOOSE_FIRST if p1.Life <= 0 and p2.Life <= 0: return CHOOSE_EITHER elif p1.Life <= 0: return CHOOSE_SECOND elif p2.Life <= 0: return CHOOSE_FIRST if p1.Data.group_leader: return CHOOSE_SECOND elif p2.Data.group_leader: return CHOOSE_FIRST enemy = Bladex.GetEntity(p1.GetEnemyName()) if not enemy: return CHOOSE_EITHER val = enemy.SQDistance2(p1) - enemy.SQDistance2(p2) if val < 0: return CHOOSE_FIRST elif val > 0: return CHOOSE_SECOND else: return CHOOSE_EITHER def ChooseFurthest(entity1name, entity2name): p1 = Bladex.GetEntity(entity1name) p2 = Bladex.GetEntity(entity2name) if not p1 and not p2: return CHOOSE_EITHER elif not p1: return CHOOSE_SECOND elif not p2: return CHOOSE_FIRST if p1.Life <= 0 and p2.Life <= 0: return CHOOSE_EITHER elif p1.Life <= 0: return CHOOSE_SECOND elif p2.Life <= 0: return CHOOSE_FIRST if p1.Data.group_leader: return CHOOSE_SECOND elif p2.Data.group_leader: return CHOOSE_FIRST enemy = Bladex.GetEntity(p1.GetEnemyName()) if not enemy: return CHOOSE_EITHER val = enemy.SQDistance2(p1) - enemy.SQDistance2(p2) if val < 0: return CHOOSE_SECOND elif val > 0: return CHOOSE_FIRST else: return CHOOSE_EITHER def ChooseMostLife(entity1name, entity2name): p1 = Bladex.GetEntity(entity1name) p2 = Bladex.GetEntity(entity2name) if not p1 and not p2: return CHOOSE_EITHER elif not p1: return CHOOSE_SECOND elif not p2: return CHOOSE_FIRST if p1.Life <= 0 and p2.Life <= 0: return CHOOSE_EITHER elif p1.Life <= 0: return CHOOSE_SECOND elif p2.Life <= 0: return CHOOSE_FIRST l1 = p1.Life l2 = p2.Life val = l2 - l1 if val < 0: return CHOOSE_FIRST elif val > 0: return CHOOSE_SECOND else: return ChooseNearest(entity1name, entity2name) def ChooseFighter(entity1name, entity2name): p1 = Bladex.GetEntity(entity1name) p2 = Bladex.GetEntity(entity2name) if not p1 and not p2: return CHOOSE_EITHER elif not p1: return CHOOSE_SECOND elif not p2: return CHOOSE_FIRST if p1.Life <= 0 and p2.Life <= 0: return CHOOSE_EITHER elif p1.Life <= 0: return CHOOSE_SECOND elif p2.Life <= 0: return CHOOSE_FIRST enemy = Bladex.GetEntity(p1.GetEnemyName()) if not (p1.InCombat): if not (p2.InCombat): return ChooseNearest(entity1name, entity2name) return CHOOSE_SECOND elif not (p2.InCombat): return CHOOSE_FIRST if not p1.CanISee(enemy): if not p2.CanISee(enemy): return ChooseMostLife(entity1name, entity2name) return CHOOSE_SECOND elif not p2.CanISee(enemy): return CHOOSE_FIRST return ChooseMostLife(entity1name, entity2name) def ChooseLeaderOutOfCombat(entity1name, entity2name): p1 = Bladex.GetEntity(entity1name) p2 = Bladex.GetEntity(entity2name) if p1.CanISee(p2): if not p2.CanISee(p1): return CHOOSE_FIRST elif p2.CanISee(p1): return CHOOSE_SECOND enemy = Bladex.GetEntity(p1.GetEnemyName()) if p1.CanISee(enemy): if not p2.CanISee(enemy): return CHOOSE_FIRST elif p2.CanISee(enemy): return CHOOSE_SECOND return ChooseFurthest(entity1name, entity2name) def ChooseLeader(entity1name, entity2name): p1 = Bladex.GetEntity(entity1name) p2 = Bladex.GetEntity(entity2name) if not p1 and not p2: return CHOOSE_EITHER elif not p1: return CHOOSE_SECOND elif not p2: return CHOOSE_FIRST if p1.Life <= 0 and p2.Life <= 0: return CHOOSE_EITHER elif p1.Life <= 0: return CHOOSE_SECOND elif p2.Life <= 0: return CHOOSE_FIRST enemy = Bladex.GetEntity(p1.GetEnemyName()) if p1.Data.group_fighter: if p2.InCombat and p2.CanISee(enemy) and p2.GetActionMode() == ROUTE_CHASE and p2.AstarState == ASTAR_SOLVED: return CHOOSE_SECOND return CHOOSE_FIRST elif p2.Data.group_fighter: if p1.InCombat and p1.CanISee(enemy) and p1.GetActionMode() == ROUTE_CHASE and p1.AstarState == ASTAR_SOLVED: return CHOOSE_FIRST return CHOOSE_SECOND if not (p1.InCombat): if not (p2.InCombat): return ChooseLeaderOutOfCombat(entity1name, entity2name) return CHOOSE_SECOND elif not (p2.InCombat): return CHOOSE_FIRST if not p1.CanISee(enemy): if not p2.CanISee(enemy): return ChooseMostLife(entity1name, entity2name) return CHOOSE_SECOND elif not p2.CanISee(enemy): return CHOOSE_FIRST return ChooseMostLife(entity1name, entity2name) class NPCPerson(Basic_Funcs.PlayerPerson): InvestigatingSound = FALSE SoundPriorities = [ -1.0, -1.0, -1.0, -1.0, -1.0] Asleep = FALSE SleepYOffset = 1100.0 group_fighter = TRUE group_leader = TRUE AttackingNPC = FALSE imusic_noseen_warp = 0 DelayNoSeenFuncMusicBackUp = 0 last_insulting_time_1AA = -1 LastThrownHurtTime = 0 AttacksOwnKind = FALSE AttackNPCTime = 5 Angry = FALSE Furious = FALSE ChanceOfFuryOnHurt = 0.0 ChanceOfFuryOnLeaderDeath = 0.0 ImpatientAttackTime = 5.0 def __init__(self, me): Basic_Funcs.PlayerPerson.__init__(self, me) self.SoundPriorities = [ -1.0, -1.0, -1.0, -1.0, -1.0] AddMyWatchAnims(me.Name) self.NPC = 1 self.ResetCombat(me.Name) self.NoFXOnHit = FALSE me.SubscribeToList('Listeners') me.Deaf = 0 me.CombatGroup = 'Group of ' + me.Name me.SeeFunc = self.StdSeeTheEnemy me.HearFunc = self.StdHearFunc me.DelayNoSeenFunc = self.StdDelayNoSeen me.NoAllowedAreaFunc = self.StdNoAllowedArea me.EnemyNoAllowedAreaFunc = self.StdEnemyNoAllowedArea me.ImHurtFunc = self.StdImHurt me.ImDeadFunc = self.StdImDead me.EnemyDeadFunc = self.StdEnemyDead me.AnmEndedFunc = self.StdAnmEnded me.EnterCloseFunc = self.StdEnterClose me.EnterLargeFunc = self.StdEnterLarge me.EnterPrimaryAAFunc = self.StdEnterPrimaryAA me.EnterSecondaryAAFunc = self.StdEnterSecondaryAA me.CharSeeingEnemyFunc = self.StdCharSeeingEnemy me.ToggleCombatFunc = self.StdToggleCombat self.WeaponsOut(me.Name) def ResetCombat(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: me.BlockingPropensity = 0.5 me.AttackList = [] me.CombatDistFlag = not (self.group_fighter) self.AttacksOwnKind = FALSE self.AttackNPCTime = 5 self.Angry = FALSE self.Furious = FALSE self.ChanceOfFuryOnHurt = 0.0 self.ChanceOfFuryOnLeaderDeath = 0.0 self.ImpatientAttackTime = 5.0 def StopNPCsAttacking(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: enemy = Bladex.GetEntity(me.GetEnemyName()) if enemy and enemy.Life > 0 and enemy.Data.NPC: enemy.Data.StopAttackingNPC(enemy.Name) self.StopAttackingNPC(EntityName) def StopAttackingNPC(self, EntityName): if self.AttackingNPC: self.AttackingNPC = FALSE me = Bladex.GetEntity(EntityName) if me and me.Life > 0: enemy = Bladex.GetEntity(me.GetEnemyName()) if not enemy or enemy.Data.NPC: enemy = Bladex.GetEntity('Player1') if not enemy: print EntityName + ': Cannot access handle to Player, in StopAttackingNPC()' return None Damage.DropInvalidObjectsOnImpact(EntityName) me.Wuea = Reference.WUEA_ENDED me.InterruptCombat() me.SetEnemy(enemy) MaxCombatDist = Bladex.GetCharType(me.CharType, me.CharTypeExt).MaxCombatDist if me.SQDistance2(enemy) < MaxCombatDist * MaxCombatDist or me.CanISee(enemy): me.SetActiveEnemy(enemy) me.Chase(enemy, me.ActionAreaMax) if me.GetActionMode() == ROUTE_CHASE and self.IsArcher(): self.Switch2MeleeWeapons(EntityName) else: me.LaunchWatch() Damage.DropInvalidObjectsOnImpact(EntityName) me.Wuea = Reference.WUEA_ENDED me.LaunchAnmType('attack_look', 1) self.CheckToJoin(EntityName) def StdRouteEnded(self, EntityName): pass def StdEndChase(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: if not (me.InCombat): Reference.debugprint(EntityName + ': I have ended a chase without combat (StdEndChase1)') enemy_pos = me.EnemyLastSeen if Actions.IsFacingPos(EntityName, enemy_pos[0], enemy_pos[2]): self.StdEndChase2(EntityName) else: Actions.TurnToFacePos(EntityName, enemy_pos[0], enemy_pos[2]) me.RouteEndedFunc = self.StdEndChase2 def StdEndChase2(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: Reference.debugprint(EntityName + ': I have ended a chase without combat (StdEndChase2)') me.RouteEndedFunc = self.StdRouteEnded me.StopLooking() self.InvestigatingSound = FALSE enemy = Bladex.GetEntity(me.GetEnemyName()) if enemy: pass enemy_in_sight = me.CanISee(enemy) if enemy_in_sight and enemy.InsideActionArea(me.ActionAreaMax): if Actions.IsFacingEntity(EntityName, me.GetEnemyName()): self.LaunchMyWatch(EntityName) else: Actions.TurnToFaceEntity(EntityName, me.GetEnemyName()) me.RouteEndedFunc = self.LaunchMyWatch elif enemy_in_sight: self.StdSeeEnemyUnreachable(EntityName) else: Damage.DropInvalidObjectsOnImpact(EntityName) me.Wuea = Reference.WUEA_ENDED if me.GetActionMode() != ROUTE_WATCH: self.LaunchMyWatch(EntityName) me.LaunchAnmType('look_around', 1) me.DelayNoSeenFunc = self.EndChaseDelayNoSeen if me.Data.imusic_noseen_warp == 1: DMusic.RestoreMusicWarperDelayNoSeenFunc(EntityName) def PutMeToSleep(self, EntityName): if not (self.Asleep): me = Bladex.GetEntity(EntityName) me.SetTmpAnmFlags(1, 1, 0, 0, 1, 1) me.Position = (me.Position[0], me.Position[1] + self.SleepYOffset, me.Position[2]) me.LaunchAnimation('Tkn_sleep') me.Blind = 1 self.Asleep = TRUE def WakeMeUp(self, EntityName): if self.Asleep: me = Bladex.GetEntity(EntityName) me.Blind = 0 me.Position = (me.Position[0], me.Position[1] - self.SleepYOffset * 0.5, me.Position[2]) if me.AnimName[:5] == 'Sleep' or me.AnimName[:5] == 'sleep': me.Wuea = Reference.WUEA_ENDED me.LaunchAnmType('alarm01', 1) self.Asleep = FALSE def StdStartChase(self, EntityName): me = Bladex.GetEntity(EntityName) enemy = Bladex.GetEntity(me.GetEnemyName()) me.AnmEndedFunc = self.StdAnmEnded if enemy.InsideActionArea(me.ActionAreaMax) and self.IsArcher() and me.InsideActionArea(me.ActionAreaMax): self.StdStartChase2(EntityName) else: self.StdSeeEnemyUnreachable(EntityName) def StdSeeEnemyUnreachable(self, EntityName, check1aaTo2aa = 1): me = Bladex.GetEntity(EntityName) Reference.debugprint(EntityName + ': Enemy Unreachable') if Bladex.GetTime() - self.LastThrownHurtTime < THROWNHURTTIME_GAP: return None if me.InsideActionArea(me.ActionAreaMin) and check1aaTo2aa and not (me.Will1aaTo2aa): back_area_min = me.ActionAreaMin back_area_max = me.ActionAreaMax me.ActionAreaMin = 0 me.ActionAreaMax = 0 enemy = Bladex.GetEntity(me.GetEnemyName()) des_pos = enemy.Position me.GoToJogging = 1 if me.GoTo(des_pos[0], des_pos[1], des_pos[2]): me.ActionAreaMin = back_area_min me.ActionAreaMax = back_area_max else: Reference.debugprint(EntityName + ': GoTo enemy_pos not working, with action area 0!') me.ActionAreaMin = back_area_min me.ActionAreaMax = back_area_max return None elif me.InsideActionArea(me.ActionAreaMin): if me.GetActionMode() != ROUTE_WATCH: self.LaunchMyWatch(EntityName) if not Actions.IsFacingEntity(EntityName, me.GetEnemyName()): Actions.TurnToFaceEntity(EntityName, me.GetEnemyName()) else: curr_time = Bladex.GetTime() if curr_time - self.last_insulting_time_1AA > 4: insult_prob = whrandom.uniform(0.0, 1.0) if insult_prob < 0.8: Combat.Insult(EntityName) insult_var = whrandom.uniform(-2.0, 1.0) self.last_insulting_time_1AA = Bladex.GetTime() + insult_var else: back_area_min = me.ActionAreaMin back_area_max = me.ActionAreaMax me.ActionAreaMax = 0 me.ActionAreaMin = 0 init_pos = me.InitPos me.InvertedRoute = 1 if me.GoTo(init_pos[0], init_pos[1], init_pos[2]): me.ActionAreaMin = back_area_min me.ActionAreaMax = back_area_max else: Reference.debugprint(EntityName + ': GoTo init_pos not working, with action area 0!') me.ActionAreaMin = back_area_min me.ActionAreaMax = back_area_max def StdStartChase2(self, EntityName): me = Bladex.GetEntity(EntityName) enemy = Bladex.GetEntity(me.GetEnemyName()) oldActionMode = me.GetActionMode() if oldActionMode == ROUTE_WATCH or oldActionMode == ROUTE_BOWING: me.RouteEndedFunc = self.StdRouteEnded if oldActionMode == ROUTE_CHASE: pass else: self.ResetCombat(EntityName) last_time_seen = me.LastTimeSeen me.Chase(enemy, me.ActionAreaMax) if me.GetActionMode() == ROUTE_CHASE: if self.IsArcher(): self.Switch2MeleeWeapons(EntityName) elif Bladex.GetTime() - last_time_seen > 40 or last_time_seen < 0: me.LaunchAnmType('alarm01', 1) self.InvestigatingSound = FALSE me.RouteEndedFunc = self.StdEndChase if me.Aim or Actions.CurrentlyBowing(EntityName): me.Wuea = Reference.WUEA_ENDED Actions.EndBowMode(EntityName) else: self.StdChaseFailed(EntityName, oldActionMode) def IsArcher(self): return Actions.StatL(self.Name) == Actions.RA_BOW def StdChaseFailed(self, EntityName, oldActionMode): me = Bladex.GetEntity(EntityName) newActionMode = me.GetActionMode() if newActionMode == ROUTE_BOWING: Reference.debugprint(EntityName + ': I cannot start a chase so I will bow') elif oldActionMode == ROUTE_WATCH: Reference.debugprint(EntityName + ': I cannot start a chase so I will watch again') self.LaunchMyWatch(EntityName) enemy = Bladex.GetEntity(me.GetEnemyName()) if enemy and me.CanISee(enemy) and me.InsideActionArea(me.ActionAreaMin): inv = me.GetInventory() if inv.HasBow and me.RangeActive: enemy_pos = me.EnemyLastSeen if not Actions.IsFacingPos(EntityName, enemy_pos[0], enemy_pos[2]): Actions.TurnToFacePos(EntityName, enemy_pos[0], enemy_pos[2]) else: self.StdSeeEnemyUnreachable(EntityName, 0) def GiveOrders(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0 and self.NextOrdersTo and self.NextOrders: me.Wuea = Reference.WUEA_ENDED me.SetTmpAnmFlags(1, 0, 1, 0, 1, 1) me.LaunchAnmType('order', 1) me.AnmEndedFunc = self.GiveOrders2 def GiveOrders2(self, EntityName): me = Bladex.GetEntity(EntityName) def CheckToJoin(self, EntityName): me = Bladex.GetEntity(EntityName) ally_list = me.GetCombatants() for ally_name in ally_list: if ally_name != EntityName: ally = Bladex.GetEntity(ally_name) if ally: return None self.CheckGoodGroupFormation(EntityName, TRUE) def JoinGroup(self, EntityName, GroupName): me = Bladex.GetEntity(EntityName) me.CombatGroup = GroupName self.group_fighter = FALSE self.group_leader = FALSE if not (self.Furious): me.CombatDistFlag = 1 self.CheckGoodGroupFormation(EntityName, TRUE) def LeaveGroup(self, EntityName): me = Bladex.GetEntity(EntityName) if self.group_fighter or self.group_leader: self.SetGroupFormation(EntityName, FALSE, self.group_leader) NewCombatGroup = 'Group of ' + me.Name if me.CombatGroup == NewCombatGroup: NewCombatGroup = NewCombatGroup + '... Splitters' me.CombatGroup = NewCombatGroup self.group_leader = TRUE self.group_fighter = TRUE def StdSeeTheEnemy(self, EntityName): me = Bladex.GetEntity(EntityName) Reference.debugprint(EntityName + ': I see the enemy') life = me.Life if life > 0.0: if me.Blind == 1: pass else: me.LookAtEntity(me.GetEnemyName()) if me.GetActionMode() == ROUTE_BAY: me.Wuea = Reference.WUEA_ENDED self.CheckToJoin(EntityName) if me.GetActionMode() != ROUTE_CHASE: self.StdStartChase(EntityName) if me.GetActionMode() == ROUTE_BOWING: if self.AimPressed: angle = Reference.TARGET_ANGLE_MAX - me.Accuracy * (Reference.TARGET_ANGLE_MAX - Reference.TARGET_ANGLE_MIN) if me.AimOffTarget < angle: print 'Releasing Arrow' Actions.TestReleaseArrow(EntityName) elif me.Wuea != Reference.WUEA_WAIT: print 'Drawing Bow' Actions.TestDrawBow(EntityName) elif me.Aim or Actions.CurrentlyBowing(EntityName): me.Wuea = Reference.WUEA_ENDED Actions.EndBowMode(EntityName) me.SetOnFloor() else: print EntityName + ': Cannot get a handle on me' def GetSoundType(self, SoundName): if Reference.SoundTypes.has_key(SoundName): return Reference.SoundTypes[SoundName][0] return Reference.SND_UNCLASSIFIED def GetSoundPriority(self, EntityName, SoundName, Volume): me = Bladex.GetEntity(EntityName) priority = Reference.SND_UNCLASSIFIED sound_type = self.GetSoundType(SoundName) if sound_type != Reference.SND_UNCLASSIFIED: priority = self.SoundPriorities[sound_type] return priority + Volume * 0.01 def IsSoundHigherPriority(self, EntityName, SoundName, Volume): me = Bladex.GetEntity(EntityName) priority = self.GetSoundPriority(EntityName, SoundName, Volume) if priority <= 0.0: return FALSE elif not (self.InvestigatingSound) or me.GetActionMode() != ROUTE_SINGLE: return TRUE else: investigating_priority = self.GetSoundPriority(EntityName, self.InvestigatingSoundName, self.InvestigatingSoundVolume) return priority > investigating_priority def StdInvestigateSound(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: me.StartLooking(self.InvestigatingSoundX, self.InvestigatingSoundY, self.InvestigatingSoundZ) Reference.debugprint(EntityName + ': Im going to investigate ' + self.InvestigatingSoundName + ' at pos ' + `self.InvestigatingSoundX` + ', ' + `self.InvestigatingSoundY` + ', ' + `self.InvestigatingSoundZ`) me.GoToSneaking = 1 me.GoTo(self.InvestigatingSoundX, self.InvestigatingSoundY, self.InvestigatingSoundZ) if me.AstarState != ASTAR_SOLVED: me.GoToSneaking = 0 if Actions.IsFacingPos(EntityName, self.InvestigatingSoundX, self.InvestigatingSoundZ): self.LaunchMyWatch(EntityName) else: Actions.TurnToFacePos(EntityName, self.InvestigatingSoundX, self.InvestigatingSoundZ) me.RouteEndedFunc = self.LaunchMyWatch else: me.Heard = TRUE me.RouteEndedFunc = self.StdEndChase2 def CanGoTo(self, EntityName, x, y, z): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: me.GoTo(x, y, z) if me.AstarState == ASTAR_SOLVED: me.LaunchWatch() return TRUE return FALSE def StdHearFunc(self, EntityName, SoundName, x, y, z, Volume): me = Bladex.GetEntity(EntityName) if me and me.Life > 0 and me.Deaf != 1: if Volume < Bladex.GetCharType(me.CharType, me.CharTypeExt).HearMinVolume: return None if me.InCombat: return None if DEBUG_SOUNDS: pdb.set_trace() sound_type = self.GetSoundType(SoundName) if sound_type == Reference.SND_UNCLASSIFIED: return None enemy = Bladex.GetEntity(me.GetEnemyName()) if not enemy and not (enemy.Person) or enemy.Life <= 0: return None if sound_type == Reference.SND_NOISYPC: if enemy.LastSound != SoundName: return None elsp = enemy.LastSoundPosition if elsp[0] != x and elsp[1] != y or elsp[2] != z: return None if me.LastSound == SoundName: lsp = me.LastSoundPosition if lsp[0] == x and lsp[1] == y and lsp[2] == z: return None if Bladex.GetTime() - self.LastThrownHurtTime < THROWNHURTTIME_GAP * 0.5: return None if me.CanISee(enemy): return None if self.Asleep: self.WakeMeUp(EntityName) if me.GetActionMode() == ROUTE_BAY and me.CanGoTo(x, y, z) == 0: return None if self.group_leader: self.DealtWithSound = SoundName self.DealtWithSoundX = x self.DealtWithSoundY = y self.DealtWithSoundZ = z investigator = self.GetGroupFighter(EntityName) if not investigator and investigator.GetActionMode() == ROUTE_CHASE or investigator.InCombat: investigator = me else: group_leader = self.GetGroupLeader(EntityName) if group_leader: if not group_leader.InCombat: pass if not (group_leader.GetActionMode() == ROUTE_CHASE): try: ldr_data = group_leader.Data if SoundName == ldr_data.DealtWithSound and x == ldr_data.DealtWithSoundX and y == ldr_data.DealtWithSoundY and z == ldr_data.DealtWithSoundZ: return None except: pass group_leader.HearFunc(group_leader.Name, SoundName, x, y, z, Volume) if not (me.InCombat) and me.GetActionMode() != ROUTE_CHASE: if not Actions.IsFacingPos(EntityName, x, z): Actions.QuickTurnToFacePos(EntityName, x, z) return None else: investigator = me if investigator.Data.InvestigatingSound and SoundName == investigator.Data.InvestigatingSoundName and x == investigator.Data.InvestigatingSoundX and y == investigator.Data.InvestigatingSoundY and z == investigator.Data.InvestigatingSoundZ: return None elif investigator.Data.IsSoundHigherPriority(investigator.Name, SoundName, Volume) and investigator.GetActionMode() != ROUTE_CHASE and not (investigator.InCombat): me.StartLooking(x, y, z) if not Actions.IsFacingPos(EntityName, x, z): Actions.QuickTurnToFacePos(EntityName, x, z) if investigator.Name != EntityName: if not Actions.IsFacingPos(investigator.Name, x, z): Actions.QuickTurnToFacePos(investigator.Name, x, z) if not (investigator.Data.InvestigatingSound): if me.AnimName[:4] != 'hurt' and me.AnimName[:5] != 'sleep': if investigator.Data.CanGoTo(investigator.Name, x, y, z): me.Wuea = Reference.WUEA_ENDED me.SetTmpAnmFlags(1, 0, 1, 0, 1, 1) me.LaunchAnmType('alarm01', 1) investigator.Data.InvestigatingSound = TRUE investigator.Data.InvestigatingSoundName = SoundName investigator.Data.InvestigatingSoundVolume = Volume investigator.Data.InvestigatingSoundX = x investigator.Data.InvestigatingSoundY = y investigator.Data.InvestigatingSoundZ = z if me.AnimName == 'alarm01': if EntityName != investigator.Name: self.NextOrdersTo = [] self.NextOrdersTo.append(investigator.Name) self.NextOrders = investigator.Data.StdInvestigateSound me.AnmEndedFunc = self.GiveOrders else: me.AnmEndedFunc = self.StdInvestigateSound elif EntityName != investigator.Name: self.NextOrdersTo = [] self.NextOrdersTo.append(investigator.Name) self.NextOrders = investigator.Data.StdInvestigateSound self.GiveOrders(EntityName) else: self.StdInvestigateSound(EntityName) def LaunchMyWatch(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: enemy = Bladex.GetEntity(me.GetEnemyName()) if not enemy or not me.CanISee(enemy): me.StopLooking() me.GoToJogging = 0 me.GoToSneaking = 0 me.LaunchWatch() def Turn180AndWatch(self, EntityName): me = Bladex.GetEntity(EntityName) Actions.Turn180(EntityName) me.RouteEndedFunc = self.LaunchMyWatch def LaunchMyPatrol(self, EntityName): me = Bladex.GetEntity(EntityName) me.StopLooking() init_pos = me.InitPos my_pos = me.Position x = init_pos[0] - my_pos[0] z = init_pos[2] - my_pos[2] DiscountDistance = 1000.0 if not me.InsideActionArea(me.ActionAreaMin) or x * x + z * z > DiscountDistance * DiscountDistance: me.GoTo(init_pos[0], init_pos[1], init_pos[2]) Reference.debugprint(EntityName + ': Going 2 InitPos - self.LaunchMyPatrol') me.RouteEndedFunc = self.Turn180AndWatch else: Reference.debugprint(EntityName + ': Not back2init cause quite close and inside MinAA') def StdDelayNoSeen(self, EntityName): me = Bladex.GetEntity(EntityName) if me.Life > 0: if not (self.Asleep) and not (me.Blind): if me.Aim or Actions.CurrentlyBowing(EntityName): me.Wuea = Reference.WUEA_ENDED Actions.EndBowMode(EntityName) me.SetOnFloor() Reference.debugprint(EntityName + ': Im in StdDelayNoSeen') me.StopLooking() enemy_name = me.GetEnemyName() enemy = Bladex.GetEntity(enemy_name) if me.GetActionMode() != ROUTE_CHASE: if me.GetActionMode() != ROUTE_SINGLE and me.GetActionMode() != ROUTE_BAY: Reference.debugprint(EntityName + ': I am not chasing') self.LaunchMyPatrol(EntityName) else: Reference.debugprint(EntityName + ': I am chasing') if me.AstarState != ASTAR_SOLVED: lastseenpos = me.EnemyLastSeen me.StartLooking(lastseenpos[0], lastseenpos[1], lastseenpos[2]) if Actions.IsFacingPos(EntityName, lastseenpos[0], lastseenpos[2]): self.LaunchMyWatch(EntityName) else: Actions.TurnToFacePos(EntityName, lastseenpos[0], lastseenpos[2]) me.RouteEndedFunc = self.LaunchMyWatch def EndChaseDelayNoSeen(self, EntityName): me = Bladex.GetEntity(EntityName) Reference.debugprint(EntityName + ': Im in EndChaseDelayNoSeen!') if me.Life > 0: me.DelayNoSeenFunc = self.StdDelayNoSeen self.StdDelayNoSeen(EntityName) if me.Data.imusic_noseen_warp == 1: DMusic.RestoreMusicWarperDelayNoSeenFunc(EntityName) def StdNoAllowedArea(self, EntityName): me = Bladex.GetEntity(EntityName) Reference.debugprint(EntityName + ': Im entering non-allowed area!') back_area_min = me.ActionAreaMin back_area_max = me.ActionAreaMax me.ActionAreaMin = 0 me.ActionAreaMax = 0 init_pos = me.InitPos me.InvertedRoute = 0 if me.GoTo(init_pos[0], init_pos[1], init_pos[2]): me.ActionAreaMin = back_area_min me.ActionAreaMax = back_area_max def StdEnemyNoAllowedArea(self, EntityName): me = Bladex.GetEntity(EntityName) enemy = Bladex.GetEntity(me.GetEnemyName()) if me.GetActionMode() != ROUTE_CHASE: return None init_pos = me.InitPos if not me.InsideActionArea(me.ActionAreaMin) and me.InsideActionArea(me.ActionAreaMax): me.InvertedRoute = 1 else: me.InvertedRoute = 0 me.GoTo(init_pos[0], init_pos[1], init_pos[2]) Reference.debugprint(EntityName + ': My enemy has entered a non-allowed area') def StdImHurt(self, EntityName): Reference.debugprint(EntityName + ': Oh! That hurt.') me = Bladex.GetEntity(EntityName) if self.NPC == 0: return None if self.Asleep: self.WakeMeUp(EntityName) def GroupCoveringPoint(self, EntityName, x, y, z, include_me = TRUE): me = Bladex.GetEntity(EntityName) if me.CombatGroup: memberlist = me.GetGroupMembers() for member_name in memberlist: if include_me or member_name != EntityName: member = Bladex.GetEntity(member_name) if member.TestPosInOwnBox(x, y, z, 1.05): return TRUE elif include_me: return me.TestPosInOwnBox(x, y, z, 1.05) return FALSE def GetGroupLeader(self, EntityName): me = Bladex.GetEntity(EntityName) if me.CombatGroup: memberlist = me.GetGroupMembers() for member_name in memberlist: member = Bladex.GetEntity(member_name) return None def GetGroupFighter(self, EntityName): me = Bladex.GetEntity(EntityName) if me.CombatGroup: memberlist = me.GetGroupMembers() for member_name in memberlist: member = Bladex.GetEntity(member_name) return None def CheckGoodGroupFormation(self, EntityName, include_me): me = Bladex.GetEntity(EntityName) if me.CombatGroup: memberlist = me.GetGroupMembers() if len(memberlist) > 1: fighter_found = None leader_found = None enemy = Bladex.GetEntity(me.GetEnemyName()) for member_name in memberlist: if include_me or member_name != EntityName: member = Bladex.GetEntity(member_name) if not leader_found and member and member.Data.group_leader and member.Life > 0: leader_found = member.Name else: member.Data.group_leader = FALSE if not fighter_found and member and member.Data.group_fighter and member.Life > 0 and enemy and member.CanISee(enemy): member.CombatDistFlag = 0 fighter_found = member.Name elif member.Data.group_fighter: if not (member.Data.Furious): member.CombatDistFlag = 1 member.Data.group_fighter = FALSE if fighter_found and leader_found and fighter_found != leader_found: return None self.SetGroupFormation(EntityName, include_me, not leader_found) elif include_me: self.group_leader = TRUE self.group_fighter = TRUE me.CombatDistFlag = 0 return None def CallGroupMemberFunc(self, EntityName, func, include_me): me = Bladex.GetEntity(EntityName) def SetNoGroupFighter(self, EntityName): me = Bladex.GetEntity(EntityName) if me.CombatGroup: memberlist = me.GetGroupMembers() for member_name in memberlist: member = Bladex.GetEntity(member_name) member.Data.group_fighter = FALSE def SetNoGroupLeader(self, EntityName): me = Bladex.GetEntity(EntityName) def SetGroupFormation(self, EntityName, include_me, new_leader_needed): if new_leader_needed: self.SetGroupLeader(EntityName, include_me) self.SetGroupFighter(EntityName, include_me) def SetGroupFighter(self, EntityName, include_me): me = Bladex.GetEntity(EntityName) if me.CombatGroup: self.SetNoGroupFighter(EntityName) memberlist = me.GetGroupMembers() if not include_me and memberlist.count(EntityName) > 0: memberlist.remove(EntityName) if len(memberlist) > 0: memberlist.sort(ChooseFighter) member = Bladex.GetEntity(memberlist[0]) if member and member.Life > 0: member.CombatDistFlag = 0 member.Data.group_fighter = TRUE def SetGroupLeader(self, EntityName, include_me): me = Bladex.GetEntity(EntityName) if me.CombatGroup: self.SetNoGroupLeader(EntityName) memberlist = me.GetGroupMembers() if not include_me and memberlist.count(EntityName) > 0: memberlist.remove(EntityName) if len(memberlist) > 0: memberlist.sort(ChooseLeader) member = Bladex.GetEntity(memberlist[0]) if member and member.Life > 0: member.Data.group_leader = TRUE def Respond2Thrown(self, EntityName, AttackerName): me = Bladex.GetEntity(EntityName) if AttackerName: enemy = Bladex.GetEntity(me.GetEnemyName()) if enemy and not enemy.InsideActionArea(me.ActionAreaMax): self.LastThrownHurtTime = Bladex.GetTime() init_pos = me.InitPos me.InvertedRoute = 0 me.GoToJogging = 1 if me.GoTo(init_pos[0], init_pos[1], init_pos[2]): me.RouteEndedFunc = self.Turn180AndWatch elif me.GetActionMode() == ROUTE_WATCH: Actions.QuickTurnToFaceEntity(EntityName, AttackerName) else: print 'Respond2Thrown->Bug?' def RespondToHit(self, EntityName, AttackerName, DamagePoints, DamageZone, Shielded): Basic_Funcs.PlayerPerson.RespondToHit(self, EntityName, AttackerName, DamagePoints, DamageZone, Shielded) if AttackerName and AttackerName != 'BWorld' and AttackerName != EntityName: me = Bladex.GetEntity(EntityName) if me and me.Life > 0: chartype = Bladex.GetCharType(me.CharType, me.CharTypeExt) if me.Life <= CharStats.GetCharMaxLife(me.Kind, me.Level) * 0.25 and whrandom.random() < self.ChanceOfFuryOnHurt: self.GetFurious(EntityName) damage_factor = DamagePoints / (me.Life + DamagePoints) if damage_factor > me.Data.DamageFactorNone: Reference.debugprint(EntityName + ': Im being attacked by ' + AttackerName) if AttackerName != me.GetEnemyName(): Reference.debugprint(EntityName + ': ' + AttackerName + ' is not my enemy!') attacker = Bladex.GetEntity(AttackerName) if attacker and self.AttacksOwnKind or attacker.Kind != me.Kind: Reference.debugprint(EntityName + ': I will attack back') if not (attacker.Data.NPC) or not (self.AttackingNPC): Reference.debugprint('attacker.Data.NPC: ' + `attacker.Data.NPC` + ', self.AttackingNPC: ' + `self.AttackingNPC`) Damage.DropInvalidObjectsOnImpact(EntityName) me.Wuea = Reference.WUEA_ENDED me.InterruptCombat() me.SetEnemy(attacker) me.SetActiveEnemy(attacker) me.Chase(attacker, me.ActionAreaMax) if me.GetActionMode() == ROUTE_CHASE and self.IsArcher(): self.Switch2MeleeWeapons(EntityName) if attacker.Data.NPC: self.AttackingNPC = TRUE Bladex.AddScheduledFunc(Bladex.GetTime() + self.AttackNPCTime, self.StopNPCsAttacking, (EntityName,)) if me.CombatGroup == attacker.CombatGroup: self.LeaveGroup(EntityName) self.CheckToJoin(EntityName) return None if me.CombatGroup and self.group_fighter and me.Life > 0: self.SetGroupFormation(EntityName, TRUE, FALSE) def HitFunc(self, EntityName, WeaponName, Cx, Cy, Cz, DirX, DirY, DirZ, wcx, wcy, wcz, wdx, wdy, wdz): me = Bladex.GetEntity(EntityName) if me and me.Life > 0: if not (me.InCombat): weapon = Bladex.GetEntity(WeaponName) if weapon and weapon.Parent: if not Actions.IsFacingEntity(EntityName, weapon.Parent): Actions.QuickTurnToFaceEntity(EntityName, WeaponName) else: pos = me.Position x = pos[0] + (Cx - pos[0]) * 1000.0 z = pos[2] + (Cz - pos[2]) * 1000.0 if not Actions.IsFacingPos(EntityName, x, z): Actions.QuickTurnToFacePos(EntityName, x, z) Basic_Funcs.PlayerPerson.HitFunc(self, EntityName, WeaponName, Cx, Cy, Cz, DirX, DirY, DirZ, wcx, wcy, wcz, wdx, wdy, wdz) def StdImDead(self, EntityName): Reference.debugprint(EntityName + ': I died!') Basic_Funcs.PlayerPerson.PCImDead(self, EntityName) me = Bladex.GetEntity(EntityName) if me.Life > 0: print EntityName + ': Warning! dead func when Life > 0!' DMusic.InformDead(EntityName) me.RemoveFromList('Listeners') me.AddAnmEventFunc('UnlinkAll', self.UnlinkAll) if self.Asleep: me.Wuea = Reference.WUEA_ENDED me.LaunchAnmType('sleep_wall_d') Reference.debugprint(EntityName + ': Uuurgh! I died in my sleep!') if self.group_leader: memberlist = me.GetGroupMembers() if EntityName in memberlist: memberlist.remove(EntityName) if len(memberlist) == 1: member = Bladex.GetEntity(memberlist[0]) if member and member.Life > 0: enemy = Bladex.GetEntity(member.GetEnemyName()) if member.SQDistance2(enemy) > 3000 * 3000 or not Actions.IsFacingEntity(enemy.Name, member.Name): if whrandom.random() < self.ChanceOfFuryOnLeaderDeath: member.Data.GetFurious(member.Name) self.CheckGoodGroupFormation(EntityName, FALSE) self.CallGroupMemberFunc(EntityName, Combat.GetAngry, FALSE) me.RemoveFromList(me.CombatGroup) csound = Bladex.GetEntity(EntityName + 'ContinuosSound') if csound: csound.StopSound() csound.SubscribeToList('Pin') try: object = Bladex.GetEntity(me.InvLeft) if me.InvLeft and object and not (object.TestHit): Actions.RemoveFromInventory(me, object, 'DropLeftEvent') object.Alpha = 1.0 object.Impulse(0.0, 0.0, 0.0) except AttributeError: pdb.set_trace() try: object = Bladex.GetEntity(me.InvRight) if me.InvRight and object and not (object.TestHit): Actions.RemoveFromInventory(me, object, 'DropRightEvent') object.Alpha = 1.0 object.Impulse(0.0, 0.0, 0.0) except AttributeError: pdb.set_trace() inv = me.GetInventory() while inv.nObjects > 0: object_name = inv.GetObject(0) object = Bladex.GetEntity(object_name) if object: object.Position = me.Position me.Unlink(object) inv.RemoveObject(object_name) object.ExcludeHitFor(me) if object.Kind in TwinkleObjs: Bladex.AddScheduledFunc(Bladex.GetTime(), Actions.TakeObject, ('Player1', object_name)) elif object.TestHit: print 'WARNING OBJECT ' + object.Name + ' REMOVED FROM WORLD BECAUSE COLLIDING' object.RemoveFromWorld() else: object.Alpha = 1.0 object.Impulse(0.0, 0.0, 0.0) while inv.nWeapons > 0: object_name = inv.GetWeapon(0) object = Bladex.GetEntity(object_name) if object: object.Position = me.Position me.Unlink(object) inv.RemoveWeapon(object_name) object.ExcludeHitFor(me) try: if object.TestHit: object.RemoveFromWorld() else: object.Alpha = 1.0 object.Impulse(0.0, 0.0, 0.0) except AttributeError: print 'TestHit unsupported for object ' + object.Name pdb.set_trace() while inv.nShields > 0: object_name = inv.GetShield(0) object = Bladex.GetEntity(object_name) if object: object.Position = me.Position me.Unlink(object) inv.RemoveShield(object_name) object.ExcludeHitFor(me) if object.TestHit: object.RemoveFromWorld() else: object.Alpha = 1.0 object.Impulse(0.0, 0.0, 0.0) while inv.nQuivers > 0: object_name = inv.GetQuiver(0) object = Bladex.GetEntity(object_name) if object: object.Position = me.Position me.Unlink(object) inv.RemoveQuiver(object_name) object.ExcludeHitFor(me) if object.TestHit: object.RemoveFromWorld() else: object.Alpha = 1.0 object.Impulse(0.0, 0.0, 0.0) while inv.nKeys > 0: object_name = inv.GetKey(0) object = Bladex.GetEntity(object_name) if object: object.Position = me.Position me.Unlink(object) inv.RemoveKey(object_name) object.ExcludeHitFor(me) Bladex.AddScheduledFunc(Bladex.GetTime(), Actions.TakeObject, ('Player1', object_name)) char = Bladex.GetEntity('Player1') new_key_sound.Stop() new_key_sound.PlayStereo() def StdEnemyDead(self, EntityName): me = Bladex.GetEntity(EntityName) if me: if me.Life > 0 and me.GetActionMode() == ROUTE_CHASE or me.InCombat: me.DelayNoSeenFunc = self.StdDelayNoSeen if me.Data.imusic_noseen_warp == 1: DMusic.RestoreMusicWarperDelayNoSeenFunc(EntityName) self.InvestigatingSound = FALSE self.LaunchMyWatch(EntityName) Reference.debugprint(EntityName + ': My enemy is dead.He he ! - py') def GetFurious(self, EntityName): me = Bladex.GetEntity(EntityName) if me and self.Furious == 0: Reference.debugprint(EntityName + ': Getting Furious') self.Furious = 1 me.BlockingPropensity = 0 movelist = me.AttackList first_attack = None for move in movelist: pass me.AttackList = filter(Combat.DoneInFury, me.AttackList) if first_attack: first_attack[1] = 1.0 me.AttackList.insert(0, first_attack) me.CombatDistFlag = 0 Damage.DropInvalidObjectsOnImpact(EntityName) me.Wuea = Reference.WUEA_ENDED me.InterruptCombat() me.LaunchAnmType('fury', 1) FuryTime = 30.0 Bladex.AddScheduledFunc(Bladex.GetTime() + FuryTime, self.ResetCombat, (EntityName,)) def StdAnmEnded(self, EntityName): Reference.debugprint(EntityName + ': Anm ended - py ') def StdEnterClose(self, EntityName): Reference.debugprint(EntityName + ': I am entering close combat') me = Bladex.GetEntity(EntityName) if me and me.Life > 0: self.SetGroupFormation(EntityName, TRUE, FALSE) self.Switch2MeleeWeapons(EntityName) def Switch2MeleeWeapons(self, EntityName): me = Bladex.GetEntity(EntityName) if me and me.Life > 0 and not (me.RangeActive): inv = me.GetInventory() right_type = Reference.GiveObjectFlag(me.InvRight) if not inv.HoldingBow: if not right_type == Reference.OBJ_STANDARD: pass if not (right_type == Reference.OBJ_WEAPON): enemy = Bladex.GetEntity(me.GetEnemyName()) if me.AstarState != ASTAR_NOSOLVED: me.SwitchTo1H() weapon_name = inv.GetSelectedWeapon() if weapon_name and weapon_name != me.InvRight and weapon_name != me.InvLeft: out = ScorerActions.CB_WeaponOutX(EntityName, 0) if not out: me.AnmEndedFunc = ScorerActions.CB_WeaponOutX Bladex.AddScheduledFunc(Bladex.GetTime() + 2.0, self.Switch2MeleeWeapons, (EntityName,), EntityName + 'ReSwitch2MeleeWeapons') Actions.EndBowMode(EntityName) def WeaponsOut(self, EntityName): me = Bladex.GetEntity(EntityName) if me.Life > 0: inv = me.GetInventory() if inv.HasBow: des_quiver_name = inv.GetSelectedQuiver() if des_quiver_name: inv.LinkBack(des_quiver_name) inv.LinkRightHand('None') quiver = Bladex.GetEntity(des_quiver_name) if quiver and quiver.Data.NumberOfArrows() > 0: arrow = quiver.Data.GiveArrow() inv.LinkRightHand(arrow.Name) bow = inv.GetBow() inv.LinkLeftHand(bow) return None print 'Enemy starting with bow, but without quiver/arrows' if inv.nWeapons > 0 and not (me.InvRight): weapon_name = inv.GetSelectedWeapon() if not weapon_name: weapon_name = inv.GetWeapon(0) inv.LinkRightHand('None') inv.LinkRightHand(weapon_name) if inv.nShields > 0 and not (me.InvLeft): shield_name = inv.GetSelectedShield() if not shield_name: shield_name = inv.GetShield(0) inv.LinkLeftHand('None') inv.LinkLeftHand(weapon_name) def StdEnterLarge(self, EntityName): me = Bladex.GetEntity(EntityName) Reference.debugprint(EntityName + ': Im entering large area!') if me.Life > 0 and not (me.MeleeActive): inv = me.GetInventory() if inv.HasBow: left_type = Reference.GiveObjectFlag(me.InvLeft) if left_type != Reference.OBJ_BOW: me.SwitchToBow() if inv.GetSelectedWeapon() != me.InvRight and inv.GetSelectedWeapon() != me.InvLeft: out = ScorerActions.CB_WeaponOutX(EntityName, 0) if not out: me.AnmEndedFunc = ScorerActions.CB_WeaponOutX Bladex.AddScheduledFunc(Bladex.GetTime() + 2.0, self.StdEnterLarge, (EntityName,), EntityName + 'ReStdEnterLarge') def StdEnterPrimaryAA(self, EntityName): me = Bladex.GetEntity(EntityName) Reference.debugprint(EntityName + ': Im entering primary area!') if me.Life > 0: if me.InvertedRoute == 1: self.LaunchMyWatch(EntityName) me.LastTimeSeen = Bladex.GetTime() me.InvertedRoute = 0 def StdEnterSecondaryAA(self, EntityName): Reference.debugprint(EntityName + ': Im entering secondary area!') def StdCharSeeingEnemy(self, EntityName, EntityName2): me = Bladex.GetEntity(EntityName) ally = Bladex.GetEntity(EntityName2) if me.CombatGroup == ally.CombatGroup: pass if me.Life > 0: if ally and me.CanISee(ally) and me.GetActionMode() != ROUTE_CHASE: if ally.GetActionMode() == ROUTE_CHASE and me.GetActionMode() != ROUTE_CHASE: me.SeeFunc(EntityName) if ally.GetActionMode() == ROUTE_SINGLE and ally.Data.InvestigatingSound: self.StdHearFunc(EntityName, ally.Data.InvestigatingSoundName, ally.Data.InvestigatingSoundX, ally.Data.InvestigatingSoundY, ally.Data.InvestigatingSoundZ, 1.0) def StdToggleCombat(self, EntityName): import DMusic if self.NPC == 1: DMusic.notifyCombat(EntityName) def __save_core_funcs__(self): me = Bladex.GetEntity(self.Name) if not me: print '__save_core_funcs__() Warning: trying to save a non existent entity', self.Name return None core_funcs = [] j = 0 funcs = [ ('SeeFunc', self.StdSeeTheEnemy), ('HearFunc', self.StdHearFunc), ('DelayNoSeenFunc', self.StdDelayNoSeen), ('NoAllowedAreaFunc', self.StdNoAllowedArea), ('EnemyNoAllowedAreaFunc', self.StdEnemyNoAllowedArea), ('ImHurtFunc', self.StdImHurt), ('ImDeadFunc', self.StdImDead), ('EnemyDeadFunc', self.StdEnemyDead), ('AnmEndedFunc', self.StdAnmEnded), ('EnterCloseFunc', self.StdEnterClose), ('EnterLargeFunc', self.StdEnterLarge), ('EnterPrimaryAAFunc', self.StdEnterPrimaryAA), ('EnterSecondaryAAFunc', self.StdEnterSecondaryAA), ('CharSeeingEnemyFunc', self.StdCharSeeingEnemy), ('ToggleCombatFunc', self.StdToggleCombat), ('DamageFunc', Damage.CalculateDamage)] for i in funcs: exec 'f = me.' + i[0] if i[1] != f: print 'Save Core Func para', me.Name, ' callback ', i[0], ' funcion ', f core_funcs.append((j, GameStateAux.SaveFunctionAux(f))) j = j + 1 return core_funcs def __load_core_funcs__(self, param): me = Bladex.GetEntity(self.Name) if not me: print '__load_core_funcs__ -> Warning, trying to get a non existent entity', self.Name return None funcs = [ 'SeeFunc', 'HearFunc', 'DelayNoSeenFunc', 'NoAllowedAreaFunc', 'EnemyNoAllowedAreaFunc', 'ImHurtFunc', 'ImDeadFunc', 'EnemyDeadFunc', 'AnmEndedFunc', 'EnterCloseFunc', 'EnterLargeFunc', 'EnterPrimaryAAFunc', 'EnterSecondaryAAFunc', 'CharSeeingEnemyFunc', 'ToggleCombatFunc', 'DamageFunc'] for i in param: try: GameStateAux.LoadFunctionAux(i[1], me, funcs[i[0]]) except Exception: 0 exc = 0 param print 'Exception in __load_core_funcs__', exc, i except: 0 def __getstate__(self): PlayerPerson_state = Basic_Funcs.PlayerPerson.__getstate__(self) if PlayerPerson_state[0] != 1: print 'ERROR: NPCPerson.__getstate__(): Base class version differs.' return playerperson_state me = Bladex.GetEntity(self.Name) PlayerPerson_state[1]['NPCPerson'] = (self.InvestigatingSound, self.SoundPriorities, self.Asleep, self.SleepYOffset, self.group_fighter, self.group_leader, self.AttackingNPC, self.last_insulting_time_1AA, self.LastThrownHurtTime, self.AttacksOwnKind, self.AttackNPCTime, self.Angry, self.Furious, self.ChanceOfFuryOnHurt, self.ChanceOfFuryOnLeaderDeath, self.ImpatientAttackTime, self.imusic_noseen_warp, self.DelayNoSeenFuncMusicBackUp, me.CombatGroup, self.__save_core_funcs__()) return PlayerPerson_state def __setstate__(self, parm): Basic_Funcs.PlayerPerson.__setstate__(self, parm) me = Bladex.GetEntity(self.Name) me.SeeFunc = self.StdSeeTheEnemy me.HearFunc = self.StdHearFunc me.DelayNoSeenFunc = self.StdDelayNoSeen me.NoAllowedAreaFunc = self.StdNoAllowedArea me.EnemyNoAllowedAreaFunc = self.StdEnemyNoAllowedArea me.ImHurtFunc = self.StdImHurt me.ImDeadFunc = self.StdImDead me.EnemyDeadFunc = self.StdEnemyDead me.AnmEndedFunc = self.StdAnmEnded me.EnterCloseFunc = self.StdEnterClose me.EnterLargeFunc = self.StdEnterLarge me.EnterPrimaryAAFunc = self.StdEnterPrimaryAA me.EnterSecondaryAAFunc = self.StdEnterSecondaryAA me.CharSeeingEnemyFunc = self.StdCharSeeingEnemy me.ToggleCombatFunc = self.StdToggleCombat version = parm[0] if version == 1: parms = parm[1]['NPCPerson'] self.InvestigatingSound = parms[0] self.SoundPriorities = parms[1] self.Asleep = parms[2] self.SleepYOffset = parms[3] self.group_fighter = parms[4] self.group_leader = parms[5] self.AttackingNPC = parms[6] self.last_insulting_time_1AA = parms[7] self.LastThrownHurtTime = parms[8] self.AttacksOwnKind = parms[9] self.AttackNPCTime = parms[10] self.Angry = parms[11] self.Furious = parms[12] self.ChanceOfFuryOnHurt = parms[13] self.ChanceOfFuryOnLeaderDeath = parms[14] self.ImpatientAttackTime = parms[15] self.imusic_noseen_warp = parms[16] self.DelayNoSeenFuncMusicBackUp = parms[17] me.CombatGroup = parms[18] self.__load_core_funcs__(parms[19]) self.ResetCombat(self.Name) AddMyWatchAnims(self.Name) me = Bladex.GetEntity(self.Name) me.CombatDistFlag = not (self.group_fighter) self.NoFXOnHit = FALSE self.WeaponsOut(self.Name) def AddMyWatchAnims(EntityName): Reference.debugprint(EntityName + ' adding WatchAnims') me = Bladex.GetEntity(EntityName) class StupidNPCPerson(Basic_Funcs.PlayerPerson): InvestigatingSound = FALSE SoundPriorities = [ -1.0, -1.0, -1.0, -1.0, -1.0] def __init__(self, me): Basic_Funcs.PlayerPerson.__init__(self, me) self.SoundPriorities = [ -1.0, -1.0, -1.0, -1.0, -1.0] self.NPC = 1 me.SubscribeToList('Listeners') me.Deaf = 0 def RespondToHit(self, EntityName, AttackerName, DamagePoints, DamageZone, Shielded): pass