Snowball_Event_~

Newbie Spellweaver
Joined
Apr 8, 2009
Messages
22
Reaction score
2
Here is the snowball event that I made. I decided to release it due to some reasons. It is not GMS-alike because I didn't like the way GMS does it.
You can check out this video to see what it is like : YouTube - AzuraStory Snowball Event 2

Anyway, here it is. Credits to Bassoe for some packets and some stuff I used from kevintjuh93's release in RZ. Credits to kevintjuh93 of RaGeZONE for the rollSnowball packet. Credits to me for the rest. Hope this does not get to ragezone. Also, this is for v62. Don't mind my poor coding skillz

In MapleCharacter.java :

PHP:
import net.sf.azura.server.MapleSnowball;

Add into handlePacket in private void changeMapInternal(final MapleMap to, final Point pos, MaplePacket warpPacket) { :

PHP:
if (to.getId() == 109060000) {
            int teamz = (pos.y > -80 ? 0 : 1);
            if (to.getSnowBall(teamz) == null) {
                MapleSnowball ball = new MapleSnowball(teamz);
                to.setSnowBall(ball);
            }
       }


In MapleMap.java :

PHP:
import net.sf.azura.server.MapleSnowball; 
 
 
Code: 
private MapleSnowball snowball0 = null;
private MapleSnowball snowball1 = null; 
 
 
Code: 
public void setSnowBall(MapleSnowball ball) {
        switch (ball.getTeam()) {
            case 0:
                this.snowball0 = ball;
                break;
            case 1:
                this.snowball1 = ball;
                break;
            default:
                break;
        }
    }

    public MapleSnowball getSnowBall(int team) {
        switch (team) {
            case 0:
                return snowball0;
            case 1:
                return snowball1;
            default:
                return null;
        }


Make a new file MapleSnowball.java and put it into server folder with this in :


PHP:
package net.sf.azura.server;

import java.awt.Point;

/**
 *
 * @author Bassoe
 * Edited by acEvolution to suit his needs :P
 */

// TODO : Award points when snowman is hit once. 50 points enables a team to sabotage the other by stunning the whole team.
public class MapleSnowball {
    
    private Point position;
    private int team;
    public static boolean isInvis0 = false, isInvis1 = false;

    public MapleSnowball(int team_) {
        this.team = team_;
        switch (team_) {
            case 0:
                this.position = new Point(0, 155);
                break;
            case 1:
                this.position = new Point(0, -84);
                break;
            default:
                this.position = new Point(0, 0);
                break;
        }
    }

    public int getTeam() {
        return team;
    }


    public Point getPosition() {
        return position;
    }

    
    public void setPositionX(int pos) {
        this.position.x = pos;    
    }

}

Add these into MaplePacketCreator.java :

PHP:
  public static MaplePacket leftKnockBack() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.LEFT_KNOCK_BACK.getValue());
        return mplew.getPacket();
    }

        
        public static MaplePacket rollSnowball(int type, int rollDistance0, int rollDistance1, int startPoint0, int startPoint1) {
            // DA 00 XX 00 00 00 00 00 00 00 00 R1 R2 00 R1 R2 00 00 00 00 00 00 00 00 00 00
            // Packet given by kevintjuh93, written by acEvolution           
            MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
            mplew.writeShort(SendPacketOpcode.ROLL_SNOWBALL.getValue());
            mplew.write(type); // 0 = normal, 1 = rolls from start to end, 2 = btm invis, 3 = top invis
            if (type == 2) {
                MapleSnowball.isInvis0 = true;
            } else if (type == 3) {
                MapleSnowball.isInvis1 = true;
            }
            mplew.writeLong(0);
            mplew.write(rollDistance0); // bottom snowball
            mplew.write(startPoint0); // stage
            mplew.write(0);
            mplew.write(rollDistance1); // top snowball
            mplew.write(startPoint1); // stage
            mplew.write(0);
            mplew.writeLong(0);
            mplew.writeShort(0);
            return mplew.getPacket(); 
        }

        public static MaplePacket hitSnowBall(int team, int damage) {
            MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
            mplew.writeShort(SendPacketOpcode.HIT_SNOWBALL.getValue());
            mplew.write(team);// 0 is down, 1 is up
            mplew.writeInt(damage);
            return mplew.getPacket();
        }

        public static MaplePacket snowballMessage(int team, int message) {
            MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
            mplew.writeShort(SendPacketOpcode.SNOWBALL_MESSAGE.getValue());
            mplew.write(team);// 0 is down, 1 is up
            mplew.writeInt(message);
            return mplew.getPacket();
        }


Add these into SendPacketOpcode :

PHP:
LEFT_KNOCK_BACK, HIT_SNOWBALL, SNOWBALL_MESSAGE, ROLL_SNOWBALL,


Add these into sendops.properties :

ROLL_SNOWBALL = 0xDA
HIT_SNOWBALL = 0xDB
SNOWBALL_MESSAGE = 0xDC
LEFT_KNOCK_BACK = 0xDD


Add these into recvops.properties :

PHP:
SNOWBALL = 0xB3

Add this into PacketProcessor.java :

PHP:

Add this into RecvPacketOpcode :

PHP:
SNOWBALL,


Make a new file SnowballHandler.java and put it into net.channel.handler folder with this in :

PHP:
import net.sf.azura.client.MapleClient;
import net.sf.azura.net.AbstractMaplePacketHandler;
import net.sf.azura.tools.data.input.SeekableLittleEndianAccessor; 

 /**
 *
 * @author AceEvolution
 */
 public class SnowballHandler extends AbstractMaplePacketHandler {

    @Override
    public void handlePacket(SeekableLittleEndianAccessor slea, final MapleClient c) {
       //Snowball Event is handled in CloseRangeDamageHandler
       //This file is here so that you don't get flooded with unhandled messages in Channel.bat
    }
}


In CloseRangeDamageHandler.java :

Follow this part closely, it is important where you declare your integers otherwise you cannot end the event. This is because public void handlePacket is like public void run(). Everything under handlePacket gets runned again and again. Therefore if you declare an int i = 0, and later on declare i++, int i will go back to 0 once the void is runned again.


Under

PHP:
public class CloseRangeDamageHandler extends AbstractDealDamageHandler {
Add :
PHP:
@Override

Add :

PHP:
int extraDistance0 = startPoint0 * 256;
int extraDistance1 = startPoint1 * 256;

Under :

PHP:
// handle charged blow
        if (attack.numAttacked > 0 && attack.skill == 1211002) {
            boolean advcharge_prob = false;
            int advcharge_level = player.getSkillLevel(SkillFactory.getSkill(1220010));
            if (advcharge_level > 0) {
                MapleStatEffect advcharge_effect = SkillFactory.getSkill(1220010).getEffect(advcharge_level);
                advcharge_prob = advcharge_effect.makeChanceResult();
            } else {
                advcharge_prob = false;
            }
            if (!advcharge_prob) {
                player.cancelEffectFromBuffStat(MapleBuffStat.WK_CHARGE);
            }
        }


Add :


PHP:
                 /* Start of Snowball Event
                 * @author-AceEvolution
                 */
                if (player.getMapId() == 109060000) {
                int team = c.getPlayer().getPosition().y > -80 ? 0 : 1;
                int distance0 = player.getMap().getSnowBall(0).getPosition().x, distance1 = player.getMap().getSnowBall(1).getPosition().x;
                int playerPos = (player.getPosition().x - 400) / 3; // Proportional to snowballpos
                int damage = Math.random() < 0.01 ? 10 : 0;
                final MapleSnowball ball = player.getMap().getSnowBall(team);
                if (ball != null)
                if (ball.getPosition().x == 65) { // Going to stage 1
                    if (damage == 10) {
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team, damage));
                    ball.setPositionX((ball.getPosition().x + 1));
                    player.getMap().broadcastMessage(MaplePacketCreator.rollSnowball(0, distance0 - extraDistance0, distance1 - extraDistance1, startPoint0, startPoint1));
                    } else {
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team, damage));
                    }
                } else if (ball.getPosition().x == 255 || ball.getPosition().x == 511 || ball.getPosition().x == 767) { // Other stages
                    if (damage == 10) {
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team, damage));
                    ball.setPositionX((ball.getPosition().x + 1));
                    player.getMap().broadcastMessage(MaplePacketCreator.rollSnowball(0, distance0 - extraDistance0, distance1 - extraDistance1, startPoint0, startPoint1));
                    if (team == 0) {
                    startPoint0++;
                    } else {
                    startPoint1++;
                    }
                    } else {
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team, damage));
                    }
                } else if (ball.getPosition().x == 899) { // Crossing the finishing line
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team, 10));
                    ball.setPositionX((900));
                    player.getMap().broadcastMessage(MaplePacketCreator.rollSnowball(team + 2, distance0 - extraDistance0, distance1 - extraDistance1, startPoint0, startPoint1));
                    for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) {
                    chr.getClient().getSession().write(MaplePacketCreator.serverNotice(6, "Congratulations! Team " + team + " has won the Snowball Event!"));
                    chr.changeMap(c.getPlayer().getClient().getChannelServer().getMapFactory().getMap(team == 1 ? 109050000 : 910000000), c.getPlayer().getClient().getChannelServer().getMapFactory().getMap(team == 1 ? 109050000 : 910000000).getPortal(0));
                    }
                } else {
                    if (playerPos >= ball.getPosition().x) { // In case lag happens and the person is able to get pass the snowball
                        c.getSession().write(MaplePacketCreator.leftKnockBack());
                        c.getSession().write(MaplePacketCreator.enableActions());
                } else if (playerPos < ball.getPosition().x && playerPos >= (ball.getPosition().x - 40)) {
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team, 10));
                    ball.setPositionX((ball.getPosition().x + 1));
                    player.getMap().broadcastMessage(MaplePacketCreator.rollSnowball(0, distance0 - extraDistance0, distance1 - extraDistance1, startPoint0, startPoint1));
                } else if (player.getPosition().x < -360 && player.getPosition().x > -560) {
                    player.getMap().broadcastMessage(MaplePacketCreator.hitSnowBall(team + 2, 15)); // Hitting the snowman
                }
                }
                }


Also add imports :


PHP:
import net.sf.odinms.server.MapleSnowball;
import net.sf.odinms.server.maps.MapleMap;



Spawnpoint for top platform is 1 so either do !warp 109060000 1 or !warp playername 109060000 1 to get up.

Ok good luck. A thanks would be nice ;o

Courtesy of Osiris for helping me compress the giant wall of code ;D Thanks Osiris.


By :Kev acevolution :love:
 
There's 2 exploits in this.
Hit snowball and your a level 5 GM.
Touch Snowman and you drop the DB.
This is not approved.
 
for some reason after i compiled and start server my channel.bat has this error:

Exception in thread "main" java.lang.RuntimeException: java.lang.NumberFormatExc
eption: For input string: "500 "
at net.sf.odinms.net.channel.ChannelServer.run(ChannelServer.java:217)
at net.sf.odinms.net.channel.ChannelServer.main(ChannelServer.java:599)
Caused by: java.lang.NumberFormatException: For input string: "500 "
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at net.sf.odinms.net.channel.ChannelServer.run(ChannelServer.java:187)
... 1 more

plz help me thx
 
for some reason after i compiled and start server my channel.bat has this error:

Exception in thread "main" java.lang.RuntimeException: java.lang.NumberFormatExc
eption: For input string: "500 "
at net.sf.odinms.net.channel.ChannelServer.run(ChannelServer.java:217)
at net.sf.odinms.net.channel.ChannelServer.main(ChannelServer.java:599)
Caused by: java.lang.NumberFormatException: For input string: "500 "
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at net.sf.odinms.net.channel.ChannelServer.run(ChannelServer.java:187)
... 1 more

plz help me thx

That doesn't have nothing related to the thread release. >.>
 
  • Like
Reactions: ^^^
Back