A pet NPC that attacks enemies on command.

Aerisetta

Active member

Wondering if I can get some help on this.

in this video, the player is controlling the Blue Hoodie guy who punches.

There is a succbus with a scythe who follows him around (the pet)
Right now, the Succubus is a NPC entity that is hostile and chasing the player.
However, she cannot damage the player and only damages enemies (this is correct).
Right now, the succubus NPC does not follow the player's command, it is actually just attacking the player but hitting the enemies.

What I would like is.
  1. the succubus continues to follow the player.
  2. The succubus does NOT attack on it's own
  3. When the player presses a button, the succubus will dash towards the enemy attack with an attack.
  4. The succubus then returns to following the player.
  5. I want the succubus to do the attack without the player doing any animation change
Thanks
 
No, item as in the foods. I haven't figured out why NPCs isn't taking any foods yet.
I am doing tests to the file NPCVictory4.
L'npc does not take food because in every file header of food entity there is stealth 1
that, in my games, is connected to think.c,
that is declared in npcs' file header:
thinkspcript data/..../think.c
To your file NPCVictory4 I added this script and npc takes food.
C-like:
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.
    }
}
About "call" feature I will make you to know when I finish to test it.
 
@Bloodbane I finished the test and I noted three things by comparing the Partner menu and NPCVictory 4 about "call system":
1) Through the partner menu, if I spawn a second partner while the first one has the ‘call’, the second partner will also have the ‘call’. Through your system, if I spawn a second partner while the first one has the ‘call’, the second partner does not have the ‘call’ and is hostile.
2) Through the partner menu, after I generate two partners that have the ‘call’ and one of them dies, the ‘call’ is also removed from the surviving partner, who becomes hostile. Through your system, if the partners have the ‘call’ and one of them dies, the dead partner’s ‘call’ remains on the screen, the surviving partner continues to have the ‘call’ and remains inactive, and to remove also the dead partner’s ‘call’ I have to press the related button.
3) Through the partner menu, after spawning two partners that have the ‘call’, if the player dies the partners continue to have the ‘call’ and remain inactive; through your system, if the player dies the NPCs become hostile while still displaying the ‘call’ text.
I hope this is useful for you. :)
 
I believe it's because the script kills all enemies except the spawner (Enemer). The script gives order to Enemer to stop spawning and remove itself but there's small chance it could have spawned an enemy before it receives the order.
 
I will need to see the whole spawn set, at least in wait group.
I am testing every level. For now I put you stage 2.
Francesco Ficarelli's Heroes - 0000.png
Code:
music        data/bgs/levels/stage_2/bor.bor
panel        data/bgs/levels/stage_2/n01.gif       
order        a

#z          220 244 160 lunghezza stage 1219 (ultimo at 787)

# due ostacoli - 53 nemici (incluso boss) 

#questo per attivare l'invincibilità di 3 secondi agli npc dal secondo spawn in poi
spawn npc_makeinv
coords 20 200
at 0


#Enemies
#-------1

spawn   RandEnemyAliasMap #1
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at      34

spawn   RandEnemyAliasMap #2
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at      136

spawn   RandEnemyAliasMap #3
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at 204

wait
at 241

group   4 4  #default 5 5
at 241


spawn   RandEnemyAliasMap #4
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at 241

spawn   RandEnemyAliasMap #5
spawnscript data/scripts/enemies/randmz.c
#map     2
health  70
#alias   Trooper
coords  -30 205
at 241

spawn   RandEnemyAliasMap #6
spawnscript data/scripts/enemies/randmz.c
#map     2
health  80
#alias   George
coords  462 210
at 241

spawn   RandEnemyAliasMap #7
spawnscript data/scripts/enemies/randmz.c
#map     1
health  75
#alias   Two_P
coords  -30 190
at 241

spawn   RandEnemyAliasMap #8
spawnscript data/scripts/enemies/randmz.c
health  80
coords  462 215
at 241

spawn   RandEnemyAliasMap #9
spawnscript data/scripts/enemies/randmz.c
#map     2
health  115
#alias   Mantis
coords  -30 190
at 241

spawn   RandEnemyAliasMap #10
spawnscript data/scripts/enemies/randmz.c
#map     1
health  120
#alias   Hollywood
coords  462 210
at 241

spawn   RandEnemyAliasMap #11
spawnscript data/scripts/enemies/randmz.c
#map     1
health  100
#alias   Hans
coords  -30 205
at 241

spawn   RandEnemyAliasMap #12
spawnscript data/scripts/enemies/randmz.c
#map     4
health  115
#alias   Taro
coords  462 170
at 241

spawn   RandEnemyAliasMap #13
spawnscript data/scripts/enemies/randmz.c
health  115
coords  -30 200
at 241

spawn   RandEnemyAliasMap #14
spawnscript data/scripts/enemies/randmz.c
health  115
coords  462 205
at 241

spawn   RandEnemyAliasMap #15
spawnscript data/scripts/enemies/randmz.c
coords  -30 140
at 241 #90

spawn   Box #obstacle n. 1
#spawnscript data/scripts/enemies/randmz.c
item    RandItem
coords  482 220
at 275 # x 757

spawn   RandEnemyAliasMap #16
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at 340 #x 802

spawn   RandEnemyAliasMap #17
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at      340 #x 802

spawn   Drum #obstacle
#spawnscript data/scripts/enemies/randmz.c
item    RandItem
coords  482 220
at 432 # x 914

spawn   RandEnemyAliasMap #18
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at      476 # x 938

spawn   RandEnemyAliasMap #19
spawnscript data/scripts/enemies/randmz.c
#map     3
health  150
#alias   Buffalo
coords  462 210
at      600

#-------2

group   5 5 #default 6 6
at      787

spawn   RandEnemyAliasMap #20
spawnscript data/scripts/enemies/randmz.c
#map     3
health  140
#alias   Frank
coords  462 210
at      787

spawn   RandEnemyAliasMap #21
spawnscript data/scripts/enemies/randmz.c
#map     2
health  80
#alias   George
coords  -30 200
at      787

spawn   RandEnemyAliasMap #22
spawnscript data/scripts/enemies/randmz.c
health  115
coords  462 210
at      787

spawn   RandEnemyAliasMap #23
spawnscript data/scripts/enemies/randmz.c
health  115
coords  -30 205
at      787

spawn   RandEnemyAliasMap #24
spawnscript data/scripts/enemies/randmz.c
#map     1
health  150
#alias   Warrior
coords  462 210
at      787

spawn   RandEnemyAliasMap #25
spawnscript data/scripts/enemies/randmz.c
#map     8
health  400
#alias   N._Andore
coords  -30 190
at      787

spawn   Max #boss #26
spawnscript data/scripts/enemies/randmz.c
#boss 1 #non serve visto che ho anim victory per gli npc
item BossDed
#map     4
#alias   Will
coords  462 215
at      787

spawn   RandEnemyAliasMap #27
spawnscript data/scripts/enemies/randmz.c
#map     1
health  115
#alias   Ichiro
coords  -30 190
at      787

spawn   RandEnemyAliasMap #28
spawnscript data/scripts/enemies/randmz.c
health  100
#alias   Eagle
coords  462 210
at      787

spawn   RandEnemyAliasMap #29
spawnscript data/scripts/enemies/randmz.c
#map     4
health  70
#alias   Ricochet
coords  -30 205
at      787

spawn   RandEnemyAliasMap #30
spawnscript data/scripts/enemies/randmz.c
health  70
coords  462 170
at      787

spawn   RandEnemyAliasMap #31
spawnscript data/scripts/enemies/randmz.c
#map     3
health  100
#alias   Hawk
coords  -30 200
at      787

spawn   RandEnemyAliasMap #32
spawnscript data/scripts/enemies/randmz.c
health  160
#alias   Zebra
coords  462 205
at      787

spawn   RandEnemyAliasMap #33
spawnscript data/scripts/enemies/randmz.c
#map     4
health  90
#alias   Jeff
coords  -30 210
at      787

spawn   RandEnemyAliasMap #34
spawnscript data/scripts/enemies/randmz.c
health  115
coords  462 205
at      787

spawn   RandEnemyAliasMap #35
spawnscript data/scripts/enemies/randmz.c
health  115
coords  -30 210
at      787

spawn   RandEnemyAliasMap #36
spawnscript data/scripts/enemies/randmz.c
health  130
coords  462 190
at      787

spawn   RandEnemyAliasMap #37
spawnscript data/scripts/enemies/randmz.c
health  150
coords  -30 215
at      787

spawn   RandEnemyAliasMap #38
spawnscript data/scripts/enemies/randmz.c
health  115
#alias   Samanosuke
coords  462 190
at      787

spawn   RandEnemyAliasMap #39
spawnscript data/scripts/enemies/randmz.c
health  140
coords  -30 210
at      787

spawn   RandEnemyAliasMap #40
spawnscript data/scripts/enemies/randmz.c
health  90
coords  462 205
at      787

spawn   RandEnemyAliasMap #41
spawnscript data/scripts/enemies/randmz.c
#map     3
health  90
#alias   Three_X
coords  -30 170
at      787

spawn   RandEnemyAliasMap #42
spawnscript data/scripts/enemies/randmz.c
#map     3
health  100
#alias   Udo
coords  462 200
at      787

spawn   RandEnemyAliasMap #43
spawnscript data/scripts/enemies/randmz.c
#map     1
health  100
#alias   Smith
coords  -30 205
at      787

spawn   RandEnemyAliasMap #44
spawnscript data/scripts/enemies/randmz.c
coords  462 140
at      787 #prima era 90

spawn   RandEnemyAliasMap #45
spawnscript data/scripts/enemies/randmz.c
#map     3
health  115
#alias   Keiko
coords  -30 210
at      787

spawn   RandEnemyAliasMap #46
spawnscript data/scripts/enemies/randmz.c
health  70
coords  462 205
at      787

spawn   RandEnemyAliasMap #47
spawnscript data/scripts/enemies/randmz.c
#map     2
health  70
#alias   Billy
coords  -30 210
at      787

spawn   RandEnemyAliasMap #48
spawnscript data/scripts/enemies/randmz.c
#map     4
health  80
#alias   Robin
coords  462 190
at      787

spawn   RandEnemyAliasMap #49
spawnscript data/scripts/enemies/randmz.c
health  120
coords  -30 215
at      787

spawn   RandEnemyAliasMap #50
spawnscript data/scripts/enemies/randmz.c 
health  120
coords  462 190
at      787

spawn   RandEnemyAliasMap #51
spawnscript data/scripts/enemies/randmz.c
#map     1
health  80
#alias   Darren
coords  -30 210
at      787

spawn   RandEnemyAliasMap #52
spawnscript data/scripts/enemies/randmz.c
#map     3
health  100
#alias   Krauss
coords  462 205
at      787

spawn   RandEnemyAliasMap #53
spawnscript data/scripts/enemies/randmz.c
#map     2
health  150
#alias   Ukyo
coords  -30 210
at      787

#questo per attivare l'anim victory npc
group   1 1
at      0

spawn   delay
health  20
coords  200 190
at      0
 
I've checked the level text and found the issue : missing scripts declared in this delay spawn:
Code:
spawn   delay
@script
void main()
{
    setglobalvar("Vict", 0);
    setglobalvar("Victor", "X");
}
@end_script
health    5
coords  200 190
at      0

This script will end victory state and allow players and NPCs to go on.
I've set it like this to give time for them to perform victory animation.
 
Hmmm.... hard to say. It looks as if they are chasing an invisible enemy before playing victory animation. Which is strange since BossDed should've killed all enemies right after boss is defeated.
 
Back
Top Bottom