def GetBribed(self, pcPlayer, bribeString): if not (bribeString[:5] == "Bribe"): Barks.CreateFloatingBark("Huh? That's no bribe!", self.screenPosX - 128, self.screenPosY - 16) return # Pull out the amount from the string amount = int(bribeString[6:]) success = 0 PlayerSkill = pcPlayer.PC.Attributes.GetAttribute( "Wits") + pcPlayer.PC.Attributes.GetSkill("Negotiation") MonsterSkill = self.Attributes.GetAttribute( "Wits") + self.Attributes.GetSkill("Negotiate") try: if (amount > self.NegotiationBase): success = dice.StandardRoll(PlayerSkill + 5, MonsterSkill) elif (amount < self.NegotiationBase): success = dice.StandardRoll(PlayerSkill, MonsterSkill + 5) else: success = dice.StandardRoll(PlayerSkill, MonsterSkill) except: success = 0 print "Error! Monster had no NegotiationBase from negotiation calculation" if (success): Barks.CreateFloatingBark("%s is appeased." % self.name, self.screenPosX - 128, self.screenPosY - 16) TextBox.MainText.AddText("%s accepts a bribe of %d" % (self.name, amount)) pcPlayer.PC.TakeMoney(amount) self.attitude = 1 return else: # Better do another check to make sure it's not offended. success = dice.StandardRoll(PlayerSkill, MonsterSkill) if (success): Barks.CreateFloatingBark( "%s is not impressed by your puny offer." % self.name, self.screenPosX - 128, self.screenPosY - 16) TextBox.MainText.AddText("%s doesn't accept bribe of %d" % (self.name, amount)) return else: Barks.CreateFloatingBark( "%s is offended by your pathetic offer!" % self.name, self.screenPosX - 128, self.screenPosY - 16) TextBox.MainText.AddText( "%s is offended by an attempted bribe of %d" % (self.name, amount)) self.attitude = -1 return
def BeAttacked(self, attacker): armor = self.GetArmor() + self.GetBonusForAction("armor") defense = self.GetDefense() + self.GetBonusForAction("defense") offense = attacker.GetOffense() + attacker.GetBonusForAction("attack") damage = attacker.GetDamage() + attacker.GetBonusForAction("damage") # This will torque them off self.attitude = -1 TextBox.MainText.AddText("Player (atk %d) attacks %s (def %d)" % (offense, self.name, defense)) if (dice.StandardRoll(offense, defense) == 0): Barks.CreateFloatingBark("Player misses!", self.screenPosX - 128, self.screenPosY - 16) TextBox.MainText.AddText("Player misses %s." % (self.name)) return realDamage = dice.DamageRoll(damage, armor) TextBox.MainText.AddText("Damage %d vs. armor %d" % (damage, armor)) if (realDamage < 1): Barks.CreateFloatingBark("Armor Resists Damage!", self.screenPosX - 128, self.screenPosY - 16) TextBox.MainText.AddText("Player does no damage.") return Barks.CreateFloatingBark("Player hits for %d!" % realDamage, self.screenPosX - 128, self.screenPosY - 16) TextBox.MainText.AddText("%s takes %d damage." % (self.name, realDamage)) self.TakeDamage(realDamage) return
def TakeCurseAttack(self, curseLevel, attacker): if (curseLevel < 1): curseLevel = 1 if (curseLevel > 4): curseLevel = 4 duration = 10 + (attacker.PC.Attributes.GetSkill("magic") + attacker.GetBonusForAction("magic")) * 2 attackerLevel = attacker.PC.Attributes.GetAttribute( "Will") + attacker.PC.Attributes.GetSkill( "magic") + attacker.GetBonusForAction("magic") defenderLevel = self.Attributes.GetAttribute( "Will") + self.Attributes.GetSkill( "magic defense") + self.GetBonusForAction("magic defense") save = dice.StandardRoll(defenderLevel, attackerLevel) if (save): Barks.CreateFloatingBark("Saved! No effect!", self.screenPosX, self.screenPosY) TextBox.MainText.AddText("%s saves against magic " % self.name) TextBox.MainText.AddText("(%d to %d) and isn't cursed." % (attackerLevel, defenderLevel)) else: Barks.CreateFloatingBark("CURSED", self.screenPosX, self.screenPosY) TextBox.MainText.AddText("%s fails saves against magic" % self.name) TextBox.MainText.AddText( "(%d to %d) and is cursed for %d rounds." % (attackerLevel, defenderLevel, duration)) self.AddSpellEffect('curse', -curseLevel, duration)
def TakeBoltAttack(self, boltLevel, attacker): if (boltLevel<1): boltLevel = 1 if (boltLevel>4): boltLevel = 4 attackerLevel = attacker.PC.Attributes.GetAttribute("Wil")+attacker.PC.Attributes.GetSkill("magic")+attacker.GetBonusForAction("magic") defenderLevel = self.Attributes.GetAttribute("Wil")+self.Attributes.GetSkill("magic defense")+self.GetBonusForAction("magic defense") damageBase = 10 + attacker.PC.Attributes.GetSkill("magic") + attacker.GetBonusForAction("magic") totalDamage = 0 for x in range(0,boltLevel): totalDamage += dice.DamageRoll(damageBase,0) save = dice.StandardRoll(defenderLevel, attackerLevel) if (save): totalDamage = (1+totalDamage)/2 Barks.CreateFloatingBark("Saved! Reduced Damage (%d)!"%totalDamage,self.screenPosX, self.screenPosY) TextBox.MainText.AddText("%s saves against magic "%self.name) TextBox.MainText.AddText("(%d to %d) for %d damage."%(attackerLevel,defenderLevel,totalDamage)) else: Barks.CreateFloatingBark("Smack-down by bolt for %d damage!"%totalDamage,self.screenPosX, self.screenPosY) TextBox.MainText.AddText("%s fails saves against magic "%self.name) TextBox.MainText.AddText("(%d to %d) for %d damage."%(attackerLevel,defenderLevel,totalDamage)) self.TakeDamage(totalDamage)
def CheckForUnlock(self, oPC): if (self.lockLevel < 1): return 1 lockpicking = oPC.PC.Attributes.GetAttribute('Agility') + oPC.PC.Attributes.GetSkill("Thievery")+oPC.GetBonusForAction("Thievery") rslt = dice.StandardRoll(lockpicking, self.lockLevel) if (rslt>0): TextBox.MainText.AddText("Player (%d) picks lock (%d)"%(lockpicking,self.lockLevel)) self.lockLevel = 0 return 1 else: TextBox.MainText.AddText("Player (%d) fails to pick lock(%d)"%(lockpicking,self.lockLevel)) return 0
def UpdatePlayerNonTurnBased(self, timeDelta): "Perform per-frame housekeeping on Player" if (not self.Player.IsSettled()): self.Player.ContinueMovement(timeDelta*4,self.map) if (self.Player.TookItem): self.Player.TookItem = 0 # Warn all monsters in the room that the player stole something for x in self.ActiveAI: if x.position.roomID == self.Player.PC.position.roomID: hidden = dice.StandardRoll(self.Player.PC.GetStealSkill()+self.Player.GetBonusForAction("thievery"), x.GetPerception()+x.GetBonusForAction("search")) if not hidden: TextBox.MainText.AddText("%s sees player steal something!"%x.name) x.attitude = -1 else: TextBox.MainText.AddText("%s doesn't notice your actions."%x.name)
def CheckForTraps(self, oPC): if (self.trap < 1): return 1 lockpicking = oPC.PC.Attributes.GetAttribute('Wits') + oPC.PC.Attributes.GetSkill("Search")+oPC.GetBonusForAction("Search") rslt = dice.StandardRoll(lockpicking, self.trap) if (rslt>0): TextBox.MainText.AddText("Player (%d) avoids trap (%d)"%(lockpicking,self.trap)) Barks.CreateFloatingBark("Player avoids trap!",oPC.screenPosX - 128,oPC.screenPosY -16) else: TextBox.MainText.AddText("Player (%d) accidentally sets off trap (%d)"%(lockpicking,self.trap)) damageLevel = self.trap / 2 realDamage = dice.DamageRoll(damageLevel,oPC.PC.GetArmor()) Barks.CreateFloatingBark("Boom! Player sets off trap for %d damage!"%realDamage,oPC.screenPosX - 128,oPC.screenPosY -16) TextBox.MainText.AddText("Player takes %d damage through armor."%realDamage) oPC.TakeDamage(realDamage)
def BeAttacked(self, attacker): armor = self.GetArmor() + self.GetBonusForAction("armor") defense = self.GetDefense() + self.GetBonusForAction("defend") offense = attacker.GetOffense() + attacker.GetBonusForAction("attack") damage = attacker.GetDamage() + attacker.GetBonusForAction("damage") attackerVert = attacker.position.Y if (attackerVert == self.PC.position.Y): offsetY = 32 else: offsetY = -16 TextBox.MainText.AddText("%s (atk %d) attacks player (def %d)" % (attacker.name, offense, defense)) if (dice.StandardRoll(offense, defense) == 0): Barks.CreateFloatingBark("%s misses player!" % attacker.name, self.screenPosX - 128, self.screenPosY + offsetY) TextBox.MainText.AddText("%s misses!" % attacker.name) return realDamage = dice.DamageRoll(damage, armor) TextBox.MainText.AddText("Damage %d vs. armor %d" % (damage, armor)) if (realDamage < 1): Barks.CreateFloatingBark("Player's Armor Resists Damage!", self.screenPosX - 128, self.screenPosY + offsetY) TextBox.MainText.AddText("Attack does no damage!") return Barks.CreateFloatingBark( "%s hits Player for %d!" % (attacker.name, realDamage), self.screenPosX - 128, self.screenPosY + offsetY) TextBox.MainText.AddText("Player takes %d damage" % (realDamage)) self.TakeDamage(realDamage) return