Steven1985
Active member
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.
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