This is the current code! This code works, as far as mob drops go but what doesn't work is the damage. No matter what my Var is set to my weapon only does 2 damage per hit.
Is my code wrong or is it something so simple I was just oblivious to it? Any help would be much appreciated.
Sorry for crappy looking code not sure how to make it look like it does in Droid edit
I don't have my phone out right now to test it, but as far as I can see, you are missing semicolons after declaring the dmg and mixed variables. It might have just been a typo when you were copying onto the forums, but yeah. Also, when I do custom damage and vanilla drops, I have no dmg variable, because I already know what the weapon is from Player.getCarriedItem, so I just use a number(I like to not use variable where I can). I also have no mixed variable, for the same reason. When I am killing the mob, instead of setting the health to 2 and letting the normal 1 damage hit kill it, I set the health to 1 and then give it wither. It might not make a difference doing all of this, but it also might be what makes it work somewhere in there(In a mod I made, this setup worked for me).
Hmm ok. I just took the variables out and left it set as vanilla sword. Seems to work. Maybe it's just cause I'm using a gold sword. But shouldn't be able to 1 hit ko chicken mobs and what not?
Says I didn't define mob. Am I supposed to put mob id there?
Replace the word mob with the id of the entity that died, also you don't need all of that for vanilla drops, just set the health to 1 and set on fire(has visual effects), wither(works in background instantly killing the mob if it's at 1 health), instant damage(same as wither), etc. With setting custom drops to every mob, you will be recreating every single mob in the game's drops, including players, that have been killed with the sword. Easier to kill with external means, although killing players with this method will yield a message in chat saying that they were killed by fire or magic, instead of you with a sword. Can you post the full code online please with copy and paste? Then it would be easier for everyone to see whats wrong with it.
Well I toyed around with it some more and found that I was missing the if (player.getCarriedItem ()==380){} in my deathHook. Now it insta kills, drops vanilla drops, and drops my added apple (test purposes)
Has been SOLVED!!
ModPE.setItem (1000, "sword", 3, "Golden Angel");
Function attackHook (attacker, victim){
If (Player.getCarriedItem == 1000){
Var dmg = 14
Var mixed = Entity.getHealth (victim) - dmg
If(mixed > 2){
Entity.setHealth (victim, mixed);
}else {
Entity.setHealth (victim, 2);
}
}
This is the current code! This code works, as far as mob drops go but what doesn't work is the damage. No matter what my Var is set to my weapon only does 2 damage per hit.
Is my code wrong or is it something so simple I was just oblivious to it? Any help would be much appreciated.
Sorry for crappy looking code not sure how to make it look like it does in Droid edit
I don't have my phone out right now to test it, but as far as I can see, you are missing semicolons after declaring the dmg and mixed variables. It might have just been a typo when you were copying onto the forums, but yeah. Also, when I do custom damage and vanilla drops, I have no dmg variable, because I already know what the weapon is from Player.getCarriedItem, so I just use a number(I like to not use variable where I can). I also have no mixed variable, for the same reason. When I am killing the mob, instead of setting the health to 2 and letting the normal 1 damage hit kill it, I set the health to 1 and then give it wither. It might not make a difference doing all of this, but it also might be what makes it work somewhere in there(In a mod I made, this setup worked for me).
I have nothing to say...
Hmm ok. I just took the variables out and left it set as vanilla sword. Seems to work. Maybe it's just cause I'm using a gold sword. But shouldn't be able to 1 hit ko chicken mobs and what not?
<code>function attackHook(attacker, victim){}</code>
Hey Boy Thats Tooo Many Code Make It Simple
//SimpleSword
ModPE.setItem(1000, "sword", 3, "Global Angel Sword");
//AttackHook
function attackHook(attacker, victim){
if(Player.getCarriedItem() == 1000){
var dmg = 14;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
}
}
YOU DONT NEED THAT MANY CODEING, THIS WILL WORK!!! TRUST ME
And this is just mob drops fill it up
function deathHook(attacker,victim)
{
if(mob==victim);
{
Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), range, itemId, ammount, damage);
}
}
+1 If I Helped
+1 mate
Though I did get an error. Says I didn't define mob. Am I supposed to put mob id there?
Replace the word mob with the id of the entity that died, also you don't need all of that for vanilla drops, just set the health to 1 and set on fire(has visual effects), wither(works in background instantly killing the mob if it's at 1 health), instant damage(same as wither), etc. With setting custom drops to every mob, you will be recreating every single mob in the game's drops, including players, that have been killed with the sword. Easier to kill with external means, although killing players with this method will yield a message in chat saying that they were killed by fire or magic, instead of you with a sword. Can you post the full code online please with copy and paste? Then it would be easier for everyone to see whats wrong with it.
I have nothing to say...
//Sword
ModPE.setItem(380, "sword", 3, "Killer", 1);
//attack code
function attackHook(attacker, victim){
if(getCarriedItem() == 380){
Entity.setHealth(victim, 1);
}
}
//death code
function deathHook(attacker, victim){
if(Player.getCarriedItem() == 380){
if(Entity.getEntityTypeId() == 13){
Level.dropItem(Entity.getX(victim), Entity.getY(victim), Entity.getZ(victim), 0, 260, 1);
}
}
}
Well I toyed around with it some more and found that I was missing the if (player.getCarriedItem ()==380){} in my deathHook. Now it insta kills, drops vanilla drops, and drops my added apple (test purposes)
I wanna thank both of you for your help
Glad to have been a help
I have nothing to say...
Always needed, mob id is one
That's code where weapon does 1 damage but also sets victims heart to 1, That's tooo op
CODE:
ModPE.setItem (1001, "scythe", 3, "§eNinja Tırpanı");
function attackHook(attacker, victim){
if(Player.getCarriedItem() == 1001){
var dmg = 14;
Entity.setHealth(victim, Entity.getHealth(victim) - dmg);
}
}
Player.addItemCreativeInv(1001,5,0);
Item.setHandEquipped(1001, 1);
Item.addShapedRecipe(1001, 1, 0, [" cc","c d"," d"], ["c", 266, 0, "d", 265, 0]);
ERROR:
org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalArgumentException: The item icon scythe:3 does not exist (Deneme 1.js#28)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(Unknown Source)
at org.mozilla.javascript.FunctionObject.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpretLoop(Unknown Source)
at script(Deneme 1.js:28)
at org.mozilla.javascript.Interpreter.interpret(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source)
at org.mozilla.javascript.InterpretedFunction.exec(Unknown Source)
at net.zhuoweizhang.mcpelauncher.ScriptManager.initJustLoadedScript(ScriptManager.java:253)
at net.zhuoweizhang.mcpelauncher.ScriptManager$ParseThread.run(ScriptManager.java:179)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: The item icon scythe:3 does not exist
at net.zhuoweizhang.mcpelauncher.ScriptManager$NativeModPEApi.setItem(ScriptManager.java:2773)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
... 11 more
Bro Tell Me If U Have something In Texture Pack Thats Called "scythe_3.png" Its Add Item Eroor
If U Wanna Help With ModPE I Can Help, No Prob, I Know Basics And Stff Like Ore Gen And Block
How do u spawn custom mobs? And How do u make a custom pickaxe
Skellox i sent you a PM, please tell me what you need there, I will be happy to help
I have nothing to say...