public override bool OnDialog(GameObject attachee, GameObject triggerer) { if (!triggerer.GetAlignment().IsGood()) { GameObject good_pc = null; foreach (var obj in GameSystems.Party.PartyMembers) { if ((ScriptDaemon.is_safe_to_talk_rfv(attachee, obj, 45, false, false) && obj.GetAlignment().IsGood())) { good_pc = obj; } } if (good_pc != null) { attachee.TurnTowards(triggerer); triggerer.BeginDialog(attachee, 200); // "I would prefer to speak to the good hearted one" } } else if ((attachee.FindItemByName(3014) != null)) { attachee.TurnTowards(triggerer); triggerer.BeginDialog(attachee, 50); } else { attachee.TurnTowards(triggerer); triggerer.BeginDialog(attachee, 1); } return(SkipDefault); }
public override bool OnHeartbeat(GameObject attachee, GameObject triggerer) { if (attachee.GetScriptId(ObjScriptEvent.EnterCombat) == 0) { attachee.SetScriptId(ObjScriptEvent.EnterCombat, 185); // assigns san_enter_combat if one doesn't exist } // This script's execution of searching for a good aligned PC usually fails // The reason: it searches for a PC at a distance of 15 // Very often, your good aligned PC would be standing slightly farther away // While another PC would be just at that distance // So the script would fail to find the good aligned PC, and find the nearer PC and initiate conversation with that PC // Suggested fix: search for a good PC slightly farther away (distance 25) // If one is not found, look for any PC at distance 15 if ((!GameSystems.Combat.IsCombatActive())) { GameObject good_pc = null; GameObject paladin_pc = null; GameObject good_tank_pc = null; GameObject good_cleric_pc = null; GameObject faraway_good_pc = null; // near_pc = OBJ_HANDLE_NULL foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC)) { if ((ScriptDaemon.is_safe_to_talk_rfv(attachee, obj, 25))) { // near_pc = obj if ((obj.GetAlignment().IsGood())) { good_pc = obj; if ((obj.GetStat(Stat.level_paladin) > 1)) { paladin_pc = obj; } if ((obj.GetStat(Stat.level_fighter) > 1) || (obj.GetStat(Stat.level_barbarian) > 1) || (obj.GetStat(Stat.level_ranger) > 1)) { good_tank_pc = obj; } if ((obj.GetStat(Stat.level_cleric) > 1)) { good_cleric_pc = obj; } } } } // if (obj.item_find(3014) != OBJ_HANDLE_NULL ): # Prince Thrommel's Golden Amulet (name ID; shared with halfling sai) // obj.begin_dialog(attachee,50) // game.new_sid = 0 // return RUN_DEFAULT if ((paladin_pc != null)) { attachee.TurnTowards(paladin_pc); paladin_pc.BeginDialog(attachee, 1); DetachScript(); } else if ((good_tank_pc != null)) { attachee.TurnTowards(good_tank_pc); good_tank_pc.BeginDialog(attachee, 1); DetachScript(); } else if ((good_cleric_pc != null)) { attachee.TurnTowards(good_cleric_pc); good_cleric_pc.BeginDialog(attachee, 1); DetachScript(); } else if ((good_pc != null)) { attachee.TurnTowards(good_pc); good_pc.BeginDialog(attachee, 1); DetachScript(); } else { GameObject near_pc = null; foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC)) { if ((ScriptDaemon.is_safe_to_talk_rfv(attachee, obj, 15))) { near_pc = obj; if ((obj.GetAlignment().IsGood())) { good_pc = obj; } if ((obj.FindItemByName(3014) != null)) // Prince Thrommel's Golden Amulet (name ID; shared with halfling sai) { attachee.TurnTowards(obj); obj.BeginDialog(attachee, 50); DetachScript(); return(RunDefault); } } if ((ScriptDaemon.is_safe_to_talk_rfv(attachee, obj, 45, false, false) && obj.GetAlignment().IsGood())) { faraway_good_pc = obj; } } if ((near_pc != null)) { attachee.TurnTowards(near_pc); if (faraway_good_pc == null) { near_pc.BeginDialog(attachee, 1); } else { near_pc.BeginDialog(attachee, 200); } DetachScript(); } } } return(RunDefault); }
public static void call_good_pc(GameObject npc, GameObject pc) { npc.RemoveScript(ObjScriptEvent.Heartbeat); // remove heartbeat so it doesn't interfere GameObject good_pc = null; GameObject paladin_pc = null; GameObject good_tank_pc = null; GameObject good_cleric_pc = null; GameObject new_talker = null; // game.particles( "sp-summon monster I", pc ) # fired ok foreach (var obj in ObjList.ListVicinity(npc.GetLocation(), ObjectListFilter.OLC_PC)) { if ((ScriptDaemon.is_safe_to_talk_rfv(npc, obj, 45, false, false) && obj.GetAlignment().IsGood())) { // game.particles( 'Orb-Summon-Fire-Elemental', pc ) good_pc = obj; if ((obj.GetStat(Stat.level_paladin) > 1)) { paladin_pc = obj; } if ((obj.GetStat(Stat.level_fighter) > 1) || (obj.GetStat(Stat.level_barbarian) > 1) || (obj.GetStat(Stat.level_ranger) > 1)) { good_tank_pc = obj; } if ((obj.GetStat(Stat.level_cleric) > 1)) { good_cleric_pc = obj; } } } if ((paladin_pc != null)) { new_talker = paladin_pc; } else if ((good_tank_pc != null)) { new_talker = good_tank_pc; } else if ((good_cleric_pc != null)) { new_talker = good_cleric_pc; } else if ((good_pc != null)) { new_talker = good_pc; } if (new_talker == null) // failsafe { new_talker = pc; new_talker.BeginDialog(npc, 240); } else { new_talker.Move(pc.GetLocation().OffsetTiles(-2, 0)); new_talker.TurnTowards(npc); npc.TurnTowards(new_talker); new_talker.BeginDialog(npc, 220); return; } return; }
public override bool OnHeartbeat(GameObject attachee, GameObject triggerer) { attachee.SetScriptId(ObjScriptEvent.EnterCombat, 109); // assign enter_combat script if ((GameSystems.Combat.IsCombatActive())) { if ((attachee != null && !attachee.IsUnconscious() && !attachee.D20Query(D20DispatcherKey.QUE_Prone))) { run_off(attachee, triggerer); return(SkipDefault); } } if ((!GameSystems.Combat.IsCombatActive() && ScriptDaemon.tpsts("dala_buggered_off", 1))) { var downed_bozos = 0; foreach (var hostel_patron in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC)) { if ((new[] { 8018, 14145, 14074 }).Contains(hostel_patron.GetNameId())) { if (hostel_patron.IsUnconscious() || hostel_patron.GetLeader() != null) { downed_bozos += 1; } } } if (downed_bozos >= 2) { // attachee.float_mesfile_line( 'mes\\test.mes', 1, 0 ) attachee.FadeTo(255, 1, 50); foreach (var hostel_patron in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC)) { foreach (var pc in SelectedPartyLeader.GetPartyMembers()) { hostel_patron.AIRemoveFromShitlist(pc); hostel_patron.SetReaction(pc, 80); } } attachee.ClearObjectFlag(ObjectFlag.CLICK_THROUGH); attachee.ClearObjectFlag(ObjectFlag.OFF); foreach (var hostel_patron in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC)) { foreach (var pc in SelectedPartyLeader.GetPartyMembers()) { hostel_patron.AIRemoveFromShitlist(pc); hostel_patron.SetReaction(pc, 80); } } attachee.SetBaseStat(Stat.strength, 10); if (!ScriptDaemon.get_f("have_talked_to_dala_post_battle")) // initiate Dala monologue where she faints { foreach (var pc in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC)) { if (ScriptDaemon.is_safe_to_talk_rfv(attachee, pc, 40)) { ScriptDaemon.set_f("have_talked_to_dala_post_battle"); pc.BeginDialog(attachee, 200); } } } } } else if ((!GameSystems.Combat.IsCombatActive())) // this takes care of the infinite battle loop { // attachee.float_mesfile_line( 'mes\\test.mes', 2, 0 ) foreach (var hostel_patron in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC)) { if (!((new[] { 8018, 14145, 14074 }).Contains(hostel_patron.GetNameId()))) // added condition because apparently sometimes combat doesn't start before this heartbeat fires and thus it sets them to non-hostile status and no combat actually commences { foreach (var pc in SelectedPartyLeader.GetPartyMembers()) { hostel_patron.AIRemoveFromShitlist(pc); hostel_patron.SetReaction(pc, 80); } } } } if ((GetQuestState(37) == QuestState.Completed)) { // game.new_sid = 0 # commented by S.A. - the heartbeat is now needed var dummy = 1; } else if ((!GetGlobalFlag(89))) { if ((!GameSystems.Combat.IsCombatActive())) { var(xx, yy) = attachee.GetLocation(); if (xx == 478 && yy == 504 && !attachee.HasLineOfSight(SelectedPartyLeader)) { attachee.TurnTowards(SelectedPartyLeader); } foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC)) { if ((attachee.HasLineOfSight(obj))) { SetGlobalFlag(89, true); StartTimer(7200000, () => reset_global_flag_89(attachee)); // call reset_global_flag_89 in 2 hours attachee.StealFrom(obj); return(RunDefault); } } } } return(RunDefault); }