Beispiel #1
0
def OnProjectileDestroyed(attachee, args, evt_obj):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(args, tpdp.EventArgs)
    assert isinstance(evt_obj, tpdp.EventObjAttack)
    try:
        print("Belch_Fire_OnProjectileDestroyed")
        tgt = evt_obj.attack_packet.target
        print("target: {}".format(tgt))
        if (not tgt):
            tgt = attachee.obj_get_obj(toee.obj_f_last_hit_by)
            print("target2: {}".format(tgt))
        #proj.obj_get_obj(toee.obj_f_last_hit_by, d20action.target) ammo_item
        flags = evt_obj.attack_packet.get_flags()
        hit = flags & toee.D20CAF_HIT
        print("hit: {}, flags: {}".format(hit, flags))
        if (hit and tgt):
            dc = 19
            #tgt.damage_with_reduction(attachee, toee.D20DT_FIRE, toee.dice_new("6d6"), toee.D20DAP_NORMAL, )
            tgt.reflex_save_and_damage(attachee, dc,
                                       toee.D20_Save_Reduction_Half,
                                       toee.D20STD_F_NONE,
                                       toee.dice_new("6d6"), toee.D20DT_FIRE,
                                       toee.D20DAP_NORMAL, toee.D20A_NONE, 0)
            toee.game.particles("su-Ball_of_Fire-Hit", tgt)
            range = 6
            adj_dice = toee.dice_new("3d6")
            for obj in toee.game.obj_list_range(tgt.location, range,
                                                toee.OLC_PC | toee.OLC_NPC):
                if (obj == tgt): continue
                f = obj.object_flags_get()
                if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                        or (f & toee.OF_DONTDRAW)):
                    continue
                obj.reflex_save_and_damage(attachee, dc,
                                           toee.D20_Save_Reduction_Half,
                                           toee.D20STD_F_NONE, adj_dice,
                                           toee.D20DT_FIRE, toee.D20DAP_NORMAL,
                                           toee.D20A_NONE, 0)
                #toee.game.particles("sp-Spheres of Fire-hit", obj)

        else:
            print("missed")
    except Exception, e:
        print "Belch_Fire_OnProjectileDestroyed error:"
        print '-' * 60
        traceback.print_exc(file=sys.stdout)
        print '-' * 60
        debugg.breakp("error")
Beispiel #2
0
def npc_move_silently_against_listener(npc, target):
    assert isinstance(npc, toee.PyObjHandle)
    assert isinstance(target, toee.PyObjHandle)

    dice20 = toee.dice_new("1d20")

    npc_bonus_list = tpdp.BonusList()
    npc_roll = dice20.roll()
    npc_score = tpdp.dispatch_skill(npc, toee.skill_move_silently,
                                    npc_bonus_list, toee.OBJ_HANDLE_NULL, 1)
    npc_score_total = npc_score + npc_roll
    print("npc hide roll: {}, skill: {}, total: {}".format(
        npc_roll, npc_score, npc_score_total))

    target_bonus_list = tpdp.BonusList()
    target_roll = dice20.roll()
    target_score = tpdp.dispatch_skill(target, toee.skill_listen,
                                       target_bonus_list, toee.OBJ_HANDLE_NULL,
                                       1)
    target_score_total = target_score + target_roll
    print("target listen roll: {}, skill: {}, total: {}".format(
        target_roll, target_score, target_score_total))
    success = npc_score_total > target_score_total
    hist_id = tpdp.create_history_type6_opposed_check(
        npc, target, npc_roll, target_roll, npc_bonus_list, target_bonus_list,
        5126, 103 - success, 1)  # \overrides\tpmes\combat.mes"
    toee.game.create_history_from_id(hist_id)
    return not success
def Line_Of_Acid_Perform(attachee, args, evt_obj):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(args, tpdp.EventArgs)
    assert isinstance(evt_obj, tpdp.EventObjD20Action)
    try:
        radius = args.get_arg(0)
        if (not radius): radius = 40
        damage_multiplier = args.get_arg(1)
        if (not damage_multiplier): damage_multiplier = 4
        dc = args.get_arg(2)
        if (not dc): dc = 16
        caster = attachee
        targets, furthest = BreathLineGetBestTargets(caster, radius)
        print(targets)
        if (targets):
            if (not furthest): furthest = targets[0]
            target_loc = furthest.location
            target_loc_off_x = furthest.off_x
            target_loc_off_y = furthest.off_y
            target_loc_off_z = furthest.obj_get_int(toee.obj_f_offset_z)
            caster.turn_towards(furthest)
            toee.game.create_history_freeform(
                "{} performs Breath Weapon (Su)!\n\n".format(
                    caster.description))
            toee.game.particles("sp-Call Lightning", caster)
            #toee.game.particles("sp-Cone of Cold", caster )
            toee.game.pfx_lightning_bolt(caster, target_loc, target_loc_off_x,
                                         target_loc_off_y, target_loc_off_z)
            affected = targets
            dce = toee.dice_new("{}d4".format(damage_multiplier))
            for target in affected:
                assert isinstance(target, toee.PyObjHandle)
                if (target == caster): continue
                if (target.type != toee.obj_t_npc
                        and target.type != toee.obj_t_pc):
                    continue
                f = target.object_flags_get()
                if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                        or (f & toee.OF_DONTDRAW)):
                    continue
                descriptor = 0  #toee.D20STD_F_SPELL_DESCRIPTOR_ACID todo
                target.reflex_save_and_damage(caster, dc,
                                              toee.DAMAGE_REDUCTION_HALF,
                                              descriptor, dce, toee.D20DT_ACID,
                                              toee.D20DAP_NORMAL,
                                              toee.D20A_CLASS_ABILITY_SA, 0)
                toee.game.particles("sp-Call Lightning-hit", target)

            if (furthest > 0 and caster.anim_goal_push_attack(
                    furthest, toee.game.random_range(0, 2), 1, 0)):
                new_anim_id = caster.anim_goal_get_new_id()
                #print("pushed new anim id: {}".format(new_anim_id))
                evt_obj.d20a.flags |= toee.D20CAF_NEED_ANIM_COMPLETED
                evt_obj.d20a.anim_id = new_anim_id
    except Exception, e:
        print "Line_Of_Acid_Perform:"
        print '-' * 60
        traceback.print_exc(file=sys.stdout)
        print '-' * 60
        debugg.breakp("error")
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")
Beispiel #5
0
def npc_make_hide(npc, ignore_observed):
    assert isinstance(npc, toee.PyObjHandle)
    if (not ignore_observed): return 0  # implement it later

    dice20 = toee.dice_new("1d20")

    npc_bonus_list = tpdp.BonusList()
    npc_roll = dice20.roll()
    npc_score = tpdp.dispatch_skill(npc, toee.skill_hide, npc_bonus_list,
                                    toee.OBJ_HANDLE_NULL, 1)
    npc_score_total = npc_score + npc_roll
    print("npc hide roll: {}, skill: {}, total: {}".format(
        npc_roll, npc_score, npc_score_total))

    hidden_not_from_count = 0
    objects = toee.game.obj_list_vicinity(npc.location,
                                          toee.OLC_PC | toee.OLC_NPC)
    if (objects):
        foes = []
        for obj in objects:
            if (obj == npc): continue
            f = obj.object_flags_get()
            if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                    or (f & toee.OF_DONTDRAW)):
                continue
            if (obj.allegiance_shared(npc)): continue
            if (not obj.can_see(npc)): continue
            foes.append(obj)
        if (foes):
            for target in foes:
                target_bonus_list = tpdp.BonusList()
                target_roll = dice20.roll()
                target_score = tpdp.dispatch_skill(target, toee.skill_spot,
                                                   target_bonus_list,
                                                   toee.OBJ_HANDLE_NULL, 1)
                target_score_total = target_score + target_roll
                print("target hide roll: {}, skill: {}, total: {}".format(
                    target_roll, target_score, target_score_total))
                success = npc_score_total > target_score_total
                hist_id = tpdp.create_history_type6_opposed_check(
                    npc, target, npc_roll, target_roll, npc_bonus_list,
                    target_bonus_list, 5126, 103 - success,
                    1)  # \overrides\tpmes\combat.mes"
                toee.game.create_history_from_id(hist_id)
                if (not success):
                    hidden_not_from_count += 1
                    npc.float_text_line("(Failed to Hide)", toee.tf_red)
                    print("Failed to Hide")
                    break

    if (hidden_not_from_count): return 0
    if (foes):  # make sure chars even see him
        npc.float_text_line("Hidden!", toee.tf_blue)
    print("HIDDEN!")
    npc.anim_goal_interrupt()
    npc.critter_flag_set(toee.OCF_MOVING_SILENTLY)
    return 1
 def created(self, npc):
     assert isinstance(npc, toee.PyObjHandle)
     super(CtrlShadow, self).created(npc)
     npc.condition_add_with_args("Monster_Ability_Drain_Su", 0, 0,
                                 toee.stat_strength,
                                 toee.dice_new("1d6").packed, 0)
     npc.condition_add("Monster_Touch_Attack")
     #npc.condition_add("Monster_No_Damage")
     npc.condition_add_with_args("Monster Damage Type", toee.D20DT_SUBDUAL)
     return
    def created(self, npc):
        assert isinstance(npc, toee.PyObjHandle)
        super(CtrlBeetleBombardier, self).created(npc)
        # assign scripts
        #utils_obj.obj_scripts_clear(npc)
        npc.scripts[const_toee.sn_start_combat] = COE_ENCOUNTERS
        npc.scripts[const_toee.sn_enter_combat] = COE_ENCOUNTERS

        npc.condition_add_with_args("Acid_Spray", 10,
                                    toee.dice_new("1d4+2").packed, 13)
        return
Beispiel #8
0
def Quills_Ex_OnGetBonusAttacks(attachee, args, evt_obj):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(args, tpdp.EventArgs)
    assert isinstance(evt_obj, tpdp.EventObjD20Action)

    if (evt_obj.bonus_list):
        quill_attacks = toee.dice_new("1d4").roll()
        # assume critter has at least two
        add_quill_attacks = quill_attacks - 1
        if (add_quill_attacks > 0):
            evt_obj.bonus_list.add(add_quill_attacks, 34, "Quills")
    return 0
Beispiel #9
0
def trap_trigger_kassen_blades(attachee, triggerer, partsys, trap):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(triggerer, toee.PyObjHandle)
    assert isinstance(trap, toee.PyTrap)

    dice = toee.dice_new("1d8+1")
    dice_crit = toee.dice_new("2d8+2")

    hot_range_y = (477, 478, 482, 483, 486, 487, 490, 491)
    for pc in toee.game.leader.group_list():
        x, y = utils_obj.loc2sec(pc.location)
        if (not y in hot_range_y): continue
        if (partsys): toee.game.particles(partsys, pc)
        toee.game.sound(4029, 1)
        hit = trap.attack(pc, 10, 19, 0)
        if (hit & toee.D20CAF_HIT):
            dice_ = dice
            if (hit & toee.D20CAF_CRITICAL): dice_ = dice_crit
            pc.damage(attachee, toee.D20DT_SLASHING, dice_, toee.D20DAP_NORMAL,
                      toee.D20A_NONE)
    return
Beispiel #10
0
def Python_Action_Shriek_Perform(attachee, args, evt_obj):
	assert isinstance(attachee, toee.PyObjHandle)
	assert isinstance(args, tpdp.EventArgs)
	try:
		#debugg.breakp("Python_Action_Shriek_Perform")
		caster = attachee
		print("caster: {}".format(caster))
		toee.game.create_history_freeform("{} performs Shriek (Su)!\n\n".format(caster.description))
		affected = toee.game.obj_list_range(caster.location, 60, toee.OLC_CRITTERS)
		print("found: {}".format(affected))
		dce = toee.dice_new("2d4")
		dc = args.get_arg(0)
		if (not dc):
			dc = 12
		furthest = None
		furthest_dist = 0
		for target in affected:
			assert isinstance(target, toee.PyObjHandle)
			if (target == caster): continue
			if (target.type != toee.obj_t_npc and target.type != toee.obj_t_pc): continue
			f = target.object_flags_get()
			if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED) or (f & toee.OF_DONTDRAW)): continue
			if (not target.can_see(caster)):
				print("{}::not target.can_see({}), skip".format(GetConditionName(), target))
				continue
			if (target.d20_query(toee.EK_Q_Critter_Is_Deafened - toee.EK_Q_Helpless)):
				print("{}::target.d20_query(toee.EK_Q_Critter_Is_Deafened - toee.EK_Q_Helpless)({}), skip".format(GetConditionName(), target))
				continue
			print("processing target: {}".format(target))
			dist = target.distance_to(caster)
			if (not furthest or furthest_dist < dist):
				furthest = target
				furthest_dist = dist
			saved = target.saving_throw(dc, toee.D20_Save_Will, D20STD_SPELL_DESCRIPTOR_FEAR, caster)
			if (saved): continue
			remaining = dce.roll()
			#part = toee.game.particles('sp-Fear-Hit', target)
			target.condition_add_with_args("Paralyzed", remaining, 0)
			target.float_mesfile_line( 'mes\\combat.mes', 149, 1) # {149}{Paralyzed!}

		if (furthest):
			caster.turn_towards(furthest)
		toee.game.particles("sp-Fear", caster)

		if (len(affected) > 0 and caster.anim_goal_push_attack(affected[0], toee.game.random_range(0, 2), 1, 0)):
			new_anim_id = caster.anim_goal_get_new_id()
			#print("pushed new anim id: {}".format(new_anim_id))
			d20action.flags |= toee.D20CAF_NEED_ANIM_COMPLETED
			d20action.anim_id = new_anim_id
	except Exception, e:
		print "Python_Action_Shriek error:", sys.exc_info()[0]
		print(str(e))
Beispiel #11
0
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")
Beispiel #12
0
def npc_listen_against_pc(npc, distance_threshhold):
    assert isinstance(npc, toee.PyObjHandle)
    assert isinstance(distance_threshhold, int)
    objects = toee.game.obj_list_vicinity(npc.location,
                                          toee.OLC_PC | toee.OLC_NPC)
    if (not objects): return None
    foes = []
    for obj in objects:
        assert isinstance(obj, toee.PyObjHandle)
        if (obj == npc): continue
        f = obj.object_flags_get()
        if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                or (f & toee.OF_DONTDRAW)):
            continue
        if (obj.allegiance_shared(npc)): continue
        dist = npc.distance_to(obj)
        if (dist > distance_threshhold):
            continue
        print("distance: {}".format(dist))
        if (not obj.critter_flags_get() & toee.OCF_MOVING_SILENTLY): return obj
        foes.append(obj)
    if (not foes): return None

    dice20 = toee.dice_new("1d20")

    npc_bonus_list = tpdp.BonusList()
    npc_roll = dice20.roll()
    npc_score = tpdp.dispatch_skill(npc, toee.skill_listen, npc_bonus_list,
                                    toee.OBJ_HANDLE_NULL, 1)
    npc_score_total = npc_score + npc_roll
    print("npc listen roll: {}, skill: {}, total: {}".format(
        npc_roll, npc_score, npc_score_total))

    for target in foes:
        target_bonus_list = tpdp.BonusList()
        target_roll = dice20.roll()
        target_score = tpdp.dispatch_skill(target, toee.skill_move_silently,
                                           target_bonus_list,
                                           toee.OBJ_HANDLE_NULL, 1)
        target_score_total = target_score + target_roll
        print("target move silently roll: {}, skill: {}, total: {}".format(
            target_roll, target_score, target_score_total))
        success = npc_score_total > target_score_total
        hist_id = tpdp.create_history_type6_opposed_check(
            npc, target, npc_roll, target_roll, npc_bonus_list,
            target_bonus_list, 5125, 103 - success,
            1)  # \overrides\tpmes\combat.mes"
        toee.game.create_history_from_id(hist_id)
        if (success): return target
    return None
 def RollNpc(self, npc):
     assert isinstance(npc, toee.PyObjHandle)
     self.dice20 = toee.dice_new("1d20")
     self.npc_skill = npc.skill_level_get(toee.skill_listen)
     self.npc_skill_bonus = -10  # PHB p79: A sleeping character may make Listen checks at a –10 penalty. A successful check awakens the sleeper.
     self.npcroll_result = self.dice20.roll()
     self.npcroll_total = self.npcroll_result + self.npc_skill + self.npc_skill_bonus
     if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL == 2):
         print(
             "LISTEN ROLL NPC ({}):{} = {} + skill_listen: {} + npc_skill_bonus: {}"
             .format(npc.description, self.npcroll_total,
                     self.npcroll_result, self.npc_skill,
                     self.npc_skill_bonus))
     return
def trap_trigger_kassen_blades(attachee, triggerer, partsys, trap):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(triggerer, toee.PyObjHandle)
    assert isinstance(trap, toee.PyTrap)

    dice = toee.dice_new("1d8")
    dice_crit = toee.dice_new("2d8")

    toee.game.particles("Trap-Darts2", trap.obj)
    toee.game.sound(4023, 1)

    hot_range_x = (470, 484)
    hot_range_y = (471, 485)
    for pc in toee.game.leader.group_list():
        x, y = utils_obj.loc2sec(pc.location)
        if ((x < hot_range_x[0]) or (x > hot_range_x[1])): continue
        if ((y < hot_range_y[0]) or (y > hot_range_y[1])): continue
        hit = trap.attack(pc, 10, 19, 0)
        if (hit & toee.D20CAF_HIT):
            dice_ = dice
            if (hit & toee.D20CAF_CRITICAL): dice_ = dice_crit
            pc.damage(attachee, toee.D20DT_SUBDUAL, dice_,
                      toee.D20DAP_SLASHING, toee.D20A_NONE)
    return
Beispiel #15
0
def npc_perform_improved_diversion(npc):
    assert isinstance(npc, toee.PyObjHandle)

    npc_skill = npc.skill_level_get(toee.skill_bluff)
    npc_roll_dice = toee.dice_new("1d20")
    npcroll_result = npc_roll_dice.roll()
    npcroll_total = npcroll_result + npc_skill
    print("npc_perform_improved_diversion ROLL NPC:{} = {} + skill_bluff: {}".
          format(npcroll_total, npcroll_result, npc_skill))

    target_skill = target.skill_level_get(toee.skill_sense_motive)
    target_roll_dice = toee.dice_new("1d20")
    targetroll_result = target_roll_dice.roll()
    targetroll_total = targetroll_result + target_skill
    print(
        "npc_perform_improved_diversion ROLL target:{} = {} + skill_sense_motive: {}"
        .format(targetroll_total, targetroll_result, target_skill))

    if (targetroll_total >= npcroll_total):
        print("diversion failed")
        return 0

    print("diversion success")
    return 1
def Lethal_Shock_Perform(attachee, args, evt_obj):
    assert isinstance(attachee, toee.PyObjHandle)
    try:
        #debugg.breakp("Lethal_Shock_Perform")
        caster = attachee
        #print("caster: {}".format(caster))
        toee.game.create_history_freeform(
            "{} performs Lethal Shock (Su)!\n\n".format(caster.description))
        toee.game.particles("sp-Call Lightning", caster)
        affected = toee.game.obj_list_range(caster.location, 20,
                                            toee.OLC_CRITTERS)
        #print("found: {}".format(affected))
        dce = toee.dice_new("4d8")
        for target in affected:
            assert isinstance(target, toee.PyObjHandle)
            if (target == caster): continue
            if (target.type != toee.obj_t_npc
                    and target.type != toee.obj_t_pc):
                continue
            f = target.object_flags_get()
            if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                    or (f & toee.OF_DONTDRAW)):
                continue
            #print("processing target: {}".format(target))
            saved = target.saving_throw(12, toee.D20_Save_Reflex,
                                        toee.D20STD_F_NONE, caster)
            #print("saved: {}".format(saved))
            reduction = 100
            if (saved): reduction = toee.DAMAGE_REDUCTION_HALF
            target.damage_with_reduction(caster, toee.D20DT_ELECTRICITY, dce,
                                         toee.D20DAP_NORMAL, reduction,
                                         toee.D20A_CLASS_ABILITY_SA)
            toee.game.particles("sp-Call Lightning-hit", target)

        if (len(affected) > 0 and caster.anim_goal_push_attack(
                affected[0], toee.game.random_range(0, 2), 1, 0)):
            new_anim_id = caster.anim_goal_get_new_id()
            #print("pushed new anim id: {}".format(new_anim_id))
            d20action.flags |= toee.D20CAF_NEED_ANIM_COMPLETED
            d20action.anim_id = new_anim_id
    except Exception, e:
        print "Lethal_Shock_Perform error:", sys.exc_info()[0]
        print(str(e))
def trap_trigger_glyph_of_warding(attachee, triggerer, partsys):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(triggerer, toee.PyObjHandle)

    if (partsys):
        toee.game.particles(partsys, attachee)
    toee.game.sound(4029, 1)
    dice = toee.dice_new("2d8")
    radius_ft = 7
    for obj in toee.game.obj_list_range(attachee.location, radius_ft,
                                        toee.OLC_CRITTERS):
        f = obj.object_flags_get()
        if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                or (f & toee.OF_DONTDRAW)):
            continue
        obj.reflex_save_and_damage(attachee, 14, toee.D20_Save_Reduction_Half,
                                   0x4 | 0x2000 | 0x20, dice, toee.D20DT_ACID,
                                   toee.D20DAP_MAGIC, toee.D20A_NONE, 0)

    return
Beispiel #18
0
def perform_sneak_for_attack(npc, target):
    assert isinstance(npc, toee.PyObjHandle)
    assert isinstance(target, toee.PyObjHandle)
    print("perform_sneak_for_attack, npc:{}, target:{}".format(npc, target))

    if (not (npc.has_los(target))):
        print("success no LOS")
        return 1

    if (npc.can_sneak_attack(target) != 1):
        print("failed can_sneak_attack")
        return 0

    overcome_observed = True
    if (npc_is_observed(npc, target) != 0):
        overcome_observed = npc_overcome_observed(npc, target)

    if (not overcome_observed): return 0

    # hide vs spot check
    npc_skill = npc.skill_level_get(toee.skill_hide)
    npc_roll_dice = dice_new("1d20")
    npcroll_result = npc_roll_dice.roll()
    npcroll_total = npcroll_result + npc_skill
    print("perform_sneak_for_attack ROLL NPC:{} = {} + npc_skill: {}".format(
        npcroll_total, npcroll_result, npc_skill))

    target_skill = target.skill_level_get(toee.skill_spot)
    target_roll_dice = toee.dice_new("1d20")
    targetroll_result = target_roll_dice.roll()
    targetroll_total = targetroll_result + target_skill
    print(
        "perform_sneak_for_attack ROLL target:{} = {} + skill_spot: {}".format(
            targetroll_total, targetroll_result, target_skill))

    if (targetroll_total >= npcroll_total):
        print("HIDE failed")
        return 0

    print("HIDE success")
    return 1
Beispiel #19
0
def skill_roll(attachee, triggerer, dc, ayup, nope, skill_num, text):
	assert isinstance(attachee, toee.PyObjHandle)
	assert isinstance(triggerer, toee.PyObjHandle)
	assert isinstance(dc, int)
	assert isinstance(ayup, int)
	assert isinstance(nope, int)
	assert isinstance(skill_num, int)
	assert isinstance(text, str)

	bon_list = tpdp.BonusList()
	skill_value = tpdp.dispatch_skill(triggerer, skill_num, bon_list, toee.OBJ_HANDLE_NULL, 1)
	dice = toee.dice_new("1d20")
	roll_result = dice.roll()
	success = skill_value + roll_result >= dc
	hist_id = tpdp.create_history_dc_roll(triggerer, dc, dice, roll_result, text, bon_list)
	toee.game.create_history_from_id(hist_id)

	if success:
		triggerer.begin_dialog( attachee, ayup )
	else:
		triggerer.begin_dialog( attachee, nope )
	return success
Beispiel #20
0
def trap_trigger_pit_trap(attachee, triggerer, partsys):
    assert isinstance(attachee, toee.PyObjHandle)
    assert isinstance(triggerer, toee.PyObjHandle)

    if (partsys):
        toee.game.particles(partsys, attachee)
    #toee.game.sound(4029, 1)
    dice = toee.dice_new("1d6")
    dc_reflex = 20
    radius_ft = 7
    for obj in toee.game.obj_list_range(attachee.location, radius_ft,
                                        toee.OLC_CRITTERS):
        f = obj.object_flags_get()
        if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                or (f & toee.OF_DONTDRAW)):
            continue
        if (not obj.reflex_save_and_damage(
                attachee, dc_reflex, toee.D20_Save_Reduction_Half,
                toee.D20STD_F_TRAP, dice, toee.D20DT_SUBDUAL,
                toee.D20DAP_NORMAL, toee.D20A_NONE, 0)):
            obj.fall_down()
    return
def Pull_Down_Ceiling_Perform(attachee, args, evt_obj):
	assert isinstance(attachee, toee.PyObjHandle)
	try:
		#debugg.breakp("Pull_Down_Ceiling_Perform")
		caster = attachee
		#print("caster: {}".format(caster))
		toee.game.create_history_freeform("{} Pulls Down the Ceiling!\n\n".format(caster.description))
		toee.game.particles("ef-ripples-huge", caster)
		caster.float_text_line("Pulls Down the Ceiling!", 0)
		affected = toee.game.obj_list_range(caster.location, 15, toee.OLC_CRITTERS)
		#print("found: {}".format(affected))
		dce = toee.dice_new("6d6")
		for target in affected:
			assert isinstance(target, toee.PyObjHandle)
			if (target == caster): continue
			if (target.type != toee.obj_t_npc and target.type != toee.obj_t_pc): continue
			f = target.object_flags_get()
			if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED) or (f & toee.OF_DONTDRAW)): continue
			#print("processing target: {}".format(target))
			saved = target.saving_throw(15, toee.D20_Save_Reflex, toee.D20STD_F_NONE, caster)
			#print("saved: {}".format(saved))
			reduction = 100
			if (saved): reduction = toee.DAMAGE_REDUCTION_HALF
			target.damage_with_reduction(caster, toee.D20DT_BLUDGEONING, dce, toee.D20DAP_NORMAL, reduction, toee.D20A_CLASS_ABILITY_SA)
			if (not saved and target.d20_query(toee.Q_Prone) == 0):
				target.fall_down()
				target.condition_add("Prone")
				target.float_mesfile_line('mes\\combat.mes', 104, 1 ) # Tripped!
			toee.game.particles("ef-splash", target)

		if (len(affected) > 0 and caster.anim_goal_push_attack(affected[0], toee.game.random_range(0, 2), 1, 0)):
			new_anim_id = caster.anim_goal_get_new_id()
			#print("pushed new anim id: {}".format(new_anim_id))
			d20action.flags |= toee.D20CAF_NEED_ANIM_COMPLETED
			d20action.anim_id = new_anim_id
	except Exception, e:
		print "Pull_Down_Ceiling_Perform error:", sys.exc_info()[0]
		print(str(e))
def Lodged_Quills_OnD20PythonActionPerform(attachee, args, evt_obj):
	assert isinstance(attachee, toee.PyObjHandle)
	assert isinstance(args, tpdp.EventArgs)
	assert isinstance(evt_obj, tpdp.EventObjD20Action)
	#debug.breakp("Lodged_Quills_OnD20PythonActionPerform start")
	try:
		lodged_quills = args.get_arg(0)
		if (lodged_quills):
			target = evt_obj.d20a.target
			#toee.game.create_history_freeform("{} removes lodged Quill...\n\n".format(attachee.description))
			check = attachee.skill_roll(toee.skill_heal, 20, 0)
			if (check):
				attachee.float_text_line("Quill removed successfully!", toee.tf_green)
			else:
				dice = toee.dice_new("1d6")
				target.damage(toee.OBJ_HANDLE_NULL, toee.D20DT_BLOOD_LOSS, dice, toee.D20DAP_NORMAL, toee.D20A_UNSPECIFIED_ATTACK)
				attachee.float_text_line("Quill removed with some blood loss!", toee.tf_red)
			args.set_arg(0, lodged_quills - 1)
		if (not args.get_arg(0)):
			args.condition_remove()
	except Exception, e:
		print "Lodged_Quills_OnD20PythonActionPerform error:", sys.exc_info()[0]
		print(str(e))
def pc_party_set_starting_gold_as_raw(roll=None):
    totalgp = 0
    for pc in toee.game.party:
        class_num = pc.char_classes[0]
        pcgp = 200
        if (class_num == toee.stat_level_barbarian):
            if (roll): pcgp = toee.dice_new("4d4").roll() * 10
            else: pcgp = 160
        elif (class_num == toee.stat_level_bard):
            if (roll): pcgp = toee.dice_new("4d4").roll() * 10
            else: pcgp = 160
        elif (class_num == toee.stat_level_cleric):
            if (roll): pcgp = toee.dice_new("5d4").roll() * 10
            else: pcgp = 200
        elif (class_num == toee.stat_level_druid):
            if (roll): pcgp = toee.dice_new("2d4").roll() * 10
            else: pcgp = 80
        elif (class_num == toee.stat_level_fighter):
            if (roll): pcgp = toee.dice_new("6d4").roll() * 10
            else: pcgp = 240
        elif (class_num == toee.stat_level_monk):
            if (roll): pcgp = toee.dice_new("5d4").roll() * 10
            else: pcgp = 200
        elif (class_num == toee.stat_level_paladin):
            if (roll): pcgp = toee.dice_new("6d4").roll() * 10
            else: pcgp = 240
        elif (class_num == toee.stat_level_ranger):
            if (roll): pcgp = toee.dice_new("6d4").roll() * 10
            else: pcgp = 240
        elif (class_num == toee.stat_level_rogue):
            if (roll): pcgp = toee.dice_new("5d4").roll() * 10
            else: pcgp = 200
        elif (class_num == toee.stat_level_sorcerer):
            if (roll): pcgp = toee.dice_new("3d4").roll() * 10
            else: pcgp = 120
        elif (class_num == toee.stat_level_wizard):
            if (roll): pcgp = toee.dice_new("3d4").roll() * 10
            else: pcgp = 120
        totalgp += pcgp
    total = totalgp * 100
    currentcp = toee.game.party[0].money_get()
    diff = total - currentcp
    print("Supposed totalgp: {}, current: {}, diff: {}".format(
        totalgp, currentcp // 100, diff))
    if (diff > 0):
        toee.game.party[0].money_adj(diff)
    return diff
    def get_weapon_list(self):
        result = list()

        weapon = self.npc.item_worn_at(toee.item_wear_weapon_primary)
        if (weapon):
            item = StatInspectWeapon()
            item.attack_bonus = self.npc.stat_level_get(
                toee.stat_melee_attack_bonus)
            item.name = weapon.description
            weapon_type = weapon.obj_get_int(toee.obj_f_weapon_type)
            item.is_ranged = toee.game.is_ranged_weapon(weapon_type)
            if (item.is_ranged):
                item.attack_bonus = self.npc.stat_level_get(
                    toee.stat_ranged_attack_bonus)

            if (1):
                wname = item.name.lower()
                conds_equipment = None
                if (hasattr(self.npc, 'conditions_get')):
                    kind = 2  #itemConds
                    conds_equipment = self.npc.conditions_get(kind)
                    if (debug_print): print(conds_equipment)
                    if conds_equipment:
                        already = dict()
                        for cond in conds_equipment:
                            cond_name = cond[0]
                            if (cond_name in already): continue
                            already[cond_name] = 1
                            if (cond_name == "Weapon Masterwork"):
                                if (not "Weapon Enhancement Bonus" in already):
                                    item.attack_bonus += 1
                                    item.is_masterwork = 1
                                continue

                            if (cond_name == "Weapon Enhancement Bonus"):
                                if ("Weapon Masterwork" in already):
                                    item.attack_bonus -= 1
                                    item.is_masterwork = 0
                                b = cond[1][0]
                                item.attack_bonus += b
                                item.damage_bonus += b
                                item.ench_bonus += b
                                continue

                            if (cond_name == "Weapon Flaming"):
                                if (item.damage_bonus_dice_str):
                                    item.damage_bonus_dice_str = item.damage_bonus_dice_str + " "
                                item.damage_bonus_dice_str += "+ 1d6 (fire)"
                                continue

                            if (cond_name == "Weapon Frost"):
                                if (item.damage_bonus_dice_str):
                                    item.damage_bonus_dice_str = item.damage_bonus_dice_str + " "
                                item.damage_bonus_dice_str += "+ 1d6 (cold)"
                                continue

                            if (cond_name == "Weapon Shock"):
                                if (item.damage_bonus_dice_str):
                                    item.damage_bonus_dice_str = item.damage_bonus_dice_str + " "
                                item.damage_bonus_dice_str += "+ 1d6 (electricity)"
                                continue

                            if (cond_name == "Weapon Holy"):
                                if (item.damage_bonus_dice_str):
                                    item.damage_bonus_dice_str = item.damage_bonus_dice_str + " "
                                item.damage_bonus_dice_str += "+ 2d6 (holy)"
                                continue

                            if (cond_name == "Weapon Unholy"):
                                if (item.damage_bonus_dice_str):
                                    item.damage_bonus_dice_str = item.damage_bonus_dice_str + " "
                                item.damage_bonus_dice_str += "+ 2d6 (unholy)"
                                continue

                            if (cond_name == "Composite Bow"):
                                b = cond[1][0]
                                item.damage_bonus += b
                                continue
                #debugg.breakp("")

            if (1):
                dmg_dice_packed = weapon.obj_get_int(
                    toee.obj_f_weapon_damage_dice)
                if (debug_print):
                    print("Weapon dmg_dice_packed: {}".format(dmg_dice_packed))
                dmg_dice = toee.dice_new("1d1")
                dmg_dice.packed = dmg_dice_packed
                dmg_dice.bonus += item.damage_bonus
                if (not item.is_ranged):
                    damage_bonus = self.npc.stat_level_get(
                        toee.stat_damage_bonus)
                    if (debug_print):
                        print("Weapon damage_bonus: {}".format(damage_bonus))
                    dmg_dice.bonus += damage_bonus
                dmg_dice_str = str(dmg_dice)
                if (debug_print):
                    print("Weapon dmg_dice_str: {}".format(dmg_dice_str))
                item.damage_dice_str = dmg_dice_str

            if (1):
                crit_range = weapon.obj_get_int(toee.obj_f_weapon_crit_range)
                if (debug_print):
                    print("Weapon crit_range: {}".format(crit_range))
                if (crit_range == 0): crit_range = 20
                else: crit_range = 21 - crit_range
                crit_range_str = ""
                if (crit_range < 20):
                    crit_range_str = "{}-20".format(crit_range)
                if (debug_print):
                    print("Weapon crit_range_str: {}".format(crit_range_str))
                item.crit_range_str = crit_range_str

            if (1):
                crit_hit_chart = weapon.obj_get_int(
                    toee.obj_f_weapon_crit_hit_chart)
                if (crit_hit_chart == 0): crit_hit_chart = 2
                item.crit_chart = crit_hit_chart
            if (debug_print): print(item)

            result.append(item)
        else:
            attack_count = 0
            for i in range(0, 4):
                atk = self.npc.obj_get_idx_int(toee.obj_f_critter_attacks_idx,
                                               i)
                attack_count += atk
            if (attack_count):
                atkidx = 0
                str_mod = self.npc.stat_level_get(toee.stat_str_mod)
                for i in range(0, 3):
                    atk_num = self.npc.obj_get_idx_int(
                        toee.obj_f_critter_attacks_idx, i)
                    if (not atk_num): continue
                    atkidx += 1
                    item = StatInspectWeapon()
                    #item.attack_bonus = self.npc.stat_level_get(toee.stat_melee_attack_bonus)
                    #item.name = "Natural {}".format("atkidx")
                    item.name = self.get_natural_attack_name(
                        self.npc.obj_get_idx_int(toee.obj_f_attack_types_idx,
                                                 i))
                    item.attack_bonus = self.npc.obj_get_idx_int(
                        toee.obj_f_attack_bonus_idx, i)
                    if (not item.is_ranged and atkidx != 4):
                        item.attack_bonus += str_mod
                    item.atk_num = atk_num
                    # todo size malus
                    dmg_dice_packed = self.npc.obj_get_idx_int(
                        toee.obj_f_critter_damage_idx, i)
                    dmg_dice = toee.dice_new("1d1")
                    dmg_dice.packed = dmg_dice_packed
                    if (not item.is_ranged and atkidx != 4):
                        dmg_dice.bonus += str_mod
                    dmg_dice_str = str(dmg_dice)
                    if (debug_print):
                        print("Natural dmg_dice_str: {}".format(dmg_dice_str))
                    item.damage_dice_str = dmg_dice_str
                    result.append(item)

        return result
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")
Beispiel #27
0
def npc_make_hide_and_surprise(npc):
    assert isinstance(npc, toee.PyObjHandle)
    print("npc_make_hide_and_surprise: {}".format(npc))

    dice20 = toee.dice_new("1d20")

    npc_bonus_list = tpdp.BonusList()
    npc_roll = dice20.roll()
    npc_score = tpdp.dispatch_skill(npc, toee.skill_hide, npc_bonus_list,
                                    toee.OBJ_HANDLE_NULL, 1)
    npc_score_total = npc_score + npc_roll
    print("npc hide roll: {}, skill: {}, total: {}".format(
        npc_roll, npc_score, npc_score_total))

    hidden_not_from_count = 0
    hidden_from_count = 0
    objects = toee.game.obj_list_vicinity(npc.location,
                                          toee.OLC_PC | toee.OLC_NPC)
    if (objects):
        suprised_list = list()
        notsuprised_list = list()
        foes = []
        for obj in objects:
            if (obj == npc): continue
            f = obj.object_flags_get()
            if ((f & toee.OF_OFF) or (f & toee.OF_DESTROYED)
                    or (f & toee.OF_DONTDRAW)):
                continue
            if (obj.allegiance_shared(npc)): continue
            if (not obj.can_see(npc)):
                suprised_list.append(obj)
                continue
            foes.append(obj)
        if (foes):
            for target in foes:
                target_bonus_list = tpdp.BonusList()
                target_roll = dice20.roll()
                target_score = tpdp.dispatch_skill(target, toee.skill_spot,
                                                   target_bonus_list,
                                                   toee.OBJ_HANDLE_NULL, 1)
                target_score_total = target_score + target_roll
                print("target hide roll: {}, skill: {}, total: {}".format(
                    target_roll, target_score, target_score_total))
                success = npc_score_total > target_score_total
                hist_id = tpdp.create_history_type6_opposed_check(
                    npc, target, npc_roll, target_roll, npc_bonus_list,
                    target_bonus_list, 5126, 103 - success,
                    1)  # \overrides\tpmes\combat.mes"
                toee.game.create_history_from_id(hist_id)
                if (not success):
                    hidden_not_from_count += 1
                    notsuprised_list.append(target)
                else:
                    suprised_list.append(target)
                    hidden_from_count += 1

    if (hidden_from_count == 0):
        print("no suprise round")
        npc.critter_flag_unset(toee.OCF_MOVING_SILENTLY)
        # no suprise round
        return 0

    if (hidden_not_from_count == 0):
        npc.float_text_line("Hidden!", toee.tf_blue)
        print("HIDDEN!")
        npc.anim_goal_interrupt()
        npc.critter_flag_set(toee.OCF_MOVING_SILENTLY)
    else:
        print("Failed to Hide")

    #npc.float_text_line("Surprise!", toee.tf_light_blue)

    for target in suprised_list:
        print("Surprised: {}".format(target))
        target.condition_add("Surprised2")
        target.float_text_line("Surprised!", toee.tf_red)

    for target in notsuprised_list:
        print("Not Surprised: {}".format(target))
        target.condition_add("SurpriseRound2")

    npc.condition_add("SurpriseRound2")
    return 1