I can't seem to figure out how to randomly spawn a custom mob with given attributes. Now I will be honest here, I SUCK at making MCPE Scripts. And furthermore, I probably curse the entire modding community with any script I've ever made, with help or not. But, I enjoy it and I want to be good at it. But enough sobbing, I know you don't want to hear it. I would appreciate any help you can give me, in the form of all of the existing Functions/Hooks. Thanks for the help!
Rollback Post to RevisionRollBack
DO NOT OPEN THAT SPOILER!!!
If you are reading this then you you totally ignored what I said about not opening that spoiler three spoilers ago.. Don't you remember? I said "DO NOT OPEN THAT SPOILER!!! But no, you were a rebel and did it anyway!
function entityAddedHook(entity) { } and replace the spawned Mob or use Math.random() to spawn randomly. If you spawn a Mob randomly spawn it on the first block that is not air.
function entityAddedHook(entity) { } and replace the spawned Mob or use Math.random() to spawn randomly. If you spawn a Mob randomly spawn it on the first block that is not air.
Do you have an example?
Rollback Post to RevisionRollBack
DO NOT OPEN THAT SPOILER!!!
If you are reading this then you you totally ignored what I said about not opening that spoiler three spoilers ago.. Don't you remember? I said "DO NOT OPEN THAT SPOILER!!! But no, you were a rebel and did it anyway!
Level.spawnMob(Entity.getX(ent), Entity.getY(ent), Entity.getZ(ent), Id, texture); //spawn your Entity where another has spawned
Entity.remove(ent); //After that you can (but mustn´t) remove the other Entity
}
Way 2:
var tick=0;
var y;
var x;
var z;
function modTick(){
if(tick==0){
tick=Math.random()*400+400; //tick is now a number between 400 and 800. This means a new Entity spawn every 20-40 seconds (20 ticks=1 second)
}
tick--; //count tick down
if(tick==1){ //is tick is one you spawn an Entity
y=128;
x=(Math.random()*200-100)+Player.getX(); //x and z are now between -100 and 100 from the player, now only y is missing
z=(Math.random()*200-100)+Player.getZ();
for(var i=0; i<128; i++){
if(Level.getTile(x, y, z)==0){ //is the block where the Entity would spawn in the moment y will be countet down, the loop repeats that 128 times so you find the first block that is not air
y--;
}
}
y++; //After the loop count y + 1 to prevent that the Entity spawns in a block
Level.spawnMob(x, y, z, Id, texture); //spawn your Entity
Level.spawnMob(Entity.getX(ent), Entity.getY(ent), Entity.getZ(ent), Id, texture); //spawn your Entity where another has spawned
Entity.remove(ent); //After that you can (but mustn´t) remove the other Entity
}
Way 2:
var tick=0;
var y;
var x;
var z;
function modTick(){
if(tick==0){
tick=Math.random()*400+400; //tick is now a number between 400 and 800. This means a new Entity spawn every 20-40 seconds (20 ticks=1 second)
}
tick--; //count tick down
if(tick==1){ //is tick is one you spawn an Entity
y=128;
x=(Math.random()*200-100)+Player.getX(); //x and z are now between -100 and 100 from the player, now only y is missing
z=(Math.random()*200-100)+Player.getZ();
for(var i=0; i<128; i++){
if(Level.getTile(x, y, z)==0){ //is the block where the Entity would spawn in the moment y will be countet down, the loop repeats that 128 times so you find the first block that is not air
y--;
}
}
y++; //After the loop count y + 1 to prevent that the Entity spawns in a block
Level.spawnMob(x, y, z, Id, texture); //spawn your Entity
}
//
}
Thanks for the help! I ended up using the first method. The script is now up!
Rollback Post to RevisionRollBack
DO NOT OPEN THAT SPOILER!!!
If you are reading this then you you totally ignored what I said about not opening that spoiler three spoilers ago.. Don't you remember? I said "DO NOT OPEN THAT SPOILER!!! But no, you were a rebel and did it anyway!
I can't seem to figure out how to randomly spawn a custom mob with given attributes. Now I will be honest here, I SUCK at making MCPE Scripts. And furthermore, I probably curse the entire modding community with any script I've ever made, with help or not. But, I enjoy it and I want to be good at it. But enough sobbing, I know you don't want to hear it. I would appreciate any help you can give me, in the form of all of the existing Functions/Hooks. Thanks for the help!
You can use
function entityAddedHook(entity) { } and replace the spawned Mob or use Math.random() to spawn randomly. If you spawn a Mob randomly spawn it on the first block that is not air.
Do you have an example?
function entityAddedHook(ent){
Level.spawnMob(Entity.getX(ent), Entity.getY(ent), Entity.getZ(ent), Id, texture); //spawn your Entity where another has spawned
Entity.remove(ent); //After that you can (but mustn´t) remove the other Entity
}
Way 2:
var tick=0;
var y;
var x;
var z;
function modTick(){
if(tick==0){
tick=Math.random()*400+400; //tick is now a number between 400 and 800. This means a new Entity spawn every 20-40 seconds (20 ticks=1 second)
}
tick--; //count tick down
if(tick==1){ //is tick is one you spawn an Entity
y=128;
x=(Math.random()*200-100)+Player.getX(); //x and z are now between -100 and 100 from the player, now only y is missing
z=(Math.random()*200-100)+Player.getZ();
for(var i=0; i<128; i++){
if(Level.getTile(x, y, z)==0){ //is the block where the Entity would spawn in the moment y will be countet down, the loop repeats that 128 times so you find the first block that is not air
y--;
}
}
y++; //After the loop count y + 1 to prevent that the Entity spawns in a block
Level.spawnMob(x, y, z, Id, texture); //spawn your Entity
}
//
}
Thanks for the help! I ended up using the first method. The script is now up!
Help me an esamle dowlond link?