def playHitSound(self, skillId, ammoSkillId, skillResult, weaponSubType=None): if WeaponGlobals.getIsStaffChargeSkill(skillId): return None if WeaponGlobals.getIsStaffAttackSkill(skillId): return None skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) if skillId == InventoryType.UseItem: skillInfo = WeaponGlobals.getSkillAnimInfo(ammoSkillId) if skillInfo: soundFx = None sfxs = None if skillResult == WeaponGlobals.RESULT_HIT: getHitSfxFunc = skillInfo[WeaponGlobals.HIT_SFX_INDEX] if getHitSfxFunc: sfxs = getHitSfxFunc() elif skillResult == WeaponGlobals.RESULT_MISTIMED_HIT: getMistimedHitSfxFunc = skillInfo[ WeaponGlobals.MISTIMEDHIT_SFX_INDEX] if getMistimedHitSfxFunc: sfxs = getMistimedHitSfxFunc() else: getMissSfxFunc = skillInfo[WeaponGlobals.MISS_SFX_INDEX] if getMissSfxFunc: sfxs = getMissSfxFunc() if sfxs: if type(sfxs) == types.DictType: if weaponSubType: sfxList = sfxs.get(weaponSubType) soundFx = random.choice(sfxList) else: soundFx = sfxs.get(ammoSkillId) elif type(sfxs) == types.TupleType: soundFx = random.choice(sfxs) else: soundFx = sfxs if soundFx: base.playSfx(soundFx, node=self, volume=0.69999999999999996, cutoff=75)
def playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects = [], multihit = 0, targetBonus = 0, skillResult = 0): (targetHp, targetPower, targetEffect, targetMojo, targetSwiftness) = targetEffects if attacker: self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp) self.cleanupOuchIval() if not targetBonus: if ammoSkillId: effectId = WeaponGlobals.getHitEffect(ammoSkillId) else: effectId = WeaponGlobals.getHitEffect(skillId) if not targetBonus and not (self.NoPain) and not (self.noIntervals) and targetEffects[0] < 0: if self.gameFSM.state not in ('Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract', 'ShipBoarding', 'Injured', 'Dying'): ouchSfx = None currentAnim = self.getCurrentAnim() if currentAnim == 'run': painAnim = 'run_hit' elif currentAnim == 'walk': painAnim = 'walk_hit' else: painAnim = 'idle_hit' actorIval = self.actorInterval(painAnim, playRate = random.uniform(0.69999999999999996, 1.5)) if self.currentWeapon and WeaponGlobals.getIsStaffAttackSkill(skillId): skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) getOuchSfxFunc = skillInfo[WeaponGlobals.OUCH_SFX_INDEX] if getOuchSfxFunc: ouchSfx = getOuchSfxFunc() else: ouchSfx = self.getSfx('pain') if ouchSfx: self.ouchAnim = Sequence(Func(base.playSfx, ouchSfx, node = self, cutoff = 75), actorIval) else: self.ouchAnim = actorIval self.ouchAnim.start() if self.combatEffect: self.combatEffect.destroy() self.combatEffect = None self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker) self.combatEffect.reparentTo(self) self.combatEffect.setPos(self, pos[0], pos[1], pos[2]) if not WeaponGlobals.getIsDollAttackSkill(skillId) and not WeaponGlobals.getIsStaffAttackSkill(skillId): if attacker and not attacker.isEmpty(): self.combatEffect.lookAt(attacker) self.combatEffect.setH(self.combatEffect, 180) self.combatEffect.play() if WeaponGlobals.getIsDollAttackSkill(skillId): self.voodooSmokeEffect2 = AttuneSmoke.getEffect() if self.voodooSmokeEffect2: self.voodooSmokeEffect2.reparentTo(self) self.voodooSmokeEffect2.setPos(0, 0, 0.20000000000000001) self.voodooSmokeEffect2.play()
def playHitSound(self, skillId, ammoSkillId, skillResult, weaponSubType = None): if WeaponGlobals.getIsStaffChargeSkill(skillId): return None if WeaponGlobals.getIsStaffAttackSkill(skillId): return None skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) if skillId == InventoryType.UseItem: skillInfo = WeaponGlobals.getSkillAnimInfo(ammoSkillId) if skillInfo: soundFx = None sfxs = None if skillResult == WeaponGlobals.RESULT_HIT: getHitSfxFunc = skillInfo[WeaponGlobals.HIT_SFX_INDEX] if getHitSfxFunc: sfxs = getHitSfxFunc() elif skillResult == WeaponGlobals.RESULT_MISTIMED_HIT: getMistimedHitSfxFunc = skillInfo[WeaponGlobals.MISTIMEDHIT_SFX_INDEX] if getMistimedHitSfxFunc: sfxs = getMistimedHitSfxFunc() else: getMissSfxFunc = skillInfo[WeaponGlobals.MISS_SFX_INDEX] if getMissSfxFunc: sfxs = getMissSfxFunc() if sfxs: if type(sfxs) == types.DictType: if weaponSubType: sfxList = sfxs.get(weaponSubType) soundFx = random.choice(sfxList) else: soundFx = sfxs.get(ammoSkillId) elif type(sfxs) == types.TupleType: soundFx = random.choice(sfxs) else: soundFx = sfxs if soundFx: base.playSfx(soundFx, node = self, volume = 0.69999999999999996, cutoff = 75)
def preprocessAttackAnim(self): if self.currentAttack[0] >= InventoryType.begin_WeaponSkillGrenade and self.currentAttack[0] < InventoryType.end_WeaponSkillGrenade: skillInfo = WeaponGlobals.getSkillAnimInfo(EnemySkills.EnemySkills.GRENADE_RELOAD) if not skillInfo: return None anim = skillInfo[WeaponGlobals.PLAYABLE_INDEX] reloadAnim = getattr(self.cr.combatAnims, anim)(self, EnemySkills.EnemySkills.GRENADE_RELOAD, 0, 0, None, 1) if reloadAnim: self.curAttackAnim = Sequence(self.curAttackAnim, reloadAnim)
def playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects=[], multihit=0, targetBonus=0, skillResult=0): targetHp, targetPower, targetEffect, targetMojo, targetSwiftness = targetEffects if attacker: self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp) self.cleanupOuchIval() if not targetBonus: if ammoSkillId: effectId = WeaponGlobals.getHitEffect(ammoSkillId) else: effectId = WeaponGlobals.getHitEffect(skillId) if not targetBonus and not self.NoPain and not self.noIntervals and targetEffects[0] < 0: if self.gameFSM.state not in ('Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract', 'ShipBoarding', 'Injured', 'Dying'): ouchSfx = None currentAnim = self.getCurrentAnim() if currentAnim == 'run': painAnim = 'run_hit' else: if currentAnim == 'walk': painAnim = 'walk_hit' else: painAnim = 'idle_hit' actorIval = self.actorInterval(painAnim, playRate=random.uniform(0.7, 1.5)) if self.currentWeapon and WeaponGlobals.getIsStaffAttackSkill(skillId): skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) getOuchSfxFunc = skillInfo[WeaponGlobals.OUCH_SFX_INDEX] if getOuchSfxFunc: ouchSfx = getOuchSfxFunc() else: ouchSfx = self.getSfx('pain') if ouchSfx: self.ouchAnim = Sequence(Func(base.playSfx, ouchSfx, node=self, cutoff=75), actorIval) self.ouchAnim = actorIval self.ouchAnim.start() if self.combatEffect: self.combatEffect.destroy() self.combatEffect = None self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker) self.combatEffect.reparentTo(self) self.combatEffect.setPos(self, pos[0], pos[1], pos[2]) if not WeaponGlobals.getIsDollAttackSkill(skillId) and not WeaponGlobals.getIsStaffAttackSkill(skillId): if attacker and not attacker.isEmpty(): self.combatEffect.lookAt(attacker) self.combatEffect.setH(self.combatEffect, 180) self.combatEffect.play() if WeaponGlobals.getIsDollAttackSkill(skillId): self.voodooSmokeEffect2 = AttuneSmoke.getEffect() if self.voodooSmokeEffect2: self.voodooSmokeEffect2.reparentTo(self) self.voodooSmokeEffect2.setPos(0, 0, 0.2) self.voodooSmokeEffect2.play() return
def checkComboExpired(self, avId, weaponId, skillId, skillResult): attacker = base.cr.doId2do.get(avId) if not attacker: return 0 if skillId in self.EXCLUDED_SKILLS: return 0 skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) if not skillInfo: return 0 barTime = self.TimingCache.get(skillId, None) if barTime is None: anim = skillInfo[WeaponGlobals.PLAYABLE_INDEX] skillAnim = getattr(base.cr.combatAnims, anim)(attacker, skillId, 0, 0, None, skillResult) if skillAnim == None: return 1 barTime = skillAnim.getDuration() self.TimingCache[skillId] = barTime curTime = globalClock.getFrameTime() for attackerId in self.timers: comboLength = len(self.timers[attackerId]) lastEntry = self.timers[attackerId][comboLength - 1] lastSkillId = lastEntry[self.SKILLID_INDEX] timestamp = lastEntry[self.TIMESTAMP_INDEX] if (barTime + timestamp - curTime) + self.TOLERANCE > 0: if attackerId != avId: return 0 subtypeId = ItemGlobals.getSubtype(weaponId) if not subtypeId: return 0 repId = WeaponGlobals.getSkillReputationCategoryId(skillId) if not repId: return 0 if repId != WeaponGlobals.getRepId(weaponId): return 0 comboChain = self.COMBO_ORDER.get(subtypeId) if comboChain: if skillId in self.SPECIAL_SKILLS.get(repId, []): if lastSkillId not in self.SPECIAL_SKILLS.get( repId, []): return 0 elif lastSkillId == skillId: numHits = WeaponGlobals.getNumHits(skillId) if comboLength < numHits: return 0 elif comboLength >= numHits: preMultihitEntry = self.timers[attackerId][ comboLength - numHits] preMultihitSkillId = preMultihitEntry[ self.SKILLID_INDEX] if preMultihitSkillId != skillId: return 0 elif skillId in comboChain: index = comboChain.index(skillId) if index > 0: requisiteAttack = comboChain[index - 1] if lastSkillId == requisiteAttack: return 0 currentAttack = comboChain[index] if lastSkillId == skillId: return 0 elif not comboLength: return 0 return 1
def playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects=[], multihit=0, targetBonus=0, skillResult=0): (targetHp, targetPower, targetEffect, targetMojo, targetSwiftness) = targetEffects if self.gameFSM.state in ('Injured', ): return None if not targetBonus: if ammoSkillId: effectId = WeaponGlobals.getHitEffect(ammoSkillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(ammoSkillId) else: effectId = WeaponGlobals.getHitEffect(skillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(skillId) if attacker: self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp, skillResult) if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects( ) or skillEffectId == WeaponGlobals.C_KNOCKDOWN: self.cleanupOuchIval() if not targetBonus and not (self.NoPain) and not ( self.noIntervals) and targetEffects[0] < 0: if self.gameFSM.state not in ( 'Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract', 'ShipBoarding', 'Injured', 'Dying', 'Death' ) or WeaponGlobals.C_KNOCKDOWN in self.getSkillEffects( ) or self.gameFSM.state not in ('ShipBoarding', 'Injured', 'Dying', 'Death'): if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects( ) or skillEffectId == WeaponGlobals.C_KNOCKDOWN: ouchSfx = None if self.currentWeapon: if not self.avatarType.isA( AvatarTypes.Creature ) and skillEffectId == WeaponGlobals.C_KNOCKDOWN and not ItemGlobals.getWeaponAttributes( self.currentWeaponId, ItemGlobals.SURE_FOOTED): if self.isLocal(): actorIval = Sequence( self.actorInterval('injured_fall', playRate=1.5, blendOutT=0), self.actorInterval('injured_standup', playRate=1.5, blendInT=0), Func(messenger.send, 'skillFinished')) else: actorIval = Sequence( self.actorInterval('injured_fall', playRate=1.5, blendOutT=0), self.actorInterval('injured_standup', playRate=1.5, blendInT=0)) elif not self.avatarType.isA( AvatarTypes.Creature ) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval( 'sand_in_eyes_holdweapon_noswing', playRate=random.uniform( 0.69999999999999996, 1.5)) else: actorIval = self.actorInterval( self.currentWeapon.painAnim, playRate=random.uniform( 0.69999999999999996, 1.5)) if WeaponGlobals.getIsStaffAttackSkill(skillId): skillInfo = WeaponGlobals.getSkillAnimInfo( skillId) getOuchSfxFunc = skillInfo[ WeaponGlobals.OUCH_SFX_INDEX] if getOuchSfxFunc: ouchSfx = getOuchSfxFunc() else: ouchSfx = self.getSfx('pain') elif not self.avatarType.isA( AvatarTypes.Creature ) and skillEffectId == WeaponGlobals.C_KNOCKDOWN: actorIval = Sequence( self.actorInterval('injured_fall', playRate=1.5, blendOutT=0), self.actorInterval('injured_standup', playRate=1.5, blendInT=0)) elif not self.avatarType.isA( AvatarTypes.Creature ) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval('sand_in_eyes', playRate=random.uniform( 0.69999999999999996, 1.5)) else: actorIval = self.actorInterval('idle_hit', playRate=random.uniform( 0.69999999999999996, 1.5)) if ouchSfx: self.ouchAnim = Sequence( Func(base.playSfx, ouchSfx, node=self, cutoff=75), actorIval) else: self.ouchAnim = actorIval self.ouchAnim.start() skillEffectId == WeaponGlobals.C_KNOCKDOWN if self.combatEffect: self.combatEffect.destroy() self.combatEffect = None self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker, skillResult) self.combatEffect.reparentTo(self) self.combatEffect.setPos(self, pos[0], pos[1], pos[2]) if not WeaponGlobals.getIsDollAttackSkill( skillId) and not WeaponGlobals.getIsStaffAttackSkill(skillId): if not WeaponGlobals.isSelfUseSkill(skillId): if attacker and not attacker.isEmpty(): self.combatEffect.lookAt(attacker) self.combatEffect.setH(self.combatEffect, 180) skillEffects = self.getSkillEffects() if WeaponGlobals.C_MELEE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass( skillId) == WeaponGlobals.AC_COMBAT: self.pulseGhostGuardEffect(attacker, Vec4(0, 0, 0, 1), wantBlending=False) elif WeaponGlobals.C_MISSILE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass( skillId) == WeaponGlobals.AC_MISSILE: self.pulseGhostGuardEffect(attacker, Vec4(1, 1, 1, 1), wantBlending=True) elif WeaponGlobals.C_MAGIC_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_MAGIC: self.pulseGhostGuardEffect(attacker, Vec4(0.5, 0.29999999999999999, 1, 1), wantBlending=True) self.combatEffect.play() if WeaponGlobals.getIsDollAttackSkill(skillId): self.voodooSmokeEffect2 = AttuneSmoke.getEffect() if self.voodooSmokeEffect2: self.voodooSmokeEffect2.reparentTo(self) self.voodooSmokeEffect2.setPos(0, 0, 0.20000000000000001) self.voodooSmokeEffect2.play()
def playOuch(self, skillId, ammoSkillId, targetEffects, attacker, pos, itemEffects = [], multihit = 0, targetBonus = 0, skillResult = 0): (targetHp, targetPower, targetEffect, targetMojo, targetSwiftness) = targetEffects if self.gameFSM.state in ('Injured',): return None if not targetBonus: if ammoSkillId: effectId = WeaponGlobals.getHitEffect(ammoSkillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(ammoSkillId) else: effectId = WeaponGlobals.getHitEffect(skillId) skillEffectId = WeaponGlobals.getSkillEffectFlag(skillId) if attacker: self.addCombo(attacker.getDoId(), attacker.currentWeaponId, skillId, -targetHp, skillResult) if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects() or skillEffectId == WeaponGlobals.C_KNOCKDOWN: self.cleanupOuchIval() if not targetBonus and not (self.NoPain) and not (self.noIntervals) and targetEffects[0] < 0: if self.gameFSM.state not in ('Ensnared', 'Knockdown', 'Stunned', 'Rooted', 'NPCInteract', 'ShipBoarding', 'Injured', 'Dying', 'Death') or WeaponGlobals.C_KNOCKDOWN in self.getSkillEffects() or self.gameFSM.state not in ('ShipBoarding', 'Injured', 'Dying', 'Death'): if WeaponGlobals.C_KNOCKDOWN not in self.getSkillEffects() or skillEffectId == WeaponGlobals.C_KNOCKDOWN: ouchSfx = None if self.currentWeapon: if not self.avatarType.isA(AvatarTypes.Creature) and skillEffectId == WeaponGlobals.C_KNOCKDOWN and not ItemGlobals.getWeaponAttributes(self.currentWeaponId, ItemGlobals.SURE_FOOTED): if self.isLocal(): actorIval = Sequence(self.actorInterval('injured_fall', playRate = 1.5, blendOutT = 0), self.actorInterval('injured_standup', playRate = 1.5, blendInT = 0), Func(messenger.send, 'skillFinished')) else: actorIval = Sequence(self.actorInterval('injured_fall', playRate = 1.5, blendOutT = 0), self.actorInterval('injured_standup', playRate = 1.5, blendInT = 0)) elif not self.avatarType.isA(AvatarTypes.Creature) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval('sand_in_eyes_holdweapon_noswing', playRate = random.uniform(0.69999999999999996, 1.5)) else: actorIval = self.actorInterval(self.currentWeapon.painAnim, playRate = random.uniform(0.69999999999999996, 1.5)) if WeaponGlobals.getIsStaffAttackSkill(skillId): skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) getOuchSfxFunc = skillInfo[WeaponGlobals.OUCH_SFX_INDEX] if getOuchSfxFunc: ouchSfx = getOuchSfxFunc() else: ouchSfx = self.getSfx('pain') elif not self.avatarType.isA(AvatarTypes.Creature) and skillEffectId == WeaponGlobals.C_KNOCKDOWN: actorIval = Sequence(self.actorInterval('injured_fall', playRate = 1.5, blendOutT = 0), self.actorInterval('injured_standup', playRate = 1.5, blendInT = 0)) elif not self.avatarType.isA(AvatarTypes.Creature) and effectId == WeaponGlobals.VFX_BLIND: actorIval = self.actorInterval('sand_in_eyes', playRate = random.uniform(0.69999999999999996, 1.5)) else: actorIval = self.actorInterval('idle_hit', playRate = random.uniform(0.69999999999999996, 1.5)) if ouchSfx: self.ouchAnim = Sequence(Func(base.playSfx, ouchSfx, node = self, cutoff = 75), actorIval) else: self.ouchAnim = actorIval self.ouchAnim.start() skillEffectId == WeaponGlobals.C_KNOCKDOWN if self.combatEffect: self.combatEffect.destroy() self.combatEffect = None self.combatEffect = CombatEffect.CombatEffect(effectId, multihit, attacker, skillResult) self.combatEffect.reparentTo(self) self.combatEffect.setPos(self, pos[0], pos[1], pos[2]) if not WeaponGlobals.getIsDollAttackSkill(skillId) and not WeaponGlobals.getIsStaffAttackSkill(skillId): if not WeaponGlobals.isSelfUseSkill(skillId): if attacker and not attacker.isEmpty(): self.combatEffect.lookAt(attacker) self.combatEffect.setH(self.combatEffect, 180) skillEffects = self.getSkillEffects() if WeaponGlobals.C_MELEE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_COMBAT: self.pulseGhostGuardEffect(attacker, Vec4(0, 0, 0, 1), wantBlending = False) elif WeaponGlobals.C_MISSILE_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_MISSILE: self.pulseGhostGuardEffect(attacker, Vec4(1, 1, 1, 1), wantBlending = True) elif WeaponGlobals.C_MAGIC_SHIELD in skillEffects: if WeaponGlobals.getAttackClass(skillId) == WeaponGlobals.AC_MAGIC: self.pulseGhostGuardEffect(attacker, Vec4(0.5, 0.29999999999999999, 1, 1), wantBlending = True) self.combatEffect.play() if WeaponGlobals.getIsDollAttackSkill(skillId): self.voodooSmokeEffect2 = AttuneSmoke.getEffect() if self.voodooSmokeEffect2: self.voodooSmokeEffect2.reparentTo(self) self.voodooSmokeEffect2.setPos(0, 0, 0.20000000000000001) self.voodooSmokeEffect2.play()
def checkComboExpired(self, avId, weaponId, skillId, skillResult): attacker = base.cr.doId2do.get(avId) if not attacker: return 0 if skillId in self.EXCLUDED_SKILLS: return 0 skillInfo = WeaponGlobals.getSkillAnimInfo(skillId) if not skillInfo: return 0 barTime = self.TimingCache.get(skillId, None) if barTime is None: anim = skillInfo[WeaponGlobals.PLAYABLE_INDEX] skillAnim = getattr(base.cr.combatAnims, anim)(attacker, skillId, 0, 0, None, skillResult) if skillAnim == None: return 1 barTime = skillAnim.getDuration() self.TimingCache[skillId] = barTime curTime = globalClock.getFrameTime() for attackerId in self.timers: comboLength = len(self.timers[attackerId]) lastEntry = self.timers[attackerId][comboLength - 1] lastSkillId = lastEntry[self.SKILLID_INDEX] timestamp = lastEntry[self.TIMESTAMP_INDEX] if (barTime + timestamp - curTime) + self.TOLERANCE > 0: if attackerId != avId: return 0 subtypeId = ItemGlobals.getSubtype(weaponId) if not subtypeId: return 0 repId = WeaponGlobals.getSkillReputationCategoryId(skillId) if not repId: return 0 if repId != WeaponGlobals.getRepId(weaponId): return 0 comboChain = self.COMBO_ORDER.get(subtypeId) if comboChain: if skillId in self.SPECIAL_SKILLS.get(repId, []): if lastSkillId not in self.SPECIAL_SKILLS.get(repId, []): return 0 elif lastSkillId == skillId: numHits = WeaponGlobals.getNumHits(skillId) if comboLength < numHits: return 0 elif comboLength >= numHits: preMultihitEntry = self.timers[attackerId][comboLength - numHits] preMultihitSkillId = preMultihitEntry[self.SKILLID_INDEX] if preMultihitSkillId != skillId: return 0 elif skillId in comboChain: index = comboChain.index(skillId) if index > 0: requisiteAttack = comboChain[index - 1] if lastSkillId == requisiteAttack: return 0 currentAttack = comboChain[index] if lastSkillId == skillId: return 0 elif not comboLength: return 0 return 1