mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 14:07:16 +02:00
Working on cleaning some strange behavior when trying to submitting faulty typeclasses to script system. Also fixing bugs here and there.
This commit is contained in:
parent
dae375d1c4
commit
6cb2b8b745
12 changed files with 301 additions and 141 deletions
|
|
@ -99,16 +99,18 @@ class AttackTimer(Script):
|
|||
"Called every self.interval seconds."
|
||||
if self.obj.db.inactive:
|
||||
return
|
||||
|
||||
if self.obj.db.roam_mode:
|
||||
#print "attack timer: at_repeat", self.dbobj.id, self.ndb.twisted_task, id(self.ndb.twisted_task)
|
||||
if self.obj.db.roam_mode:
|
||||
self.obj.roam()
|
||||
return
|
||||
#return
|
||||
elif self.obj.db.battle_mode:
|
||||
#print "attack"
|
||||
self.obj.attack()
|
||||
return
|
||||
elif self.obj.db.pursue_mode:
|
||||
#print "pursue"
|
||||
self.obj.pursue()
|
||||
return
|
||||
#return
|
||||
else:
|
||||
#dead mode. Wait for respawn.
|
||||
dead_at = self.db.dead_at
|
||||
|
|
@ -250,14 +252,13 @@ class Enemy(Mob):
|
|||
those that previously attacked it.
|
||||
"""
|
||||
last_attacker = self.db.last_attacker
|
||||
players = [obj for obj in self.location.contents if utils.inherits_from(obj, BASE_CHARACTER_TYPECLASS)]
|
||||
players = [obj for obj in self.location.contents if utils.inherits_from(obj, BASE_CHARACTER_TYPECLASS) and not obj.is_superuser]
|
||||
if players:
|
||||
# we found players in the room. Maybe we caught up with some, or some walked in on us
|
||||
# before we had time to pursue them. Switch to battle mode.
|
||||
self.battle_mode = True
|
||||
self.roam_mode = False
|
||||
self.pursue_mode = False
|
||||
#self.attack()
|
||||
else:
|
||||
# find all possible destinations.
|
||||
destinations = [ex.destination for ex in self.location.exits if ex.access(self, "traverse")]
|
||||
|
|
|
|||
|
|
@ -242,7 +242,12 @@ class StateLightSourceOn(Script):
|
|||
prematurely, this hook will also be called in that case.
|
||||
"""
|
||||
# calculate remaining burntime
|
||||
time_burnt = time.time() - self.db.script_started
|
||||
try:
|
||||
time_burnt = time.time() - self.db.script_started
|
||||
except TypeError:
|
||||
# can happen if script_started is not defined
|
||||
time_burnt = self.interval
|
||||
|
||||
burntime = self.interval - time_burnt
|
||||
self.obj.db.burntime = burntime
|
||||
if burntime <= 0:
|
||||
|
|
@ -732,12 +737,7 @@ class CmdAttack(Command):
|
|||
# should return True if target is defeated, False otherwise.
|
||||
return target.at_hit(self.obj, self.caller, damage)
|
||||
elif target.db.health:
|
||||
target.db.health -= damage
|
||||
if target.db.health <= 0:
|
||||
# enemy is down!
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
target.db.health -= damage
|
||||
else:
|
||||
# sorry, impossible to fight this enemy ...
|
||||
self.caller.msg("The enemy seems unaffacted.")
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ class CmdLookBridge(Command):
|
|||
def func(self):
|
||||
"Looking around, including a chance to fall."
|
||||
bridge_position = self.caller.db.tutorial_bridge_position
|
||||
|
||||
|
||||
|
||||
messages =("You are standing {wvery close to the the bridge's western foundation{n. If you go west you will be back on solid ground ...",
|
||||
"The bridge slopes precariously where it extends eastwards towards the lowest point - the center point of the hang bridge.",
|
||||
|
|
@ -486,8 +486,8 @@ class CmdLookBridge(Command):
|
|||
self.caller.msg(message)
|
||||
|
||||
# there is a chance that we fall if we are on the western or central part of the bridge.
|
||||
if bridge_position < 3 and random.random() < 0.2 and not self.caller.is_superuser:
|
||||
# we fall on 20% of the times.
|
||||
if bridge_position < 3 and random.random() < 0.05 and not self.caller.is_superuser:
|
||||
# we fall on 5% of the times.
|
||||
fexit = ObjectDB.objects.object_search(self.obj.db.fall_exit)
|
||||
if fexit:
|
||||
string = "\n Suddenly the plank you stand on gives way under your feet! You fall!"
|
||||
|
|
@ -500,7 +500,8 @@ class CmdLookBridge(Command):
|
|||
# at_object_leave hook manually (otherwise this is done by move_to()).
|
||||
self.caller.msg("{r%s{n" % string)
|
||||
self.obj.at_object_leave(self.caller, fexit)
|
||||
self.caller.location = fexit[0] # stealth move, without any other hook calls.
|
||||
self.caller.location = fexit[0] # stealth move, without any other hook calls.
|
||||
self.obj.msg_contents("A plank gives way under %s's feet and they fall from the bridge!" % self.caller.key)
|
||||
|
||||
# custom help command
|
||||
class CmdBridgeHelp(Command):
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ class IrregularEvent(Script):
|
|||
rand = random.random()
|
||||
if rand <= self.db.random_chance:
|
||||
try:
|
||||
#self.obj.msg_contents("irregular event for %s(#%i)" % (self.obj, self.obj.id))
|
||||
self.obj.update_irregular()
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue