It is even better if the value of the coin is different in the random item. Any tutorials or scripts for that?Well, the other item games usually have is health item. This item type usually varies in size, shape and value. You could have them as alternate item from random item drop.
Even with coin, you can randomize it so player could get one coin, two coins or even three coins.
thank you Where can I find randomizer scripts?Maybe have the enemy throw a generic, invisible "item" entity upon death, and said item entity will randomly generate any other item in its spawn animation?
Use randomizer script in the spawn animation, that in result will triger a follow animation. Then each follow anim spawns a different item, then the entity kills itself
(I hope I'm making sense, otherwise I could clarify tomorrow )
void main()
{
spawnX("ka1", "ka2", "ka3", "ka4", 0, 0, 0);
}
void spawnX(void name1, void name2, void name3, void name4, float dx, float dy, float dz)
{//Spawns random entity next to caller (4 ENTITIES, ITENS, WEAPONS)
void self = getlocalvar("self");
void vSpawn;
void vName = getentityproperty(self,"defaultname");
int iDir = getentityproperty(self,"direction");
int iR = rand()%50+50;
if(iR >= 0 && iR < 25){
vName = name1;
}
else
if(iR >= 25 && iR < 50){
vName = name2;
}
else
if(iR >= 50 && iR < 75){
vName = name3;
}
else
if(iR >= 75 && iR <= 100){
vName = name4;
}
clearspawnentry();
setspawnentry("name", vName);
vSpawn = spawn();
bindentity(vSpawn, self, dx, dz, dy, iDir);
return vSpawn;
}
First create a transparent text and then add onspawnscript data/scripts/foodx.c to the text
Finally, copy the following script in foodx.c and adjust it to the random items you want, such as ka1 to change 1up
Code:void main() { spawnX("ka1", "ka2", "ka3", "ka4", 0, 0, 0); } void spawnX(void name1, void name2, void name3, void name4, float dx, float dy, float dz) {//Spawns random entity next to caller (4 ENTITIES, ITENS, WEAPONS) void self = getlocalvar("self"); void vSpawn; void vName = getentityproperty(self,"defaultname"); int iDir = getentityproperty(self,"direction"); int iR = rand()%50+50; if(iR >= 0 && iR < 25){ vName = name1; } else if(iR >= 25 && iR < 50){ vName = name2; } else if(iR >= 50 && iR < 75){ vName = name3; } else if(iR >= 75 && iR <= 100){ vName = name4; } clearspawnentry(); setspawnentry("name", vName); vSpawn = spawn(); bindentity(vSpawn, self, dx, dz, dy, iDir); return vSpawn; }
Very good, I forgot one thing, the random script will not take effect the first time you start the game, you need to add the following script in update.c or updated.cFirst create a transparent text and then add onspawnscript data/scripts/foodx.c to the text
Finally, copy the following script in foodx.c and adjust it to the random items you want, such as ka1 to change 1up
Code:void main() { spawnX("ka1", "ka2", "ka3", "ka4", 0, 0, 0); } void spawnX(void name1, void name2, void name3, void name4, float dx, float dy, float dz) {//Spawns random entity next to caller (4 ENTITIES, ITENS, WEAPONS) void self = getlocalvar("self"); void vSpawn; void vName = getentityproperty(self,"defaultname"); int iDir = getentityproperty(self,"direction"); int iR = rand()%50+50; if(iR >= 0 && iR < 25){ vName = name1; } else if(iR >= 25 && iR < 50){ vName = name2; } else if(iR >= 50 && iR < 75){ vName = name3; } else if(iR >= 75 && iR <= 100){ vName = name4; } clearspawnentry(); setspawnentry("name", vName); vSpawn = spawn(); bindentity(vSpawn, self, dx, dz, dy, iDir); return vSpawn; }
void main()
{
randomSeed();
}
void randomSeed()
{//Thanks to msmalik681 RANDOM++ SCRIPT
int seed; //INITIALIZE SEED.
if(seed == NULL()){ //START IT OFF
seed = 1;
}
seed++; //INCREMENT SEED
srand(seed); //APPLY SEED TO RANDOM FUNCTION
}