Fix game now gives back missed HMs if any

This commit is contained in:
infinitefusion
2024-12-30 15:58:23 -05:00
parent 0a7f0cbbef
commit c2954b8e84
15 changed files with 142 additions and 84 deletions

View File

@@ -1561,89 +1561,6 @@ def turnPlayerTowardsEvent(event)
end
end
def showQuestStatistics(eventId,includeRocketQuests=false)
quests_accepted = []
quests_in_progress=[]
quests_completed=[]
for quest in $Trainer.quests
next if quest.npc == QuestBranchRocket && !includeRocketQuests
quests_accepted<<quest
if quest.completed
quests_completed << quest
else
quests_in_progress << quest
end
end
pbCallBub(2, eventId)
pbMessage("Accepted quests: \\C[1]#{quests_accepted.length}")
pbCallBub(2, eventId)
pbMessage("Completed quests: \\C[1]#{quests_completed.length}")
pbCallBub(2, eventId)
pbMessage("In-progress: \\C[1]#{quests_in_progress.length}")
end
def get_completed_quests(includeRocketQuests=false)
quests_completed=[]
for quest in $Trainer.quests
next if quest.npc == QuestBranchRocket && !includeRocketQuests
quests_completed << quest if quest.completed
end
return quests_completed
end
def getQuestReward(eventId)
$PokemonGlobal.questRewardsObtained = [] if !$PokemonGlobal.questRewardsObtained
nb_quests_completed = get_completed_quests(false).length #pbGet(VAR_STAT_QUESTS_COMPLETED)
pbSet(VAR_STAT_QUESTS_COMPLETED,nb_quests_completed)
rewards_to_give = []
for reward in QUEST_REWARDS
rewards_to_give << reward if nb_quests_completed >= reward.nb_quests && !$PokemonGlobal.questRewardsObtained.include?(reward.item)
end
#Calculate how many until next reward
next_reward = get_next_quest_reward
nb_to_next_reward = next_reward.nb_quests - nb_quests_completed
rewards_to_give << next_reward if nb_to_next_reward <=0 #for compatibility with old system
#Give rewards
for reward in rewards_to_give
if !reward.can_have_multiple && $PokemonBag.pbQuantity(reward.item) >= 1
$PokemonGlobal.questRewardsObtained << reward.item
next
end
pbCallBub(2, eventId)
pbMessage("Also, there's one more thing...")
pbCallBub(2, eventId)
pbMessage("As a gift for having helped so many people, I want to give you this.")
pbReceiveItem(reward.item, reward.quantity)
$PokemonGlobal.questRewardsObtained << reward.item
#recalculate nb to next reward
next_reward = get_next_quest_reward
nb_to_next_reward = next_reward.nb_quests - nb_quests_completed
end
pbCallBub(2, eventId)
if nb_to_next_reward == 0
pbMessage("I have no more rewards to give you! Thanks for helping all these people!")
elsif nb_to_next_reward == 1
pbMessage("Help #{nb_to_next_reward} more person and I'll give you something good!")
else
pbMessage("Help #{nb_to_next_reward} more people and I'll give you something good!")
end
end
def get_next_quest_reward()
for reward in QUEST_REWARDS
nextReward = reward
break if !$PokemonGlobal.questRewardsObtained.include?(reward.item)
end
# rewards_to_give << nextReward if nb_to_next_reward <=0 #for compatibility with old system
return nextReward
end
def displaySpriteWindowWithMessage(pif_sprite, message = "", x = 0, y = 0,z=0)
spriteLoader = BattleSpriteLoader.new
@@ -1667,3 +1584,57 @@ def select_any_pokemon()
return pbChooseList(commands, 0, nil, 1)
end
SWITCH_SS_ANNE_DEPARTED=88
SWITCH_SNORLAX_GONE_ROUTE_12=110
SWITCH_TELEPORT_NPC = 122
SWITCH_GOT_DIVE=317
SWITCH_GOT_ROCK_CLIMB=661
SWITCH_GOT_WATERFALL=388
def fixMissedHMs()
#Flash
if $PokemonBag.pbQuantity(:HM08) < 1 && $PokemonGlobal.questRewardsObtained.include?(:HM08)
pbReceiveItem(:HM08)
end
#Cut
if $PokemonBag.pbQuantity(:HM01) < 1 && $game_switches[SWITCH_SS_ANNE_DEPARTED]
pbReceiveItem(:HM01)
end
#Strength
if $PokemonBag.pbQuantity(:HM04) < 1 && $game_switches[SWITCH_SNORLAX_GONE_ROUTE_12]
pbReceiveItem(:HM04)
end
#Surf
if $PokemonBag.pbQuantity(:HM03) < 1 && $game_self_switches[[107, 1, "A"]]
pbReceiveItem(:HM03)
end
#Teleport
if $PokemonBag.pbQuantity(:HM07) < 1 && $game_switches[SWITCH_TELEPORT_NPC]
pbReceiveItem(:HM07)
end
#Fly
if $PokemonBag.pbQuantity(:HM02) < 1 && $game_self_switches[[439, 1, "B"]]
pbReceiveItem(:HM02)
end
#Waterfall
if $PokemonBag.pbQuantity(:HM05) < 1 && $game_switches[SWITCH_GOT_WATERFALL]
pbReceiveItem(:HM05)
end
#Dive
if $PokemonBag.pbQuantity(:HM06) < 1 && $game_switches[SWITCH_GOT_DIVE]
pbReceiveItem(:HM06)
end
#Rock Climb
if $PokemonBag.pbQuantity(:HM10) < 1 && $game_switches[SWITCH_GOT_ROCK_CLIMB]
pbReceiveItem(:HM10)
end
end