source
Source for my MapleSolaxiaV2 (v83 MapleStory).
This commit is contained in:
53
src/server/quest/actions/BuffAction.java
Normal file
53
src/server/quest/actions/BuffAction.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class BuffAction extends MapleQuestAction {
|
||||
int itemEffect;
|
||||
|
||||
public BuffAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.BUFF, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
itemEffect = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider.getInstance().getItemEffect(itemEffect).applyTo(chr);
|
||||
}
|
||||
}
|
||||
56
src/server/quest/actions/ExpAction.java
Normal file
56
src/server/quest/actions/ExpAction.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class ExpAction extends MapleQuestAction {
|
||||
int exp;
|
||||
|
||||
public ExpAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.EXP, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
exp = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
if (chr.isBeginnerJob()) {
|
||||
chr.gainExp(exp, true, true);
|
||||
} else {
|
||||
chr.gainExp(exp * chr.getExpRate(), true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
src/server/quest/actions/FameAction.java
Normal file
57
src/server/quest/actions/FameAction.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleStat;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class FameAction extends MapleQuestAction {
|
||||
int fame;
|
||||
|
||||
public FameAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.FAME, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
fame = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
chr.addFame(fame);
|
||||
chr.updateSingleStat(MapleStat.FAME, chr.getFame());
|
||||
chr.announce(MaplePacketCreator.getShowFameGain(fame));
|
||||
}
|
||||
}
|
||||
224
src/server/quest/actions/ItemAction.java
Normal file
224
src/server/quest/actions/ItemAction.java
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
import client.inventory.Item;
|
||||
import client.inventory.MapleInventory;
|
||||
import client.inventory.MapleInventoryType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.MapleInventoryManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
import tools.Randomizer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class ItemAction extends MapleQuestAction {
|
||||
Map<Integer, ItemData> items = new HashMap<>();
|
||||
|
||||
public ItemAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.ITEM, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData iEntry : data.getChildren()) {
|
||||
int id = MapleDataTool.getInt(iEntry.getChildByPath("id"));
|
||||
int count = MapleDataTool.getInt(iEntry.getChildByPath("count"), 1);
|
||||
|
||||
Integer prop = null;
|
||||
MapleData propData = iEntry.getChildByPath("prop");
|
||||
if(propData != null)
|
||||
prop = MapleDataTool.getInt(propData);
|
||||
|
||||
int gender = 2;
|
||||
if (iEntry.getChildByPath("gender") != null)
|
||||
gender = MapleDataTool.getInt(iEntry.getChildByPath("gender"));
|
||||
|
||||
int job = -1;
|
||||
if (iEntry.getChildByPath("job") != null)
|
||||
job = MapleDataTool.getInt(iEntry.getChildByPath("job"));
|
||||
|
||||
items.put(id, new ItemData(id, count, prop, job, gender));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
Map<Integer, Integer> props = new HashMap<>();
|
||||
for(ItemData item : items.values()) {
|
||||
if(item.getProp() != null && item.getProp() != -1 && canGetItem(item, chr)) {
|
||||
for (int i = 0; i < item.getProp(); i++) {
|
||||
props.put(props.size(), item.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
int selection = 0;
|
||||
int extNum = 0;
|
||||
if (props.size() > 0) {
|
||||
selection = props.get(Randomizer.nextInt(props.size()));
|
||||
}
|
||||
for (ItemData iEntry : items.values()) {
|
||||
if (!canGetItem(iEntry, chr)) {
|
||||
continue;
|
||||
}
|
||||
if(iEntry.getProp() != null) {
|
||||
if(iEntry.getProp() == -1) {
|
||||
if(extSelection != extNum++)
|
||||
continue;
|
||||
} else if(iEntry.getId() != selection)
|
||||
continue;
|
||||
}
|
||||
|
||||
if(iEntry.getCount() < 0) { // Remove Items
|
||||
MapleInventoryType type = ii.getInventoryType(iEntry.getId());
|
||||
int quantity = iEntry.getCount() * -1; // Invert
|
||||
if(type.equals(MapleInventoryType.EQUIP)) {
|
||||
if(chr.getInventory(type).countById(iEntry.getId()) < quantity) {
|
||||
// Not enough in the equip inventoty, so check Equipped...
|
||||
if(chr.getInventory(MapleInventoryType.EQUIPPED).countById(iEntry.getId()) > quantity) {
|
||||
// Found it equipped, so change the type to equipped.
|
||||
type = MapleInventoryType.EQUIPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
MapleInventoryManipulator.removeById(chr.getClient(), type, iEntry.getId(), quantity, true, false);
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iEntry.getId(), (short) iEntry.getCount(), true));
|
||||
} else {
|
||||
if (chr.getInventory(MapleItemInformationProvider.getInstance().getInventoryType(iEntry.getId())).getNextFreeSlot() > -1) {
|
||||
MapleInventoryManipulator.addById(chr.getClient(), iEntry.getId(), (short) iEntry.getCount());
|
||||
chr.announce(MaplePacketCreator.getShowItemGain(iEntry.getId(), (short) iEntry.getCount(), true));
|
||||
} else {
|
||||
chr.dropMessage(1, "Inventory Full");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
EnumMap<MapleInventoryType, Integer> props = new EnumMap<>(MapleInventoryType.class);
|
||||
List<Pair<Item, MapleInventoryType>> itemList = new ArrayList<>();
|
||||
for(ItemData item : items.values()) {
|
||||
if (!canGetItem(item, chr)) {
|
||||
continue;
|
||||
}
|
||||
MapleInventoryType type = ii.getInventoryType(item.getId());
|
||||
if(item.getProp() != null) {
|
||||
if(!props.containsKey(type)) {
|
||||
props.put(type, item.getId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item.getCount() > 0) {
|
||||
// Make sure they can hold the item.
|
||||
Item toItem = new Item(item.getId(), (short) 0, (short) item.getCount());
|
||||
itemList.add(new Pair<>(toItem, type));
|
||||
} else {
|
||||
// Make sure they actually have the item.
|
||||
int quantity = item.getCount() * -1;
|
||||
if(chr.getInventory(type).countById(item.getId()) < quantity) {
|
||||
if(type.equals(MapleInventoryType.EQUIP) && chr.getInventory(MapleInventoryType.EQUIPPED).countById(item.getId()) > quantity)
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Integer itemID : props.values()) {
|
||||
MapleInventoryType type = ii.getInventoryType(itemID);
|
||||
Item toItem = new Item(itemID, (short) 0, (short) 1);
|
||||
itemList.add(new Pair<>(toItem, type));
|
||||
}
|
||||
|
||||
if (!MapleInventory.checkSpots(chr, itemList)) {
|
||||
chr.dropMessage(1, "Please check if you have enough space in your inventory.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canGetItem(ItemData item, MapleCharacter chr) {
|
||||
if (item.getGender() != 2 && item.getGender() != chr.getGender()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(item.getJob() != -1) {
|
||||
if (item.getJob() != chr.getJob().getId()) {
|
||||
return false;
|
||||
} else if (MapleJob.getBy5ByteEncoding(item.getJob()).getId() / 100 != chr.getJob().getId() / 100) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private class ItemData {
|
||||
private final int id, count, job, gender;
|
||||
private final Integer prop;
|
||||
|
||||
public ItemData(int id, int count, Integer prop, int job, int gender) {
|
||||
this.id = id;
|
||||
this.count = count;
|
||||
this.prop = prop;
|
||||
this.job = job;
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public Integer getProp() {
|
||||
return prop;
|
||||
}
|
||||
|
||||
public int getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
public int getGender() {
|
||||
return gender;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/server/quest/actions/MapleQuestAction.java
Normal file
39
src/server/quest/actions/MapleQuestAction.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public abstract class MapleQuestAction {
|
||||
private final MapleQuestActionType type;
|
||||
protected int questID;
|
||||
|
||||
public MapleQuestAction(MapleQuestActionType action, MapleQuest quest) {
|
||||
this.type = action;
|
||||
this.questID = quest.getId();
|
||||
}
|
||||
|
||||
public abstract void run(MapleCharacter chr, Integer extSelection);
|
||||
public abstract void processData(MapleData data);
|
||||
|
||||
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
return !(status.getStatus() == MapleQuestStatus.Status.NOT_STARTED && status.getForfeited() > 0);
|
||||
}
|
||||
|
||||
public MapleQuestActionType getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
53
src/server/quest/actions/MesoAction.java
Normal file
53
src/server/quest/actions/MesoAction.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class MesoAction extends MapleQuestAction {
|
||||
int mesos;
|
||||
|
||||
public MesoAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.MESO, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
mesos = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
chr.gainMeso(mesos < 0 ? mesos : mesos * chr.getMesoRate(), true, false, true);
|
||||
}
|
||||
}
|
||||
55
src/server/quest/actions/NextQuestAction.java
Normal file
55
src/server/quest/actions/NextQuestAction.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class NextQuestAction extends MapleQuestAction {
|
||||
int nextQuest;
|
||||
|
||||
public NextQuestAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.NEXTQUEST, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
nextQuest = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
chr.announce(MaplePacketCreator.updateQuestFinish((short) questID, status.getNpc(), (short) nextQuest));
|
||||
}
|
||||
}
|
||||
64
src/server/quest/actions/PetSkillAction.java
Normal file
64
src/server/quest/actions/PetSkillAction.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import constants.ItemConstants;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class PetSkillAction extends MapleQuestAction {
|
||||
int flag;
|
||||
|
||||
public PetSkillAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.PETSKILL, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
flag = MapleDataTool.getInt("petskill", data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer extSelection) {
|
||||
MapleQuestStatus status = chr.getQuest(MapleQuest.getInstance(questID));
|
||||
if(!(status.getStatus() == MapleQuestStatus.Status.NOT_STARTED && status.getForfeited() > 0))
|
||||
return false;
|
||||
|
||||
return chr.getPet(0) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
chr.getPet(0).setFlag((byte) ItemConstants.getFlagByInt(flag));
|
||||
}
|
||||
}
|
||||
64
src/server/quest/actions/QuestAction.java
Normal file
64
src/server/quest/actions/QuestAction.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleQuestStatus;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class QuestAction extends MapleQuestAction {
|
||||
int mesos;
|
||||
Map<Integer, Integer> quests = new HashMap<>();
|
||||
|
||||
public QuestAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.QUEST, quest);
|
||||
questID = quest.getId();
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData qEntry : data) {
|
||||
int questid = MapleDataTool.getInt(qEntry.getChildByPath("id"));
|
||||
int stat = MapleDataTool.getInt(qEntry.getChildByPath("state"));
|
||||
quests.put(questid, stat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
for(Integer questID : quests.keySet()) {
|
||||
int stat = quests.get(questID);
|
||||
chr.updateQuest(new MapleQuestStatus(MapleQuest.getInstance(questID), MapleQuestStatus.Status.getById(stat)));
|
||||
}
|
||||
}
|
||||
}
|
||||
120
src/server/quest/actions/SkillAction.java
Normal file
120
src/server/quest/actions/SkillAction.java
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.actions;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import client.MapleJob;
|
||||
import client.Skill;
|
||||
import client.SkillFactory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestActionType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tyler (Twdtwd)
|
||||
*/
|
||||
public class SkillAction extends MapleQuestAction {
|
||||
int itemEffect;
|
||||
Map<Integer, SkillData> skillData = new HashMap<>();
|
||||
|
||||
public SkillAction(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestActionType.SKILL, quest);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
for (MapleData sEntry : data) {
|
||||
byte skillLevel = 0;
|
||||
int skillid = MapleDataTool.getInt(sEntry.getChildByPath("id"));
|
||||
MapleData skillLevelData = sEntry.getChildByPath("skillLevel");
|
||||
if(skillLevelData != null)
|
||||
skillLevel = (byte) MapleDataTool.getInt(skillLevelData);
|
||||
int masterLevel = MapleDataTool.getInt(sEntry.getChildByPath("masterLevel"));
|
||||
List<Integer> jobs = new ArrayList<>();
|
||||
|
||||
MapleData applicableJobs = sEntry.getChildByPath("job");
|
||||
if(applicableJobs != null) {
|
||||
for (MapleData applicableJob : applicableJobs.getChildren()) {
|
||||
jobs.add(MapleDataTool.getInt(applicableJob));
|
||||
}
|
||||
}
|
||||
|
||||
skillData.put(skillid, new SkillData(skillid, skillLevel, masterLevel, jobs));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(MapleCharacter chr, Integer extSelection) {
|
||||
for(SkillData skill : skillData.values()) {
|
||||
Skill skillObject = SkillFactory.getSkill(skill.getId());
|
||||
boolean shouldLearn = false;
|
||||
|
||||
if(skill.jobsContains(chr.getJob()) || skillObject.isBeginnerSkill())
|
||||
shouldLearn = true;
|
||||
|
||||
byte skillLevel = (byte) Math.max(skill.getLevel(), chr.getSkillLevel(skillObject));
|
||||
int masterLevel = Math.max(skill.getMasterLevel(), chr.getMasterLevel(skillObject));
|
||||
if (shouldLearn) {
|
||||
chr.changeSkillLevel(skillObject, skillLevel, masterLevel, -1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class SkillData {
|
||||
protected int id, level, masterLevel;
|
||||
List<Integer> jobs = new ArrayList<>();
|
||||
|
||||
public SkillData(int id, int level, int masterLevel, List<Integer> jobs) {
|
||||
this.id = id;
|
||||
this.level = level;
|
||||
this.masterLevel = masterLevel;
|
||||
this.jobs = jobs;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getMasterLevel() {
|
||||
return masterLevel;
|
||||
}
|
||||
|
||||
public boolean jobsContains(MapleJob job) {
|
||||
return jobs.contains(job.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user