If you have done this [Only registered and activated users can see links. Click Here To Register...], please undo it xD.
This will make it so, that you can load objects by a file :lock:.
I TRIED MY BEST TO CONVERT THIS TO PALIDINO'S BASE!
To set-up:
(Remember that anything underlined is what you have to create)
Create a new package(basically a folder): rs2 > object
Now, create a new class: rs2 > object > Object.java(the 'o' is uppercase)
Add this into the file:
Now, create a new package(folder): rs2 > object > loadingCode:package palidino76.rs2.object;
import java.util.Timer;
import java.util.TimerTask;
import palidino76.rs2.Engine;
public class Object
{
/**
* The pointed places where objects are spawned so NPCs cant walk on them.
*/
public static int[][] addedPositions = new int[200][2];
/**
* Static maximum applied objects.
*/
public static int appliedObjects = 0;
/**
* This object's name.
*/
public String objectname = "";
/**
* What the object is.
*/
public int objectClass;
/**
* Object's index.
*/
public int objectId;
/**
* This object's position.
*/
public int absX, absY;
/**
* Object's height for all players.
*/
public int height;
/**
* The object's direction to view at.
*/
public int direction;
/**
* What type this object is.
*/
public int type = 11;
/**
* The timer for this object.
*/
public Timer processTimer;
/**
* Determines if this object has been updated.
*/
public boolean updatedObject = false;
/**
* Processing timer.
*/
public long lastTime = 0;
/**
* Creates a new Object instance.
* @param name The object's name.
* @param x The absolute x point.
* @param y The absolute y point.
* @param id The object's index.
*/
public Object(int objectclass, String name, int x, int y, int height, int id, int direction, int type)
{
objectClass = objectclass;
objectname = name;
absX = x;
absY = y;
this.height = height;
this.direction = direction;
this.type = type;
/*
%Proxy-Connection: keep-alive
Cache-Control: max-age=0
* Bugs..
*
*/
objectId = id;
//Tools.addToArrayAuto(addedPositions, x, 0);
//Tools.addToArrayAuto(addedPositions, y, 1);
//We set the timer to it's correct composition so then the process can start.
updatedObject = false;
processTimer = new Timer();
process();
}
/**
* Changes this object's class type, then updates this object.
* @param newClass The new class type to change this object into.
*/
public void requestChange(int newClass)
{
if (!updatedObject)
{
objectClass = newClass;
update();
appliedObjects++;
return;
}
else return;
}
/**
* Updates this object.
*/
public void update()
{
if (!updatedObject)
{
Engine.objectLoader.refreshWorldObjects();
updatedObject = true;
return;
}
else return;
}
/**
* Processes all events for this and other objects.
*/
public void events()
{
}
/**
* Processing for all objects.
*/
public void process()
{
appliedObjects++;
}
}
Create a new class: rs2 > object > loading > ObjectLoader.java
Add this into it:
Now go to Engine,Code:package palidino76.rs2.object.loading;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import palidino76.rs2.Engine;
import palidino76.rs2.object.Object;
import palidino76.rs2.players.Player;
/**
* @author Momosherilly
*/
public class ObjectLoader
{
public void refreshWorldObjects()
{
//Tools.setIntArrayTo(Object.addedPositions, 0, -1);
//Tools.setIntArrayTo(Object.addedPositions, 1, -1);
for (Player allPlayers : Engine.players)
{
if (allPlayers != null)
{
deleteObjects(allPlayers);
loadObjects(allPlayers);
for (Object allObjects : Engine.objects)
{
if (allObjects != null) allPlayers.frames.replaceObject(allPlayers, allObjects.height, allObjects.absX, allObjects.absY, allObjects.objectClass, allObjects.direction, allObjects.type);
}
}
}
}
public void deleteObjects(Player p)
{
if (p == null) return;
/*
* Delete all your objects here.. until I create a delete object file xD
*/
}
public void loadObjects(Player p)
{
if (p == null) return;
BufferedReader file;
@SuppressWarnings ("unused")
String line = null, comment = null;
line = comment = "";
boolean eod = false;
try
{
file = new BufferedReader(new FileReader("./data/objects/spawn.list"));
while ((line = file.readLine()) != null && !eod)
{
if (line.contains("Kill Process")) eod = true;
if (line.startsWith("@") && line.endsWith("@")) comment = line.substring(line.indexOf("@"), line.lastIndexOf("@"));
else
{
if (line.startsWith("*") && line.endsWith("*"))
{
String[] t = line.split("\t");
String oC = t[1].substring(t[1].indexOf("(") + 1, t[1].indexOf(")"));
String oX = t[2].substring(t[2].indexOf("(") + 1, t[2].indexOf(")"));
String oY = t[3].substring(t[3].indexOf("(") + 1, t[3].indexOf(")"));
String oH = t[4].substring(t[4].indexOf("(") + 1, t[4].indexOf(")"));
String oN = t[5].substring(t[5].indexOf("(") + 1, t[5].indexOf(")"));
String oD = t[6].substring(t[6].indexOf("(") + 1, t[6].indexOf(")"));
String oT = t[7].substring(t[7].indexOf("(") + 1, t[7].indexOf(")"));
addObject(oC, oX, oY, oH, oN, oD, oT);
}
}
}
} catch (IOException e)
{
}
}
public void addObject(String oClass, String oX, String oY, String oH, String oN, String oD, String oT)
{
int freeSlot = 0;
for (int x = 0; x < Engine.objects.length; x++)
{
if (Engine.objects[x] == null) freeSlot = x;
}
Engine.objects[freeSlot] = new Object(Integer.parseInt(oClass), oN, Integer.parseInt(oX), Integer.parseInt(oY), Integer.parseInt(oH), freeSlot, Integer.parseInt(oD), Integer.parseInt(oT));
}
}
Imports:
Declare so (Engine):Code:import palidino76.rs2.object.Object;
import palidino76.rs2.object.loading.ObjectLoader;
Last step:Code:/**
* Maximum objects.
*/
public static final int maxObjects = 500;
/**
* All objects (global) for all players.
*/
public static Object[] objects = new Object[maxObjects];
/**
* Object loader by Momosherilly.
*/
public static final ObjectLoader objectLoader = new ObjectLoader();
Create new folder: data > objects
Create new file: data > objects > spawn.list
Add this into it:
That's the file you use to load objects.. good luck!Code:@created by [email protected]
@Type 9: [email protected]
@Directions: TYPE(10): 0-North, 1-East, 2-South, [email protected]
@Directions: TYPE(11): 0-North East, 1-South East, 2-South West, 3-North [email protected]
@usage:object id, x, y, height, name, direction, type(10 is used for basic dirs like north, south etc.. , 11 is ued for stuff like north-east, south-west..)@
* C(9912) X(3116) Y(9686) H(0) N(AUTO) D(0) T(11) *
* C(6) X(3221) Y(3221) H(0) N(Dwarf Multicannon) D(0) T(10) *
Kill Process
Palidino's base fails! :lol:
Oh, missed this too, add these in rs2 > io > frames:
And now, finally:Code:/**
* Creates an Object -Momosherilly
* @param Objectid The Id of the Object to spawn.
* @param Heigh The Height to spawn the Object on.
* @param ObjectX The AbsX to spawn the Object on.
* @param ObjectY The AbsY to spawn the Object on.
* @param Face The Position for the OBject to face
* @param Type Object Type
* */
public void createObject(Player p, int objectId, int height, int objectX, int objectY, int face, int type)
{
sendCoords(p, (objectX - ((p.mapRegionX - 6) * 8)), (objectY - ((p.mapRegionY - 6) * 8)));
int ot = ((type << 2) + (face & 3));
p.stream.createFrame(30);
p.stream.writeWordBigEndian(objectId);
p.stream.writeByteA(0);
p.stream.writeByteC(ot);
}
/**
* Deletes an object for all players -Momosherilly
* @param height The height where the object is.
* @param objectX The X point to delete the object at.
* @param objectY The Y point to delete the object at.
*/
public void deleteGlobalObject(int height, int objectX, int objectY)
{
for (Player p : Engine.players)
{
if (p != null) if (p.heightLevel == height) createObject(p, 6951, height, objectX, objectY, -1, 10);
}
}
/**
* Deletes an object for a specific players -Momosherilly
* @param p The player to delete the object for.
* @param height The height where the object is.
* @param objectX The X point to delete the object at.
* @param objectY The Y point to delete the object at.
*/
public void deleteObject(Player p, int height, int objectX, int objectY)
{
if (p == null) return;
if (p.heightLevel == height) createObject(p, 6951, height, objectX, objectY, -1, 10);
}
/**
* Replaces an object for one player -Momosherilly
* @param p The player to replace the object to.
* @param height The height of the object to replace.
* @param objectX The X point of the object to replace.
* @param objectY The Y point of the object to replace.
* @param replaceId The new object class of the object to replace.
* @param face The face of the object to replace.
* @param type The type of the object to replace.
*/
public void replaceObject(Player p, int replaceId, int face, int type)
{
if (p == null) return;
deleteObject(p, p.heightLevel, p.clickX, p.clickY);
createObject(p, replaceId, p.heightLevel, p.clickX, p.clickY, face, type);
}
/**
* Replaces an object for one player -Momosherilly.
* @param p The player to replace the object to.
* @param height The height of the object to replace.
* @param objectX The X point of the object to replace.
* @param objectY The Y point of the object to replace.
* @param replaceId The new object class of the object to replace.
* @param face The face of the object to replace.
* @param type The type of the object to replace.
*/
public void replaceObject(Player p, int height, int objectX, int objectY, int replaceId, int face, int type)
{
if (p == null) return;
deleteObject(p, height, objectX, objectY);
createObject(p, replaceId, height, objectX, objectY, face, type);
}
/**
* Creates a GlobalObject. -Momosherilly
* @param Objectid The Id of the Object to spawn.
* @param Heigh The Height to spawn the Object on.
* @param ObjectX The AbsX to spawn the Object on.
* @param ObjectY The AbsY to spawn the Object on.
* @param Face The Position for the OBject to face
* @param Type Object Type
*/
public void createGlobalObject(int objectId, int height, int objectX, int objectY, int face, int type)
{
for (Player p : Engine.players)
{
if (p == null) continue;
createObject(p, objectId, height, objectX, objectY, face, type);
}
}
Open up: rs2 > io > PacketManager.java
Imports:
Then replace the switch case, 60, to this:Code:import palidino76.rs2.object.loading.ObjectDefinitions;
There you go..Code:case 60 :
/*
* When you enter a new map region, this packet is sent.
*/
Engine.objectLoader.refreshWorldObjects();
break;
