Jump to content
  • 0
Sign in to follow this  
geowayne

PI - firemaking skill - error help!

Question

Hello I've looked all over for a firemaking coding but they don't really work.

My problem is: my character will do the lighting animation but he will just keep bending and acting as if he is lighting. NO FIRE will come out! or log starting to get fire....

please take a look at mine and tell me what is missing and what I've done wrong.

Thank you!


[CODE]package server.model.players.skills;

import server.Config;
import server.model.players.Client;
import server.model.objects.Objects;
import server.Server;
/**
* Firemaking.java
*
* @author Sanity
*
**/
public class Firemaking {

private Client c;

private int[] logs = {1511,1521,1519,1517,1515,1513};
private int[] exp = {1,3,4,5,7,8};
private int[] level = {1,15,30,45,60,75};
public long lastLight;
private int DELAY = 1250;
public boolean resetAnim = true;

public Firemaking(Client c) {
this.c = c;
}

public void checkLogType(int logType, int otherItem) {
for (int j = 0; j < logs.length;j++) {
if (logs[j] == logType || logs[j] == otherItem) {
lightFire(j);
return;
}
}
}

public void lightFire(int slot) {
if (c.duelStatus >= 5) {
c.sendMessage("Why am I trying to light a fire in the duel arena?");
return;
}
if (c.playerLevel[c.playerFiremaking] >= level[slot]) {
if (c.getItems().playerHasItem(590) && c.getItems().playerHasItem(logs[slot])) {
if (System.currentTimeMillis() - lastLight > DELAY) {
c.startAnimation(733,0);
c.getItems().deleteItem(logs[slot], c.getItems().getItemSlot(logs[slot]), 1);
c.getPA().addSkillXP(logs[slot] * Config.FIREMAKING_EXPERIENCE, c.playerFiremaking);
Objects fire = new Objects(2732,c.getX(),c.getY(), 0, -1, 10, 3);
Objects fire2 = new Objects(-1,c.getX(),c.getY(), 0, -1, 10, 60);
c.sendMessage("You light the fire.");
this.lastLight = System.currentTimeMillis();
//c.getPA().frame1();
resetAnim = true;
}
}
}
}

}[/CODE] Edited by geowayne

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
[quote name='geowayne']Hello I've looked all over for a firemaking coding but they don't really work.

My problem is: my character will do the lighting animation but he will just keep bending and acting as if he is lighting. NO FIRE will come out! or log starting to get fire....

please take a look at mine and tell me what is missing and what I've done wrong.

Thank you!


[CODE]package server.model.players.skills;

import server.Config;
import server.model.players.Client;
import server.model.objects.Objects;
import server.Server;
/**
* Firemaking.java
*
* @author Sanity
*
**/
public class Firemaking {

private Client c;

private int[] logs = {1511,1521,1519,1517,1515,1513};
private int[] exp = {1,3,4,5,7,8};
private int[] level = {1,15,30,45,60,75};
public long lastLight;
private int DELAY = 1250;
public boolean resetAnim = true;

public Firemaking(Client c) {
this.c = c;
}

public void checkLogType(int logType, int otherItem) {
for (int j = 0; j < logs.length;j++) {
if (logs[j] == logType || logs[j] == otherItem) {
lightFire(j);
return;
}
}
}

public void lightFire(int slot) {
if (c.duelStatus >= 5) {
c.sendMessage("Why am I trying to light a fire in the duel arena?");
return;
}
if (c.playerLevel[c.playerFiremaking] >= level[slot]) {
if (c.getItems().playerHasItem(590) && c.getItems().playerHasItem(logs[slot])) {
if (System.currentTimeMillis() - lastLight > DELAY) {
c.startAnimation(733,0);
c.getItems().deleteItem(logs[slot], c.getItems().getItemSlot(logs[slot]), 1);
c.getPA().addSkillXP(logs[slot] * Config.FIREMAKING_EXPERIENCE, c.playerFiremaking);
Objects fire = new Objects(2732,c.getX(),c.getY(), 0, -1, 10, 3);
Objects fire2 = new Objects(-1,c.getX(),c.getY(), 0, -1, 10, 60);
c.sendMessage("You light the fire.");
this.lastLight = System.currentTimeMillis();
//c.getPA().frame1();
resetAnim = true;
}
}
}
}

}[/CODE][/QUOTE]

Okay so the player does the animation, but the lit fire doesnt appear on the ground? Does it remove the log successfully from their inventories and add the skill xp?

Share this post


Link to post
Share on other sites
  • 0
With the code you provided I cannot give you a clear answer. Here is the code you need to be questioning.
[CODE]
Objects fire = new Objects(2732,c.getX(),c.getY(), 0, -1, 10, 3);
Objects fire2 = new Objects(-1,c.getX(),c.getY(), 0, -1, 10, 60);
[/CODE]

Find the file called Objects.java. You need to see what the constructor is doing. I would think that you need to add the object to the World to process.

With your current system, you do realize you can light a fire (any type) in 1250ms ~ 1 second? I would use the Math class - random function, to at least add some variance to that.

Share this post


Link to post
Share on other sites
  • 0
[MENTION=31794]iHack[/MENTION] - yes it deletes what need to be remove form the inventory, gives exp, but no animation
[MENTION=1045]Emily[/MENTION] - thanks for pointing that out, yes i do know that it is absolutely fast for them to be able to skill.

i still can't seem to change it. here is my file


object.java
[CODE]package server.model.objects;


public class Objects {

public int objectId;
public int objectX;
public int objectY;
public int objectHeight;
public int objectFace;
public int objectType;
public int objectTicks;


public Objects(int id, int x, int y, int height, int face, int type, int ticks) {
this.objectId = id;
this.objectX = x;
this.objectY = y;
this.objectHeight = height;
this.objectFace = face;
this.objectType = type;
this.objectTicks = ticks;
}


public int getObjectId() {
return this.objectId;
}

public int getObjectX() {
return this.objectX;
}

public int getObjectY() {
return this.objectY;
}

public int getObjectHeight() {
return this.objectHeight;
}

public int getObjectFace() {
return this.objectFace;
}

public int getObjectType() {
return this.objectType;
}


}[/CODE]

objects.java
[CODE]package server.model.objects;

import server.Server;

public class Object {

public int objectId;
public int objectX;
public int objectY;
public int height;
public int face;
public int type;
public int newId;
public int tick;

public Object(int id, int x, int y, int height, int face, int type, int newId, int ticks) {
this.objectId = id;
this.objectX = x;
this.objectY = y;
this.height = height;
this.face = face;
this.type = type;
this.newId = newId;
this.tick = ticks;
Server.objectManager.addObject(this);
}


}[/CODE]


objecthandler.java
[CODE]package server.world;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import server.Server;
import server.model.objects.Objects;
import server.model.players.Client;
import server.model.players.Player;
import server.util.Misc;

/**
* @author Sanity
*/

public class ObjectHandler {


public List<Objects> globalObjects = new ArrayList<Objects>();
public ObjectHandler() {
loadGlobalObjects("./Data/cfg/global-objects.cfg");
loadDoorConfig("./Data/cfg/doors.cfg");
}


/**
* Adds object to list
**/
public void addObject(Objects object) {
globalObjects.add(object);
}

/**
* Removes object from list
**/
public void removeObject(Objects object) {
globalObjects.remove(object);
}

/**
* Does object exist
**/
public Objects objectExists(int objectX, int objectY, int objectHeight) {
for(Objects o : globalObjects) {
if(o.getObjectX() == objectX && o.getObjectY() == objectY && o.getObjectHeight() == objectHeight) {
return o;
}
}
return null;
}

/**
* Update objects when entering a new region or logging in
**/
public void updateObjects(Client c) {
for(Objects o : globalObjects) {
if(c != null) {
if(c.heightLevel == o.getObjectHeight() && o.objectTicks == 0) {
if (c.distanceToPoint(o.getObjectX(), o.getObjectY()) <= 60) {
c.getPA().object(o.getObjectId(), o.getObjectX(), o.getObjectY(), o.getObjectFace(), o.getObjectType());
}
}
}
}
if (c.distanceToPoint(2813, 3463) <= 60) {
c.getFarming().updateHerbPatch();
}
if (c.distanceToPoint(2961, 3389) <= 60) {
c.getPA().object(6552, 2961, 3389, -1, 10);
}
}


/**
* Creates the object for anyone who is within 60 squares of the object
**/
public void placeObject(Objects o) {
for (Player p : Server.playerHandler.players){
if(p != null) {
Client person = (Client)p;
if(person != null){
if(person.heightLevel == o.getObjectHeight() && o.objectTicks == 0) {
if (person.distanceToPoint(o.getObjectX(), o.getObjectY()) <= 60) {
person.getPA().object(o.getObjectId(), o.getObjectX(), o.getObjectY(), o.getObjectFace(), o.getObjectType());
}
}
}
}
}
}

public void process() {
for (int j = 0; j < globalObjects.size(); j++) {
if (globalObjects.get(j) != null) {
Objects o = globalObjects.get(j);
if(o.objectTicks > 0) {
o.objectTicks--;
}
if (o.objectTicks == 1) {
Objects deleteObject = objectExists(o.getObjectX(), o.getObjectY(), o.getObjectHeight());
removeObject(deleteObject);
o.objectTicks = 0;
placeObject(o);
removeObject(o);
if (isObelisk(o.objectId)) {
int index = getObeliskIndex(o.objectId);
if (activated[index]) {
activated[index] = false;
teleportObelisk(index);
}
}
}
}

}
/*for(Objects o : globalObjects) {
if(o.objectTicks > 0) {
o.objectTicks--;
}
if(o.objectTicks == 1) {
Objects deleteObject = objectExists(o.getObjectX(), o.getObjectY(), o.getObjectHeight());
if(deleteObject != null) {
removeObject(deleteObject);
}
o.objectTicks = 0;
placeObject(o);
removeObject(o);
if (isObelisk(o.objectId)) {
int index = getObeliskIndex(o.objectId);
if (activated[index]) {
activated[index] = false;
teleportObelisk(index);
}
}
break;
}
}*/
}

public boolean loadGlobalObjects(String fileName) {
String line = "";
String token = "";
String token2 = "";
String token2_2 = "";
String[] token3 = new String[10];
boolean EndOfFile = false;
int ReadMode = 0;
BufferedReader objectFile = null;
try {
objectFile = new BufferedReader(new FileReader("./"+fileName));
} catch(FileNotFoundException fileex) {
Misc.println(fileName+": file not found.");
return false;
}
try {
line = objectFile.readLine();
} catch(IOException ioexception) {
Misc.println(fileName+": error loading file.");
return false;
}
while(EndOfFile == false && line != null) {
line = line.trim();
int spot = line.indexOf("=");
if (spot > -1) {
token = line.substring(0, spot);
token = token.trim();
token2 = line.substring(spot + 1);
token2 = token2.trim();
token2_2 = token2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token3 = token2_2.split("\t");
if (token.equals("object")) {
Objects object = new Objects(Integer.parseInt(token3[0]), Integer.parseInt(token3[1]), Integer.parseInt(token3[2]), Integer.parseInt(token3[3]), Integer.parseInt(token3[4]), Integer.parseInt(token3[5]), 0);
addObject(object);
}
} else {
if (line.equals("[ENDOFOBJECTLIST]")) {
try { objectFile.close(); } catch(IOException ioexception) { }
return true;
}
}
try {
line = objectFile.readLine();
} catch(IOException ioexception1) { EndOfFile = true; }
}
try { objectFile.close(); } catch(IOException ioexception) { }
return false;
}


/**
* Doors
**/

public static final int MAX_DOORS = 100;
public static int[][] doors = new int[MAX_DOORS][5];
public static int doorFace = 0;

public void doorHandling(int doorId, int doorX, int doorY, int doorHeight) {
for(int i = 0; i < doors.length; i++){
if(doorX == doors[i][0] && doorY == doors[i][1] && doorHeight == doors[i][2]) {
if(doors[i][4] == 0) {
doorId++;
} else {
doorId--;
}
for (Player p : Server.playerHandler.players){
if(p != null) {
Client person = (Client)p;
if(person != null){
if(person.heightLevel == doorHeight) {
if (person.distanceToPoint(doorX, doorY) <= 60) {
person.getPA().object(-1, doors[i][0], doors[i][1], 0, 0);
if(doors[i][3] == 0 && doors[i][4] == 1) {
person.getPA().object(doorId, doors[i][0], doors[i][1]+1, -1, 0);
} else if(doors[i][3] == -1 && doors[i][4] == 1) {
person.getPA().object(doorId, doors[i][0]-1, doors[i][1], -2, 0);
} else if(doors[i][3] == -2 && doors[i][4] == 1) {
person.getPA().object(doorId, doors[i][0], doors[i][1]-1, -3, 0);
} else if(doors[i][3] == -3 && doors[i][4] == 1) {
person.getPA().object(doorId, doors[i][0]+1, doors[i][1], 0, 0);
} else if(doors[i][3] == 0 && doors[i][4] == 0) {
person.getPA().object(doorId, doors[i][0]-1, doors[i][1], -3, 0);
} else if(doors[i][3] == -1 && doors[i][4] == 0) {
person.getPA().object(doorId, doors[i][0], doors[i][1]-1, 0, 0);
} else if(doors[i][3] == -2 && doors[i][4] == 0) {
person.getPA().object(doorId, doors[i][0]+1, doors[i][1], -1, 0);
} else if(doors[i][3] == -3 && doors[i][4] == 0) {
person.getPA().object(doorId, doors[i][0], doors[i][1]+1, -2, 0);
}
}
}
}
}
}
}
}
}

public boolean loadDoorConfig(String fileName) {
String line = "";
String token = "";
String token2 = "";
String token2_2 = "";
String[] token3 = new String[10];
boolean EndOfFile = false;
int ReadMode = 0;
BufferedReader objectFile = null;
try {
objectFile = new BufferedReader(new FileReader("./"+fileName));
} catch(FileNotFoundException fileex) {
Misc.println(fileName+": file not found.");
return false;
}
try {
line = objectFile.readLine();
} catch(IOException ioexception) {
Misc.println(fileName+": error loading file.");
return false;
}
int door = 0;
while(EndOfFile == false && line != null) {
line = line.trim();
int spot = line.indexOf("=");
if (spot > -1) {
token = line.substring(0, spot);
token = token.trim();
token2 = line.substring(spot + 1);
token2 = token2.trim();
token2_2 = token2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token2_2 = token2_2.replaceAll("\t\t", "\t");
token3 = token2_2.split("\t");
if (token.equals("door")) {
doors[door][0] = Integer.parseInt(token3[0]);
doors[door][1] = Integer.parseInt(token3[1]);
doors[door][2] = Integer.parseInt(token3[2]);
doors[door][3] = Integer.parseInt(token3[3]);
doors[door][4] = Integer.parseInt(token3[4]);
door++;
}
} else {
if (line.equals("[ENDOFDOORLIST]")) {
try { objectFile.close(); } catch(IOException ioexception) { }
return true;
}
}
try {
line = objectFile.readLine();
} catch(IOException ioexception1) { EndOfFile = true; }
}
try { objectFile.close(); } catch(IOException ioexception) { }
return false;
}

public final int IN_USE_ID = 14825;
public boolean isObelisk(int id) {
for (int j = 0; j < obeliskIds.length; j++) {
if (obeliskIds[j] == id)
return true;
}
return false;
}
public int[] obeliskIds = {14829,14830,111235,14828,14826,14831};
public int[][] obeliskCoords = {{3154,3618},{3225,3665},{3033,3730},{3104,3792},{2978,3864},{3305,3914}};
public boolean[] activated = {false,false,false,false,false,false};
public void startObelisk(int obeliskId) {
int index = getObeliskIndex(obeliskId);
if (index >= 0) {
if (!activated[index]) {
activated[index] = true;
Objects obby1 = new Objects(14825, obeliskCoords[index][0], obeliskCoords[index][1], 0, -1, 10, 0);
Objects obby2 = new Objects(14825, obeliskCoords[index][0] + 4, obeliskCoords[index][1], 0, -1, 10, 0);
Objects obby3 = new Objects(14825, obeliskCoords[index][0], obeliskCoords[index][1] + 4, 0, -1, 10, 0);
Objects obby4 = new Objects(14825, obeliskCoords[index][0] + 4, obeliskCoords[index][1] + 4, 0, -1, 10, 0);
addObject(obby1);
addObject(obby2);
addObject(obby3);
addObject(obby4);
Server.objectHandler.placeObject(obby1);
Server.objectHandler.placeObject(obby2);
Server.objectHandler.placeObject(obby3);
Server.objectHandler.placeObject(obby4);
Objects obby5 = new Objects(obeliskIds[index], obeliskCoords[index][0], obeliskCoords[index][1], 0, -1, 10, 10);
Objects obby6 = new Objects(obeliskIds[index], obeliskCoords[index][0] + 4, obeliskCoords[index][1], 0, -1, 10, 10);
Objects obby7 = new Objects(obeliskIds[index], obeliskCoords[index][0], obeliskCoords[index][1] + 4, 0, -1, 10, 10);
Objects obby8 = new Objects(obeliskIds[index], obeliskCoords[index][0] + 4, obeliskCoords[index][1] + 4, 0, -1, 10, 10);
addObject(obby5);
addObject(obby6);
addObject(obby7);
addObject(obby8);
}
}
}

public int getObeliskIndex(int id) {
for (int j = 0; j < obeliskIds.length; j++) {
if (obeliskIds[j] == id)
return j;
}
return -1;
}

public void teleportObelisk(int port) {
int random = Misc.random(5);
while (random == port) {
random = Misc.random(5);
}
for (int j = 0; j < Server.playerHandler.players.length; j++) {
if (Server.playerHandler.players[j] != null) {
Client c = (Client)Server.playerHandler.players[j];
if (c.goodDistance(c.getX(), c.getY(), obeliskCoords[port][0] + 2, obeliskCoords[port][1] + 2, 1)) {
c.getPA().startTeleport2(obeliskCoords[random][0] + 2, obeliskCoords[random][1] + 2, 0);
}
}
}
}
}
[/CODE] Edited by geowayne

Share this post


Link to post
Share on other sites
Sign in to follow this  

×