Author Topic: Girl of Doubt Quest Killcounter  (Read 56 times)

Offline Avanael

  • Vassal
  • *
  • Posts: 5
Girl of Doubt Quest Killcounter
« on: January 14, 2020, 08:13:40 PM »
Hello :D

For this quest at one point you have to kill 2 mobs in order to continue the quest. Those kills are counted via global variable and are not being resetted which means, every time the server restarts, only the first player gets to finish the quest while other players are not able to finish because the variable sums up every time a player kills those 2 mobs.

Here's the fix where the kill count is stored via player variable.

Code: [Select]
diff --git a/dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java b/dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java
index 65d022a..ee1f072 100644
--- a/dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java
+++ b/dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java
@@ -142,6 +142,7 @@
  {
  if (!npc.getVariables().getBoolean(I_QUEST1, false))
  {
+ qs.set("killCount", 0);
  npc.getVariables().set(I_QUEST1, true);
  addSpawn(CREATURE_OF_THE_DUSK1, 89440, -238016, -9632, getRandom(360), false, 0, false, player.getInstanceId());
  addSpawn(CREATURE_OF_THE_DUSK2, 89524, -238131, -9632, getRandom(360), false, 0, false, player.getInstanceId());
@@ -197,7 +198,7 @@
  public String onKill(Npc npc, PlayerInstance player, boolean isSummon)
  {
  final QuestState qs = getRandomPartyMemberState(player, -1, 3, npc);
- if(qs != null)
+ if (qs != null)
  {
  if (CommonUtil.contains(MOBS, npc.getId()))
  {
@@ -208,7 +209,8 @@
  }
  else
  {
- killCount++;
+ int killCount = qs.getInt("killCount");
+ qs.set("killCount", killCount++);
  if (killCount == 2)
  {
  qs.setMemoState(6);

The global variable "killCount" at the top isn't deleted in this diff because I forgot it in my commit though.

Online Mobius

  • Administrator
  • Distinguished King
  • *****
  • Posts: 6618
Re: Girl of Doubt Quest Killcounter
« Reply #1 on: January 14, 2020, 08:32:52 PM »
Can you try this?
Code: [Select]
Index: dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java
===================================================================
--- dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java (revision 6710)
+++ dist/game/data/scripts/quests/Q10292_SevenSignsGirlOfDoubt/Q10292_SevenSignsGirlOfDoubt.java (working copy)
@@ -42,8 +42,8 @@
  // Misc
  private static final int MIN_LEVEL = 81;
  // Variables
- private static int killCount = 0;
  private static final String I_QUEST1 = "I_QUEST1";
+ private static final String KILLCOUNT_VAR = "killCount";
  // Monster
  private static final int CREATURE_OF_THE_DUSK1 = 27422;
  private static final int CREATURE_OF_THE_DUSK2 = 27424;
@@ -208,12 +208,16 @@
  }
  else
  {
- killCount++;
- if (killCount == 2)
+ if (qs.getInt(KILLCOUNT_VAR) == 1)
  {
+ qs.unset(KILLCOUNT_VAR);
  qs.setMemoState(6);
  qs.setCond(6);
  }
+ else
+ {
+ qs.set(KILLCOUNT_VAR, 1);
+ }
  }
  }
  return super.onKill(npc, player, isSummon);

Offline Avanael

  • Vassal
  • *
  • Posts: 5
Re: Girl of Doubt Quest Killcounter
« Reply #2 on: January 14, 2020, 10:33:00 PM »
That's even better structurewise and also works, tested it :)

Online Mobius

  • Administrator
  • Distinguished King
  • *****
  • Posts: 6618
Re: Girl of Doubt Quest Killcounter
« Reply #3 on: January 14, 2020, 10:35:40 PM »
Thank you.
Locked until a new free version comes.