Character specific food pick up

SEEGET

Active member
Hey guys I'm trying to create a food/ health or a 1up item that can only be picked up by a specific character and not the others. How can I this be achieved. Much regards..
 
Hey guys I'm trying to create a food/ health or a 1up item that can only be picked up by a specific character and not the others. How can I this be achieved. Much regards..
I didn't test but I believe you will need to replicate the whole item system with scripts in order to apply a filter.
I suggest testing the pickup() script function, this one will force an entity to pick an item.

pickup(entity, item);

Maybe adding an entity enumeration with range check can help too, then check entity type or name before executing the pickup() function.
 
a food/ health or a 1up item that can only be picked up by a specific character and not the others. How can I this be achieved.

For simple items, you could use didhitscript to do the character selection. If it's taken by correct character, the script will run item pickup script as if regular item. However, if it's taken by incorrect character, the script will drop clone of the item.
 
I didn't test but I believe you will need to replicate the whole item system with scripts in order to apply a filter.
I suggest testing the pickup() script function, this one will force an entity to pick an item.



Maybe adding an entity enumeration with range check can help too, then check entity type or name before executing the pickup() function.
Thanks brother 😊 😊
For simple items, you could use didhitscript to do the character selection. If it's taken by correct character, the script will run item pickup script as if regular item. However, if it's taken by incorrect character, the script will drop clone of the item.
Awesome I'll try them all thanks
 
Alright, here's an example:
itemX.c
C:
void main()
{//Script for character specific items
    void self = getlocalvar("self");
    char Item = getentityproperty(self,"defaultname");
    void target = getlocalvar("damagetaker"); // Get player who picks the item
    int PIndex = getentityproperty(target,"playerindex"); // Get player's index
    int PName = getentityproperty(target,"defaultname"); // Get player's name
    int PScore = getplayerproperty(PIndex, "score");

    if(Item=="Meat"){
      int HMP = getentityproperty(target,"health");

      if(PName=="Guy"){
        changeentityproperty(target, "health", HMP + 100);
      } else {
        int x = getentityproperty(target, "x");
        int z = getentityproperty(target, "z");

        spawn01("Meat",x,10,z);
      }
    } else if(Item=="1up"){
      int PLives = getplayerproperty(PIndex, "lives");

      if(PName=="Guile"){
        changeplayerproperty(PIndex, "lives", PLives+1);
      } else {
        int x = getentityproperty(target, "x");
        int z = getentityproperty(target, "z");

        spawn01("1up",x,10,z);
      }
    }

    changeplayerproperty(PIndex, "score", PScore-1);
    killentity(self); //Suicide!
}

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
    //fY: Y location
    //fZ: Z location

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.

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

    vSpawn = spawn(); //Spawn in entity
    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location. 

    return vSpawn; //Return spawn
}

Save that in data/scripts/didhit/ folder.
Then declare the script in both meat.txt and 1up.txt with this line:
didhitscript data/scripts/didhit/itemX.c

With this script, if a character other than Guy picks up Meat, the item will be technically taken but instead of giving 100 HP, the script will drop another meat. If Guy picks up the Meat, he'll get 100 HP.
Same goes with 1up, Guile gets extra life from the item while others don't.
 
Alright, here's an example:
itemX.c
C:
void main()
{//Script for character specific items
    void self = getlocalvar("self");
    char Item = getentityproperty(self,"defaultname");
    void target = getlocalvar("damagetaker"); // Get player who picks the item
    int PIndex = getentityproperty(target,"playerindex"); // Get player's index
    int PName = getentityproperty(target,"defaultname"); // Get player's name
    int PScore = getplayerproperty(PIndex, "score");

    if(Item=="Meat"){
      int HMP = getentityproperty(target,"health");

      if(PName=="Guy"){
        changeentityproperty(target, "health", HMP + 100);
      } else {
        int x = getentityproperty(target, "x");
        int z = getentityproperty(target, "z");

        spawn01("Meat",x,10,z);
      }
    } else if(Item=="1up"){
      int PLives = getplayerproperty(PIndex, "lives");

      if(PName=="Guile"){
        changeplayerproperty(PIndex, "lives", PLives+1);
      } else {
        int x = getentityproperty(target, "x");
        int z = getentityproperty(target, "z");

        spawn01("1up",x,10,z);
      }
    }

    changeplayerproperty(PIndex, "score", PScore-1);
    killentity(self); //Suicide!
}

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
    //fY: Y location
    //fZ: Z location

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.

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

    vSpawn = spawn(); //Spawn in entity
    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.

    return vSpawn; //Return spawn
}

Save that in data/scripts/didhit/ folder.
Then declare the script in both meat.txt and 1up.txt with this line:


With this script, if a character other than Guy picks up Meat, the item will be technically taken but instead of giving 100 HP, the script will drop another meat. If Guy picks up the Meat, he'll get 100 HP.
Same goes with 1up, Guile gets extra life from the item while others don't.
Very much appreciated thank you once more
 
Back
Top Bottom