[Release] Dragon Evolution + a few pet scripting methods *Updated

Status
Not open for further replies.
Joined
Apr 20, 2008
Messages
578
Reaction score
76
Hmm, about time I released this from the old thread.

Basically you can evolve your dragons in a manner like gMS; though not exact (no packets sent?). Same fullness, closeness, name, and level. And checks for everything else, and even lets you evolve once already evolved like gMS. And finally, like gMS, has a rare black dragon.

There are requirements.

REQUIREMENTS
- Brain
- A repack/source of OdinMS origin
- Experience with adding stuff (such as the real reborn method(just an example you dont need the real reborn method))
- Pets in your source/repack

If you have them.. continue.
If not.. don't.

Here it is..

First, go to net/sf/odinms/scripting/AbstractPlayerInteraction.java. That's right, you're compiling for this one. However, it's only one file!

1. Add imports at the top. If you dont already have them.

Code:
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.net.channel.handler.SpawnPetHandler;

2. Change your gainItem method. Remove it and Replace it with this. (if you have iGoofy's or not, still replace, as iGoofy's doesnt check for quantity, and thus can't remove a pet from your inventory)

Code:
    public void gainItem(int id, short quantity) {
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
                        if (id >= 5000000 && id <= 5000045 && quantity > 0) {
            try {
                java.sql.Connection con = (java.sql.Connection) DatabaseConnection.getConnection();
                java.sql.PreparedStatement ps = (java.sql.PreparedStatement) con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness) VALUES (?, ?, ?, ?)");
                ps.setString(1, ii.getName(id));
                ps.setInt(2, 1);
                ps.setInt(3, 0);
                ps.setInt(4, 100);
                ps.executeUpdate();
                java.sql.ResultSet rs = ps.getGeneratedKeys();
                rs.next();
                //c.getPlayer().equipChanged();
		MapleInventoryManipulator.addById(c, id, (short) quantity, c.getPlayer().getName() + " receieved pet, ID " + id + ", from a scripted PlayerInteraction. (Quantity: " + quantity + ")", null, rs.getInt(1));
                rs.close();
                ps.close();
            } catch (java.sql.SQLException ex) {
                java.util.logging.Logger.getLogger(AbstractPlayerInteraction.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
        if (quantity >= 0) {
            StringBuilder logInfo = new StringBuilder(c.getPlayer().getName());
            logInfo.append(" received ");
            logInfo.append(quantity);
            logInfo.append(" from a scripted PlayerInteraction (");
            logInfo.append(this.toString());
            logInfo.append(")");
            MapleInventoryManipulator.addById(c, id, quantity, logInfo.toString());
                
        } else {
            MapleInventoryManipulator.removeById(c, MapleItemInformationProvider.getInstance().getInventoryType(id), id, -quantity, true, false);
                    }
                }
        c.getSession().write(MaplePacketCreator.getShowItemGain(id, quantity, true));
    }

3. Add new gainPet method. I presume you already know how.

Code:
	public void gainPet(int id, String name, int level, int closeness, int fullness) {
		if (id > 5000045 && id < 5000000) {
			id = 5000000;
		} else if (level > 30) {
			level = 30;
		} else if (closeness > 30000) {
			closeness = 30000;
		} else if (fullness > 100) {
			fullness = 100;
		}
		try {
			java.sql.Connection con = DatabaseConnection.getConnection();
			java.sql.PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness) VALUES (?, ?, ?, ?)");
			ps.setString(1, name);
			ps.setInt(2, level);
			ps.setInt(3, closeness);
			ps.setInt(4, fullness);
			ps.executeUpdate();
			java.sql.ResultSet rs = ps.getGeneratedKeys();
			rs.next();
                        MapleInventoryManipulator.addById(c, id, (short)1, c.getPlayer().getName() + " receieved pet, ID " + id + ", from a scripted PlayerInteraction.(gainPet)",  null, rs.getInt(1));
			rs.close();
			ps.close();
		} catch (java.sql.SQLException ex) {
			java.util.logging.Logger.getLogger(AbstractPlayerInteraction.class.getName()).log(Level.SEVERE, null, ex);
		}
		c.getSession().write(MaplePacketCreator.getShowItemGain(id, (short)1, true));
	}

4. Add new unequipPet method.

Code:
	public void unequipPet(MapleClient c) {
		SpawnPetHandler pethandler = new SpawnPetHandler();
		pethandler.unequipPet(c);
	}

5. Compile.

6. Add new script. 1032102.js in scripts/npc
Code:
/*
	Made by RMZero213 of RaGEZONE forums.
	Just keep this header here and don't claim that you made it.
*/

/*
	1032102.js
	Mar the Fairy
	Dragon Evolver
*/

importPackage(net.sf.odinms.client);
importPackage(net.sf.odinms.server);

var status = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.sendOk("Alright, see you next time.");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendYesNo("I am Mar the Fairy. If you have a dragon at level 15 or higher and a rock of evolution. I can evolve your dragon. If you are lucky, you may even get a black one! Would you like me to do so?");
		} else if (status == 1) {
			if (cm.haveItem(5000028, 1)) {
				cm.gainItem(5000028, -1);
				cm.gainItem(5000029, 1);
				cm.sendOk("I don't know how you got that egg, but it has hatched, apparently!");
				cm.dispose();
			} else if (cm.getChar().getPet() == null) {
				cm.sendOk("Make sure your pet is equipped.");
				cm.dispose();
			} else if (cm.getChar().getPet().getItemId() < 5000029 || cm.getChar().getPet().getItemId() > 5000033 || !cm.haveItem(5380000,1)) {
				cm.sendOk("You do not meet the requirements. You need #i5380000##t5380000#, as well as either one of #d#i5000029##t5000029##k, #g#i5000030##t5000030##k, #r#i5000031##t5000031##k, #b#i5000032##t5000032##k, or #e#i5000033##t5000033##n equipped. Please come back when you do.");
				cm.dispose();
			} else if (cm.getChar().getPet().getLevel() < 15) {
				cm.sendOk("Your pet must be level 15 or above to evolve.");
				cm.dispose();
			} else if (cm.haveItem(5000029,2) || cm.haveItem(5000030,2) || cm.haveItem(5000031,2) || cm.haveItem(5000032,2) || cm.haveItem(5000033,2)) {
				cm.sendSimple("You have a dragon which isn't out, and as well as a dragon which is out. I can remove one for you. Remember that the data for the dragon I am removing will be lost.\r\n#r#L0#Remove my CASH first slot.#l#k\r\n#b#L1#Remove the first dragon in my inventory.#l#k\r\n#g#L2#No thanks.#l#k");
			} else {
				var id = cm.getChar().getPet().getItemId();
				var name = cm.getChar().getPet().getName();
				var level = cm.getChar().getPet().getLevel();
				var closeness = cm.getChar().getPet().getCloseness();
				var fullness = cm.getChar().getPet().getFullness();
				//MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
				if (id < 5000029 || id > 5000033) {
					cm.sendOk("Something wrong, try again.");
					cm.dispose();
				}
				var rand = 1 + Math.floor(Math.random() * 10);
				var after = 0;
				if (rand >= 1 && rand <= 3) {
					after = 5000030;
				} else if (rand >= 4 && rand <= 6) {
					after = 5000031;
				} else if (rand >= 7 && rand <= 9) {
					after = 5000032;
				} else if (rand == 10) {
					after = 5000033;
				} else {
					cm.sendOk("Something wrong. Try again.");
					cm.dispose();
				}
				if (name.equals(MapleItemInformationProvider.getInstance().getName(id))) {
					name = MapleItemInformationProvider.getInstance().getName(after);
				}
				cm.unequipPet(cm.getC());
				cm.gainItem(5380000, -1);
				cm.gainItem(id, -1);
				cm.gainPet(after, name, level, closeness, fullness);
				cm.sendOk("Your dragon has now evolved!! It used to be a #i" + id + "##t" + id + "#, and now it's a #i" + after + "##t" + after + "#!");
				cm.dispose();
			}
		} else if (status == 2) {
			if (selection == 0) {
				MapleInventoryManipulator.removeFromSlot(cm.getC(), MapleInventoryType.CASH, 1, 1, true);
				cm.sendOk("Your cash first slot is removed.");
			} else if (selection == 1) {
				if (cm.haveItem(5000029, 2)) {
					cm.gainItem(5000029, -1);
				} else if (cm.haveItem(5000030, 2)) {
					cm.gainItem(5000030, -1);
				} else if (cm.haveItem(5000031, 2)) {
					cm.gainItem(5000031, -1);
				} else if (cm.haveItem(5000032, 2)) {
					cm.gainItem(5000032, -1);
				} else if (cm.haveItem(5000033, 2)) {
					cm.gainItem(5000033, -1);
				}
				cm.sendOk("The first dragon in your inventory is removed.");
			} else if (selection == 2) {
				cm.sendOk("Okay, come back next time.");
			}
			cm.dispose();
		}
	}
}

7. ?

8. Success!

Credits:
Me
r1c31shg00d...for the idea I guess.
Leifde - for pets
DarkMage325 - Most of the testing
Serpendiem, Matze, Vimes - creating odinMS
UntitledMS (my server, also first server to have it)

Repack people, take this all you want, keep that header there though.

The aforementioned 'previous thread' is http://forum.ragezone.com/showthread.php?t=439721. I deleted the old scripts though.

And for you 'first release is okay if noob' people, shutup. This is my first release.

UPDATE: Added name handling in the script.

A few images, credits to DarkMage325

RMZero213 - [Release] Dragon Evolution + a few pet scripting methods *Updated - RaGEZONE Forums

RMZero213 - [Release] Dragon Evolution + a few pet scripting methods *Updated - RaGEZONE Forums

RMZero213 - [Release] Dragon Evolution + a few pet scripting methods *Updated - RaGEZONE Forums

RMZero213 - [Release] Dragon Evolution + a few pet scripting methods *Updated - RaGEZONE Forums

RMZero213 - [Release] Dragon Evolution + a few pet scripting methods *Updated - RaGEZONE Forums
 
Last edited:
Re: [Release] Dragon Evolution + a few pet scripting methods

Ahh it's been 24 hours since your original release of the scripts.. and now you have the final release.. sweet lol.. HEY where's my credit lol xD I kept pulling down my server to help you test.. and like showed you lots of errors lol.. I am happy to say that I am probably the 2nd server to get this release.. I was supposed to be first T.T anyways.. if you guys are wondering the original thread he's talking about is here.. http://forum.ragezone.com/showthread.php?t=439721
 
Re: [Release] Dragon Evolution + a few pet scripting methods

Ahh it's been 24 hours since your original release of the scripts.. and now you have the final release.. sweet lol.. HEY where's my credit lol xD I kept pulling down my server to help you test.. and like showed you lots of errors lol.. I am happy to say that I am probably the 2nd server to get this release.. I was supposed to be first T.T anyways.. if you guys are wondering the original thread he's talking about is here.. http://forum.ragezone.com/showthread.php?t=439721

You were the first to get the first release (not this final one)
 
Re: [Release] Dragon Evolution + a few pet scripting methods

You were the first to get the first release (not this final one)

Lol isn't that what I said.. you tested final release first.. so I'm second right.. anyways.. here's some great ways to use this script
You can combine this script with r1c31shg00d's dragon seller and buy a pet dragon from him and get mar to evolve it.. OR.. you if you have cash shop. People in cash shop can buy the egg from the cash shop, take it to mars. She'll hatch it (well not really she just replaces it) and you can get the dragon like that. Then once it's level 15, go to mar and bring her rock of evolution and she'll evolve it. You can evolve as many times as you want. =D

yo rmzero.. is there a way to make it so after she evolves she helps you reequip it. It's sorta annoying especially getting a black dragon cause you gotta equip.. talk to her.. equip.. talk to her.. -_-..
 
Re: [Release] Dragon Evolution + a few pet scripting methods

Lol isn't that what I said.. you tested final release first.. so I'm second right.. anyways.. here's some great ways to use this script
You can combine this script with r1c31shg00d's dragon seller and buy a pet dragon from him and get mar to evolve it.. OR.. you if you have cash shop. People in cash shop can buy the egg from the cash shop, take it to mars. She'll hatch it (well not really she just replaces it) and you can get the dragon like that. Then once it's level 15, go to mar and bring her rock of evolution and she'll evolve it. You can evolve as many times as you want. =D

yo rmzero.. is there a way to make it so after she evolves she helps you reequip it. It's sorta annoying especially getting a black dragon cause you gotta equip.. talk to her.. equip.. talk to her.. -_-..

Hmm, re-equip? Does anyone know what it does on gMS?
 
Re: [Release] Dragon Evolution + a few pet scripting methods

Hmm, re-equip? Does anyone know what it does on gMS?

I don't know.. but I'm pretty sure that when you evolve a dragon in gMS it stays equipped. Cause I remember clicking like crazy on the old hag to get a black dragon.. This was um during their testing periods.. we had unlimited cash..

Unless this is tested already?

If you read.. from credits.. yes it's been tested.. about 20 times to zone in on each and every error.. God we took 24 hours to get this script working right. We just kept sending stuff back and forth. I would send him the errors and he would send me a new code
 
Re: [Release] Dragon Evolution + a few pet scripting methods

I remove the level check ^^

Why would you do that.. I don't think you understand but this code is different then that other one. this one keeps your level, closeness, name, pet id, fullness and more.. so I don't see the purpose..
 
Re: [Release] Dragon Evolution + a few pet scripting methods

Awww no Credits To Me for Starting This Whole Thing Lmao + The Top Is From My nooby Script Lmao =P
 
Status
Not open for further replies.
Back