• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Add the partner menu of streets of rage 2 by Kratus in all OpenBOR games.

Hi @Kratus , how are you?
In my new game there are two types of food: salty food (with heath value) and sweet food (with mp value) but the cpu partner does not pick up sweet food.
I have tried with the think script but it does not work.
C:
void main()
{
    partnerHealthFood();
    partnerMpItem();
    .....
}

void partnerHealthFood()
{//When npcs take health food
    void self        = getlocalvar("self");
    void parent        = getentityproperty(self, "parent");
    void pFood        = getglobalvar("partnerGetFood");
    int enemies        = openborvariant("count_enemies");
    int detect        = getentityproperty(self, "detect");
    int maxHealth    = getentityproperty(self, "maxhealth");
    int vHealth        = getentityproperty(self, "health");
    int pHealth        = getentityproperty(parent, "health");
    int percent20    = maxHealth/5;
    int group        = 3;
    
    //PARTNER GET FOOD
    //if(pFood == "yes"){
        if(vHealth > percent20*2){ //PARTNER HAS MORE THAN 40% HEALTH??
            if(vHealth < pHealth){ //PARTNER HAS LESS HEALTH THAN PLAYER??
                if(vHealth < percent20*4){ //PARTNER HAS LESS THAN 80% HEALTH??
                    if(detect != 1){changeentityproperty(self, "detect", 1);} //GET FOOD
                }
                
                if(vHealth >= percent20*4){ //PARTNER HAS MORE THAN 80% HEALTH??
                    if(enemies < group || getglobalvar("partnerParrow") == "call"){ //HAS NOT TOO MANY ENEMIES ON THE SCREEN??
                        if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD
                    }
                    else
                    {
                        if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD, CONSERVE FOOD FOR LATER
                    }
                }
            }
            else
            {
                if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD
            }
        }
        
        if(vHealth <= percent20*2){ //PARTNER HAS LESS THAN 40% HEALTH??
            if(detect != 1){changeentityproperty(self, "detect", 1);} //GET FOOD A.S.A.P.
        }
    //}
}

void partnerMpItem()
{//When npcs take mp food
    void self        = getlocalvar("self");
    void parent        = getentityproperty(self, "parent");
    void pItem        = getglobalvar("partnerGetItem");
    int enemies        = openborvariant("count_enemies");
    int detect        = getentityproperty(self, "detect");
    int maxMp    = getentityproperty(self, "maxmp");
    int vMp        = getentityproperty(self, "mp");
    int pMp        = getentityproperty(parent, "mp");
    int percent20    = maxMp/5;
    int group        = 3;
    
    //PARTNER GET FOOD
    //if(pFood == "yes"){
        if(vMp > percent20*2){ //PARTNER HAS MORE THAN 40% MP??
            if(vMp < pMp){ //PARTNER HAS LESS MP THAN PLAYER??
                if(vMp < percent20*4){ //PARTNER HAS LESS THAN 80% MP??
                    if(detect != 1){changeentityproperty(self, "detect", 1);} //GET FOOD
                }
                
                if(vMp >= percent20*4){ //PARTNER HAS MORE THAN 80% MP??
                    if(enemies < group || getglobalvar("partnerParrow") == "call"){ //HAS NOT TOO MANY ENEMIES ON THE SCREEN??
                        if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD
                    }
                    else
                    {
                        if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD, CONSERVE FOOD FOR LATER
                    }
                }
            }
            else
            {
                if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD
            }
        }
        
        if(vMp <= percent20*2){ //PARTNER HAS LESS THAN 40% MP??
            if(detect != 1){changeentityproperty(self, "detect", 1);} //GET FOOD A.S.A.P.
        }
    //}
}

C:
name    Croissant
mp    22
type        item
shadow    0

#CPU PARTNER NECESSARY CONFIGS
#DON'T FORGET TO SET ITEM'S STEALTH FACTOR TO WORK WITH "GET FOOD" OPTION
stealth 1

anim idle
    loop        1
    offset    13 14
    bbox    0 0 26 15
    delay    100
    frame    data/chars/misc/croissant01.gif
    delay   4
    frame    data/chars/misc/croissant02.gif
    frame    data/chars/misc/croissant01.gif
    frame    data/chars/misc/croissant02.gif
    frame    data/chars/misc/croissant01.gif
    frame    data/chars/misc/croissant02.gif
    frame    data/chars/misc/croissant01.gif
    frame    data/chars/misc/croissant02.gif
    frame    data/chars/misc/croissant01.gif
    frame    data/chars/misc/croissant02.gif
    frame    data/chars/misc/croissant01.gif
 
sweet food (with mp value) but the cpu partner does not pick up sweet food
@Steven1985 Hi friend, enemies/npc will only chase and pick up items that fills health and only if their health are lower than the maxhealth. In this case you need to trick them by creating health items with the minimum value of 1 and adding a didhit script to force a mp refill, like this.

Food entity's header
C:
didhitscript data/scripts/didhit.c

didhit.c file
C:
void main()
{//Custom mp refill for enemies/npc
    void target    = getlocalvar("damagetaker");
    int mp        = getentityproperty(target, "mp");
    int add        = 90;

    changeentityproperty(target, "mp", mp+add);
}
 
@Steven1985 Hi friend, enemies/npc will only chase and pick up items that fills health and only if their health are lower than the maxhealth. In this case you need to trick them by creating health items with the minimum value of 1 and adding a didhit script to force a mp refill, like this.

Food entity's header
C:
didhitscript data/scripts/didhit.c

didhit.c file
C:
void main()
{//Custom mp refill for enemies/npc
    void target    = getlocalvar("damagetaker");
    int mp        = getentityproperty(target, "mp");
    int add        = 90;

    changeentityproperty(target, "mp", mp+add);
}
Thank you so much :)
 
Back
Top Bottom