Exemplo n.º 1
0
 def addAgroRoom(self):
     found = False
     if len(G.chars):
         mx, my, mz = self.cm.loc
         for name, char in G.chars.iteritems():
             px, py, pz = char.loc
             if not char.isdead and \
             char not in self.cm.agro and \
             char.state > CState.OFFLINE and \
             (self.cm.loc == char.loc or \
             (self.cm.m.reach and Combat.isShootable(self.cm.loc, char.loc)[0])):
                 for e in char.effects:
                     if "SYSINVIS" in e.adjust:
                         char.hideDC = 666
                         break
                 if char.hideDC == 0 or (char.hideDC <= self.cm.rollSkill("perception", 5)):
                     # TODO: if ranged, do we want to 
                     # check to see if we want to agro on this person based on level
                     if math.fabs(self.cm.m.cr - char.level) > 7:
                         continue
                     elif self.cm.m.aifaction[1] == None and self.cm.m.aifaction[2] == None and self.cm.m.aifaction[3] == None and self.cm.m.aifaction[4] == None and self.cm.m.aifaction[5] == None:
                         # we are hostile by default
                         # as we add people, we want to roll random hate generated
                         self.cm.agro[char.name] = random.randint(1, 10)
                         found = True
                         continue
                     else:
                         # loop through faction and see if we trigger an attack
                         for i in self.cm.m.aifaction:
                             faction = self.cm.m.aifaction[i]
                             if faction != None and faction in G.factions:
                                 # special case, forced friendly
                                 if G.factions[faction].min == G.factions[faction].max and G.factions[faction].initial > 0:
                                     #friendly
                                     continue
                                 # special case, forced hostile
                                 # check live factions
                                 # our faction level <= 50% of the faction 
                                 elif (G.factions[faction].min == G.factions[faction].max and G.factions[faction].initial <= 0) or \
                                      ((char.faction[faction] if faction in char.faction else 0) + G.factions[faction].initial) <= ((G.factions[faction].max - G.factions[faction].min) / 2):
                                     self.cm.agro[char.name] = random.randint(1, 10)
                                     found = True
                                     break
                                 else:
                                     # friendly, move on to the next
                                     continue
                         
     if len(G.monster_live) and True == False:
         mx, my, mz = self.cm.loc
         for uid, cm in G.monster_live.iteritems():
             cmx, cmy, cmz = cm.loc
             if not cm.isdead and cm != self.cm and cm.uid not in self.cm.agro and \
             (self.cm.loc == cm.loc or (self.cm.m.reach and Combat.isShootable(self.cm.loc, cm.loc)[0])):
                 # TODO: check to see if we want to agro on this monster
                 #self.cm.agro[cm.uid] = random.randint(1, 10)
                 break
                 
     if found:
         self.wake()
     return found
Exemplo n.º 2
0
 def DoSpell(self, s, chance):
     cast = False
     roll = random.randint(1,100)
     if roll <= int(float(chance) * 100):
         sp = G.spells[int(s)]
         target = (G.chars[self.cm.target] if self.cm.target in G.chars else G.monster_live[self.cm.target])
         if sp.stype == "heal" and (self.cm.calcStatNow("LP") / self.cm.calcStat("LP")) * 100 <= random.randint(20, 40):
             cast = True
             target = self.cm
         if (sp.stype == "attack" or sp.stype == "debuff") and self.cm.target and target.loc == self.cm.loc:
             cast = True
         
         if cast:
             self.cm.action = True
             logging.debug("AI; monster %s (%s); casting; %s; targeting; %s", self.cm.m.name, self.cm.uid, sp.name, target.name)
             Combat.doSpell(self.cm, target, sp, "")
Exemplo n.º 3
0
 def handle_DOEFFECT(self, action, data, id):
     eid, partition, atext = data.partition(":")
     eff = G.effects[int(eid)]
     etimes = Utility.subVars(self.char, eff.times)
     edice = Utility.subVars(self.char, eff.dice)
     peffect = copy.deepcopy(eff)
     peffect.times = etimes
     peffect.dice = edice
     done = Combat.doCombatEffect(self.monster if self.monster else atext if atext else eff.dtype, self.char, peffect, "", "")