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

@@ -1005,4 +1005,91 @@ def pbSynchronizeQuestLog()
pbSetQuest(40, true) if $game_self_switches[[565, 9, "A"]]
pbSetQuest(41, true) if $game_self_switches[[565, 10, "A"]]
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
for reward in rewards_to_give
echoln reward.item
end
#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