def tick_operation(self, op): res = Oplist() if Ticks.verify_tick(self, op, res, self.tick_interval): # Make ourselves go away after ten ticks by decreasing our status. res.append( Operation("set", Entity(self.id, {"status!subtract": 0.1}), to=self.id)) damage_prop = self.props.damage if self.parent and damage_prop is not None: # If there's an "entity_ref" prop it's the reference to the actor which caused the poisoning. actor_id = self.id entity_ref_prop = self.props.entity_ref if entity_ref_prop is not None: actor_id = entity_ref_prop["$eid"] res.append( Operation('hit', Entity(hit_type="poison", id=actor_id, damage=damage_prop), to=self.parent.id)) return server.OPERATION_HANDLED, res return server.OPERATION_IGNORED
def tick_operation(self, op): res = Oplist() if Ticks.verify_tick(self, op, res, self.tick_interval): res.append(Operation("set", Entity(self.id, {"status!subtract": 0.1}), to=self.id)) damage_prop = self.props.damage if self.location.parent and damage_prop is not None: res.append(Operation('hit', Entity(hit_type="poison", id=self.id, damage=damage_prop), to=self.location.parent.id)) return server.OPERATION_HANDLED, res return server.OPERATION_IGNORED
def tick_operation(self, op): res = Oplist() if Ticks.verify_tick(self, op, res, self.tick_interval): status_prop = self.props.status if status_prop is not None: if self.parent: print("Flame eating into parent") # We should send an Consume op to our parent. # A 'fire' consume op should be ignored by most entities except those that are flammable. res += Operation("consume", Entity(consume_type='fire'), to=self.parent) # Reduce status of fire res += Operation("set", Entity({"status!subtract": 0.2}), to=self) else: print("Fire entity without status props.") return server.OPERATION_BLOCKED, res return server.OPERATION_IGNORED
def tick_operation(self, op): res = Oplist() if Ticks.verify_tick(self, op, res, self.tick_interval): if self.props.mode and self.props.mode == 'planted' and self.location.parent and self.props.mass: # If we're planted we should send an Consume op to our parent. # A 'soil' consume op should be ignored by most entities except those with soil. # (So a character won't get eaten if a plant is in it's inventory (which in normal cases would mean it's not "planted" though)) # Try to double mass each day mass = (self.props.mass**0.5) / ( (24 * 60 * 60) / PlantFeeding.tick_interval) res += Operation("consume", Entity(consume_type='soil', pos=self.location.pos, mass=mass), to=self.location.parent) return server.OPERATION_BLOCKED, res return server.OPERATION_IGNORED
def tick_operation(self, op): if Ticks.verify_tick(self, op, Oplist()): return server.OPERATION_HANDLED, Operation("delete", Entity(self.id), to=self.id) return server.OPERATION_IGNORED