Excellzone

Forum and disscussions since 2010


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

#1
Excell

avatar
Head Administer
Head Administer
I noticed that Mini Games are not working in all the released sources
(reason for that is that the noobs copied it from each other). This
fixes the creation of a game (it doesn't fix Match Card and Omok
itself, do this on your own ). I also added the password protection, a step closer to GMS - yay?

PlayerInteractionHandler.java
Change
Code:
IPlayerInteractionManager game = new MapleMiniGame(c.getPlayer(), type, desc);

to
Code:
IPlayerInteractionManager game = new MapleMiniGame(c.getPlayer(), type, desc, pass);

Add
Code:
else if (ips.getShopType() == 3 || ips.getShopType() == 4) { //mini game
String pass = null;
if (slea.readByte() == 1) { //a password has been entered
pass = slea.readMapleAsciiString();
}

if (pass != null && !pass.equals(ips.getPassword())) {
c.getPlayer().dropMessage(1, "The password is not correct.");
return;
}
}

after
Code:
else if (ips.getShopType() == 2) {
if (((MaplePlayerShop) ips).isBanned(c.getPlayer().getName())) {
c.getPlayer().dropMessage(1, "You have been banned from this store.");
return;
}
}

HiredMerchant.java
Change
Code:
super(owner, itemId % 10, desc, 3);

to
Code:
super(owner, itemId % 10, desc, null, 3);

IPlayerInteractionManager.java
Add
Code:
public String getPassword();

MapleMiniGame.java
Change
Code:
public MapleMiniGame(MapleCharacter owner, int type, String desc) {
super(owner, type, desc, 1);

to
Code:
public MapleMiniGame(MapleCharacter owner, int type, String desc, String pass) {
super(owner, type, desc, pass, 1);

MaplePlayerShop.java
Change
Code:
public MaplePlayerShop(MapleCharacter owner, int itemId, String desc) {
super(owner, itemId % 10, desc, 3);

to
Code:
public MaplePlayerShop(MapleCharacter owner, int itemId, String desc) {
super(owner, itemId % 10, desc, null, 3);

PlayerInteractionManager.java
Add
Code:
private String password = "";

Change
Code:
public PlayerInteractionManager(MapleCharacter owner, int type, String desc, int capacity) {
this.setPosition(owner.getPosition());
this.ownerName = owner.getName();
this.ownerId = owner.getId();
this.type = (byte) type;
this.capacity = (short) capacity;
this.description = desc;

to
Code:
public PlayerInteractionManager(MapleCharacter owner, int type, String desc, String pass, int capacity) {
this.setPosition(owner.getPosition());
this.ownerName = owner.getName();
this.ownerId = owner.getId();
this.type = (byte) type;
this.capacity = (short) capacity;
this.description = desc;
this.password = pass;

Add
Code:
@Override
public String getPassword() {
return password;
}

MaplePacketCreator.java
Change your addAnnounceBox() function to
Code:
private static void addAnnounceBox(MaplePacketLittleEndianWriter mplew, IPlayerInteractionManager interaction) {
if (interaction.getShopType() == 2) {
mplew.write(4); //Shop
mplew.writeInt(((MaplePlayerShop) interaction).getObjectId());
} else if (interaction.getShopType() == 3) {
mplew.write(2); //Match Card
mplew.writeInt(((MapleMiniGame) interaction).getObjectId());
} else if (interaction.getShopType() == 4) {
mplew.write(1); //Omok
mplew.writeInt(((MapleMiniGame) interaction).getObjectId());
}
mplew.writeMapleAsciiString(interaction.getDescription()); // desc
if (interaction.getPassword() != null)
mplew.write(1); //private
else
mplew.write(0); //public
mplew.write(interaction.getItemType());
mplew.write(1);
if (interaction.getShopType() == 2) {
mplew.write(interaction.getFreeSlot() > -1 ? 4 : 1);
mplew.write(0);
} else {
mplew.write(interaction.getFreeSlot() > -1 ? 2 : 1); //4 slots, but only 2 can enter
mplew.write(((MapleMiniGame) interaction).getStarted() ? 1 : 0);
}
}

MapleMiniGame.java
Replace
Code:
public void setOwnerPoints() {
ownerpoints++;
if (ownerpoints + visitorpoints == matchestowin) {
if (ownerpoints == visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameTie(this), true);
} else if (ownerpoints > visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 0), true);
} else if (visitorpoints > ownerpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 1), true);
}
}
ownerpoints = 0;
visitorpoints = 0;
}

public void setVisitorPoints() {
visitorpoints++;
if ((ownerpoints + visitorpoints) == matchestowin) {
if (ownerpoints > visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 0), true);
} else if (visitorpoints > ownerpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 1), true);
} else if (ownerpoints == visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameTie(this), true);
}
}
ownerpoints = 0;
visitorpoints = 0;
}

with
Code:
public void setOwnerPoints() {
ownerpoints++;
if (ownerpoints + visitorpoints == matchestowin) {
if (ownerpoints == visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameTie(this), true);
} else if (ownerpoints > visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 0), true);
} else if (visitorpoints > ownerpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 1), true);
}
ownerpoints = 0;
visitorpoints = 0;
}
}

public void setVisitorPoints() {
visitorpoints++;
if ((ownerpoints + visitorpoints) == matchestowin) {
if (ownerpoints > visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 0), true);
} else if (visitorpoints > ownerpoints) {
broadcast(MaplePacketCreator.getMiniGameWin(this, 1), true);
} else if (ownerpoints == visitorpoints) {
broadcast(MaplePacketCreator.getMiniGameTie(this), true);
}
ownerpoints = 0;
visitorpoints = 0;
}
}

Finish the rest on your own...

By the way...
Code:
EXPEL_PLAYER(0x36), //Game Expel

View user profile http://excellzone.mrforum.net

View previous topic View next topic Back to top Message [Page 1 of 1]


Permissions in this forum:
You cannot reply to topics in this forum