• All, Gmail is currently rejecting messages from my host. I have a ticket in process, but it may take some time to resolve. Until further notice, do NOT use Gmail for your accounts. You will be unable to receive confirmations and two factor messages to login.

Can you give me some ideas for random items?

DD Tokki

Well-known member
In the game now, the main item is a coin, but I thought that it would be nice to get a different result, so can I have the item come out randomly with a probability?
 
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 🪙.
 
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 🪙.
It is even better if the value of the coin is different in the random item. Any tutorials or scripts for that?
 
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 )
 
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 )
thank you Where can I find randomizer scripts?
 
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;
}
 
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;
}
1658219434720.png
Thanks to you, we succeeded in randomizing the item.
 
Some crap ^^;
isn'nt this a bit big? ... I hope this item will not drop too much. It would make sense from Sonokawa... (perhaps he don't need a random ^^)
 
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.c
Code:
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
}
Thanks for this script @msmalik681
 
Back
Top Bottom