just tried to measure time between events (in this case of killing skeleton king in Ephyra)
in DefFuncs.py I added these functions:
Code: Select all
def get_right_hand(entity_name):
#char = Bladex.GetEntity("Player1")
char = Bladex.GetEntity(entity_name)
#inv = char.GetInventory()
#obj = inv.GetSelectedObject()
right_hand = char.InvRight
if right_hand:
return right_hand
else:
return ""
def time_THEKING1():
print "time_THEKING1()"
global time_theking
time_theking = Bladex.GetTime() # start counter ("TheKing")
def time_THEKING2():
import sys
import time
import Actions
global time_theking
print "time_THEKING2()"
czas1 = Bladex.GetTime() - time_theking # stop counter
TO_FILE = 1
#
now = time.time()
year, month, day, hh, mm, ss, wd, y, z = time.localtime(now)
s1="%02d.%02d.%02d %02d:%02d:%02d" %(year, month, day, hh, mm, ss)
#
s_rh=None
char = Bladex.GetEntity("Player1")
print "char.Name=",char.Name # this works: 'char.Name=Player1'
# s_rh = get_right_hand("Player1")
# print ("s_rh=", s_rh) # doesn't work: 's_rh='
# if Actions.IsRightHandWeaponObject("Player1"):
# print "IsRightHandWeaponObject(\"Player1\")" # doesn't work: ''
# obj_name = char.InvRight
# print "obj_name=\'%s\'" %(obj_name) # doesn't work: ''
# obj = Bladex.GetEntity(obj_name)
# inventory = char.GetInventory() # doesn't work!
# obj = inventory.GetActiveWeapon()
# obj_name = obj.Name
# print "s_rh=\'%s\'" %(obj_name)
# s_rh = obj_name+" ("+obj.Kind+")"
# print "s_rh=\'%s\'" %(s_rh)
if not s_rh:
s_rh = " "
else:
s_rh = " / "+s_rh
print "time_theking @ %s %.1f [s] %s" % (s1, czas1, s_rh)
if TO_FILE:
F1 = open("time_theking.txt", "at")
F1.write("@ %s %.1f [s] %s\n" % (s1, czas1, s_rh))
F1.close()
Code: Select all
time_theking = 0
def EnGuardiaCanejo(Camera,frame): ## function after animation -> start here.
print "EnGuardiaCanejo(Camera,frame): // %.1f" %(Bladex.GetTime())
Actions.StdToggleWeapons("Player1")
time_THEKING1() ## start counter
(...)
def TheKingIsDeath(entity_name): ## king is dead.
print "TheKingIsDeath(entity_name): // %.1f" %(Bladex.GetTime())
czas_THEKING2() ## stop counter
(...)
they do count time but when it comes to check weapon in right hand they fail (as shown in comments)
in time_THEKING2() I tested 3 approaches to do this and all off them fail, moreover that - when I call time_THEKING1() and time_THEKING2() from console they work, when they're meant to be called from DefFuncs.py they fail and even stop further game progress (just like it was syntax error or something)