Solved Reading "item" on a entity?

Question that is answered or resolved.
Greetings, fellow developers! Long time no see!

here's the "item" property that can be assigned to a entity via level.
1651010564427.png

Is it possible to read this information ingame? I'm working on a script where the character grabs obstacles and is able to throw them against enemies, and I'd like to spawn the items that mentioned obstacles might hade stored in this property.
 
@paulo.bender

Hi buddy!
I don't know if there's a way to read what item the obstacle carries, but in my case I replaced the entire system by a scripted method.

First, I set a entity variable in every spawn instance, like the Barrels below:
C:
spawn        Barrel_A 1
@script void main(){setentityvar(getlocalvar("self"), "item", "Knife");}@end_script
flip        1
coords        260 260 0
at            0

spawn        Barrel_A 1
flip        1
coords        240 220 0
at            0

spawn        Barrel_A 1
@script void main(){setentityvar(getlocalvar("self"), "item", "Apple");}@end_script
flip        1
coords        280 250 0
at            0

spawn        Barrel_B 1
flip        1
coords        300 270 0
at            0

spawn        GalsiaB_ 1
map            1
flip        1
coords        600 240 0
at            1


And then, I call an "ondeathscript" event at the obstacle's header to spawn an item at the moment it's destroyed:
C:
void main()
{//Spawns item from obstacles
    void self        = getlocalvar("self");
    void vName;
    void vSpawn;
    int dir            = getentityproperty(self,"direction");
    int pCount        = openborvariant("count_players");
    float fX        = getentityproperty(self, "x");
    float fY        = getentityproperty(self, "y");
    float fZ        = getentityproperty(self, "z");
    float Vx        = 0;
    float Vy        = 1;
    float Vz        = 0;

    if(getentityvar(self, "item") != NULL()){ //1 PLAYER SPAWN
        vName = getentityvar(self, "item"); //GET THE ITEM'S NAME PREVIOUSLY SAVED
        setentityvar(self, "item", NULL()); //ERASE THE VARIABLE
    }
    else
    if(getentityvar(self, "item2") != NULL()){ //2 PLAYER SPAWN
        if(openborvariant("count_players") > 1){ //DETECT IF THERE'S 2 PLAYERS ALIVE
            vName = getentityvar(self, "item2"); //GET THE ITEM'S NAME PREVIOUSLY SAVED
        }
        else
        {
            vName = "None"; //THIS "NONE" ENTITY IS AN EMPTY ITEM USED IF THE VARIABLE IS NULL
        }
        setentityvar(self, "item2", NULL()); //ERASE THE VARIABLE
    }
    else
    {
        vName = "None";
    }
   
    clearspawnentry();
    setspawnentry("name", vName);
   
    vSpawn = spawn();
   
    changeentityproperty(vSpawn, "position", fX, fZ, fY);
    changeentityproperty(vSpawn, "direction", dir);
    tossentity(vSpawn, Vy, Vx, Vz);
   
    return vSpawn;
}

This way you have more freedom to customize the item drop feature by using scripts.
 
Back
Top Bottom