Useless... Quests are in org.moparscape.msc.gs.plugins.quests

This commit is contained in:
CodeForFame 2011-06-25 01:05:46 -05:00
parent 07876364da
commit dc7112653c
12 changed files with 0 additions and 3775 deletions

View File

@ -1,445 +0,0 @@
import org.moparscape.msc.gs.event.SingleEvent;
import org.moparscape.msc.gs.model.GameObject;
import org.moparscape.msc.gs.model.MenuHandler;
import org.moparscape.msc.gs.model.Npc;
import org.moparscape.msc.gs.model.Player;
import org.moparscape.msc.gs.quest.Quest;
import org.moparscape.msc.gs.quest.QuestAction;
/**
* Quest: Black Knight's Fortress (v1.0) Status: INCOMPLETE Start: 304, 1507
* Stage1: 269, 441 Items: - Rewards: -
*
* @author youKnowWho
*/
public class BlackKnightFortress extends Quest {
private static final int QUEST_POINTS = 1;
private static final int NPC_VARZE = 110;
private static final int WALL_ID = 22;
private static final int WALL_X = 273;
private static final int WALL_Y = 435;
private static final int GRILL_ID = -1;
private static final int GRILL_X = -1;
private static final int GRILL_Y = -1;
private static final int REQUIRED_QPOINTS = 0; // 13
private static final String[] FIRST_MENU = new String[] {
"Well what's the problem?", "Well, ah.. good luck with that" };
private static final String[] SECOND_MENU = new String[] {
"Secret weapon? That sounds really scary!",
"I can take care of that" };
private static final String[] THIRD_MENU = new String[] {
"Sure, but it'll cost you", "No, actually, I lied." };
private static final String[] FOURTH_MENU = new String[] {
"I'll get right on it then", "Sorry, I can't be bothered" };
/**
* Don't load this quest yet it's incomplete
*/
public boolean loadQuest() {
return false;
}
public void init() {
associateNpc(NPC_VARZE);
associateObject(WALL_ID, WALL_X, WALL_Y);
}
public BlackKnightFortress() {
}
public String getName() {
return "Black Knight's Fortress";
}
public int getUniqueID() {
return 2;
}
public void handleAction(QuestAction action, Object[] args,
final Player player) {
int stage = player.getQuestStage(this);
if (action == QuestAction.TALKED_NPC) {
if (!(args[0] instanceof Npc))
return;
final Npc npc = (Npc) args[0];
if (npc.getID() != NPC_VARZE)
return;
player.setBusy(true);
npc.blockedBy(player);
// handle quest complete chat?
if (stage == -1)
startQuest(player, npc);
else
handleTalk(player, npc);
} else if (action == QuestAction.USED_OBJECT) {
if (!(args[0] instanceof GameObject))
return;
final GameObject obj = (GameObject) args[0];
if (obj.getID() != WALL_ID && obj.getID() != GRILL_ID)
return;
player.setBusy(true);
if (obj.getID() == WALL_ID) {
if (player.getY() < 435 || stage >= 1) {
player.getActionSender().sendMessage(
"You push on the wall...");
player.getActionSender().sendSound("secretdoor");
world.unregisterGameObject(obj);
world.delayedSpawnObject(obj.getLoc(), 1000);
if (player.getY() < 435)
player.teleport(273, 435, false);
else
player.teleport(273, 434, false);
addDelayedMessage("It slides out of the way!", player, 1000);
} else
player.getActionSender().sendMessage(
"You see no reason to push on the wall");
} else if (obj.getID() == GRILL_ID) {
// listen
}
player.setBusy(false);
}
}
private void handleTalk(final Player player, final Npc npc) {
int stage = player.getQuestStage(this);
if (stage >= 1 && stage <= 5) {
sendChat("I don't have time to talk right now", npc, player);
addDelayedChat("Come back when you've destroyed that weapon!", npc,
player);
player.setBusy(false);
npc.unblock();
}
}
private void startQuest(final Player player, final Npc npc) {
sendChat("Good day to you, " + (player.isMale() ? "sir" : "miss"), npc,
player);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
sendChat(
"Hello sir. I've heard rumours that you're going to war with the black knights",
player, npc);
addSingleEvent(new SingleEvent(player, 4000) {
public void action() {
sendChat("Is this true?", player, npc);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
if (player.getQuestPoints() >= REQUIRED_QPOINTS) // Confirm
// rumour
{
sendChat("Who told you that?", npc, player);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
sendChat(
"Oh, it makes no difference. Yes, the rumours are true.",
npc, player);
addSingleEvent(new SingleEvent(
player, 3000) {
public void action() {
npc.blockedBy(player);
player.setBusy(false);
player.setMenuHandler(new MenuHandler(
FIRST_MENU) {
public void handleReply(
final int option,
final String reply) {
npc.blockedBy(player);
player.setBusy(true);
sendChat(
reply
+ (option == 0 ? " Surely you'll defeat them easily?"
: ""),
player, npc);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
npc.blockedBy(player);
switch (option) {
case 0:
sendChat(
"Yeah, well.. You're lucky you've earned yourself a good reputation",
npc,
player);
addSingleEvent(new SingleEvent(
player,
4000) {
public void action() {
sendChat(
"Or I wouldn't tell you.",
npc,
player);
addSingleEvent(new SingleEvent(
player,
4000) {
public void action() {
sendChat(
"The black knights have a secret weapon, and they say it will destroy us.",
npc,
player);
npc.blockedBy(player);
addSingleEvent(new SingleEvent(
player,
4000) {
public void action() {
player.setBusy(false);
player.setMenuHandler(new MenuHandler(
SECOND_MENU) {
public void handleReply(
final int option,
final String reply) {
npc.blockedBy(player);
player.setBusy(true);
if (option == 1)
sendChat(
"Well it just so happens that I'm an expert in secret weapon thwarting.",
player,
npc);
else
sendChat(
reply,
player,
npc);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
npc.blockedBy(player);
switch (option) {
case 0:
sendChat(
"What kind of sissy talk is that? Get out of my sight!",
npc,
player);
player.setBusy(false);
npc.unblock();
break;
case 1:
sendChat(
"I like your spirit, young warrior!",
npc,
player);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
sendChat(
"Do you think you could help us?",
npc,
player);
npc.blockedBy(player);
addSingleEvent(new SingleEvent(
player,
2000) {
public void action() {
player.setBusy(false);
player.setMenuHandler(new MenuHandler(
THIRD_MENU) {
public void handleReply(
final int option,
final String reply) {
sendChat(
reply,
player,
npc);
npc.blockedBy(player);
player.setBusy(true);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
npc.blockedBy(player);
switch (option) {
case 0:
sendChat(
"Money won't be a problem, assuming you can do the job.",
npc,
player);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
sendChat(
"Well then, what do you want me to do?",
player,
npc);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
sendChat(
"First of all, you'll need to find out what the weapon is... then destroy it!",
npc,
player);
addSingleEvent(new SingleEvent(
player,
4500) {
public void action() {
sendChat(
"Head north and search the black knight's castle.",
npc,
player);
npc.blockedBy(player);
player.setBusy(false);
player.setMenuHandler(new MenuHandler(
FOURTH_MENU) {
public void handleReply(
final int option,
final String reply) {
sendChat(
reply,
player,
npc);
player.setBusy(true);
npc.blockedBy(player);
addSingleEvent(new SingleEvent(
player,
3000) {
public void action() {
npc.blockedBy(player);
switch (option) {
case 0:
player.setBusy(false);
npc.unblock();
addDelayedChat(
"Good luck, "
+ player.getUsername()
+ ".",
npc,
player);
player.setQuestStage(
getUniqueID(),
1);
break;
case 1:
addDelayedChat(
"Don't waste my time! Every valuable second, doom draws nearer!",
npc,
player);
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
}
});
player.getActionSender()
.sendMenu(
FOURTH_MENU);
player.setBusy(false);
}
});
}
});
}
});
break;
case 1:
addDelayedChat(
"Don't waste my time "
+ player.getUsername()
+ "!",
npc,
player);
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
}
});
player.getActionSender()
.sendMenu(
THIRD_MENU);
player.setBusy(false);
}
});
}
});
break;
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
}
});
player.getActionSender()
.sendMenu(
SECOND_MENU);
player.setBusy(false);
}
});
}
});
}
});
break;
case 1:
sendChat(
"Um, thanks. I guess...",
npc,
player);
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
}
});
player.getActionSender()
.sendMenu(
FIRST_MENU);
player.setBusy(false);
}
});
}
});
} else // Deny rumour
{
sendChat(
"Most certainly not. The Black Knights are no threat to us!",
npc, player);
player.setBusy(false);
npc.unblock();
addDelayedMessage("You need "
+ REQUIRED_QPOINTS
+ " quest points before "
+ npc.getDef().getName()
+ " will trust you", player);
}
}
});
}
});
}
});
}
}

View File

@ -1,854 +0,0 @@
import org.moparscape.msc.gs.external.EntityHandler;
import org.moparscape.msc.gs.external.ItemDropDef;
import org.moparscape.msc.gs.model.ActiveTile;
import org.moparscape.msc.gs.model.InvItem;
import org.moparscape.msc.gs.model.Item;
import org.moparscape.msc.gs.model.Npc;
import org.moparscape.msc.gs.model.Player;
import org.moparscape.msc.gs.model.World;
import org.moparscape.msc.gs.quest.Quest;
import org.moparscape.msc.gs.quest.QuestAction;
import org.moparscape.msc.gs.tools.DataConversions;
/**
* Quest: Christmas! (v1.0) 8/1/2009
* Status: COMPLETE
* Start: Santa (id 798), 290,464
* NPCs: Farrel (id 799), 106,670
* 1st Elf (id 800), 71,589
* 2nd Elf (id 800), 656,467
* 3rd Elf (id 800), 403,685
* Evil wizard (id 801), 279,454
* Items: Santa hat (id 971), Santa top (id 1315), Santa legs (id 1314), Candy cane (id 1316),
* Toy 1 (id 1317), Toy 2 (id 1318), Toy 3 (id 1319), Toy 4 (id 1320), Gift box (id 1321)
* Reward: 0 quest points, Magic Gift Box (id 1321) (random item inside)
*
* @author punKrockeR
*/
public class Christmas extends Quest
{
private static final int SANTA_ID = 798;
private static final int FARREL_ID = 799;
private static final int ELF_ID = 800;
private static final int DARKWIZ_ID = 801;
private static final int SANTA_HAT_ID = 971;
private static final int SANTA_TOP_ID = 1315;
private static final int SANTA_LEG_ID = 1314;
private static final int CANDY_CANE_ID = 1316;
private static final int TOY1_ID = 1317;
private static final int TOY2_ID = 1318;
private static final int TOY3_ID = 1319;
private static final int TOY4_ID = 1320;
private static final int GIFT_ID = 1321;
private static final int DEFAULT_DELAY = 3200;
private World world = World.getWorld();
private static final ItemDropDef[] BOX_ITEMS = new ItemDropDef[]
{
new ItemDropDef(155, 1, 3200), // Coal, 42%
new ItemDropDef(SANTA_HAT_ID, 1, 799), // Santa hat, 2.99%
new ItemDropDef(SANTA_TOP_ID, 1, 2000), // Santa top, 20%
new ItemDropDef(SANTA_LEG_ID, 1, 2000), // Santa legs, 20%
new ItemDropDef(CANDY_CANE_ID, 1, 2000), // Candy cane, 15%
new ItemDropDef(575, 1, 1) // Christmas cracker, 0.01%
};
/**
* @return the quest's name
*/
public String getName()
{
return "Christmas!";
}
/**
* @return this quest's unique id
*/
public int getUniqueID()
{
return 5;
}
/**
* Initialises the quest
*/
public void init()
{
associateNpc(SANTA_ID);
associateNpc(FARREL_ID);
associateNpc(ELF_ID);
associateNpc(DARKWIZ_ID);
associateItem(TOY1_ID);
associateItem(TOY2_ID);
associateItem(TOY3_ID);
associateItem(TOY4_ID);
associateItem(GIFT_ID);
}
/**
* @return if the given NPC is visible to the player
*/
public boolean isNpcVisible(Npc npc, Player player)
{
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 71 && npc.getLoc().startY() == 589) // First elf
return player.getQuestStage(this) == 2 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 71 && npc.getLoc().startY() == 594) // First elf
return player.getQuestStage(this) == 2 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 72 && npc.getLoc().startY() == 585) // First elf
return player.getQuestStage(this) == 2 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 656 && npc.getLoc().startY() == 467) // Second elf
return player.getQuestStage(this) == 4 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 653 && npc.getLoc().startY() == 467) // Second elf
return player.getQuestStage(this) == 4 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 403 && npc.getLoc().startY() == 685) // Last elf
return player.getQuestStage(this) == 6 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 419 && npc.getLoc().startY() == 684) // Last elf
return player.getQuestStage(this) == 6 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 408 && npc.getLoc().startY() == 685) // Last elf
return player.getQuestStage(this) == 6 && player.getQuestStage(this) != COMPLETE;
return true;
}
/**
* @return if the given item is visible to the player
*/
public boolean isItemVisible(Item item, Player player)
{
if(item.getID() == TOY1_ID)
return player.getQuestStage(this) >= 2;
else
if(item.getID() == TOY2_ID)
return player.getQuestStage(this) >= 4;
else
if(item.getID() == TOY3_ID)
return player.getQuestStage(this) >= 6;
else
if(item.getID() == TOY4_ID)
return player.getQuestStage(this) >= 7;
return true;
}
/**
* @return if the player has the given item in his inventory, bank or if it's on the ground somewhere
*/
public boolean hasItem(Player player, int id)
{
if(player.getInventory().hasItemId(id))
{
player.getActionSender().sendMessage("You already have this elf's toy!");
return true;
}
if(player.getBank().hasItemId(id))
{
player.getActionSender().sendMessage("You already have this elf's toy in your bank!");
return true;
}
ActiveTile[][] tiles = player.getViewArea().getViewedArea(20, 20, 20, 20);
for(int x = 0; x < tiles.length; x++)
{
for(int y = 0; y < tiles[x].length; y++)
{
ActiveTile t = tiles[x][y];
if(t != null)
{
for(Item i : t.getItems())
{
if(i.getID() == id)
{
if(i.getOwner().equals(player))
{
player.getActionSender().sendMessage("You already have this elf's toy nearby on the ground!");
return true;
}
}
}
}
}
}
player.getActionSender().sendMessage("The toy falls to the ground");
return false;
}
/**
* Handles the given quest action
*/
public void handleAction(QuestAction action, Object[] args, final Player player)
{
int stage = player.getQuestStage(this);
if(action == QuestAction.USED_ITEM)
{
if(!(args[0] instanceof InvItem))
return;
final InvItem item = (InvItem)args[0];
handleUseItem(item, player);
} else
if(action == QuestAction.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() == SANTA_ID)
{
player.setBusy(true);
if(stage == -1)
startQuest(player, npc);
else
handleSantaTalk(player, npc);
} else
if(npc.getID() == FARREL_ID)
{
player.setBusy(true);
handleFarrelTalk(player, npc);
} else
if(npc.getID() == ELF_ID)
{
player.setBusy(true);
handleElfTalk(player, npc);
}
else
if(npc.getID() == DARKWIZ_ID)
{
player.setBusy(true);
handleWizardTalk(player, npc);
}
} else
if(action == QuestAction.KILLED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() == ELF_ID) // If the player doesn't have the toy in their bank or inventory, drop the toy.
{
if(npc.getLoc().startX() == 71 && npc.getLoc().startY() == 589 && player.getQuestStage(this) == 2 && !hasItem(player, TOY1_ID))
world.registerItem(new Item(TOY1_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 71 && npc.getLoc().startY() == 594 && player.getQuestStage(this) == 2 && !hasItem(player, TOY1_ID))
world.registerItem(new Item(TOY1_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 72 && npc.getLoc().startY() == 585 && player.getQuestStage(this) == 2 && !hasItem(player, TOY1_ID))
world.registerItem(new Item(TOY1_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 653 && npc.getLoc().startY() == 467 && player.getQuestStage(this) == 4 && !hasItem(player, TOY2_ID))
world.registerItem(new Item(TOY2_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 656 && npc.getLoc().startY() == 467 && player.getQuestStage(this) == 4 && !hasItem(player, TOY2_ID))
world.registerItem(new Item(TOY2_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 403 && npc.getLoc().startY() == 685 && player.getQuestStage(this) == 6 && !hasItem(player, TOY3_ID))
world.registerItem(new Item(TOY3_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 419 && npc.getLoc().startY() == 684 && player.getQuestStage(this) == 6 && !hasItem(player, TOY3_ID))
world.registerItem(new Item(TOY3_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 408 && npc.getLoc().startY() == 685 && player.getQuestStage(this) == 6 && !hasItem(player, TOY3_ID))
world.registerItem(new Item(TOY3_ID, npc.getX(), npc.getY(), 1, player));
}
}
}
/**
* Handles item use
*/
private void handleUseItem(final InvItem item, final Player player)
{
if(item.getID() == GIFT_ID)
{
player.setBusy(true);
player.getActionSender().sendMessage("You open the " + item.getDef().getName() + "...");
sleep(2000);
int total = 0;
for(ItemDropDef drop : BOX_ITEMS)
total += drop.getWeight();
int hit = DataConversions.random(0, total);
total = 0;
ItemDropDef reward = null;
for(ItemDropDef drop : BOX_ITEMS)
{
if(hit >= total && hit < (total + drop.getWeight()))
{
reward = drop;
break;
}
total += drop.getWeight();
}
player.getInventory().remove(GIFT_ID, 1);
if(reward == null)
player.getActionSender().sendMessage("You don't get shit! (reward is null)");
else
player.getInventory().add(new InvItem(reward.getID(), reward.getAmount()));
player.getActionSender().sendMessage("It contained a " + ((reward.getAmount() > 1) ? reward.getAmount() : "a ") + EntityHandler.getItemDef(reward.getID()).getName() + (reward.getAmount() > 1 ? "s" : "") + "!");
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
player.setBusy(false);
} else
player.setBusy(false);
}
/**
* Handles npc chat if the quest hasn't been started yet
*/
private void startQuest(final Player player, final Npc npc)
{
player.setBusy(true);
sendChat("Christmas! It's ruined!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Why?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("The presents... they're gone!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("What presents? Gone where?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("All my Christmas presents have been stolen!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Who stole them?", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"My own elves!",
"I landed here last night in my sleigh",
"To deliver my presents to the citizens of this land",
"But an evil Dark Knight wizard cast a spell on my Elves",
"And they stole my presents and ran away!"
);
player.setBusy(false);
int option = getMenuOption(player, "That sucks", "Where are they now?", "Good luck with that");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
sendChat("Indeed it does!", npc, player);
player.setBusy(false);
npc.unblock();
} else
if(option == 1) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"I don't know. But one of the elves, Farrel, he's in Lumbridge",
"It appears the spell didn't affect him",
"But he's in hiding from the other elves who have turned evil!",
"And I'm afraid the spell is quite irreversible"
);
player.setBusy(false);
option = getMenuOption(player, "Maybe I can help?", "Christmas really is ruined then");
if(option == -1)
return;
player.setBusy(true);
sleep(2000);
if(option == 0)
{
if(player.getQuestPoints() < 2)
{
sendChat("I doubt it, you don't have a very good reputation for helping people", npc, player);
player.setBusy(false);
npc.unblock();
sleep(2000);
player.getActionSender().sendMessage("You need at least 2 Quest Points to start this quest");
} else
{
queueChat(npc, player, DEFAULT_DELAY,
"Perhaps you can... I don't know where the others are",
"But if you can find Farrel, he can help you find them",
"All I know is that he's in Lumbridge",
"He said he's hiding near a church",
"Please find him and help me save Christmas!"
);
player.setQuestStage(getUniqueID(), 1); // Start quest
player.setBusy(false);
npc.unblock();
}
} else
{
sendChat("I'm afraid so!", npc, player);
player.setBusy(false);
npc.unblock();
}
} else
{
sendChat("Oh, I'll need it!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles Santa's chat if the quest is started but not finished
*/
private void handleSantaTalk(final Player player, final Npc npc)
{
if(player.getQuestStage(this) == COMPLETE)
{
sendChat("Merry christmas, hero!", npc, player);
sleep(2000);
player.setBusy(false);
npc.unblock();
} else
if(player.getQuestStage(this) != 7)
{
sendChat("Oh, " + player.getUsername() + ". Please find those elves!", npc, player);
sleep(2000);
player.setBusy(false);
npc.unblock();
} else
{
if(!player.getInventory().hasItemId(TOY1_ID) || !player.getInventory().hasItemId(TOY2_ID) || !player.getInventory().hasItemId(TOY3_ID) || !player.getInventory().hasItemId(TOY4_ID))
{
queueChat(npc, player, DEFAULT_DELAY,
"Farrel said you'd collected the toys",
"Please bring them all to me as soon as possible!"
);
npc.unblock();
player.setBusy(false);
return;
}
queueChat(npc, player, DEFAULT_DELAY,
player.getUsername() + "! I can't express my gratitude with words",
"You saved Christmas for your land!",
"I don't have anything I can spare for you",
"But I can give you your present early",
"It's a magic gift box. The item within is unknown",
"I hope you get something fantastic!",
"You deserve it for your heroic antics.",
"Farewell kind " + (player.isMale() ? "sir" : "lady") + "! And meeeeery christmas!"
);
player.getActionSender().sendMessage("Santa takes the toys and hands you a small gift box");
if(player.getInventory().remove(TOY1_ID, 1) == -1) { player.setBusy(false); return; }
if(player.getInventory().remove(TOY2_ID, 1) == -1) { player.setBusy(false); return; }
if(player.getInventory().remove(TOY3_ID, 1) == -1) { player.setBusy(false); return; }
if(player.getInventory().remove(TOY4_ID, 1) == -1) { player.setBusy(false); return; }
player.getInventory().add(new InvItem(GIFT_ID, 1));
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
sleep(DEFAULT_DELAY);
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), COMPLETE);
sleep(2500);
player.getActionSender().sendMessage("Maybe I should go and talk to that Evil Dark Knight Wizard...");
}
}
/**
* Handles Farrel's chat if the quest is started but not finished
*/
private void handleFarrelTalk(final Player player, final Npc npc)
{
player.setBusy(true);
if(player.getQuestStage(this) == -1)
{
sendChat("Bugger off", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
npc.unblock();
} else
if(player.getQuestStage(this) == 1)
{
player.setBusy(true);
sendChat("Who are you?", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Santa sent me to find you", player, npc);
sleep(DEFAULT_DELAY);
sendChat("What for?", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
int option = getMenuOption(player, "To murder you", "To help");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
sendChat("Go for it. It's only a matter of time before they find me anyway.", npc, player);
player.setBusy(false);
npc.unblock();
} else // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"Well if Santa trusts you, I guess I can.",
"We must get started at once if we're to find the others."
);
player.setBusy(false);
option = getMenuOption(player, "Any idea where they are?", "Maybe later");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"One of them ran to the desert nearby",
"I don't know where he's hiding, but we hate the heat",
"He must be hiding near cliffs or rocks that offer shade",
"You know this land better than I",
"It would be safer for all involved if you went, and not me"
);
player.setBusy(false);
option = getMenuOption(player, "I agree", "Pussy");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"Excellent. He should be carrying a small " + EntityHandler.getItemDef(TOY1_ID).getName(),
"Get it and bring it to me. Use any means necessary. Any.",
"My comrades cannot be saved now."
);
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), 2);
} else // No
{
sendChat("Santa's trust was misplaced. Christmas is truly ruined.", npc, player);
player.setBusy(false);
npc.unblock();
}
} else // No
{
sendChat("There won't be a \"later\"!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
} else
if(player.getQuestStage(this) == 2)
{
sendChat("Have you found the first toy?", npc, player);
sleep(2000);
player.setBusy(false);
int option = getMenuOption(player, "Not yet", "Yeah");
if(option == -1)
return;
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
sendChat("Well please act quickly. Time is running out! Remember, he's in the desert", npc, player);
player.setBusy(false);
npc.unblock();
} else // Yes
{
if(player.getInventory().hasItemId(TOY1_ID))
{
sendChat("Great! Please, hand it to me", npc, player);
sleep(DEFAULT_DELAY);
player.getActionSender().sendMessage("You give Farrel the " + EntityHandler.getItemDef(TOY1_ID).getName());
player.setQuestStage(getUniqueID(), 3);
player.getActionSender().sendSound("click");
player.getInventory().remove(TOY1_ID, 1);
player.getActionSender().sendInventory();
sleep(DEFAULT_DELAY);
questStage3(npc, player);
} else
{
sendChat("No you haven't. Please don't fool around. Time is running out!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
} else
if(player.getQuestStage(this) == 3)
{
questStage3(npc, player);
} else
if(player.getQuestStage(this) == 4)
{
sendChat("Have you found the second toy?", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
int option = getMenuOption(player, "Right on brother", "No");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
if(player.getInventory().hasItemId(TOY2_ID))
{
sendChat("I don't know what that means, but please hand me the toy", npc, player);
sleep(DEFAULT_DELAY);
player.getActionSender().sendMessage("You give Farrel the " + EntityHandler.getItemDef(TOY2_ID).getName());
player.getActionSender().sendSound("click");
player.getInventory().remove(TOY2_ID, 1);
player.setQuestStage(getUniqueID(), 5);
player.getActionSender().sendInventory();
sleep(DEFAULT_DELAY);
questStage5(npc, player);
} else
{
sendChat("I don't know what that means, but you don't have the toy", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Please hurry. Christmas is almost over!", npc, player);
player.setBusy(false);
npc.unblock();
}
} else // Yes
{
sendChat("Well please hurry. Christmas is almost over! Remember, \"Baxtorian Falls\"!", npc, player);
player.setBusy(false);
npc.unblock();
}
} else
if(player.getQuestStage(this) == 5)
{
questStage5(npc, player);
} else
if(player.getQuestStage(this) == 6) // Final present
{
player.setBusy(true);
sendChat("Did you get izzy's toy?", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
int option = getMenuOption(player, "Yes.", "No.");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
if(player.getInventory().hasItemId(TOY3_ID))
{
queueChat(npc, player, DEFAULT_DELAY,
"Thank you so much, " + player.getUsername(),
"You single-handedly saved Christmas.",
"The elves at the north pole will write songs of you hero",
"You will be respected and remembered forever, believe me.",
"The final present, I have kept all along",
"Here, you take all four presents and give them to santa",
"I'll tell him of your bravery",
"I'm sure he'll want to reward you",
"Farewell, " + player.getUsername() + ".",
"Merry christmas."
);
player.getActionSender().sendMessage("Farrel hands you the three toys");
if(player.getInventory().hasItemId(TOY1_ID)) { sendChat("Oh... You already have the toys.", npc, player); player.setBusy(false); return; }
player.getInventory().add(new InvItem(TOY1_ID, 1));
player.getInventory().add(new InvItem(TOY2_ID, 1));
//player.getInventory().add(new InvItem(TOY3_ID, 1));
player.getInventory().add(new InvItem(TOY4_ID, 1));
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), 7);
} else
{
sendChat("No you don't.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Remember, flames and lava and the ocean are Izzy's favourite things", npc, player);
player.setBusy(false);
npc.unblock();
}
} else // No
{
sendChat("Please get it. Don't hesitate just because he's my brother.", npc, player);
player.setBusy(false);
npc.unblock();
}
} else
{
sendChat("Hey there, " + player.getUsername() + "!", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles quest stage 3 chat
*/
private void questStage3(final Npc npc, final Player player)
{
sendChat("So what now?", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"While you were gone, I did some reconnaissance work",
"I overheard some humans talking about a deranged Elf they saw while sightseeing"
);
player.setBusy(false);
int option = getMenuOption(player, "Yes.", "No.");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"A place called the \"Baxtorian Falls\". Somewhere near a gnome stronghold.",
"It's not much of a lead, but it's all we've got"
);
sendChat("I'll get on it then", player, npc);
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), 4);
} else // No
{
sendChat("Suit yourself, grinch.", npc, player);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles quest stage 5 chat
*/
private void questStage5(final Npc npc, final Player player)
{
sendChat("What's next little guy?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("Don't patronize me, " + player.getUsername() + ". I'm stronger in ways you can't even imagine", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Well I'll take your word for it. Where's the last elf?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("I don't know.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("What? Not even a clue?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("I'm afraid you'll have to find izzy on your own", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Izzy? That's his name?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("The last toy to get is a " + EntityHandler.getItemDef(TOY3_ID).getName() + ". Izzy took that one.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Well did you know him very well? Where's somewhere he's likely to go?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("I knew him very well.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("He was my younger brother.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("I'm sorry, farrel.", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"What he's become... he's not my brother anymore",
"All I know that might help you is that, unlike the rest of us",
"Izzy loved the heat. Flames, lava, that sort of thing",
"And he also loved the ocean. You know this land",
"Take what little information I have to offer",
"And find my brother. Get the last toy back."
);
player.setBusy(false);
int option = getMenuOption(player, "Of course, Farrel", "No. I refuse to murder your brother", "I've had enough of this");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"Thank you dearly, " + player.getUsername(),
"Good luck. Please, make his death quick."
);
player.setQuestStage(getUniqueID(), 6);
player.setBusy(false);
npc.unblock();
} else // No
{
sendChat("Then the death of Christmas is on your conscience.", npc, player);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles talking to the evil elves
*/
private void handleElfTalk(final Player player, final Npc npc)
{
sendChat("Get out of my way tall one", npc, player);
sleep(2000);
player.setBusy(false);
npc.unblock();
}
/**
* Handles talking to the evil wizard
*/
private void handleWizardTalk(final Player player, final Npc npc)
{
if(player.getQuestStage(this) == COMPLETE)
{
sendChat("You! You thwarted my plans!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Christmas is for everyone! Why do you want to stop it?", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"None of your business, fiend! I'm going to send you back in time",
"To before you ruined my plans!"
);
player.setBusy(false);
int option = getMenuOption(player, "Please don't!", "Give it your best shot");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
queueChat(npc, player, DEFAULT_DELAY,
"Bah! It makes no difference anyway",
"I have more important things to ruin"
);
player.setBusy(false);
npc.unblock();
} else // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"I will!",
"Muahahaha!"
);
player.getActionSender().sendTeleBubble(player.getLocation().getX(), player.getLocation().getY(), false);
player.getActionSender().sendSound("spellfail");
player.teleport(289, 459, true);
sleep(DEFAULT_DELAY);
player.getActionSender().sendTeleBubble(289, 459, false);
sendChat("Huh? What? Where am i?", player, npc);
player.setQuestStage(getUniqueID(), -1);
npc.unblock();
sleep(DEFAULT_DELAY);
player.setBusy(false);
if(player.getInventory().hasItemId(TOY1_ID) || player.getInventory().hasItemId(TOY2_ID) || player.getInventory().hasItemId(TOY3_ID) || player.getInventory().hasItemId(TOY4_ID) || player.getInventory().hasItemId(GIFT_ID))
player.getActionSender().sendMessage("Santa's presents are unaffected by the Wizard's spell!");
}
} else
{
sendChat("Hahaha! You may call me, the grinch! Bahaha!", npc, player);
sleep(DEFAULT_DELAY);
player.getActionSender().sendMessage("He really does look quite insane");
player.setBusy(false);
npc.unblock();
}
}
/**
* Construct the quest (empty)
*/
public Christmas()
{
}
}

View File

@ -1,859 +0,0 @@
import org.rscdaemon.server.quest.*;
import org.rscdaemon.server.model.*;
import org.rscdaemon.server.event.*;
import org.rscdaemon.server.entityhandling.EntityHandler;
import org.rscdaemon.server.entityhandling.defs.extras.ItemDropDef;
import org.rscdaemon.server.util.DataConversions;
/**
* Quest: Christmas! (v1.0) 8/1/2009
* Status: COMPLETE
* Start: Santa (id 798), 290,464
* NPCs: Farrel (id 799), 106,670
* 1st Elf (id 800), 71,589
* 2nd Elf (id 800), 656,467
* 3rd Elf (id 800), 403,685
* Evil wizard (id 801), 279,454
* Items: Santa hat (id 971), Santa top (id 1315), Santa legs (id 1314), Candy cane (id 1316),
* Toy 1 (id 1317), Toy 2 (id 1318), Toy 3 (id 1319), Toy 4 (id 1320), Gift box (id 1321)
* Reward: 0 quest points, Magic Gift Box (id 1321) (random item inside)
*
* @author punKrockeR
*/
public class Christmas extends Quest
{
/* Here we define things which will be used in the quest, NPCs Items etc. You don't have to give the NPCs and Items a variable name but it is easier if you do and concidered 'proper' to do so. */
private static final int SANTA_ID = 798;
private static final int FARREL_ID = 799;
private static final int ELF_ID = 800;
private static final int DARKWIZ_ID = 801;
private static final int SANTA_HAT_ID = 971;
private static final int SANTA_TOP_ID = 1315;
private static final int SANTA_LEG_ID = 1314;
private static final int CANDY_CANE_ID = 1316;
private static final int TOY1_ID = 1317;
private static final int TOY2_ID = 1318;
private static final int TOY3_ID = 1319;
private static final int TOY4_ID = 1320;
private static final int GIFT_ID = 1321;
private static final int DEFAULT_DELAY = 3200; // The default delay between chat messages, in miliseconds.
private static final int QUEST_POINTS = 0; // The amount of quest points the quest will give
/*
* private static final int REWARD_XP = 500; // Amount of XP which is given as a reward
*/
private World world = World.getWorld(); // You must include this
private static final ItemDropDef[] BOX_ITEMS = new ItemDropDef[]
{
new ItemDropDef(155, 1, 3200), // Coal, 42%
new ItemDropDef(SANTA_HAT_ID, 1, 799), // Santa hat, 2.99%
new ItemDropDef(SANTA_TOP_ID, 1, 2000), // Santa top, 20%
new ItemDropDef(SANTA_LEG_ID, 1, 2000), // Santa legs, 20%
new ItemDropDef(CANDY_CANE_ID, 1, 2000), // Candy cane, 15%
new ItemDropDef(575, 1, 1) // Christmas cracker, 0.01%
};
/**
* @return the quest's name
*/
public String getName()
{
return "Christmas!";
}
/**
* @return this quest's unique id
*/
public int getUniqueID()
{
return 5;
}
/**
* Initialises the quest
* Here we associate all the NPCs, Items, GameObjects and such. It is imperative that you do this.
*/
public void init()
{
associateNpc(SANTA_ID);
associateNpc(FARREL_ID);
associateNpc(ELF_ID);
associateNpc(DARKWIZ_ID);
associateItem(TOY1_ID);
associateItem(TOY2_ID);
associateItem(TOY3_ID);
associateItem(TOY4_ID);
associateItem(GIFT_ID);
}
/**
* @return if the given NPC is visible to the player
* This function is just an example of what can be done, it is unlikely you will need to use it and if you don't, obviously do not include it in your code.
*/
public boolean isNpcVisible(Npc npc, Player player)
{
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 71 && npc.getLoc().startY() == 589) // First elf
return player.getQuestStage(this) == 2 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 71 && npc.getLoc().startY() == 594) // First elf
return player.getQuestStage(this) == 2 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 72 && npc.getLoc().startY() == 585) // First elf
return player.getQuestStage(this) == 2 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 656 && npc.getLoc().startY() == 467) // Second elf
return player.getQuestStage(this) == 4 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 653 && npc.getLoc().startY() == 467) // Second elf
return player.getQuestStage(this) == 4 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 403 && npc.getLoc().startY() == 685) // Last elf
return player.getQuestStage(this) == 6 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 419 && npc.getLoc().startY() == 684) // Last elf
return player.getQuestStage(this) == 6 && player.getQuestStage(this) != COMPLETE;
else
if(npc.getLoc().getId() == ELF_ID && npc.getLoc().startX() == 408 && npc.getLoc().startY() == 685) // Last elf
return player.getQuestStage(this) == 6 && player.getQuestStage(this) != COMPLETE;
return true;
}
/**
* @return if the given item is visible to the player
* Same as the above function.
*/
public boolean isItemVisible(Item item, Player player)
{
if(item.getID() == TOY1_ID)
return player.getQuestStage(this) >= 2;
else
if(item.getID() == TOY2_ID)
return player.getQuestStage(this) >= 4;
else
if(item.getID() == TOY3_ID)
return player.getQuestStage(this) >= 6;
else
if(item.getID() == TOY4_ID)
return player.getQuestStage(this) >= 7;
return true;
}
/**
* @return if the player has the given item in his inventory, bank or if it's on the ground somewhere
* And again.
*/
public boolean hasItem(Player player, int id)
{
if(player.getInventory().hasItemId(id))
{
player.getActionSender().sendMessage("You already have this elf's toy!");
return true;
}
if(player.getBank().hasItemId(id))
{
player.getActionSender().sendMessage("You already have this elf's toy in your bank!");
return true;
}
ActiveTile[][] tiles = player.getViewArea().getViewedArea(20, 20, 20, 20);
for(int x = 0; x < tiles.length; x++)
{
for(int y = 0; y < tiles[x].length; y++)
{
ActiveTile t = tiles[x][y];
if(t != null)
{
for(Item i : t.getItems())
{
if(i.getID() == id)
{
if(i.getOwner().equals(player))
{
player.getActionSender().sendMessage("You already have this elf's toy nearby on the ground!");
return true;
}
}
}
}
}
}
player.getActionSender().sendMessage("The toy falls to the ground");
return false;
}
/**
* Handles the given quest action
* You will use this function for every quest, the arguments must be the same.
*/
public void handleAction(QuestAction action, Object[] args, final Player player)
{
int stage = player.getQuestStage(this);
if(action == action.USED_ITEM)
{
if(!(args[0] instanceof InvItem))
return;
final InvItem item = (InvItem)args[0];
handleUseItem(item, player);
} else
if(action == action.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() == SANTA_ID)
{
player.setBusy(true);
if(stage == -1)
startQuest(player, npc);
else
handleSantaTalk(player, npc);
} else
if(npc.getID() == FARREL_ID)
{
player.setBusy(true);
handleFarrelTalk(player, npc);
} else
if(npc.getID() == ELF_ID)
{
player.setBusy(true);
handleElfTalk(player, npc);
}
else
if(npc.getID() == DARKWIZ_ID)
{
player.setBusy(true);
handleWizardTalk(player, npc);
}
} else
if(action == action.KILLED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() == ELF_ID) // If the player doesn't have the toy in their bank or inventory, drop the toy.
{
if(npc.getLoc().startX() == 71 && npc.getLoc().startY() == 589 && player.getQuestStage(this) == 2 && !hasItem(player, TOY1_ID))
world.registerItem(new Item(TOY1_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 71 && npc.getLoc().startY() == 594 && player.getQuestStage(this) == 2 && !hasItem(player, TOY1_ID))
world.registerItem(new Item(TOY1_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 72 && npc.getLoc().startY() == 585 && player.getQuestStage(this) == 2 && !hasItem(player, TOY1_ID))
world.registerItem(new Item(TOY1_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 653 && npc.getLoc().startY() == 467 && player.getQuestStage(this) == 4 && !hasItem(player, TOY2_ID))
world.registerItem(new Item(TOY2_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 656 && npc.getLoc().startY() == 467 && player.getQuestStage(this) == 4 && !hasItem(player, TOY2_ID))
world.registerItem(new Item(TOY2_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 403 && npc.getLoc().startY() == 685 && player.getQuestStage(this) == 6 && !hasItem(player, TOY3_ID))
world.registerItem(new Item(TOY3_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 419 && npc.getLoc().startY() == 684 && player.getQuestStage(this) == 6 && !hasItem(player, TOY3_ID))
world.registerItem(new Item(TOY3_ID, npc.getX(), npc.getY(), 1, player));
else
if(npc.getLoc().startX() == 408 && npc.getLoc().startY() == 685 && player.getQuestStage(this) == 6 && !hasItem(player, TOY3_ID))
world.registerItem(new Item(TOY3_ID, npc.getX(), npc.getY(), 1, player));
}
}
}
/**
* Handles item use
*/
private void handleUseItem(final InvItem item, final Player player)
{
if(item.getID() == GIFT_ID)
{
player.setBusy(true);
player.getActionSender().sendMessage("You open the " + item.getDef().getName() + "...");
sleep(2000);
int total = 0;
for(ItemDropDef drop : BOX_ITEMS)
total += drop.getWeight();
int hit = DataConversions.random(0, total);
total = 0;
ItemDropDef reward = null;
for(ItemDropDef drop : BOX_ITEMS)
{
if(hit >= total && hit < (total + drop.getWeight()))
{
reward = drop;
break;
}
total += drop.getWeight();
}
player.getInventory().remove(GIFT_ID, 1);
if(reward == null)
player.getActionSender().sendMessage("You don't get shit! (reward is null)");
else
player.getInventory().add(new InvItem(reward.getID(), reward.getAmount()));
player.getActionSender().sendMessage("It contained a " + ((reward.getAmount() > 1) ? reward.getAmount() : "a ") + EntityHandler.getItemDef(reward.getID()).getName() + (reward.getAmount() > 1 ? "s" : "") + "!");
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
player.setBusy(false);
} else
player.setBusy(false);
}
/**
* Handles npc chat if the quest hasn't been started yet
*/
private void startQuest(final Player player, final Npc npc)
{
player.setBusy(true);
sendChat("Christmas! It's ruined!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Why?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("The presents... they're gone!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("What presents? Gone where?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("All my Christmas presents have been stolen!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Who stole them?", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"My own elves!",
"I landed here last night in my sleigh",
"To deliver my presents to the citizens of this land",
"But an evil Dark Knight wizard cast a spell on my Elves",
"And they stole my presents and ran away!"
);
player.setBusy(false);
int option = getMenuOption(player, "That sucks", "Where are they now?", "Good luck with that");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
sendChat("Indeed it does!", npc, player);
player.setBusy(false);
npc.unblock();
} else
if(option == 1) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"I don't know. But one of the elves, Farrel, he's in Lumbridge",
"It appears the spell didn't affect him",
"But he's in hiding from the other elves who have turned evil!",
"And I'm afraid the spell is quite irreversible"
);
player.setBusy(false);
option = getMenuOption(player, "Maybe I can help?", "Christmas really is ruined then");
if(option == -1)
return;
player.setBusy(true);
sleep(2000);
if(option == 0)
{
if(player.getQuestPoints() < 2)
{
sendChat("I doubt it, you don't have a very good reputation for helping people", npc, player);
player.setBusy(false);
npc.unblock();
sleep(2000);
player.getActionSender().sendMessage("You need at least 2 Quest Points to start this quest");
} else
{
queueChat(npc, player, DEFAULT_DELAY,
"Perhaps you can... I don't know where the others are",
"But if you can find Farrel, he can help you find them",
"All I know is that he's in Lumbridge",
"He said he's hiding near a church",
"Please find him and help me save Christmas!"
);
player.setQuestStage(getUniqueID(), 1); // Start quest
player.setBusy(false);
npc.unblock();
}
} else
{
sendChat("I'm afraid so!", npc, player);
player.setBusy(false);
npc.unblock();
}
} else
{
sendChat("Oh, I'll need it!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles Santa's chat if the quest is started but not finished
*/
private void handleSantaTalk(final Player player, final Npc npc)
{
if(player.getQuestStage(this) == COMPLETE)
{
sendChat("Merry christmas, hero!", npc, player);
sleep(2000);
player.setBusy(false);
npc.unblock();
} else
if(player.getQuestStage(this) != 7)
{
sendChat("Oh, " + player.getUsername() + ". Please find those elves!", npc, player);
sleep(2000);
player.setBusy(false);
npc.unblock();
} else
{
if(!player.getInventory().hasItemId(TOY1_ID) || !player.getInventory().hasItemId(TOY2_ID) || !player.getInventory().hasItemId(TOY3_ID) || !player.getInventory().hasItemId(TOY4_ID))
{
queueChat(npc, player, DEFAULT_DELAY,
"Farrel said you'd collected the toys",
"Please bring them all to me as soon as possible!"
);
npc.unblock();
player.setBusy(false);
return;
}
queueChat(npc, player, DEFAULT_DELAY,
player.getUsername() + "! I can't express my gratitude with words",
"You saved Christmas for your land!",
"I don't have anything I can spare for you",
"But I can give you your present early",
"It's a magic gift box. The item within is unknown",
"I hope you get something fantastic!",
"You deserve it for your heroic antics.",
"Farewell kind " + (player.isMale() ? "sir" : "lady") + "! And meeeeery christmas!"
);
player.getActionSender().sendMessage("Santa takes the toys and hands you a small gift box");
if(player.getInventory().remove(TOY1_ID, 1) == -1) { player.setBusy(false); return; }
if(player.getInventory().remove(TOY2_ID, 1) == -1) { player.setBusy(false); return; }
if(player.getInventory().remove(TOY3_ID, 1) == -1) { player.setBusy(false); return; }
if(player.getInventory().remove(TOY4_ID, 1) == -1) { player.setBusy(false); return; }
player.getInventory().add(new InvItem(GIFT_ID, 1));
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
sleep(DEFAULT_DELAY);
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), COMPLETE);
sleep(2500);
player.getActionSender().sendMessage("Maybe I should go and talk to that Evil Dark Knight Wizard...");
}
}
/**
* Handles Farrel's chat if the quest is started but not finished
*/
private void handleFarrelTalk(final Player player, final Npc npc)
{
player.setBusy(true);
if(player.getQuestStage(this) == -1)
{
sendChat("Bugger off", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
npc.unblock();
} else
if(player.getQuestStage(this) == 1)
{
player.setBusy(true);
sendChat("Who are you?", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Santa sent me to find you", player, npc);
sleep(DEFAULT_DELAY);
sendChat("What for?", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
int option = getMenuOption(player, "To murder you", "To help");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
sendChat("Go for it. It's only a matter of time before they find me anyway.", npc, player);
player.setBusy(false);
npc.unblock();
} else // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"Well if Santa trusts you, I guess I can.",
"We must get started at once if we're to find the others."
);
player.setBusy(false);
option = getMenuOption(player, "Any idea where they are?", "Maybe later");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"One of them ran to the desert nearby",
"I don't know where he's hiding, but we hate the heat",
"He must be hiding near cliffs or rocks that offer shade",
"You know this land better than I",
"It would be safer for all involved if you went, and not me"
);
player.setBusy(false);
option = getMenuOption(player, "I agree", "Pussy");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"Excellent. He should be carrying a small " + EntityHandler.getItemDef(TOY1_ID).getName(),
"Get it and bring it to me. Use any means necessary. Any.",
"My comrades cannot be saved now."
);
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), 2);
} else // No
{
sendChat("Santa's trust was misplaced. Christmas is truly ruined.", npc, player);
player.setBusy(false);
npc.unblock();
}
} else // No
{
sendChat("There won't be a \"later\"!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
} else
if(player.getQuestStage(this) == 2)
{
sendChat("Have you found the first toy?", npc, player);
sleep(2000);
player.setBusy(false);
int option = getMenuOption(player, "Not yet", "Yeah");
if(option == -1)
return;
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
sendChat("Well please act quickly. Time is running out! Remember, he's in the desert", npc, player);
player.setBusy(false);
npc.unblock();
} else // Yes
{
if(player.getInventory().hasItemId(TOY1_ID))
{
sendChat("Great! Please, hand it to me", npc, player);
sleep(DEFAULT_DELAY);
player.getActionSender().sendMessage("You give Farrel the " + EntityHandler.getItemDef(TOY1_ID).getName());
player.setQuestStage(getUniqueID(), 3);
player.getActionSender().sendSound("click");
player.getInventory().remove(TOY1_ID, 1);
player.getActionSender().sendInventory();
sleep(DEFAULT_DELAY);
questStage3(npc, player);
} else
{
sendChat("No you haven't. Please don't fool around. Time is running out!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
} else
if(player.getQuestStage(this) == 3)
{
questStage3(npc, player);
} else
if(player.getQuestStage(this) == 4)
{
sendChat("Have you found the second toy?", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
int option = getMenuOption(player, "Right on brother", "No");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
if(player.getInventory().hasItemId(TOY2_ID))
{
sendChat("I don't know what that means, but please hand me the toy", npc, player);
sleep(DEFAULT_DELAY);
player.getActionSender().sendMessage("You give Farrel the " + EntityHandler.getItemDef(TOY2_ID).getName());
player.getActionSender().sendSound("click");
player.getInventory().remove(TOY2_ID, 1);
player.setQuestStage(getUniqueID(), 5);
player.getActionSender().sendInventory();
sleep(DEFAULT_DELAY);
questStage5(npc, player);
} else
{
sendChat("I don't know what that means, but you don't have the toy", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Please hurry. Christmas is almost over!", npc, player);
player.setBusy(false);
npc.unblock();
}
} else // Yes
{
sendChat("Well please hurry. Christmas is almost over! Remember, \"Baxtorian Falls\"!", npc, player);
player.setBusy(false);
npc.unblock();
}
} else
if(player.getQuestStage(this) == 5)
{
questStage5(npc, player);
} else
if(player.getQuestStage(this) == 6) // Final present
{
player.setBusy(true);
sendChat("Did you get izzy's toy?", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
int option = getMenuOption(player, "Yes.", "No.");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
if(player.getInventory().hasItemId(TOY3_ID))
{
queueChat(npc, player, DEFAULT_DELAY,
"Thank you so much, " + player.getUsername(),
"You single-handedly saved Christmas.",
"The elves at the north pole will write songs of you hero",
"You will be respected and remembered forever, believe me.",
"The final present, I have kept all along",
"Here, you take all four presents and give them to santa",
"I'll tell him of your bravery",
"I'm sure he'll want to reward you",
"Farewell, " + player.getUsername() + ".",
"Merry christmas."
);
player.getActionSender().sendMessage("Farrel hands you the three toys");
if(player.getInventory().hasItemId(TOY1_ID)) { sendChat("Oh... You already have the toys.", npc, player); player.setBusy(false); return; }
player.getInventory().add(new InvItem(TOY1_ID, 1));
player.getInventory().add(new InvItem(TOY2_ID, 1));
//player.getInventory().add(new InvItem(TOY3_ID, 1));
player.getInventory().add(new InvItem(TOY4_ID, 1));
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), 7);
} else
{
sendChat("No you don't.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Remember, flames and lava and the ocean are Izzy's favourite things", npc, player);
player.setBusy(false);
npc.unblock();
}
} else // No
{
sendChat("Please get it. Don't hesitate just because he's my brother.", npc, player);
player.setBusy(false);
npc.unblock();
}
} else
{
sendChat("Hey there, " + player.getUsername() + "!", npc, player);
sleep(DEFAULT_DELAY);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles quest stage 3 chat
*/
private void questStage3(final Npc npc, final Player player)
{
sendChat("So what now?", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"While you were gone, I did some reconnaissance work",
"I overheard some humans talking about a deranged Elf they saw while sightseeing"
);
player.setBusy(false);
int option = getMenuOption(player, "Yes.", "No.");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"A place called the \"Baxtorian Falls\". Somewhere near a gnome stronghold.",
"It's not much of a lead, but it's all we've got"
);
sendChat("I'll get on it then", player, npc);
player.setBusy(false);
npc.unblock();
player.setQuestStage(getUniqueID(), 4);
} else // No
{
sendChat("Suit yourself, grinch.", npc, player);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles quest stage 5 chat
*/
private void questStage5(final Npc npc, final Player player)
{
sendChat("What's next little guy?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("Don't patronize me, " + player.getUsername() + ". I'm stronger in ways you can't even imagine", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Well I'll take your word for it. Where's the last elf?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("I don't know.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("What? Not even a clue?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("I'm afraid you'll have to find izzy on your own", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Izzy? That's his name?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("The last toy to get is a " + EntityHandler.getItemDef(TOY3_ID).getName() + ". Izzy took that one.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Well did you know him very well? Where's somewhere he's likely to go?", player, npc);
sleep(DEFAULT_DELAY);
sendChat("I knew him very well.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("He was my younger brother.", npc, player);
sleep(DEFAULT_DELAY);
sendChat("I'm sorry, farrel.", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"What he's become... he's not my brother anymore",
"All I know that might help you is that, unlike the rest of us",
"Izzy loved the heat. Flames, lava, that sort of thing",
"And he also loved the ocean. You know this land",
"Take what little information I have to offer",
"And find my brother. Get the last toy back."
);
player.setBusy(false);
int option = getMenuOption(player, "Of course, Farrel", "No. I refuse to murder your brother", "I've had enough of this");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"Thank you dearly, " + player.getUsername(),
"Good luck. Please, make his death quick."
);
player.setQuestStage(getUniqueID(), 6);
player.setBusy(false);
npc.unblock();
} else // No
{
sendChat("Then the death of Christmas is on your conscience.", npc, player);
player.setBusy(false);
npc.unblock();
}
}
/**
* Handles talking to the evil elves
*/
private void handleElfTalk(final Player player, final Npc npc)
{
sendChat("Get out of my way tall one", npc, player);
sleep(2000);
player.setBusy(false);
npc.unblock();
}
/**
* Handles talking to the evil wizard
*/
private void handleWizardTalk(final Player player, final Npc npc)
{
if(player.getQuestStage(this) == COMPLETE)
{
sendChat("You! You thwarted my plans!", npc, player);
sleep(DEFAULT_DELAY);
sendChat("Christmas is for everyone! Why do you want to stop it?", player, npc);
sleep(DEFAULT_DELAY);
queueChat(npc, player, DEFAULT_DELAY,
"None of your business, fiend! I'm going to send you back in time",
"To before you ruined my plans!"
);
player.setBusy(false);
int option = getMenuOption(player, "Please don't!", "Give it your best shot");
if(option == -1)
return;
player.setBusy(true);
sleep(DEFAULT_DELAY);
if(option == 0) // No
{
queueChat(npc, player, DEFAULT_DELAY,
"Bah! It makes no difference anyway",
"I have more important things to ruin"
);
player.setBusy(false);
npc.unblock();
} else // Yes
{
queueChat(npc, player, DEFAULT_DELAY,
"I will!",
"Muahahaha!"
);
player.getActionSender().sendTeleBubble(player.getLocation().getX(), player.getLocation().getY(), false);
player.getActionSender().sendSound("spellfail");
player.teleport(289, 459, true);
sleep(DEFAULT_DELAY);
player.getActionSender().sendTeleBubble(289, 459, false);
sendChat("Huh? What? Where am i?", player, npc);
player.setQuestStage(getUniqueID(), -1);
npc.unblock();
sleep(DEFAULT_DELAY);
player.setBusy(false);
if(player.getInventory().hasItemId(TOY1_ID) || player.getInventory().hasItemId(TOY2_ID) || player.getInventory().hasItemId(TOY3_ID) || player.getInventory().hasItemId(TOY4_ID) || player.getInventory().hasItemId(GIFT_ID))
player.getActionSender().sendMessage("Santa's presents are unaffected by the Wizard's spell!");
}
} else
{
sendChat("Hahaha! You may call me, the grinch! Bahaha!", npc, player);
sleep(DEFAULT_DELAY);
player.getActionSender().sendMessage("He really does look quite insane");
player.setBusy(false);
npc.unblock();
}
}
/**
* Construct the quest (empty)
*/
public Christmas()
{
}
}

View File

@ -1,310 +0,0 @@
import org.moparscape.msc.gs.event.SingleEvent;
import org.moparscape.msc.gs.model.MenuHandler;
import org.moparscape.msc.gs.model.Npc;
import org.moparscape.msc.gs.model.Player;
import org.moparscape.msc.gs.quest.Quest;
import org.moparscape.msc.gs.quest.QuestAction;
/**
* Quest: Cook's Assistant (v1.0)
* Status: COMPLETE
* Start: Lumbridge cook (id 7)
* Items: 19, 136, 22
* Reward: 1 quest point, 350 cooking xp
*
* @author youKnowWho
*/
public class CooksAssistant extends Quest
{
private static final int COOK_ID = 7;
private static final int ITEM_EGG = 19;
private static final int ITEM_FLOUR = 136;
private static final int ITEM_MILK = 22;
private static final int REWARD_XP = 350;
private static final String[] FIRST_MENU = new String[]{"Oh, ok, sorry.", "Well maybe I can help?"};
private static final String[] SECOND_MENU = new String[]{"Sure, what do you need?", "No, sorry"};
private static final int QUEST_POINTS = 1;
public void init()
{
associateNpc(COOK_ID);
}
public CooksAssistant()
{
}
public String getName()
{
return "Cook's Assistant";
}
public int getUniqueID()
{
return 0;
}
public void handleAction(QuestAction action, Object[] args, final Player player)
{
int stage = player.getQuestStage(this);
if(stage == -1) // Quest hasn't been started
{
if(action == QuestAction.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() != COOK_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
sendChat("Sorry, I can't talk right now, I'm very busy!", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
player.setBusy(false);
player.setMenuHandler(new MenuHandler(FIRST_MENU)
{
public void handleReply(final int option, final String reply)
{
player.setBusy(true);
switch(option)
{
case 0:
player.setBusy(false);
npc.unblock();
sendChat("Oh, ok, sorry.", player, npc);
break;
case 1:
sendChat("Well maybe I can help?", player, npc);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("Perhaps you can... You see, it's the duke's birthday tomorrow", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("And I haven't got the ingredients for his cake yet!", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("Do you think you could collect them for me?", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
player.setBusy(false);
player.setMenuHandler(new MenuHandler(SECOND_MENU)
{
public void handleReply(final int option, final String reply)
{
player.setBusy(true);
switch(option)
{
case 0:
sendChat("Sure, what do you need?", player, npc);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("Oh thank you so much! I'm going to need an egg, some milk and a pot of flour.", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("Please, hurry!", npc, player);
player.setQuestStage(getUniqueID(), 1);
player.setBusy(false);
npc.unblock();
}
});
}
});
break;
case 1:
sendChat("No, sorry", player, npc);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("Fine. I didn't want your help anyway.", npc, player);
player.setBusy(false);
npc.unblock();
}
});
break;
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
owner.getActionSender().sendMenu(SECOND_MENU);
}
});
}
});
}
});
}
});
break;
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
owner.getActionSender().sendMenu(FIRST_MENU);
}
});
} else
return;
} else
if(stage == 1)
{
if(action == QuestAction.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() != COOK_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
sendChat("Sorry, I can't - oh, it's you! Do you have the ingredients?", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
player.setBusy(false);
player.setMenuHandler(new MenuHandler(new String[]{"I forgot what to get!","Yes, i have them","No, not yet"})
{
public void handleReply(final int option, final String reply)
{
player.setBusy(true);
sendChat(reply, player, npc);
if(option == 0)
{
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("I need an egg, a pot flour and some milk! And quickly!", npc, player);
player.setBusy(false);
npc.unblock();
}
});
} else
if(option == 1)
{
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
//check items
if(player.getInventory().hasItemId(ITEM_EGG) && player.getInventory().hasItemId(ITEM_FLOUR) && player.getInventory().hasItemId(ITEM_MILK))
{
finishQuest(player, npc);
} else
{
sendChat("No you don't! Oh please, don't get my hopes up like that!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
});
} else
{
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("Oh, please hurry!", npc, player);
player.setBusy(false);
npc.unblock();
}
});
}
}
});
owner.getActionSender().sendMenu(new String[]{"I forgot what to get!","Yes, i have them","No, not yet"});
}
});
}
} else
if (stage == 0) {
if(action == QuestAction.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() != COOK_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
sendChat("Oh hi " + player.getUsername() + ". Thanks for your help! I can't talk at the moment though.", npc, player);
player.setBusy(false);
npc.unblock();
}
}
}
private void finishQuest(final Player player, final Npc npc)
{
sendChat("Oh, thank you so much " + player.getUsername() + "!", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
sendChat("I'm afraid don't have any money to reward you with", npc, player);
addSingleEvent(new SingleEvent(player, 3000)
{
public void action()
{
sendChat("But I can give you some cooking tips!", npc, player);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
player.incExp(7, REWARD_XP, false);
player.getActionSender().sendStat(7);
player.setQuestStage(getUniqueID(), Quest.COMPLETE);
player.getInventory().remove(ITEM_EGG, 1);
player.getInventory().remove(ITEM_MILK, 1);
player.getInventory().remove(ITEM_FLOUR, 1);
player.getActionSender().sendInventory();
player.incQuestPoints(QUEST_POINTS);
player.setBusy(false);
npc.unblock();
}
});
}
});
}
});
}
}

View File

@ -1,691 +0,0 @@
import org.moparscape.msc.gs.event.SingleEvent;
import org.moparscape.msc.gs.external.EntityHandler;
import org.moparscape.msc.gs.model.InvItem;
import org.moparscape.msc.gs.model.MenuHandler;
import org.moparscape.msc.gs.model.Npc;
import org.moparscape.msc.gs.model.Player;
import org.moparscape.msc.gs.quest.Quest;
import org.moparscape.msc.gs.quest.QuestAction;
/**
* Quest: Imp Catcher (v1.0) 5/1/2009
* Status: COMPLETE
* Start: Talborn the wizard (id 17), 218, 1635
* Items: 231, 232, 233, 234
* Reward: 1 quest point, 350 magic xp
*
* @author punKrockeR
*/
public class ImpCatcher extends Quest
{
private static final int TALBORN_ID = 17;
private static final int RED_BEAD = 231;
private static final int YELLOW_BEAD = 232;
private static final int BLACK_BEAD = 233;
private static final int WHITE_BEAD = 234;
private static final int ITEM_REWARD = 235;
private static final int REWARD_XP = 350;
private static final String[] FIRST_MENU = new String[] { "No way you crazy bastard", "Sure, why not" };
private static final String[] SECOND_MENU = new String[] { "Yeah I did", "Not yet" };
private static final int DEFAULT_EVENT_DELAY = 3200;
private static final int QUEST_POINTS = 1;
/**
* @return the quest's name
*/
public String getName()
{
return "Imp Catcher";
}
/**
* @return this quest's unique id
*/
public int getUniqueID()
{
return 3;
}
/**
* Initialises the quest
*/
public void init()
{
associateNpc(TALBORN_ID);
}
/**
* Handles the given quest action
*/
public void handleAction(QuestAction action, Object[] args, final Player player)
{
int stage = player.getQuestStage(this);
if(action == QuestAction.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
if(npc.getID() != TALBORN_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
if(stage == -1)
startQuest(player, npc);
else
handleTalk(player, npc);
}
}
/**
* Handles npc chat if the quest hasn't been started yet
*/
private void startQuest(final Player player, final Npc npc)
{
sendChat("...Avada kedavra!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
spellPlayer(player, npc);
addSingleEvent(new SingleEvent(player, 1000)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Holy shit!", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("What? Huh? Get out of the way you fool!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("You shot me you stupid sod", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Hmm, indeed. But it worked!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Yeah it did. You burnt my sleeve.", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Collateral damage. A necessary casualty.", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Your sleeve is expendable in this war", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("What war?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Well the war against those nasty little imps of course", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Imps? What threat could they possibly pose?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Those little bastards stole my beads!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Riight.. your beads. And what's so special about these beads?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Why, absolutely nothing. It's the principle of the matter.", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Surely it can't be that hard to get them to give them back", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Oh really? Why don't you try and get them back then", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Yeah right, chase imps around for free. You're crazier than I thought", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Free? Nonsense. I'd be happy to reward you.", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Hmm. What kind of reward?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
player.setBusy(true);
sendChat("I've got a few valuable things lying around, I'll find something.", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
player.setBusy(true);
sendChat("How about it? Would you help an old wizard out?", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(false);
player.setMenuHandler(new MenuHandler(FIRST_MENU)
{
public void handleReply(final int option, final String reply)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat(reply, player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
if(option == 1)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Excellent! Begin at once if you wish to collect them within a decade", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("There are four beads! Red, white, black, yellow and black.", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Ahh you said... nevermind", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("I'll come back when I get the beads...", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("If! If you get the beads. Don't underestimate the little beasts!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Sure, whatever old man.", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
player.setQuestStage(getUniqueID(), 1);
sendChat("Tarantallegra!", npc, player);
spellPlayer(player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Ouch! Would you bloody wait til I'm gone!", player, npc);
player.setBusy(false);
npc.unblock();
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Move it!", npc, player);
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
} else
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Fine. But don't come to me when you need some pomegranate!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Okaaay...", player, npc);
player.setBusy(false);
npc.unblock();
}
});
}
}
});
}
});
player.getActionSender().sendMenu(FIRST_MENU);
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
/**
* Handles npc chat if the quest is started but not finished
*/
private void handleTalk(final Player player, final Npc npc)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("I know you. You're that fellow that stole my beads!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("What? No, I'm the one that offered to find them for you.", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("It makes no difference, I still don't like you.", npc, player);
if(player.getQuestStage(getUniqueID()) != COMPLETE)
{
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("But my beads, did you find them?", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(false);
npc.blockedBy(player);
player.setMenuHandler(new MenuHandler(SECOND_MENU)
{
public void handleReply(final int option, final String reply)
{
sendChat(reply, player, npc);
if(option == 0) // Yes
{
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
if(player.getInventory().hasItemId(RED_BEAD) && player.getInventory().hasItemId(YELLOW_BEAD) && player.getInventory().hasItemId(BLACK_BEAD) && player.getInventory().hasItemId(WHITE_BEAD))
{
sendChat("Excellent! Hand them over immediately", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Alright, calm down. I thought they were useless anyway", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Useless! Oh my dear " + (player.isMale() ? "boy" : "girl") + ", they are quite important", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
finishQuest(player, npc);
}
});
}
});
}
});
} else
{
sendChat("Bollocks! Don't return til you have them you fool", npc, player);
spellPlayer(player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Hey! Watch yourself old man", player, npc);
player.setBusy(false);
npc.unblock();
}
});
}
}
});
} else // No
{
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Well what are you doing here then? Move it!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
spellPlayer(player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Would you bugger off with the spells you mad fool!", player, npc);
player.setBusy(false);
npc.unblock();
}
});
}
});
}
});
}
}
});
player.getActionSender().sendMenu(SECOND_MENU);
}
});
}
});
} else
{
player.setBusy(false);
npc.unblock();
}
}
});
}
});
}
/**
* Finishes the quest
*/
private void finishQuest(final Player player, final Npc npc)
{
player.setBusy(true);
npc.blockedBy(player);
player.getActionSender().sendMessage("You hand over the beads");
player.getInventory().remove(YELLOW_BEAD, 1);
player.getInventory().remove(RED_BEAD, 1);
player.getInventory().remove(WHITE_BEAD, 1);
player.getInventory().remove(BLACK_BEAD, 1);
player.getActionSender().sendInventory();
player.getActionSender().sendSound("click");
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Alright, that's my half of the bargain.", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Now what of my reward?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Ah, your reward. I found this! You can take it.", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
player.getActionSender().sendMessage(EntityHandler.getNpcDef(TALBORN_ID).getName() + " gives you one " + EntityHandler.getItemDef(ITEM_REWARD).getName());
player.getInventory().add(new InvItem(ITEM_REWARD, 1));
player.getActionSender().sendInventory();
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("What am I supposed to do with this?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("I don't know, whatever you like. I certainly don't want it", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("And have a read of this book", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("It'll teach you a thing or two about magic!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
player.getActionSender().sendMessage("You read the wizard's book");
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
player.incExp(6, REWARD_XP, false);
player.getActionSender().sendStat(6);
addSingleEvent(new SingleEvent(player, 2000)
{
public void action()
{
player.setBusy(true);
npc.blockedBy(player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Now I have work to do! Leave my tower!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
spellPlayer(player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Damnit! Gladly...", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setQuestStage(getUniqueID(), Quest.COMPLETE);
player.incQuestPoints(QUEST_POINTS);
player.setBusy(false);
npc.unblock();
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
/**
* Casts an imaginary spell at the player
*/
private void spellPlayer(Player player, Npc npc)
{
player.setLastDamage(0);
player.informOfModifiedHits(player);
player.getActionSender().sendTeleBubble(npc.getLocation().getX(), npc.getLocation().getY(), false);
player.getActionSender().sendSound("combat1a");
}
/**
* Construct the quest (empty)
*/
public ImpCatcher()
{
}
}

View File

@ -1,286 +0,0 @@
import org.moparscape.msc.gs.event.SingleEvent;
import org.moparscape.msc.gs.model.InvItem;
import org.moparscape.msc.gs.model.MenuHandler;
import org.moparscape.msc.gs.model.Npc;
import org.moparscape.msc.gs.model.Player;
import org.moparscape.msc.gs.quest.Quest;
import org.moparscape.msc.gs.quest.QuestAction;
/**
* Quest: Sheep Shearer (v1.0) Status: COMPLETE Start: Fred the farmer (id 77),
* 159, 619 Items: 207x20 Reward: 1 quest point, 60 gold, Crafting 350 xp
*
* @author Konijn
*/
public class SheepShearer extends Quest {
private final int FRED_ID = 77;
private final int ITEM_WOOL = 207;
private final int REWARD_XP = 350;
private final int REWARD_GP = 330;
private final String[] FIRST_MENU = new String[] {
"Sure, what do I need to do?", "No thanks, I'm good." };
private final String[] SECOND_MENU = new String[] {
"Sorry, I don't like the sound of that.", "I'd be happy to help." };
public void init() {
associateNpc(FRED_ID);
}
public SheepShearer() {
}
public String getName() {
return "Sheep Shearer";
}
public int getUniqueID() {
return 1;
}
public void handleAction(QuestAction action, Object[] args,
final Player player) {
int stage = player.getQuestStage(this);
if (stage == -1) // Quest hasn't been started
{
if (action == QuestAction.TALKED_NPC) {
if (!(args[0] instanceof Npc))
return;
final Npc npc = (Npc) args[0];
if (npc.getID() != FRED_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
sendChat("Hi there, traveller. Care to make some money?", npc,
player);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
player.setBusy(false);
player.setMenuHandler(new MenuHandler(FIRST_MENU) {
public void handleReply(final int option,
final String reply) {
player.setBusy(true);
switch (option) {
case 1:
player.setBusy(false);
npc.unblock();
sendChat("No thanks, I'm good.", player,
npc);
break;
case 0:
sendChat("Sure, what do I need to do?",
player, npc);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
sendChat(
"If you collect 20 balls of wool for me, I'll pay you 500 coins.",
npc, player);
addSingleEvent(new SingleEvent(
player, 2000) {
public void action() {
sendChat(
"Maybe I'll teach you a thing or two about crafting, too.",
npc, player);
addSingleEvent(new SingleEvent(
player, 2000) {
public void action() {
sendChat(
"I'm afraid you'll have to find your own shears, but the sheep are outside.",
npc, player);
addSingleEvent(new SingleEvent(
player,
2000) {
public void action() {
player.setBusy(false);
player.setMenuHandler(new MenuHandler(
SECOND_MENU) {
public void handleReply(
final int option,
final String reply) {
player.setBusy(true);
switch (option) {
case 1:
sendChat(
"I'd be happy to help.",
player,
npc);
addSingleEvent(new SingleEvent(
player,
2000) {
public void action() {
sendChat(
"Great! Come back and see me when you're done.",
npc,
player);
addSingleEvent(new SingleEvent(
player,
2000) {
public void action() {
player.setQuestStage(
getUniqueID(),
1);
player.setBusy(false);
npc.unblock();
}
});
}
});
break;
case 0:
sendChat(
"Sorry, I don't like the sound of that.",
player,
npc);
addSingleEvent(new SingleEvent(
player,
2000) {
public void action() {
sendChat(
"Suit yourself. Come and see me if you change your mind.",
npc,
player);
player.setBusy(false);
npc.unblock();
}
});
break;
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
owner.getActionSender()
.sendMenu(
SECOND_MENU);
}
});
}
});
}
});
}
});
break;
default:
player.setBusy(false);
npc.unblock();
break;
}
}
});
owner.getActionSender().sendMenu(FIRST_MENU);
}
});
} else
return;
} else if (stage == 1) {
if (action == QuestAction.TALKED_NPC) {
if (!(args[0] instanceof Npc))
return;
final Npc npc = (Npc) args[0];
if (npc.getID() != FRED_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
sendChat("Ahh, you've returned! Do you have my wool?", npc,
player);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
player.setBusy(false);
player.setMenuHandler(new MenuHandler(new String[] {
"I'm afraid not.", "Yes, I do." }) {
public void handleReply(final int option,
final String reply) {
player.setBusy(true);
sendChat(reply, player, npc);
if (option == 0) {
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
sendChat(
"Well, come and see me when you do. The offer still stands",
npc, player);
player.setBusy(false);
npc.unblock();
}
});
} else if (option == 1) {
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
// check items
if (player.getInventory()
.hasItemId(ITEM_WOOL)
&& player.getInventory()
.countId(ITEM_WOOL) >= 20) {
finishQuest(player, npc);
} else {
sendChat(
"Um, no you don't. Get back to me when you do. The reward still stands!",
npc, player);
player.setBusy(false);
npc.unblock();
}
}
});
}
}
});
owner.getActionSender()
.sendMenu(
new String[] { "I'm afraid not.",
"Yes, I do." });
}
});
}
} else if (stage == 0) {
if (action == QuestAction.TALKED_NPC) {
if (!(args[0] instanceof Npc))
return;
final Npc npc = (Npc) args[0];
if (npc.getID() != FRED_ID)
return;
player.setBusy(true);
npc.blockedBy(player);
sendChat("Hello " + player.getUsername() + "!", npc, player);
player.setBusy(false);
npc.unblock();
}
}
}
private void finishQuest(final Player player, final Npc npc) {
sendChat("Thank you very much! As promised, here's your reward.", npc,
player);
addSingleEvent(new SingleEvent(player, 2000) {
public void action() {
player.incExp(12, REWARD_XP, false);
player.getActionSender().sendStat(12);
player.setQuestStage(getUniqueID(), Quest.COMPLETE);
for (int i = 0; i < 20; i++)
player.getInventory().remove(ITEM_WOOL, 1);
player.getInventory().add(new InvItem(10, REWARD_GP));
player.getActionSender().sendInventory();
player.incQuestPoints(1);
player.setBusy(false);
npc.unblock();
}
});
}
}

View File

@ -1,316 +0,0 @@
import org.moparscape.msc.gs.event.SingleEvent;
import org.moparscape.msc.gs.model.MenuHandler;
import org.moparscape.msc.gs.model.Npc;
import org.moparscape.msc.gs.model.Player;
import org.moparscape.msc.gs.quest.Quest;
import org.moparscape.msc.gs.quest.QuestAction;
/**
* Quest: Vampire Slayer (v1.0) 6/1/2009
* Status: INCOMPLETE
* Start: Morgan (id 97), 215,615
* NPCs: Harlow (id 98), 82,444
* Items:
* Reward: 3 quest points, 1000 attack xp
*
* @author punKrockeR
*/
public class VampireSlayer extends Quest
{
private static final int MORGAN_ID = 97;
private static final int HARLOW_ID = 98;
//private static final int REWARD_XP = 1000;
private static final int DEFAULT_EVENT_DELAY = 3200;
//private static final int QUEST_POINTS = 3;
private static final String[] FIRST_MENU = new String[] { "No. Vampires are scary", "Ok I'm up for an adventure", "I tried fighting him. He wouldn't die" };
private static final String[] SECOND_MENU = new String[] { "No, you've had enough", "Ok mate", "Morgan needs your help" };
/**
* Don't load this quest yet it's incomplete
*/
public boolean loadQuest()
{
return false;
}
/**
* @return the quest's name
*/
public String getName()
{
return "Vampire Slayer";
}
/**
* @return this quest's unique id
*/
public int getUniqueID()
{
return 4;
}
/**
* Initialises the quest
*/
public void init()
{
associateNpc(MORGAN_ID);
associateNpc(HARLOW_ID);
}
/**
* Handles the given quest action
*/
public void handleAction(QuestAction action, Object[] args, final Player player)
{
int stage = player.getQuestStage(this);
if(action == QuestAction.TALKED_NPC)
{
if(!(args[0] instanceof Npc))
return;
final Npc npc = (Npc)args[0];
player.setBusy(true);
npc.blockedBy(player);
if(npc.getID() == MORGAN_ID)
{
if(stage == -1)
startQuest(player, npc);
else
handleMorganTalk(player, npc);
} else
if(npc.getID() == HARLOW_ID)
{
handleHarlowTalk(player, npc);
}
}
}
/**
* Handles npc chat if the quest hasn't been started yet
*/
private void startQuest(final Player player, final Npc npc)
{
sendChat("Please, please help us bold hero!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("What's the problem?", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Our little village has been dreadfully ravaged by an evil vampire!", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("There's hardly any of us left", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("We need someone to get rid of him once and for good", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(false);
player.setMenuHandler(new MenuHandler(FIRST_MENU)
{
public void handleReply(final int option, final String reply)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat(reply, player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
if(option == 0) // No
{
sendChat("I don't blame you", npc, player);
player.setBusy(false);
npc.unblock();
} else // Yes
{
npc.blockedBy(player);
sendChat("I think first you should seek help", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("I have a friend who is a retired vampire hunter called Dr Harlow", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("He may be able to give you some tips", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("He's usually found in the Jolly Bar Inn these days", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("He's a bit of an old soak", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("Mention his old friend Morgan", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("I'm sure he wouldn't want me to be killed by a vampire", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("I'll look him up then", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setQuestStage(getUniqueID(), 1); // Start quest
player.setBusy(false);
npc.unblock();
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
});
}
}
});
}
});
player.getActionSender().sendMenu(FIRST_MENU);
}
});
}
});
}
});
}
});
}
});
}
/**
* Handles Morgan's chat if the quest is started but not finished
*/
private void handleMorganTalk(final Player player, final Npc npc)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("How are you doing with your quest?", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
if(player.getQuestStage(getUniqueID()) == 1)
{
npc.blockedBy(player);
sendChat("I'm working on it still", player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("Please hurry", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
npc.blockedBy(player);
sendChat("Every day we live in fear of our lives", npc, player);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
sendChat("Afraid that we will be the vampire's next victim", npc, player);
player.setBusy(false);
npc.unblock();
}
});
}
});
}
});
} else
{
}
}
});
}
/**
* Handles Harlow's chat if the quest is started but not finished
*/
private void handleHarlowTalk(final Player player, final Npc npc)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat("Buy me a drrink pleassh", npc, player);
player.setBusy(false);
player.setMenuHandler(new MenuHandler(SECOND_MENU)
{
public void handleReply(final int option, final String reply)
{
player.setBusy(true);
npc.blockedBy(player);
sendChat(reply, player, npc);
addSingleEvent(new SingleEvent(player, DEFAULT_EVENT_DELAY)
{
public void action()
{
player.setBusy(false);
npc.unblock();
if(option == 0)
{
sendChat("Fuck you", npc, player);
player.setBusy(false);
npc.unblock();
}
}
});
}
});
player.getActionSender().sendMenu(SECOND_MENU);
}
/**
* Construct the quest (empty)
*/
public VampireSlayer()
{
}
}

View File

@ -1,2 +0,0 @@
@echo off
del *.class

View File

@ -1,4 +0,0 @@
@echo off
del *.class
javac -classpath .;../../../rscd.jar *.java
pause

View File

@ -1 +0,0 @@
/usr/java/jdk1.6.0_07/bin/javac -classpath /home/mscquests/rscd.jar *.java

View File

@ -1,7 +0,0 @@
/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
/* DO NOT EDIT */
grant {
permission java.security.AllPermission;
};

Binary file not shown.