def container_setup_dc(obj, locked_dc, key_id, hp, hardeness, break_dc): assert isinstance(obj, toee.PyObjHandle) if (obj.type != toee.obj_t_container): print( "container_setup_dc :: obj is not obj_t_container! {}".format(obj)) debug.breakp("container_setup_dc") return obj.obj_set_int(toee.obj_f_secretdoor_dc, break_dc) if (locked_dc): obj.container_flag_set(toee.OCOF_LOCKED) if (locked_dc < 0): obj.container_flag_set(toee.OCOF_JAMMED) else: obj.obj_set_int(toee.obj_f_container_lock_dc, locked_dc) if (key_id): obj.obj_set_int(toee.obj_f_container_key_id, key_id) if (hp): obj.obj_set_int(toee.obj_f_hp_pts, hp) if (hardeness): obj.obj_set_int(toee.obj_f_hp_adj, hardeness) return obj
def netted_S_BreakFree(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Query) #int __cdecl sub_100D3BC0(DispCallbackArgs args) print "netted_S_BreakFree" try: dc = args.get_arg(0) # dc break free bonuslist = tpdp.BonusList() bonus = tpdp.dispatch_stat(attachee, toee.stat_str_mod, bonuslist) dice = toee.dice_new("1d20") roll = dice.roll() check = roll + bonus >= dc hist_id = tpdp.create_history_dc_roll(attachee, dc, dice, roll, "Str", bonuslist) toee.game.create_history_from_id(hist_id) if (not check): attachee.float_mesfile_line("mes\\spell.mes", 20027, toee.tf_red) # {20027} {Entangled!} evt_obj.return_val = 0 else: attachee.float_mesfile_line("mes\\spell.mes", 21003, toee.tf_red) #{21003} {Escaped!} evt_obj.return_val = 1 netted_remove(args, 1) except Exception, e: print "netted_S_BreakFree error:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 debug.breakp("error")
def portal_setup_dc(obj, locked_dc, key_id, hp, hardeness, break_dc): assert isinstance(obj, toee.PyObjHandle) if (obj.type != toee.obj_t_portal): print("portal_setup_dc :: obj is not obj_t_portal! {}".format(obj)) debug.breakp("portal_setup_dc") return obj.obj_set_int(toee.obj_f_portal_pad_i_1, break_dc) if (locked_dc): obj.portal_flag_set(toee.OPF_LOCKED) if (locked_dc < 0): obj.portal_flag_set(toee.OPF_JAMMED) else: obj.obj_set_int(toee.obj_f_portal_lock_dc, locked_dc) if (key_id): obj.obj_set_int(toee.obj_f_portal_key_id, key_id) if (hp): obj.obj_set_int(toee.obj_f_hp_pts, hp) if (hardeness): obj.obj_set_int(toee.obj_f_hp_adj, hardeness) return obj
def loadObjects(dirname): #breakp("Storage.loadObjects({})".format(dirname)) try: ss = Storage() oo = ss.objs assert isinstance(oo, dict) oo.clear() files = os.listdir(dirname) mod_cache = dict() local_objects = list() for fileName in files: o = Storage.loadObjectStorage(dirname, fileName, mod_cache) if (not (o is None)): oo[o.name] = o local_objects.append(o) for o in local_objects: if ("storage_data_loaded_all" in dir(o)): o.storage_data_loaded_all() except Exception, e: print "!!!!!!!!!!!!! loadObjects error:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def save(savegame): #breakp("Storage.save({})".format(savegame)) try: saveDirBase = "modules\\{}\\save\\".format( Storage.get_default_module()) saveDirName = "d" + savegame saveDirName = "\\Current\\dSlot" saveDir = saveDirBase + saveDirName #print(saveDir) if (not os.path.exists(saveDir)): os.makedirs(saveDir) files = os.listdir(saveDir) for fileName in files: os.remove(os.path.join(saveDir, fileName)) Storage.saveObjects(saveDir) except: print "!!!!!!!!!!!!! Storage.save error:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 print("saveDir: {}".format(saveDir)) debug.breakp("error") return
def loadObjectStorage(dirname, fileName, mod_cache): filePath = os.path.join(dirname, fileName) #print("loadObjectStorage: filePath {}".format(filePath)) #breakp("loadObjectStorage") try: f = open(filePath, "r") o = json.load(f) f.close() #print("loadObjectStorage: json.load o = {}".format(o)) #breakp("loadObjectStorage o") #o = Storage.makeObjects(o, loaded_modules) o = Storage.make_data(o, None, mod_cache) name = o["name"] ostorage = ObjectStorage(name) if (not "origin" in o): o["origin"] = None ostorage.__dict__ = o if (not name): print("ostorage no name!") debug.breakp("ostorage no name!") return None return ostorage except Exception, e: print "loadObjectStorage error:" print '-' * 60 f.close() traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def activate_monster(self, encounter_name, monster_code_name, remove_no_attack=1, remove_no_kos=1, no_error=0): npc = None info = self.get_monsterinfo(encounter_name, monster_code_name) if (info): npc = toee.game.get_obj_by_id(info.id) if (npc): if (not info.activated): ctrl = ctrl_behaviour.CtrlBehaviour.get_from_obj(npc) if (ctrl and ("activating" in dir(ctrl))): ctrl.activating(npc) if (remove_no_attack): npc.npc_flag_unset(toee.ONF_NO_ATTACK) info.activated = 1 print("ACTIVATED: {}".format(npc)) if (remove_no_kos): npc.npc_flag_set(toee.ONF_KOS) if (ctrl and ("activated" in dir(ctrl))): ctrl.activated(npc) else: info.activated += 1 if (not npc and not no_error): print("Monster {} {} not found!".format(encounter_name, monster_code_name)) debug.breakp("Monster not found") return npc, info
def sp_darkness_hit_OnLeaveAoE(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjObjectEvent) obj_evt_id = args.get_arg(2) if (obj_evt_id != evt_obj.evt_id): return 0 target = evt_obj.target if (not attachee or not target): return 0 f = target.object_flags_get() if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED) or (f & toee.OF_DONTDRAW)): return 0 spell_id = args.get_arg(0) spell_packet = tpdp.SpellPacket(spell_id) if (not spell_packet): print("spell_packet is null!") debug.breakp("spell_packet is null") return 0 spell_packet.end_target_particles(target) spell_packet.remove_target(target) args.remove_spell_mod() print("sp-Darkness removed from {} (sp_darkness_hit_OnLeaveAoE)".format(attachee)) return 0
def breakp(v): """ Debug option for TemplePlus. Keyword arguments: v --- string or None (default None) """ if ("breakp" in dir(debug)): debug.breakp(v) return
def OnSpellEffect(spell): assert isinstance(spell, toee.PySpell) print("Silence OnSpellEffect") npc = spell.caster ## added so NPC's can use wand/potion/scroll if (npc.type != toee.obj_t_pc and npc.leader_get() == toee.OBJ_HANDLE_NULL and spell.caster_level <= 0): spell.caster_level = 8 spell.duration = 10 * spell.caster_level # test whether we targeted the ground or an object is_object = spell.is_object_selected() if (is_object and not len(spell.target_list)): print("is_object_selected returns 0 targets!") debug.breakp("") is_object = 0 if (is_object): target_item = spell.target_list[0] # allow Will saving throw to negate if target_item.obj.saving_throw_spell(spell.dc, toee.D20_Save_Will, toee.D20STD_F_NONE, spell.caster, spell.id): # saving throw successful target_item.obj.float_mesfile_line('mes\\spell.mes', 30001) toee.game.particles('Fizzle', target_item.obj) spell.target_list.remove_target(target_item.obj) else: # put sp-Silence condition on target target_item.obj.float_mesfile_line('mes\\spell.mes', 30002) spell_obj_partsys_id = toee.game.particles('sp-Silence', target_item.obj) target_item.obj.condition_add_with_args('sp-Silence', spell.id, spell.duration, 0, spell_obj_partsys_id) else: # spawn one spell_object object spell_obj = toee.game.obj_create(toee.OBJECT_SPELL_GENERIC, spell.target_loc, spell.target_loc_off_x, spell.target_loc_off_y) # add to d20initiative caster_init_value = spell.caster.get_initiative() spell_obj.d20_status_init() spell_obj.set_initiative(caster_init_value) # put sp-Silence condition on obj spell_obj_partsys_id = toee.game.particles('sp-Silence', spell_obj) spell_obj.condition_add_with_args('sp-Silence', spell.id, spell.duration, 0, spell_obj_partsys_id) return
def OnTakingDamage(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjDamage) debug.breakp("OnTakingDamage") #print("evt_obj.damage_packet.final_damage: {}".format(evt_obj.damage_packet.final_damage)) #see int AbilityConditionFixes::MonsterSubtypeFire(DispatcherCallbackArgs args){ #if (evt_obj.damage_packet.final_damage ) #D20DAP_COLD return 0
def Stench_Of_Troglodyte_Perform(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Action) try: print("Stench_Of_Troglodyte_Perform") #debug.breakp("Stench_Of_Troglodyte_Perform") toee.game.particles("Trap-poisonGas", attachee) range = args.get_arg(3) if (not range): range = 30 dc = args.get_arg(2) affected = toee.game.obj_list_range(attachee.location, range, toee.OLC_CRITTERS) for target in affected: assert isinstance(target, toee.PyObjHandle) flags = target.object_flags_get() if ((flags & toee.OF_OFF) or (flags & toee.OF_DESTROYED) or (flags & toee.OF_DONTDRAW)): continue if (target.d20_query(toee.Q_Dead)): continue if (target.d20_query(toee.Q_Critter_Is_Immune_Poison)): print("Stench_Of_Troglodyte_Perform immune to poison {}". format(target)) continue if (target.d20_query("Immune to Stench of Troglodyte")): print( "Stench_Of_Troglodyte_Perform Immune to Stench of Troglodyte {}" .format(target)) continue saved = target.saving_throw(dc, toee.D20_Save_Fortitude, toee.D20STD_F_POISON, attachee) if (not saved): print( "condition_add_with_args(Stench_Of_Troglodyte_Hit, {}, {}, {}, 1) on {}" .format(args.get_arg(0), args.get_arg(1), args.get_arg(2), target)) target.condition_add_with_args("Stench_Of_Troglodyte_Hit", args.get_arg(0), args.get_arg(1), args.get_arg(2), 1) if ("anim_goal_push_hit_by_weapon" in dir(attachee)): attachee.anim_goal_push_hit_by_weapon(target) else: print("Stench_Of_Troglodyte_Perform saved {}".format(target)) except Exception, e: print "Stench_Of_Troglodyte_ error:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def Monster_Touch_Attack_OnToHitBonus2(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjAttack) try: evt_obj.attack_packet.set_flags(toee.D20CAF_TOUCH_ATTACK) except Exception, e: print "Monster_Touch_Attack_OnToHitBonus2:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def Monster_Ability_Drain_Su_OnDealingDamage2(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjDamage) try: print("Monster_Ability_Drain_Su_OnDealingDamage2") attacks_with_drain = args.get_arg(4) num_nat_attack = evt_obj.attack_packet.event_key - 1000 print("evt_obj.attack_packet.event_key: {}, mode: {}".format( evt_obj.attack_packet.event_key, attacks_with_drain)) if (attacks_with_drain != 0): # 0 for all flag = 1 if (num_nat_attack > 0): flag = (1 << (num_nat_attack)) print("attacks_with_drain: {}, flag: {}".format( attacks_with_drain, flag)) if (not (attacks_with_drain & flag)): print("NOT THIS NATURAL ATTACK") return 0 target = evt_obj.attack_packet.target dc = args.get_arg(0) save = args.get_arg(1) toee.game.create_history_from_pattern( 68, attachee, target ) # {60}{[ACTOR] strikes with ~energy drain~[TAG_ENERGY_DRAINED] on [TARGET]!} saved = target.saving_throw(dc, save, toee.D20STD_F_NONE, attachee) if (saved): print("saved!") return 0 ability = args.get_arg(2) dice_packed = int(args.get_arg(3)) #!! long will fail dice = toee.dice_new("1d1") #print("setting dice_packed: {}".format(dice_packed)) #debug.breakp("dice_packed") dice.packed = dice_packed amount = dice.roll() print("target.condition_add_with_args(Temp_Ability_Loss, {}, {}) {}". format(ability, amount, target)) target.condition_add_with_args("Temp_Ability_Loss", ability, amount) #toee.game.create_history_from_pattern(61, attachee, toee.OBJ_HANDLE_NULL) # {61}{[ACTOR] recieves 5 ~temporary hit points~[TAG_TEMPORARY_HIT_POINTS].} except Exception, e: print "Monster_Ability_Drain_Su_OnDealingDamage2 error:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def place_encounter_k08(self): self.create_promter_at( utils_obj.sec2loc(460, 488), self.get_dialogid_default(), 80, 10, py06122_cormyr_prompter.PROMTER_DIALOG_METHOD_DIALOG, "The Gauntlet", const_toee.rotation_0400_oclock) door = utils_obj.find_nearest_obj_by_nameid_loc( utils_obj.sec2loc(460, 474), 10, coe_consts.NAME_DOOR_CRYPT1_DOOR_8_9, toee.OLC_PORTAL) if (door): utils_trap.setup_trap(door, const_traps.TRAP_SCYTHE_20x20_2, 6605) else: debug.breakp("no door!") return
def encounter_create(encounter): assert isinstance(encounter, toee.PyRandomEncounter) print("encounter_create encounter.flags: {}".format(encounter.flags)) try: if (encounter.flags & toee.ES_F_SLEEP_ENCOUNTER): daemon_ctrl = ctrl_daemon.CtrlDaemon.get_current_daemon() if (daemon_ctrl and ("encounter_create" in dir(daemon_ctrl))): daemon_ctrl.encounter_create(encounter) except Exception, e: print "!!!!!!!!!!!!! encounter_create error:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def make_instance_from_dic(propval, mod_cache): mod_class = None try: assert isinstance(propval, dict) #print("Contents of propval: ".format(propval)) #for key in propval.iterkeys(): # print("{} : {}".format(key, propval[key])) isofclass = None if ("_isofclass" in propval): isofclass = propval[u'_isofclass'] isofmodule = None if ("_isofmodule" in propval): isofmodule = propval[u'_isofmodule'] #print("make_instance_from_dic isofclass: {}, isofmodule: {}".format(isofclass, isofmodule)) if (not isofclass): return Storage.make_data(propval, None, mod_cache) result = None if (isofmodule is None): result = instantinate_by_eval(isofclass) else: mod_name = os.path.basename(isofmodule).split('.')[0] if (not (mod_cache and isofmodule in mod_cache)): mod_path = os.path.join(os.getcwd(), "overrides", "scr", mod_name + ".py") #mod_object = imp.load_source(mod_name, mod_path) mod_object = __import__(mod_name) mod_cache[isofmodule] = mod_object else: mod_object = mod_cache[isofmodule] mod_class = getattr(mod_object, isofclass) result = mod_class() #print("make_instance_from_dic result: {}, mod_class: {}, mod_object: {}".format(result, mod_class, mod_object)) sub_data = Storage.make_data(propval, result, mod_cache) result.__dict__ = sub_data if ("storage_data_loaded" in dir(result)): result.storage_data_loaded() except Exception, e: print "!!!!!!!!!!!!! make_instance_from_dic error:" print '-' * 60 print("mod_class: {}, isofclass: {}, mod_object: {}, ".format( mod_class, isofclass, mod_object)) traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def Monster_No_Damage_OnDealingDamage2(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjDamage) try: evt_obj.damage_packet.add_damage_bonus( -evt_obj.damage_packet.final_damage, 0, 0) evt_obj.damage_packet.final_damage = 0 except Exception, e: print "Monster_No_Damage_OnDealingDamage2:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def Cast_Defensively_Remove(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Signal) debug.breakp("Cast_Defensively_Remove") print("Cast_Defensively_Remove {} {}".format(attachee, evt_obj.data1)) args.condition_remove() return 0 #modObj = templeplus.pymod.PythonModifier() #modObj.ExtendExisting("Cast_Defensively") #modObj.AddHook(toee.ET_OnD20PythonSignal, "Cast_Defensively_Remove", Cast_Defensively_Remove, ()) #modObj.AddHook(toee.ET_OnD20Signal, toee.EK_S_Resurrection, Cast_Defensively_Remove, ()) #modObj.AddHook(toee.ET_OnD20Signal, toee.EK_S_SetCastDefensively, Cast_Defensively_Remove, ())
def load(savegame): #breakp("Storage.load({})".format(savegame)) saveDirBase = "modules\\{}\\save\\".format( Storage.get_default_module()) saveDirName = "d" + savegame saveDirName = "\\Current\\dSlot" saveDir = saveDirBase + saveDirName ss = Storage() oo = ss.objs oo.clear() if (os.path.exists(saveDir)): Storage.loadObjects(saveDir) else: print("Storage failed to locate dir: {}".format(saveDir)) debug.breakp("") return
def place_encounter_k10(self): self.create_promter_at( utils_obj.sec2loc(458, 451), self.get_dialogid_default(), 100, 10, py06122_cormyr_prompter.PROMTER_DIALOG_METHOD_DIALOG, "Supply Vault", const_toee.rotation_0400_oclock) if (not coe_consts.ISDEBUG): door = utils_obj.find_nearest_obj_by_nameid_loc( utils_obj.sec2loc(460, 457), 10, coe_consts.NAME_DOOR_CRYPT1_DOOR_9_10, toee.OLC_PORTAL) if (door): utils_locks.portal_setup_dc(door, utils_locks.LOCK_DC_GOOD, coe_consts.KEY_CRYPT1_DOOR_9_10 \ , utils_locks.HP_DOOR_WOODEN_STRONG, utils_locks.HARDNESS_DOOR_WOODEN_STRONG, utils_locks.BREAK_DC_DOOR_WOODEN_STRONG) else: debug.breakp("no door!") return
def reveal_monster(self, encounter_name, monster_code_name, no_error = 0): npc = None info = self.get_monsterinfo(encounter_name, monster_code_name) if (info): npc = toee.game.get_obj_by_id(info.id) if (npc and not info.revealed): ctrl = ctrl_behaviour.CtrlBehaviour.get_from_obj(npc) if (ctrl and ("revealing" in dir(ctrl))): ctrl.revealing(npc) info.revealed = 1 npc.object_flag_unset(toee.OF_DONTDRAW) if (ctrl and ("revealed" in dir(ctrl))): ctrl.revealed(npc) if (not npc and not no_error and (not info or not info.revealed)): print("Monster {} {} not found!".format(encounter_name, monster_code_name)) debug.breakp("Monster not found") return npc, info
def Napping_OnBeginRound(attachee, args, evt_obj): try: assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Signal) if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL): print("Napping_OnBeginRound") if (args.get_arg(0)): had_rolls = 0 dice_info = None listen_distance = args.get_arg(1) if (not listen_distance): listen_distance = NAPPING_LISTEN_DISTANCE_DEFAULT objs = toee.game.obj_list_range( attachee.location, listen_distance, toee.OLC_PC ) # removed for perfomance toee.OLC_PC | toee.OLC_NPC if (objs): if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL): print("Processing {} targets...".format(len(objs))) for target in objs: if (not SkillDiceInfo.isTargetEligible(attachee, target)): if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL): print("Target is not eligible: {}".format(target)) continue if (dice_info is None): dice_info = SkillDiceInfo() dice_info.distance = None heard = dice_info.CheckListenAgainst(attachee, target) if (heard == 2): NappingRemove(attachee, args) break if (heard): had_rolls = 1 else: if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL): print("No immidiate targets found") if (had_rolls): attachee.float_text_line("Zzzz?", 4) # yellow else: attachee.float_text_line("Zzzz", 2) # green except Exception, e: print "Shout Napping_OnBeginRound error:", sys.exc_info()[0] print(str(e)) debug.breakp("Napping_OnBeginRound error")
def Monaster_Bite_Perform(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Action) try: debug.breakp("Monaster_Bite_Perform") d20a = evt_obj.d20a d20a.action_type = toee.D20A_UNSPECIFIED_ATTACK #attachee.anim_goal_push_attack(evt_obj.d20a.target, 2, 0, 1) evt_obj.d20a.anim_id = attachee.anim_goal_get_new_id() evt_obj.d20a.flags |= toee.D20CAF_NEED_ANIM_COMPLETED evt_obj.d20a.data1 = 1000 evt_obj.d20a.to_hit_processing() except Exception, e: print "Monaster_Bite_Perform:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debugg.breakp("error")
def Bar_Door_Perform(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Action) try: target = evt_obj.d20a.target assert isinstance(target, toee.PyObjHandle) print(target) target_type = 0 if (target): target_type = target.type if (not target or target_type != toee.obj_t_portal): message = "Please popup Break action on Container or Portal!" target.float_text_line(message, toee.tf_red) #toee.game.alert_show(message, "Close") return 0 ag_close_door = 47 print("Barring the door") #attachee.anim_goal_use_object(target, ag_close_door, target.location, 1) attachee.turn_towards(target) target.portal_flag_unset(toee.OPF_OPEN) target.portal_flag_set(toee.OPF_LOCKED) target.portal_flag_set(toee.OPF_JAMMED) isOpen = None isJammed = None isLocked = None if (target): isOpen = target.portal_flags_get() & toee.OPF_OPEN isJammed = target.portal_flags_get() & toee.OPF_JAMMED isLocked = target.portal_flags_get() & toee.OPF_LOCKED print("target: {}, open: {}, jammed: {}, locked: {}".format(target, isOpen, isJammed, isLocked)) attachee.anim_push(102) except Exception, e: print "Bar_Door_Perform:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 debug.breakp("error")
def sp_darkness_S_Combat_End(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) print("sp_darkness_S_Combat_End attachee: {}".format(attachee)) try: spellId = args.get_arg(0) spell_packet = tpdp.SpellPacket(spellId) if (spell_packet.spell_enum == 0): print("sp_darkness_S_Combat_End attachee: {} spell_packet.spell_enum == 0!!".format(attachee)) return print("sp_darkness_S_Combat_End attachee: {} removing spell!".format(attachee)) #args.remove_spell() spell_packet.end_target_particles(attachee) lst = list() for i in range(0, 20): target = spell_packet.get_target(i) if (not target): continue #if (target == attachee): continue lst.append(target) print(lst) for target in lst: print("target.d20_send_signal(toee.EK_S_Spell_End, {}) for {}".format(spellId, target)) spell_packet.end_target_particles(target) target.d20_send_signal(toee.EK_S_Spell_End-toee.EK_S_HP_Changed, spellId) spell_packet.remove_target(target) lst = None spell_packet.update_registry() #spell_packet.remove_target(attachee) args.remove_spell_with_key(toee.EK_S_Killed) args.remove_spell_mod() args.set_arg(1, 0) except Exception, e: print "sp_darkness_S_Combat_End error:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 debug.breakp("error")
def obj_float_line_dialog(obj, method, lineId, npc): assert isinstance(obj, toee.PyObjHandle) scriptId = obj.scripts[const_toee.sn_dialog] if (scriptId <= 0): return 0 if (method == 0): obj.float_line(lineId, npc) return 1 #print("obj_float_line_dialog({}, {}, {})".format(obj, method, lineId)) #breakp("obj_float_line_dialog") fileName = utils_toee.find_dialog_file_name(scriptId) #print(fileName) #breakp("obj_float_line_dialog 2") if (fileName is None): return 0 #obj.float_mesfile_line(fileName, lineId, White) #if (1==1): return 1 fileName = "data\\dlg\\" + fileName line = utils_toee.readMesLine(fileName, lineId) if (line): line = line.replace("\\n", "\n") print("utils_toee.readMesLine = {}, lineId: {}, dlg: {}".format( line, lineId, scriptId)) debug.breakp("obj_float_line_dialog 3") if (method == 2): toee.game.alert_show(line, "Close") return 1 lineshort = "" if (method == 3): lines = line.split('.') lineshort = lines[0] if (len(lines) > 1): lineshort = lineshort + ".." else: lineshort = line if ((line is None) or (line == "")): return 0 #breakp("obj_float_line_dialog 4") obj.float_text_line(lineshort, White) line = line + "\n\n" toee.game.create_history_freeform(line) return 1
def sp_darkness_OnEnterAoE(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjObjectEvent) try: print("sp_darkness_OnEnterAoE attachee: {}, evt_obj.target: {}".format(attachee, evt_obj.target)) obj_evt_id = args.get_arg(2) if (obj_evt_id != evt_obj.evt_id): return 0 target = evt_obj.target if (not attachee or not target): return 0 f = target.object_flags_get() if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED) or (f & toee.OF_DONTDRAW)): return 0 spell_id = args.get_arg(0) spell_packet = tpdp.SpellPacket(spell_id) if (not spell_packet): print("spell_packet is null!") debug.breakp("spell_packet is null") return 0 spell_packet.trigger_aoe_hit() duration = args.get_arg(1) if (target != attachee): partsys_id = toee.game.particles( "sp-Solid Fog-hit", target) spell_packet.add_target(target, partsys_id) spell_packet.update_registry() target.condition_add_with_args('sp-Darkness hit', spell_id, duration, obj_evt_id) except Exception, e: print "sp_darkness_S_Combat_End error:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 debug.breakp("error")
def Smash_Object_Perform(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Action) try: target = evt_obj.d20a.target assert isinstance(target, toee.PyObjHandle) print(target) target_type = 0 if (target): target_type = target.type if (not target or not (target_type == toee.obj_t_container or target_type == toee.obj_t_portal)): message = "Must be Container or Portal!" target.float_text_line(message, toee.tf_red) #toee.game.alert_show(message, "Close") return 0 ac = 5 if (1): bonlistTarget = tpdp.BonusList() bonlistTarget.add(10, 0, 102) #{102}{Initial Value} bonlistTarget.add(-5, 0, 104) #{104}{~Dexterity~[TAG_DEXTERITY] Bonus} bonlistTarget.add(-2, 0, "Inanimate object") ac = bonlistTarget.get_total() atkBon = tpdp.EventObjAttack() bonus = atkBon.dispatch(attachee, target, toee.ET_OnToHitBonus2, toee.EK_D20A_UNSPECIFIED_ATTACK) flags = atkBon.attack_packet.get_flags() dice = toee.dice_new("1d20") roll = dice.roll() check = roll + bonus >= ac crit_hist_id = None if (check): flags |= toee.D20CAF_HIT critThreatRange = 21 - tpdp.EventObjAttack().dispatch( attachee, toee.OBJ_HANDLE_NULL, toee.ET_OnGetCriticalHitRange, toee.EK_D20A_UNSPECIFIED_ATTACK) if (roll >= critThreatRange): critroll = dice.roll() #critroll = 15 crit_hist_id = tpdp.create_history_attack_roll( attachee, target, critroll, atkBon.bonus_list, bonlistTarget, flags) if (critroll + bonus >= ac): flags |= toee.D20CAF_CRITICAL hist_id = tpdp.create_history_attack_roll(attachee, target, roll, atkBon.bonus_list, bonlistTarget, flags) toee.game.create_history_from_id(hist_id) if (crit_hist_id): toee.game.create_history_from_id(crit_hist_id) reduction = target.obj_get_int(toee.obj_f_hp_adj) hp0 = target.stat_level_get(toee.stat_hp_current) args.set_arg(2, reduction) target.deal_attack_damage(attachee, toee.EK_D20A_UNSPECIFIED_ATTACK, flags, toee.D20A_SUNDER) args.set_arg(2, 0) hp = target.stat_level_get(toee.stat_hp_current) print("HP changed from {} to {}".format(hp0, hp)) if (hp > 0): target.float_text_line("{} hp left".format(hp), toee.tf_yellow) return 0 if (target_type == toee.obj_t_portal): target.portal_flag_unset(toee.OPF_LOCKED) target.portal_flag_unset(toee.OPF_JAMMED) target.object_flag_set(toee.OF_DONTDRAW) #target.object_flag_set(toee.OF_EXTINCT) #target.portal_flag_set(toee.OPF_OPEN) portal_open_and_off(target) elif (target_type == toee.obj_t_container): target.container_flag_unset(toee.OCOF_LOCKED) target.container_flag_unset(toee.OCOF_JAMMED) target.container_flag_set(toee.OCOF_BUSTED) attachee.anim_goal_use_object(target) except Exception, e: args.set_arg(2, 0) print "Smash_Object_Perform:" print '-' * 60 traceback.print_exc(file=sys.stdout) print '-' * 60 debug.breakp("error")
def Break_Object_Perform(attachee, args, evt_obj): assert isinstance(attachee, toee.PyObjHandle) assert isinstance(args, tpdp.EventArgs) assert isinstance(evt_obj, tpdp.EventObjD20Action) try: target = evt_obj.d20a.target assert isinstance(target, toee.PyObjHandle) print(target) target_type = 0 if (target): target_type = target.type if (not target or not (target_type == toee.obj_t_container or target_type == toee.obj_t_portal)): message = "Please popup Break action on Container or Portal!" target.float_text_line(message, toee.tf_red) #toee.game.alert_show(message, "Close") return 0 dc = 23 if (target_type == toee.obj_t_container): container_flags = target.container_flags_get() dc = target.obj_get_int(toee.obj_f_container_pad_i_1) if (not dc): dc = target.obj_get_int(toee.obj_f_secretdoor_dc) if (not dc): dc = 23 if (not container_flags & toee.OCOF_LOCKED): target.float_text_line("Not Locked!", toee.tf_yellow) return 0 if (container_flags & toee.OCOF_ALWAYS_LOCKED): target.float_text_line("Cannot be Broken!", toee.tf_red) return 0 if (container_flags & toee.OCOF_MAGICALLY_HELD): target.float_text_line("Cannot be Broken! Magically held.", toee.tf_red) return 0 if (target_type == toee.obj_t_portal): portal_flags = target.portal_flags_get() dc = target.obj_get_int(toee.obj_f_portal_pad_i_1) if (not dc): dc = 23 if (not portal_flags & toee.OPF_LOCKED): target.float_text_line("Not Locked!", toee.tf_yellow) return 0 if (portal_flags & toee.OPF_ALWAYS_LOCKED): target.float_text_line("Cannot be Broken!", toee.tf_red) return 0 if (portal_flags & toee.OPF_MAGICALLY_HELD): target.float_text_line("Cannot be Broken! Magically held.", toee.tf_red) return 0 #text = "Break an Object" text = "Break {}".format(target.description) #debug.breakp("bonuslist") bonuslist = tpdp.BonusList() bonus = tpdp.dispatch_stat(attachee, toee.stat_str_mod, bonuslist) dice = toee.dice_new("1d20") roll = dice.roll() check = roll + bonus >= dc hist_id = tpdp.create_history_dc_roll(attachee, dc, dice, roll, text, bonuslist) toee.game.create_history_from_id(hist_id) if (check): if (target.type == toee.obj_t_container): target.container_flag_unset(toee.OCOF_LOCKED) target.container_flag_unset(toee.OCOF_JAMMED) target.container_flag_set(toee.OCOF_BUSTED) target.float_text_line("Success!", toee.tf_green) elif (target.type == toee.obj_t_portal): target.portal_flag_unset(toee.OPF_LOCKED) target.portal_flag_set(toee.OPF_BUSTED) target.float_text_line("Success!", toee.tf_green) else: if (bonus + 20 < dc): target.float_text_line("Impossible!", toee.tf_red) else: target.float_text_line("Failure!", toee.tf_red) attachee.anim_goal_use_object(target) except Exception, e: print "Break_Object_Perform:" print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 debug.breakp("error")