Jump to content
  • 0
artizan

718 Object placing temporary objects.

Question

Hi there, i was trying to do is, when a player interacts with a object, then the object will temporary spawns another object. on its place, Then if you use the new object, it turns out into another object temporary. So what i mainly did was i used woodcutting.java as a base.

and no i do not want this to receive xp, and not as farming. this was just for trying making objects spawn other objects.

[[CODE]package com.rs.game.player.actions;

import com.rs.cache.loaders.ItemDefinitions;
import com.rs.game.Animation;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.game.WorldTile;
import com.rs.game.player.Player;
import com.rs.game.player.Skills;
import com.rs.game.ForceTalk;
import com.rs.utils.Utils;




public final class EvilFarming extends Action {


public static enum EvilFarmingDefinitions {


SEEDLING1(1, 1800, -1, 20, 5, 11392, 1800, 1),

SEEDLING2(1, 1800, -1, 20, 5, 11393, 1800, 2),


SEEDLING3(1, 1800, -1, 20, 5, 11394, 1800, 3),

SEEDLING4(1, 1800, -1, 20, 5, 11395, 1800, 4),

EVILSEED1(1, 1800, -1, 20, 5, 11922, 1800, 5),

EVILSEED2(1, 1800, -1, 20, 5, 11923, 1800, 6),

EVILSEED3(1, 1800, -1, 20, 5, 11924, 1800, 7),

EVILSEED4(1, 1800, -1, 120, 17, 11927, 1800, 1),

IVYROCKS(1, 1800, -1, 120, 17, 38443, 1800, 10);

private int level;
private double xp;
private int logsId;
private int logBaseTime;
private int logRandomTime;
private int stumpId;
private int respawnDelay;
private int randomLifeProbability;


private EvilFarmingDefinitions(int level, double xp, int logsId,
int logBaseTime, int logRandomTime, int stumpId,
int respawnDelay, int randomLifeProbability) {
this.level = level;
this.xp = xp;
this.logsId = logsId;
this.logBaseTime = logBaseTime;
this.logRandomTime = logRandomTime;
this.stumpId = stumpId;
this.respawnDelay = respawnDelay;
this.randomLifeProbability = randomLifeProbability;
}


public int getLevel() {
return level;
}


public double getXp() {
return xp;
}


public int getLogsId() {
return logsId;
}


public int getLogBaseTime() {
return logBaseTime;
}


public int getLogRandomTime() {
return logRandomTime;
}


public int getStumpId() {
return stumpId;
}


public int getRespawnDelay() {
return respawnDelay;
}


public int getRandomLifeProbability() {
return randomLifeProbability;
}
}


private WorldObject tree;
private EvilFarmingDefinitions definitions;


private int emoteId;
private boolean usingBeaver = false;
private int axeTime;


public EvilFarming(WorldObject tree, EvilFarmingDefinitions definitions) {
this.tree = tree;
this.definitions = definitions;
}


@Override
public boolean start(Player player) {
if (!checkAll(player))
return false;
player.getPackets()
.sendGameMessage(
usingBeaver ? "Your beaver uses its strong teeth to chop down the tree..."
: "You attempt to light the "
+ (EvilFarmingDefinitions.IVYROCKS == definitions ? "EvilFarming"
: "EvilFarming") + "...", true);
setActionDelay(player, getWoodcuttingDelay(player));
return true;
}


private int getWoodcuttingDelay(Player player) {
int summoningBonus = player.getFamiliar() != null ? (player
.getFamiliar().getId() == 6808 || player.getFamiliar().getId() == 6807) ? 10
: 0
: 0;
int wcTimer = definitions.getLogBaseTime()
- (player.getSkills().getLevel(8) + summoningBonus)
- Utils.getRandom(axeTime);
if (wcTimer < 1 + definitions.getLogRandomTime())
wcTimer = 1 + Utils.getRandom(definitions.getLogRandomTime());
wcTimer /= player.getAuraManager().getWoodcuttingAccurayMultiplier();
return wcTimer;
}


private boolean checkAll(Player player) {
if (!setAxe(player)) {
player.getPackets().sendGameMessage("You feed the seedling with fear, The seedling gets stronger!");
return false;
}


if (!hasFiremakingLevel(player))
return false;
if (!player.getInventory().hasFreeSlots()) {
player.getPackets().sendGameMessage("Not enough space in your inventory.");
return false;
}
return true;
}


private boolean hasFiremakingLevel(Player player) {
if (definitions.getLevel() > player.getSkills().getLevel(8)) {
player.getPackets().sendGameMessage("You need a Firemaking level of " + definitions.getLevel() + " to feed this seedling.");
return false;
}
return true;
}


private boolean setAxe(Player player) {
int level = player.getSkills().getLevel(1);
int weaponId = player.getEquipment().getWeaponId();
if (weaponId != -1) {
switch (weaponId) {
case 23014: //Burning Log
if (level >= 1) {
emoteId = 11971;
axeTime = 250;
return true;
}
break;
}
}
if (player.getInventory().containsOneItem(23014)) {
if (level >= 1) { //Burning Log
emoteId = 16700;
axeTime = 13;
return true;
}
}
return false;


}


public static int getAxeAnim(Player player) {
int level = player.getSkills().getLevel(8);
int weaponId = player.getEquipment().getWeaponId();
if (weaponId != -1) {
switch (weaponId) {
case 23014: //Logs
if (level >= 1) {
return 2846;
}
break;
}
}
if (player.getInventory().containsOneItem(23014)) {
if (level >= 1) {
return 2846;
}
}
return -1;
}


private boolean hasAxe(Player player) {
if (player.getInventory().containsOneItem(23014))
return true;
int weaponId = player.getEquipment().getWeaponId();
if (weaponId == -1)
return false;
switch (weaponId) {
case 23014://Logs
return true;
default:
return false;
}


}


@Override
public boolean process(Player player) {
player.setNextAnimation(new Animation(usingBeaver ? 1 : emoteId));
return checkTree(player);
}


private boolean usedDeplateAurora;


@Override
public int processWithDelay(Player player) {
addLog(player);
if (!usedDeplateAurora
&& (1 + Math.random()) < player.getAuraManager()
.getChanceNotDepleteMN_WC()) {
usedDeplateAurora = true;
} else if (Utils.getRandom(definitions.getRandomLifeProbability()) == 0) {
long time = definitions.respawnDelay * 600;
World.spawnTemporaryObject(
new WorldObject(definitions.getStumpId(), tree.getType(), tree.getRotation(), tree.getX(), tree.getY(), tree.getPlane()), time);


if (tree.getPlane() < 3 && definitions != EvilFarmingDefinitions.IVYROCKS) {
WorldObject object = World.getObject(new WorldTile(tree.getX() - 1, tree.getY() - 1, tree.getPlane() + 1));


if (object == null) {
object = World.getObject(new WorldTile(tree.getX(), tree
.getY() - 1, tree.getPlane() + 1));
if (object == null) {
object = World.getObject(new WorldTile(tree.getX() - 1,
tree.getY(), tree.getPlane() + 1));
if (object == null) {
object = World.getObject(new WorldTile(tree.getX(),
tree.getY(), tree.getPlane() + 1));
}
}
}


if (object != null)
World.removeTemporaryObject(object, time, false);
}
player.setNextAnimation(new Animation(-1));
return -1;
}
if (!player.getInventory().hasFreeSlots()) {
player.setNextAnimation(new Animation(-1));
player.getPackets().sendGameMessage(
"Not enough space in your inventory.");
return -1;
}
return getWoodcuttingDelay(player);
}


private void addLog(Player player) {
double xpBoost = 1.00;
if (!hasFullOutfit(player) && player.getEquipment().getChestId() == 10939)
xpBoost += 0.008;
if (!hasFullOutfit(player) && player.getEquipment().getLegsId() == 10940)
xpBoost += 0.006;
if (!hasFullOutfit(player) && player.getEquipment().getHatId() == 10941)
xpBoost += 0.004;
if (!hasFullOutfit(player) && player.getEquipment().getBootsId() == 10933)
xpBoost += 0.002;
if (hasFullOutfit(player))
xpBoost += 1.500;


if (player.getEquipment().getWeaponId() == 13661 && Utils.random(1000) < 300) {
player.sendMessage("Your inferno adze burns the logs instantly.");
player.getSkills().addXp(Skills.FIREMAKING, definitions.getXp() * xpBoost);
} else {
player.getSkills().addXp(Skills.FIREMAKING, definitions.getXp() * xpBoost);
}


if (definitions == EvilFarmingDefinitions.IVYROCKS) {
player.getPackets().sendGameMessage("The seedling grows as it consumes all the fear.", true);
} else {
String logName = ItemDefinitions.getItemDefinitions(definitions.getLogsId()).getName().toLowerCase();
player.getPackets().sendGameMessage("The seedling grows as it consumes all the fear.", true);
}
}


public boolean hasFullOutfit(Player player) {
if (player.getEquipment().getChestId() == 10939
&& player.getEquipment().getLegsId() == 10940
&& player.getEquipment().getHatId() == 10941
&& player.getEquipment().getBootsId() == 10933)
return true;

return false;
}


private boolean checkTree(Player player) {
return World.getRegion(tree.getRegionId()).containsObject(tree.getId(), tree);
}


@Override
public void stop(Player player) {
setActionDelay(player, 3);
}


} [/CODE]

[CODE] if (object.getId() == 11391) {
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.SEEDLING1));
}
else if (id == 11392)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.SEEDLING2));
else if (id == 11393)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.SEEDLING3));
else if (id == 11394)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.SEEDLING4));
else if (id == 11395)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.EVILSEED1));
else if (id == 11922)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.EVILSEED2));
else if (id == 11923)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.EVILSEED3));
else if (id == 11924)
player.getActionManager().setAction(new EvilFarming(object,EvilFarmingDefinitions.EVILSEED4));[/CODE]

the result that i wanted to get was like in this photo.
[IMG]https://scontent-a-ams.xx.fbcdn.net/hphotos-xaf1/t1.0-9/10462666_474569032687941_578874284207507060_n.jpg[/IMG]

so if you used, object 1, it turns out in object 2, then use object 2 then it turns out in object 3.

but momently it does not update the curent model to the next ID, when object 11391 turns into object 11392. then i cant use it anymore. But if i spawn object 11392 on another spot. then object 11392 turns into object 11393 after using.

So my question was, is there any possible way of making this work? and not only that, is it possible to make objects spawn temporary objects *more then one*.

Help is greatly appreciated! Edited by artizan

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet


×