Skip to content

Commit

Permalink
Track completions of Chocolate for Elisabeth & Ice Cream for Annie qu…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
AntumDeluge committed Apr 16, 2024
1 parent 6195a06 commit 37de198
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 63 deletions.
11 changes: 11 additions & 0 deletions src/games/stendhal/server/entity/player/UpdateConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,17 @@ public static void updateQuests(final Player player) {
if (player.hasQuest(questSlot) && !slotState.startsWith(";")) {
player.setQuest(questSlot, ";" + slotState);
}

// 1.47: support completions tracking
for (String slot: Arrays.asList("chocolate_for_elisabeth", "icecream_for_annie")) {
if (!player.hasQuest(slot)) {
continue;
}
final String[] state = player.getQuest(slot).split(";");
if ("eating".equals(player.getQuest(slot, 0)) && "".equals(player.getQuest(slot, 2))) {
player.setQuest(slot, 2, "1");
}
}
}


Expand Down
38 changes: 20 additions & 18 deletions src/games/stendhal/server/maps/quests/ChocolateForElisabeth.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* $Id$ */
/***************************************************************************
* (C) Copyright 2003-2023 - Stendhal *
* (C) Copyright 2003-2024 - Stendhal *
***************************************************************************
***************************************************************************
* *
Expand Down Expand Up @@ -30,6 +30,7 @@
import games.stendhal.server.entity.npc.action.DropItemAction;
import games.stendhal.server.entity.npc.action.IncreaseKarmaAction;
import games.stendhal.server.entity.npc.action.IncreaseXPAction;
import games.stendhal.server.entity.npc.action.IncrementQuestAction;
import games.stendhal.server.entity.npc.action.InflictStatusOnNPCAction;
import games.stendhal.server.entity.npc.action.MultipleActions;
import games.stendhal.server.entity.npc.action.SetQuestAction;
Expand Down Expand Up @@ -104,7 +105,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestNotStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "rejected")),
new QuestNotStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, 0, "rejected")),
ConversationStates.ATTENDING,
"I can't remember when I smelt the good taste of #chocolate the last time...",
null);
Expand All @@ -117,7 +118,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"), new PlayerHasItemWithHimCondition("chocolate bar")),
new QuestInStateCondition(QUEST_SLOT, 0, "start"), new PlayerHasItemWithHimCondition("chocolate bar")),
ConversationStates.IDLE,
"My mum wants to know who I was asking for chocolate from now :(",
null);
Expand All @@ -126,7 +127,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"), new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar"))),
new QuestInStateCondition(QUEST_SLOT, 0, "start"), new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar"))),
ConversationStates.ATTENDING,
"I hope that someone will bring me some chocolate soon...:(",
null);
Expand All @@ -135,7 +136,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "mummy"), new PlayerHasItemWithHimCondition("chocolate bar")),
new QuestInStateCondition(QUEST_SLOT, 0, "mummy"), new PlayerHasItemWithHimCondition("chocolate bar")),
ConversationStates.QUESTION_1,
"Awesome! Is that chocolate for me?",
null);
Expand All @@ -144,7 +145,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "mummy"), new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar"))),
new QuestInStateCondition(QUEST_SLOT, 0, "mummy"), new NotCondition(new PlayerHasItemWithHimCondition("chocolate bar"))),
ConversationStates.ATTENDING,
"I hope that someone will bring me some chocolate soon...:(",
null);
Expand All @@ -153,7 +154,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, "start"), new QuestNotInStateCondition(QUEST_SLOT, "mummy")),
new QuestStartedCondition(QUEST_SLOT), new QuestNotInStateCondition(QUEST_SLOT, 0, "start"), new QuestNotInStateCondition(QUEST_SLOT, 0, "mummy")),
ConversationStates.ATTENDING,
"Hello.",
null);
Expand All @@ -162,7 +163,7 @@ private void chocolateStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "rejected")),
new QuestInStateCondition(QUEST_SLOT, 0, "rejected")),
ConversationStates.ATTENDING,
"Hello.",
null);
Expand Down Expand Up @@ -213,15 +214,15 @@ private void chocolateStep() {
null,
ConversationStates.ATTENDING,
"Thank you!",
new SetQuestAction(QUEST_SLOT, "start"));
new SetQuestAction(QUEST_SLOT, 0, "start"));

// Player says no, they've lost karma
npc.add(ConversationStates.QUEST_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.IDLE,
"Ok, I'll wait till mommy finds some helpers...",
new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));
new SetQuestAndModifyKarmaAction(QUEST_SLOT, 0, "rejected", -5.0));

// Player has got chocolate bar and spoken to mummy
final List<ChatAction> reward = new LinkedList<ChatAction>();
Expand All @@ -239,8 +240,9 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser
}
});
reward.add(new IncreaseXPAction(500));
reward.add(new SetQuestAction(QUEST_SLOT, "eating;"));
reward.add(new SetQuestToTimeStampAction(QUEST_SLOT,1));
reward.add(new SetQuestAction(QUEST_SLOT, 0, "eating;"));
reward.add(new SetQuestToTimeStampAction(QUEST_SLOT, 1));
reward.add(new IncrementQuestAction(QUEST_SLOT, 2, 1));
reward.add(new IncreaseKarmaAction(10.0));
reward.add(new InflictStatusOnNPCAction("chocolate bar"));

Expand Down Expand Up @@ -284,10 +286,10 @@ private void meetMummyStep() {
mummyNPC.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(mummyNPC.getName()),
new QuestInStateCondition(QUEST_SLOT, "start")),
new QuestInStateCondition(QUEST_SLOT, 0, "start")),
ConversationStates.ATTENDING,
"Oh you met my daughter Elisabeth already. You seem like a nice person so it would be really kind, if you can bring her a chocolate bar because I'm not #strong enough for that.",
new SetQuestAction(QUEST_SLOT, "mummy"));
new SetQuestAction(QUEST_SLOT, 0, "mummy"));

mummyNPC.addReply("strong", "I tried to get some chocolate for Elisabeth a few times, but I couldn't make my way through the assassins and bandits running around #there.");

Expand All @@ -305,7 +307,7 @@ public void addToWorld() {
fillQuestInfo(
"Chocolate for Elisabeth",
"Sweet, sweet chocolate! No one can live without it! And Elisabeth loooves to have some...",
true);
true, 2);
chocolateStep();
meetMummyStep();
}
Expand All @@ -318,14 +320,14 @@ public List<String> getHistory(final Player player) {
return res;
}
res.add("Elisabeth is a sweet little girl who lives in Kirdneh together with her family.");
final String questState = player.getQuest(QUEST_SLOT);
final String questState = player.getQuest(QUEST_SLOT, 0);
if ("rejected".equals(questState)) {
res.add("I don't like sweet little girls.");
}
if (player.isQuestInState(QUEST_SLOT, "start","mummy") || isCompleted(player)) {
if (player.isQuestInState(QUEST_SLOT, 0, "start","mummy") || isCompleted(player)) {
res.add("Little Elisabeth wants a chocolate bar.");
}
if (player.isQuestInState(QUEST_SLOT, "start","mummy") && player.isEquipped("chocolate bar") || isCompleted(player)) {
if (player.isQuestInState(QUEST_SLOT, 0, "start","mummy") && player.isEquipped("chocolate bar") || isCompleted(player)) {
res.add("I found a tasty chocolate bar for Elisabeth.");
}
if ("mummy".equals(questState) || isCompleted(player)) {
Expand Down
40 changes: 21 additions & 19 deletions src/games/stendhal/server/maps/quests/IcecreamForAnnie.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* $Id$ */
/***************************************************************************
* (C) Copyright 2003-2023 - Stendhal *
* (C) Copyright 2003-2024 - Stendhal *
***************************************************************************
***************************************************************************
* *
Expand All @@ -25,6 +25,7 @@
import games.stendhal.server.entity.npc.action.EquipItemAction;
import games.stendhal.server.entity.npc.action.IncreaseKarmaAction;
import games.stendhal.server.entity.npc.action.IncreaseXPAction;
import games.stendhal.server.entity.npc.action.IncrementQuestAction;
import games.stendhal.server.entity.npc.action.InflictStatusOnNPCAction;
import games.stendhal.server.entity.npc.action.MultipleActions;
import games.stendhal.server.entity.npc.action.SetQuestAction;
Expand Down Expand Up @@ -100,7 +101,7 @@ private void icecreamStep() {
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestNotStartedCondition(QUEST_SLOT),
new QuestNotInStateCondition(QUEST_SLOT, "rejected")),
new QuestNotInStateCondition(QUEST_SLOT, 0, "rejected")),
ConversationStates.ATTENDING,
"Hello, my name is Annie. I am five years old.",
null);
Expand All @@ -109,7 +110,7 @@ private void icecreamStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"),
new QuestInStateCondition(QUEST_SLOT, 0, "start"),
new PlayerHasItemWithHimCondition("icecream")),
ConversationStates.IDLE,
"Mummy says I mustn't talk to you any more. You're a stranger.",
Expand All @@ -119,7 +120,7 @@ private void icecreamStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "start"),
new QuestInStateCondition(QUEST_SLOT, 0, "start"),
new NotCondition(new PlayerHasItemWithHimCondition("icecream"))),
ConversationStates.ATTENDING,
"Hello. I'm hungry.",
Expand All @@ -129,7 +130,7 @@ private void icecreamStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "mummy"),
new QuestInStateCondition(QUEST_SLOT, 0, "mummy"),
new PlayerHasItemWithHimCondition("icecream")),
ConversationStates.QUESTION_1,
"Yummy! Is that ice cream for me?",
Expand All @@ -139,7 +140,7 @@ private void icecreamStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "mummy"),
new QuestInStateCondition(QUEST_SLOT, 0, "mummy"),
new NotCondition(new PlayerHasItemWithHimCondition("icecream"))),
ConversationStates.ATTENDING,
"Hello. I'm hungry.",
Expand All @@ -150,8 +151,8 @@ private void icecreamStep() {
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestStartedCondition(QUEST_SLOT),
new QuestNotInStateCondition(QUEST_SLOT, "start"),
new QuestNotInStateCondition(QUEST_SLOT, "mummy")),
new QuestNotInStateCondition(QUEST_SLOT, 0, "start"),
new QuestNotInStateCondition(QUEST_SLOT, 0, "mummy")),
ConversationStates.ATTENDING,
"Hello.",
null);
Expand All @@ -160,7 +161,7 @@ private void icecreamStep() {
npc.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(npc.getName()),
new QuestInStateCondition(QUEST_SLOT, "rejected")),
new QuestInStateCondition(QUEST_SLOT, 0, "rejected")),
ConversationStates.ATTENDING,
"Hello.",
null);
Expand Down Expand Up @@ -211,23 +212,24 @@ private void icecreamStep() {
null,
ConversationStates.ATTENDING,
"Thank you!",
new SetQuestAction(QUEST_SLOT, "start"));
new SetQuestAction(QUEST_SLOT, 0, "start"));

// Player says no, they've lost karma
npc.add(ConversationStates.QUEST_OFFERED,
ConversationPhrases.NO_MESSAGES,
null,
ConversationStates.IDLE,
"Ok, I'll ask my mummy instead.",
new SetQuestAndModifyKarmaAction(QUEST_SLOT, "rejected", -5.0));
new SetQuestAndModifyKarmaAction(QUEST_SLOT, 0, "rejected", -5.0));

// Player has got ice cream and spoken to mummy
final List<ChatAction> reward = new LinkedList<ChatAction>();
reward.add(new DropItemAction("icecream"));
reward.add(new EquipItemAction("present"));
reward.add(new IncreaseXPAction(500));
reward.add(new SetQuestAction(QUEST_SLOT, "eating;"));
reward.add(new SetQuestToTimeStampAction(QUEST_SLOT,1));
reward.add(new SetQuestAction(QUEST_SLOT, 0, "eating"));
reward.add(new SetQuestToTimeStampAction(QUEST_SLOT, 1));
reward.add(new IncrementQuestAction(QUEST_SLOT, 2, 1));
reward.add(new IncreaseKarmaAction(10.0));
reward.add(new InflictStatusOnNPCAction("icecream"));

Expand Down Expand Up @@ -270,10 +272,10 @@ private void meetMummyStep() {
mummyNPC.add(ConversationStates.IDLE,
ConversationPhrases.GREETING_MESSAGES,
new AndCondition(new GreetingMatchesNameCondition(mummyNPC.getName()),
new QuestInStateCondition(QUEST_SLOT, "start")),
new QuestInStateCondition(QUEST_SLOT, 0, "start")),
ConversationStates.ATTENDING,
"Hello, I see you've met my daughter Annie. I hope she wasn't too demanding. You seem like a nice person.",
new SetQuestAction(QUEST_SLOT, "mummy"));
new SetQuestAction(QUEST_SLOT, 0, "mummy"));

// any other state
mummyNPC.add(ConversationStates.IDLE,
Expand All @@ -287,7 +289,7 @@ public void addToWorld() {
fillQuestInfo(
"Ice Cream for Annie",
"The best surprise for a litte girl like Annie is a cool ice cream on summer days while playing on the playground.",
true);
true, 2);
icecreamStep();
meetMummyStep();
}
Expand All @@ -300,14 +302,14 @@ public List<String> getHistory(final Player player) {
return res;
}
res.add("Annie Jones is a sweet little girl playing in Kalavan city gardens.");
final String questState = player.getQuest(QUEST_SLOT);
final String questState = player.getQuest(QUEST_SLOT, 0);
if ("rejected".equals(questState)) {
res.add("I don't like sweet little girls.");
}
if (player.isQuestInState(QUEST_SLOT, "start","mummy") || isCompleted(player)) {
if (player.isQuestInState(QUEST_SLOT, 0, "start","mummy") || isCompleted(player)) {
res.add("Little Annie wants an ice cream.");
}
if (player.isQuestInState(QUEST_SLOT, "start","mummy") && player.isEquipped("icecream") || isCompleted(player)) {
if (player.isQuestInState(QUEST_SLOT, 0, "start","mummy") && player.isEquipped("icecream") || isCompleted(player)) {
res.add("I found a tasty ice cream for Annie.");
}
if ("mummy".equals(questState) || isCompleted(player)) {
Expand Down
Loading

0 comments on commit 37de198

Please sign in to comment.