enemy as score item

Gurtag

Member
hey guys is there a way to make an enemy give score to a player when it hits him? since items have some limitations... i am using an enemy entity wich hits the player with no damage and noreflect then goes to follow# killing it self. it is great for jumping/tosing items and the like but it is only visual, so was wondering if there is a way to give desired score value upon hiting the player..
 
hey guys is there a way to make an enemy give score to a player when it hits him? since items have some limitations... i am using an enemy entity wich hits the player with no damage and noreflect then goes to follow# killing it self. it is great for jumping/tosing items and the like but it is only visual, so was wondering if there is a way to give desired score value upon hiting the player..
I suggest using the didhitscript event in the enemy. Just call the event at the enemy header, create the file add_score.c and copy/paste the code below.

didhitscript data/scripts/add_score.c

Code:
void main()
{
    void self = getlocalvar("self");
    void target = getlocalvar("damagetaker");
    void type = getentityproperty(target, "type");
    int pIndex;
    int pScore;
    int addScore;

    //CHECK IF THE DAMAGED CHARACTER IS A PLAYER
    if(type == openborconstant("TYPE_PLAYER")){
        pIndex = getentityproperty(target, "playerindex"); //GET PLAYER INDEX
        pScore = getplayerproperty(pIndex, "score"); //GET CURRENT SCORE
        addScore = 500; //SCORE TO BE ADDED

        //ADD SCORE
        changeplayerproperty(pIndex, "score", pScore+addScore);
    }
}
 
i am using an enemy entity wich hits the player with no damage and noreflect then goes to follow# killing it self. it is great for jumping/tosing items and the like but it is only visual

If you only need entity which could be tossed around and bounces around, you could use item type + itembox to allow player to collect the item just by touching.
 
I suggest using the didhitscript event in the enemy. Just call the event at the enemy header, create the file add_score.c and copy/paste the code below.



Code:
void main()
{
    void self = getlocalvar("self");
    void target = getlocalvar("damagetaker");
    void type = getentityproperty(target, "type");
    int pIndex;
    int pScore;
    int addScore;

    //CHECK IF THE DAMAGED CHARACTER IS A PLAYER
    if(type == openborconstant("TYPE_PLAYER")){
        pIndex = getentityproperty(target, "playerindex"); //GET PLAYER INDEX
        pScore = getplayerproperty(pIndex, "score"); //GET CURRENT SCORE
        addScore = 500; //SCORE TO BE ADDED

        //ADD SCORE
        changeplayerproperty(pIndex, "score", pScore+addScore);
    }
}
that worked nice.. thanks a lot kratus


If you only need entity which could be tossed around and bounces around, you could use item type + itembox to allow player to collect the item just by touching.
hey man itembox seems to lack Z parameter wich i do need in some cases that is why i was trying to use attack box instead..
 
Back
Top Bottom