Solved more than one item in trash obstacle

Question that is answered or resolved.

dcelso

Member
Hi,
I'm trying to do a script to show more than one item once broke a trash.

Code:
spawn    trash
item    Meat
coords    370 162
at    1100

How can I detect that an obstacle is just broke to spawn a second item close to it?

any suggestions?
 
Solution
You'd need to add self remove function in spawn01.c such as this:
Code:
void suicide()
{ // Suicide!!
    void self = getlocalvar("self");

    killentity(self); //Suicide!
}

then declare it at end of animation like this:
Code:
anim idle
    loop 0
    delay    1
    offset    1 1
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "meat" -20 -20 0
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "apple" 20 20 0
    @cmd    suicide
    frame    data/chars/misc/GOLD00.GIF
never tried it myself
maybe you can use spawn01 in death/fall anim for the second item


Code:
void spawn01(void vName, float fX, float fY, float fZ)
{
    //spawn01 (Generic spawner)
    //Damon Vaughn Caskey
    //07/06/2007
    //
    //Spawns entity next to caller.
    //
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fY: Y location adjustment.
      //fZ: Z location adjustment.

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

    if (iDirection == 0){ //Is entity facing left?                 
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    
    return vSpawn; //Return spawn.
}
 
How can I detect that an obstacle is just broke to spawn a second item close to it?

any suggestions?

Having an obstacle or entity drops multiple items on death is easy. Create invisible item which spawns multiple items and have obstacle or entity drop the former.
However, creating obstacle or entity which could drop various item on death, declared in level text, is not easy.
A good way is to have obstacle accepts names declared to its entity variables (in level text) and drop those names on obstacle's DEATH.
 
Thanks bloodbane.
I'm trying to use the first suggestion but I can't get it to work.
files that I have touched:
char/misc/trash.txt
norma/1a.txt
scrits/spawn01.c
 

Attachments

You have an error calling the script, you skipped the @.
In your line you skipped the @:
cmd spawn01 "money" 370 20 165

It should set like this:
Code:
anim fall
    loop    1
    delay    1000
    offset    50 32
        @cmd    spawn01 "money" 370 20 165
    frame    data/chars/misc/trashed.gif
 
Ummm... @dcelso, that's not what I meant. What I meant is something like this:
Code:
name            Bunster
type            item
nolife          1
animationscript data/scripts/item.c

load        Bun       
load            Bread       
load            Chocolate       
load            PizzaSlice       
load            Sandwich   

anim idle
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Bun" 0 1 0
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Chocolate" 1 1 0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Bread" -1 1 0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Sandwich" 1 1 -0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "PizzaSlice" -1 1 -0.5
        @cmd    suicide
    frame    data/chars/misc/empty.gif

This entity spawns 5 other items (foods to be exact) after it is spawned. After spawning those, it removes itself.
 
You have an error calling the script, you skipped the @.
In your line you skipped the @:
cmd spawn01 "money" 370 20 165

It should set like this:
Code:
anim fall
    loop    1
    delay    1000
    offset    50 32
        @cmd    spawn01 "money" 370 20 165
    frame    data/chars/misc/trashed.gif
:O, great, nowt it worked well :'(,
 
Ummm... @dcelso, that's not what I meant. What I meant is something like this:
Code:
name            Bunster
type            item
nolife          1
animationscript data/scripts/item.c

load        Bun      
load            Bread      
load            Chocolate      
load            PizzaSlice      
load            Sandwich  

anim idle
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Bun" 0 1 0
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Chocolate" 1 1 0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Bread" -1 1 0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Sandwich" 1 1 -0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "PizzaSlice" -1 1 -0.5
        @cmd    suicide
    frame    data/chars/misc/empty.gif

This entity spawns 5 other items (foods to be exact) after it is spawned. After spawning those, it removes itself.
ah, Oh, it seems a better option.
 
Ummm... @dcelso, that's not what I meant. What I meant is something like this:
Code:
name            Bunster
type            item
nolife          1
animationscript data/scripts/item.c

load        Bun      
load            Bread      
load            Chocolate      
load            PizzaSlice      
load            Sandwich  

anim idle
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Bun" 0 1 0
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Chocolate" 1 1 0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Bread" -1 1 0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "Sandwich" 1 1 -0.5
    frame    data/chars/misc/empty.gif
        @cmd    Ispawn "PizzaSlice" -1 1 -0.5
        @cmd    suicide
    frame    data/chars/misc/empty.gif

This entity spawns 5 other items (foods to be exact) after it is spawned. After spawning those, it removes itself.

Hi Bloodbane, first of all, thans for all. :O
I'm trying this other option and I tried to change de empty.gif for an imagen to see if it dissapears, And I have tested that it not dissapears. I tried to put loop to 0, to finish the idle anim but that does not work.
Code:
name            2items
type            item
nolife          1
animationscript data/scripts/spawn01.c

anim idle
    loop 0
    delay    1
    offset    1 1
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "meat" -20 -20 0
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "apple" 20 20 0
    frame    data/chars/misc/GOLD00.GIF

How can I finish it correctly?
 

Attachments

You'd need to add self remove function in spawn01.c such as this:
Code:
void suicide()
{ // Suicide!!
    void self = getlocalvar("self");

    killentity(self); //Suicide!
}

then declare it at end of animation like this:
Code:
anim idle
    loop 0
    delay    1
    offset    1 1
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "meat" -20 -20 0
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "apple" 20 20 0
    @cmd    suicide
    frame    data/chars/misc/GOLD00.GIF
 
Solution
While toying around with mod you've shared before, I noticed something you're missing with 2items. You must load to be spawned items to ensure they are spawned.
2items should be like this:
Code:
name            2items
type            item
nolife          1
animationscript data/scripts/prscript.c
load    meat
load    apple


anim    idle
    delay    1
    offset    1 1
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "meat" -20 -20 0
    frame    data/chars/misc/GOLD00.GIF
    @cmd    spawn01 "apple" 20 20 0
    @cmd    suicide
    frame    data/chars/misc/GOLD00.GIF
 
Back
Top Bottom