ParadiseX
Would you like to react to this message? Create an account in a few clicks or log in to continue.

ParadiseX

The greatest Runescape private Server.
 
HomePortalSearchLatest imagesRegisterLog inMedia

 

 Freaky Event ! I suggest for now :)

Go down 
3 posters
AuthorMessage
DaviD

DaviD


Posts : 19
Join date : 2010-01-02

Freaky Event ! I suggest for now :) Empty
PostSubject: Freaky Event ! I suggest for now :)   Freaky Event ! I suggest for now :) Icon_minitimeSun Jan 03, 2010 1:51 pm

Freaky Event ! I suggest for now :) Forest1
Freaky Event ! I suggest for now :) Forest2
Freaky Event ! I suggest for now :) Forest3




What will I have at the end of this tutorial?
You will have added the Freaky Forester random event and will allow your players to get Forester items!

Is this a difficult tutorial?:
This tutorial is moderate in size, and as always, MAKE A BACKUP OF YOUR SERVER FILES BEFORE DOING THIS.

What files get modified?
Client.java
Npchandler.java
npc.cfg



Let's get started!

Step 1:

Open up the file called "Client.java" (If you don't see it, try finding the one named "client")
First off, you'll need to declare the following integers;

Code:
public int pheasantTail = -1;//When the server turns on, you won't need to kill one
public int pheasantKills = 0;//You wouldn't have killed any when logging in
Most of the time in my code I will explain myself with //comments.

Next declare this method, which will allow your NPCs to speak to your players.
Code:
public void npcspeech(int npc, String line, String line2, String line3) {
sendFrame126(GetNpcName(npc).replaceAll("_", " "), 4902);//Makes it state the NPC's name if it exists in npc.cfg
sendFrame126(line, 4903);//The first string will appear here
sendFrame126(line2, 4904);//The second string will appear here
sendFrame126(line3, 4905);//The final string will appear here
sendFrame126("", 4906);
sendFrame75(npc, 4901);//Shows the NPC's head. Smile
sendFrame164(4900);
NpcDialogueSend = true;
}
You'll also need to declare this method which I use in my server, public void tele;
Code:
public void teleport(int x, int y, int h) {//Start of method tele
teleportToX = x;//This provides an easier way to teleport
teleportToY = y;//Rather than restating all of this junk over and over >_>
heightLevel = h;//Alters your height lvl to the third int
}//End of method tele



Step 2:

Now to make it occur when you do something randomly;

Still in client.java, search for
Code:
case 132:
Case 132 handles first option clicking on objects.
This is the beginning of my Case 132: (this is what you should see)

Code:
case 132:
int objectX = inStream.readSignedWordBigEndianA();
int objectID = inStream.readUnsignedWord();
int objectY = inStream.readUnsignedWordA();
int face = 0;
int face2 = 0;
int GateID = 1;
if (!validClient || randomed)
break;
if (!antiHax())
break;
if (debug || (playerRights > 1)) {
println("serverobjs size " + server.objects.size());
println_debug("atObject: " + objectX + "," + objectY
+ " objectID: " + objectID); // 147 might be id for
// object state changing
}
int xDiff = Math.abs(absX - objectX);
int yDiff = Math.abs(absY - objectY);
boolean found = false;
for (Object o : server.objects) {
if ((o.type == 1) && (objectX == o.x) && (objectY == o.y)
&& (objectID == o.id)) {
found = true;
break;
}
}


Now beneath that we will be making the random occur for every object, by being at the top of the case so it effects all of the object beneath it.

Add
Code:
if (misc.random(250) == 1) {//Once every 250 object clicks you'll randomly trigger the event!
teleport(2596 + misc.random(3), 4775 + misc.random(5), 0);//So the players triggered won't all be at the same spot
sendMessage("You have been teleported to the Forester's woods, speak to him for help.");//Help your players out Wink
break;
}



What this does is explained with the //comments; randomly, every 250 clicks of objects, you'll trigger the random event. You can edit the message if you'd like.





Step 3:



Now, return to the first line of your client.java by using
CTRL + G, then enter 1. (CTRL + G is something I always use when I code, I suggest you start/continue using it)

Now we'll make the required kill and all save in your character files.

(At the top of your client.java)
Search for
Code:
if (token.equals("character-height")) {

You'll see this most likely.

Code:
case 2:
if (token.equals("character-height")) {
heightLevel = Integer.parseInt(token2)
;
After
Code:
heightLevel = Integer.parseInt(token2);

Add another segment for the code
Code:
} else if (token.equals("character-pheasantTail")) {//Using the ints we declare earlier
pheasantTail = Integer.parseInt(token2);
} else if (token.equals("character-pheasantKills")) {
pheasantKills = Integer.parseInt(token2);


This will save your players' files for the random event in case they get disconnected, they won't need to start over.

Now search for
Code:
character-height
Once more, this is the saving for when they log out as it's under


Code:
public void savegame(boolean logout)


You'll most-likely see this or something similar;

Code:
characterfile.newLine();
characterfile.write("character-height = ", 0, 19);
characterfile.write(Integer.toString(heightLevel), 0, Integer
.toString(heightLevel).length());

Beneath that add

Code:
characterfile.newLine();
characterfile.write("character-pheasantT = ", 0, 22);//Earlier I made tail come first, so in the char data, I'll do that too. Smile
characterfile.write(Integer.toString(pheasantTail), 0, Integer
.toString(pheasantTail).length());
characterfile.newLine();
characterfile.write("character-pheasantK = ", 0, 22);//Shortening the character file info to save space <3
characterfile.write(Integer.toString(pheasantKills), 0, Integer//This refers to the int we declared earlier Smile
.toString(pheasantKills).length());//Also refers to the int we declared


This will save your players' files if they log out during the random event.




Step 4:


Return to the first line once more (CTRL + G 1)

CTRL + F for
Code:
case 155:
Case 155 handles all npc's first click options, which will most likely be NPC chat .
Now you'll see something like, or similar to this;

Code:
case 155:
// first Click npc
NPCSlot = inStream.readSignedWordBigEndian();
if ((NPCSlot < 0) || (NPCSlot >= server.npcHandler.npcs.length)
|| (server.npcHandler.npcs[NPCSlot] == null))
break;
NPCID = server.npcHandler.npcs[NPCSlot].npcType;

faceNPC(NPCSlot);

boolean FishingGo = false;
boolean PutNPCCoords = false;

Beneath that put (yes I know this is a very lengthy bit of code)
Code:
if (NPCID == 2458)
{//Start of Freaky Forester's first chat option
if(pheasantTail == -1 && misc.random(4) == 1) {//If they havn't done the random yet Wink
npcspeech(2458, "Hello there "+playerName+", I'm very famished.", "I really enjoy pheasant", "but only the one tailed ones.");//NPC Speech.
pheasantTail = 1;//Kills required to move forward Smile
} else if (pheasantTail == -1 && misc.random(4) == 2) {
npcspeech(2458, "Hello there "+playerName+", I'm very famished.", "I really enjoy eating pheasants", "but only the two tailed ones.");
pheasantTail = 2;//Kills required
} else if (pheasantTail == -1 && misc.random(4) == 3) {
npcspeech(2458, "Hello there "+playerName+", I'm very famished.", "I really enjoy eating pheasants", "but only the three tailed ones.");
pheasantTail = 3;
} else if (pheasantTail == -1 && misc.random(4) == 4) {
npcspeech(2458, "Hello there "+playerName+", I'm very famished.", "I really enjoy eating pheasants", "but only the four tailed ones.");
pheasantTail = 4;
} else if (pheasantTail == misc.random(4) && pheasantKills != misc.random(4)) {//If the # of tails required and the one killed don't match
npcspeech(2458, "Sorry, but I asked you to kill the pheasant", "With "+pheasantTail+" tails,", "those ones taste the best!");
} else if (pheasantTail == pheasantKills && playerHasItem(6178)) {
npcspeech(2458, "Thank you for giving me the pheasant I wanted!", "I have teleport you away from this land...", "I've also given you some of my clothing.");
int[] forester = {6180, 6181, 6182};
int k = (int) (Math.random() * forester.length);
addItem(forester[k], 1);
deleteItem(6178, getItemSlot(6178), 1);//Deletes it Wink
teleport(2803 + misc.random(2), 3432 + misc.random(4), 0);
} else if (pheasantTail == pheasantKills && !playerHasItem(6178)) {
npcspeech(2458, "I'm sorry but I wanted the pheasant with "+pheasantTail+"", "tails on it, you've killed the wrong one.", "Please kill the right one for me.");
}//End of the else if's
}//End of Freaky Forester's chat



Step 5:

Now close your client.java, take a deep breath, get a drink of water, whatever.. Now open NPChandler.java (for some computers it may just show up as "NPCHandler" )


If you have slayer, this step will be so much easier.


If you do have slayer in your server
Search for
Code:
.addSkillXP

If you have Slayer and search for that, you'll see something like this;
Code:
} else if (npcs[i].npcType == 1653) {
temp.addSkillXP(100, 18)
;
Underneath you'll need to add this;
Code:
} else if (npcs[i].npcType == 2461) {
if(temp.pheasantTail == 3) {
temp.pheasantKills = 3;
} else {
temp.sendMessage("I think I killed the wrong pheasant..");
}
} else if (npcs[i].npcType == 2462) {
if(temp.pheasantTail == 4) {
temp.pheasantKills = 4;
} else {
temp.sendMessage("I think I killed the wrong pheasant..");
}
} else if (npcs[i].npcType == 2460) {
if(temp.pheasantTail == 2) {
temp.pheasantKills = 2;
} else {
temp.sendMessage("I think I killed the wrong pheasant..");
}
} else if (npcs[i].npcType == 2459) {
if(temp.pheasantTail == 1) {
temp.pheasantKills = 1;
} else {
temp.sendMessage("I think I killed the wrong pheasant..");
}


Basically, if you kill the right pheasant, you can move on in the event, if not.. You'll be notified.


Now go to your config folder, open "npcdrops.cfg" add the following
Code:
npcdrop = 2159 6178 1 100 //Pheasant with one tail/Raw pheasant/100%
npcdrop = 2160 6178 1 100 //2 tails
npcdrop = 2161 6178 1 100 //3 tails
npcdrop = 2162 6178 1 100 //4 tails



For your "autospawn.cfg", add this
Code:
spawn = 2458 2601 4777 0 2603 4779 2599 4775 1 Freaky forester (random event)
spawn = 2459 2605 4775 0 2603 4773 2607 4777 1 Pheasant
spawn = 2459 2596 4774 0 2597 4775 2595 4773 1 Pheasant
spawn = 2460 2605 4770 0 2604 4769 2606 4771 1 Pheasant
spawn = 2461 2601 4770 0 2602 4771 2600 4769 1 Pheasant
spawn = 2462 2604 4780 0 2605 4781 2603 4779 1 Pheasant


-Thanks DaviD

NOTE I HAVE DOING IT ON DEMISES IDK IT WILL WORK HERE TOO
Back to top Go down
https://paradisex.forumotion.net
Necro




Posts : 13
Join date : 2010-01-02

Freaky Event ! I suggest for now :) Empty
PostSubject: Woah   Freaky Event ! I suggest for now :) Icon_minitimeSun Jan 03, 2010 2:40 pm

It seems really easy to code it but..
When you really code it's really hard.. Razz
Back to top Go down
owner unborn
Admin



Posts : 12
Join date : 2010-01-02

Freaky Event ! I suggest for now :) Empty
PostSubject: Re: Freaky Event ! I suggest for now :)   Freaky Event ! I suggest for now :) Icon_minitimeSun Jan 03, 2010 3:25 pm

I'll add this to my "to-do-list" lol
Back to top Go down
https://paradisex.forumotion.net
 
Freaky Event ! I suggest for now :)
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
ParadiseX :: Announcements-
Jump to: