void main() //aggiunto da me
{
NPiKir();
partnerFood();
}
void NPiKir(){ //prima era void main
void self = getlocalvar("self");
int MHP = getentityproperty(self,"maxhealth");
int HP = getentityproperty(self,"health");
void Par = getentityproperty(self, "parent");
if(HP <= MHP*0.6){
changeentityproperty(self, "aimove", openborconstant("AIMOVE1_NORMAL"));
changeentityproperty(self, "attackthrottle", 0.2);
changeentityproperty(self, "attackthrottletime", 80);
} else if(HP < MHP*0.5){
changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
changeentityproperty(self, "attackthrottle", 0.4);
changeentityproperty(self, "attackthrottletime", 100);
}
if(Par){
void ExPar = getentityproperty(Par, "exists");
if(!ExPar){
changeentityproperty(self, "parent", NULL());
changeentityproperty(self, "hostile", openborconstant("TYPE_ENEMY")); //tolto , openborconstant("TYPE_ITEM")
}
} else {
void P1 = getplayerproperty(0, "entity");
void PPart1, PPart2, PPart3, PPart4, PPart5;
if(P1){
PPart1 = getentityvar(P1, "Partner1");
PPart2 = getentityvar(P1, "Partner2");
PPart3 = getentityvar(P1, "Partner3");
PPart4 = getentityvar(P1, "Partner4");
PPart5 = getentityvar(P1, "Partner5");
changeentityproperty(self,"parent", P1);
if(!PPart1){
setentityvar(P1, "Partner1", self);
} else if(!PPart2){
setentityvar(P1, "Partner2", self);
} else if(!PPart3){
setentityvar(P1, "Partner3", self);
} else if(!PPart4){
setentityvar(P1, "Partner4", self);
} else if(!PPart5){
setentityvar(P1, "Partner5", self);
}
}
changeentityproperty(self, "hostile", openborconstant("TYPE_ENEMY")); //tolto , openborconstant("TYPE_ITEM")
}
}
void partnerFood()
//Occorre precisare che se l'alleato non ha il parent, cioè non segue il giocatore, seguirà comunque le istruzioni.
{//When npcs take food
void self = getlocalvar("self");
void parent = getentityproperty(self, "parent");
//Dichiarazione di una variabile che rappresenta il "genitore" dell'entità attuale;
//getentityproperty(self, "parent"): recupera una proprietà dell'entità attuale (self), in questo caso il suo genitore.
//Il genitore è un'entità che ha creato l'entità self o è associata all'entità self.
//int enemies = openborvariant("count_enemies"); //numero di nemici attivi nel livello
int detect = getentityproperty(self, "detect");
//detect: una variabile intera che rappresenta il raggio o la capacità di "rilevamento" dell'entità attuale.
//getentityproperty(self, "detect"): Recupera la proprietà detect dell'entità self.
//Questo può essere usato per determinare se l'entità può "vedere" o percepire il cibo.
int maxHealth = getentityproperty(self, "maxhealth");
int vHealth = getentityproperty(self, "health"); // salute attuale del partner
int pHealth = getentityproperty(parent, "health"); //salute attuale del genitore
int percent20 = maxHealth/5; //default percent20 = maxHealth/5
//int group = 3; //numero di nemici da tenere in considerazione
//PARTNER GET FOOD
//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.
//}
//PARTNER GET FOOD MADE BY ME
if(vHealth < pHealth){ //PARTNER HAS LESS HEALTH THAN PLAYER??
if(detect != 1){changeentityproperty(self, "detect", 1);} //GET FOOD Se la proprietà detect dell'NPC non è già impostata a 1, cambia la proprietà detect dell'NPC a 1 cioè cerca cibo
}
else
{
if(detect != 0){changeentityproperty(self, "detect", 0);} //NOT GET FOOD //se questa riga non c'è il partner prenderà il cibo fino a che non arriva ad avere salute piena
//e se di nuovo ne perde un po' e ne ha di più del giocatore andrà sempre a prendere cibo
//queste quattro righe di codice (da else a }) se non ci sono qui ci devono essere a vhealth <=percent... (sotto)
}
if(vHealth <= percent20*2){ //PARTNER HAS LESS THAN 40% HEALTH??
if(detect != 1){changeentityproperty(self, "detect", 1);} //GET FOOD A.S.A.P.
}
}