Hello, I'm going to trust you with the code that I've made so far since I have not really came down to the quality of the code yet.
Things that are missing; all players that step on the fire gets hurt
all players can see the fire
only one fire coords are stored.
Code:
package server.model.players.content;
import server.Server;
import server.event.CycleEvent;
import server.event.CycleEventContainer;
import server.event.CycleEventHandler;
import server.model.players.Client;
public class CreateFlame {
//player uses spell on ground item, ground item is removed and a fire is made.
//standing on the fire will cause 1-2 damage per client.process() cycle. This
//can only be done in wilderness.
public static int igniteId = 1502;
public static void spellCast(final Client c, final int itemId, final int itemX, final int itemY){
if(c == null)return;
if(itemId == igniteId){
if(c.ignitedFireId != -1){
c.sendMessage("You can only have one fire started at a time.");
return;
}
c.igniteStage = 0;
c.turnPlayerTo(itemX, itemY);
c.startAnimation(708);//iban emote
c.gfx100(246);//dragon battleaxe gfx
//88 - iban skull projectile
//ibans ashes = 1502
CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
@Override
public void execute(CycleEventContainer container) {
if(c.igniteStage == 0){
c.getPA().createPlayersProjectile(itemX, itemY, 1, 1, 50, 550/*speed*/, 88/*id*/, 43, 31, -c.getId() - 1, 65);
}
if(c.igniteStage == 1){
Server.itemHandler.removeGroundItem(c, igniteId, itemX, itemY, false);
c.getPA().checkObjectSpawn(11404, itemX, itemY, 2, 10);
c.ignitedFireLength = System.currentTimeMillis();
c.ignitedFireId = 1;
c.burningFires.put(0, itemX);
c.burningFires.put(1, itemY);
c.sendMessage(c.burningFires.get(0)+"");
c.sendMessage(c.burningFires.get(1)+"");
}
if(c.igniteStage == 10){
container.stop();
return;
}
c.igniteStage++;
}
@Override
public void stop() {
c.getPA().checkObjectSpawn(-1, itemX, itemY, 2, 10);
c.ignitedFireLength = 0;
c.ignitedFireId = -1;
c.sendMessage("Your fire burns out..");
c.burningFires.clear();
}
}, 2);
} else {
c.sendMessage("Nothing interesting happens.");
}
}
}
Client process
Code:
if(burningFires.get(0) != null && burningFires.get(1) != null)
if(absX == burningFires.get(0) && absY == burningFires.get(1)){
if(lastBurn+1000 >= System.currentTimeMillis() || lastBurn == 0){
sendMessage("You are burned by the fire!");
lastBurn = System.currentTimeMillis();
}
// System.out.println("key: " + key + " value: " + burningFires.get(key));
//}
}
}
public HashMap<Integer, Integer> burningFires = new HashMap<Integer, Integer>();
player
Code:
public int igniteStage = -1;
public int ignitedFireId = -1;
public long ignitedFireLength = 0;
public long lastBurn = 0;
I can't figure the storing of a fire id & coords part out. If you think you can program it feel free to do so, you may release with some credits to me.