Exemplo n.º 1
0
    def CheckListenAgainst(self, attachee, target):
        assert isinstance(attachee, toee.PyObjHandle)
        assert isinstance(target, toee.PyObjHandle)

        if (self.dice20 is None):
            self.RollNpc(attachee)

        result = 0
        #debug.breakp("CheckListenAgainst1")
        target_distance = self.distance
        if (target_distance is None):
            target_distance = attachee.distance_to(target)
        target_distance_bonus = int(target_distance // 10 + 1)
        target_battle_bonus = 0
        targetcritter_flags = target.critter_flags_get()
        if (targetcritter_flags & toee.OCF_COMBAT_MODE_ACTIVE):
            target_battle_bonus = -10
        target_skill = target.skill_level_get(toee.skill_move_silently)
        target_is_moving_silently = 0
        if (targetcritter_flags & toee.OCF_MOVING_SILENTLY):
            target_is_moving_silently = 1
        targetroll_result = 10
        if (target_is_moving_silently): targetroll_result = self.dice20.roll()
        targetroll_total = targetroll_result + target_skill + target_distance_bonus + target_battle_bonus
        if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL == 2):
            print(
                "MOVE SILENTLY ROLL target ({}):{} = {} + skill_move_silently: {} + dist bonus: {}, _battle_bonus: {}"
                .format(target.description, targetroll_total,
                        targetroll_result, target_skill, target_distance_bonus,
                        target_battle_bonus))
        if (self.npcroll_total < targetroll_total):
            if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL == 2): print("Did not hear")
            result = 1
        else:
            if (NAPPING_LISTEN_DEBUG_PRINT_LEVEL == 2): print("Awakes!")
            npc_bonus_list = tpdp.BonusList()
            #debug.breakp("CheckListenAgainst2")
            tpdp.dispatch_skill(attachee, toee.skill_listen, npc_bonus_list,
                                toee.OBJ_HANDLE_NULL, 1)
            if (self.npc_skill_bonus):
                npc_bonus_list.add(self.npc_skill_bonus, 0, "Sleeping")

            target_bonus_list = tpdp.BonusList()
            tpdp.dispatch_skill(target, toee.skill_move_silently,
                                target_bonus_list, toee.OBJ_HANDLE_NULL, 1)
            if (target_distance_bonus):
                target_bonus_list.add(
                    target_distance_bonus, 0,
                    "Distance {:.0f} ft".format(target_distance))

            if (target_battle_bonus):
                target_bonus_list.add(target_battle_bonus, 0, "Battle")

            attachee.float_text_line("Awakes!", 1)
            hist_id = tpdp.create_history_type6_opposed_check(
                attachee, target, self.npcroll_result, targetroll_result,
                npc_bonus_list, target_bonus_list, 5125, 102, 1)
            toee.game.create_history_from_id(hist_id)
            return 2
        return result
Exemplo n.º 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
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
0
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")
Exemplo n.º 6
0
def skillCheck(attachee, skillEnum, skillCheckDc):
    skillName = game.get_mesline("mes/skill.mes", skillEnum)
    bonusListSkill = tpdp.BonusList()
    skillValue = tpdp.dispatch_skill(attachee, skillEnum , bonusListSkill, OBJ_HANDLE_NULL, 1)
    skillDice = dice_new('1d20')
    skillDiceRoll = skillDice.roll()
    skillRollResult = skillDiceRoll + skillValue
    skillHistoryId = tpdp.create_history_dc_roll(attachee, skillCheckDc, skillDice, skillDiceRoll, "{}".format(skillName), bonusListSkill)
    game.create_history_from_id(skillHistoryId)
    checkResult = True if skillRollResult >= skillCheckDc else False
    return checkResult
Exemplo n.º 7
0
def reflex_roll_delta(target, dc):
	dice = dice_new('1d20')

	reflex_mod = target.stat_level_get(stat_save_reflexes)
	bonus = tpdp.BonusList()
	bonus.add(reflex_mod, 0, "~Reflex~[TAG_SAVE_REFLEX] Saves")
	roll = dice.roll()

	hist = tpdp.create_history_dc_roll(
			target, dc, dice, roll, "Reflexive Balance", bonus)

	game.create_history_from_id(hist)

	print roll

	return roll + reflex_mod - dc
Exemplo n.º 8
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
Exemplo n.º 9
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
Exemplo n.º 10
0
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")
Exemplo n.º 11
0
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")