[DEMO] Scripted Select Screen

Is it possible to setup multiple parents to the NPC and setup multiple NPC's to 1 parent?

The former is impossible cause an entity can only have one parent. The latter is possible.

is there a way to setup how often the NPC will use the attack or FREESPECIAL only when the mp is available?
Enemies and NPCs won't perform FREESPECIAL if they don't have enough MP already.

Can you please give me an example of this?

Do you know how to use animationscript? if you know, I could share a function for that purpose.
But for now, there's sample script I could share to show what I mean with parent setting:
Code:
spawn    Anita
@script
void main()
{
    void P1 = getplayerproperty(0, "entity");
    void self = getlocalvar("self");

    changeentityproperty(self,"parent", P1);
}
@end_script
map    2
coords    100 220 1
at    0

Anita is NPC with subtype follow.
Try declaring that script to your NPC and see what happens :)
 
The former is impossible cause an entity can only have one parent. The latter is possible.


Enemies and NPCs won't perform FREESPECIAL if they don't have enough MP already.



Do you know how to use animationscript? if you know, I could share a function for that purpose.
But for now, there's sample script I could share to show what I mean with parent setting:
Code:
spawn    Anita
@script
void main()
{
    void P1 = getplayerproperty(0, "entity");
    void self = getlocalvar("self");

    changeentityproperty(self,"parent", P1);
}
@end_script
map    2
coords    100 220 1
at    0

Anita is NPC with subtype follow.
Try declaring that script to your NPC and see what happens :)
Thank you very much. The script seems to work for only player 1. so I guess I will have to use for loop for 4 players.

If player 1, 2, 3, or 4 spawns a NPC ally with subtype follow in a level,
doesn't the engine automatically assign this player as the parent of this NPC without a parent animationscript?
If the answer is yes, what's the purpose for setting up the parent animationscript?
If I want to despawn this NPC after a period of time, how I can do that?
Thank you
 
The script seems to work for only player 1

That's because it's specifically for player 1. For player 2, you need to modify it into this:
void P1 = getplayerproperty(1, "entity");

0 for player 1, 1 for 2 and so on.

doesn't the engine automatically assign this player as the parent of this NPC without a parent animationscript?

There are two ways to spawn other entities without script and without shooting them: spawnframe and summonframe. I may need to check but if I'm not mistaken, the latter assigns spawning player as the parent while the former doesn't.
IOW it depends on how you spawn NPC.

If I want to despawn this NPC after a period of time, how I can do that?

Lifespan should be enough do kill the NPC. Unless, there's other thing you want during despawning?
 
@Bloodbane,

Both native sub entity commands set the child's parent to spawning entitiy's pointer. The difference is that summon populates a child property on the parent entity with the spawned entity's pointer. That's what enables unsummon effect.

Spawn:

new_entity->parent = parent_entity

Summon:

new_entity->parent = parent_entity
parent_entity->child = new_entity

There's only one parent and child property per entity, so if you want an entity to have more children, you'll need to record them manually with scripted variables. The child property does absolutely nothing in native logic other than unsummon effect. Parent is used to determine what entity a follow type NPC tries to stay near.

HTH,
DC
 
Last edited:
The former is impossible cause an entity can only have one parent. The latter is possible.


Enemies and NPCs won't perform FREESPECIAL if they don't have enough MP already.



Do you know how to use animationscript? if you know, I could share a function for that purpose.
But for now, there's sample script I could share to show what I mean with parent setting:
Code:
spawn    Anita
@script
void main()
{
    void P1 = getplayerproperty(0, "entity");
    void self = getlocalvar("self");

    changeentityproperty(self,"parent", P1);
}
@end_script
map    2
coords    100 220 1
at    0

Anita is NPC with subtype follow.
Try declaring that script to your NPC and see what happens :)
I've tried to create my own helper Entity, but it only showed up very quickly (like a blink of an eye) then disappeared.
Can someone please take a look at my code and see what I did wrong? Thank you so much
I want to be able to spawn this Mikey anytime in the level.
I've tried to spawn this entity as @cmd spawn01 "Mikey" 0 0 0
I've also tried @cmd projectile 1 "Mikey" 0 0 0

Code:
void spawn01(void vName, float fX, float fY, float fZ)
{

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

    if (iDirection == 0){ //Is entity facing left?                
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
   
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
   
    return vSpawn; //Return spawn.
}

Code:
name                Mikey
type                npc
subtype             follow
lifespan            60
remove                0
nolife              1
hostile             enemy
candamage           enemy obstacle
speed               20
running             40 1 1 5 1
turndelay           0    3
bounce              1
noquake             1
#shadow 3
gfxshadow 1 3
diesound            data/chars/players/Helpers/Ally/die1.wav
flash               flash
bflash              guard
dust                dust01
toflip              1
nodieblink          1
falldie             2

palette data/chars/players/Helpers/Ally/Mikey_Stand02.gif #1
animationscript        data/scripts/animatedscripts.c
ondrawscript        data/scripts/shadows.c

load                quake
   
       
anim    idle
    @script
    void self = getlocalvar("self");
            if(getentityproperty(self, "health")<=0)  {
                damageentity(self, self, 100, 1, 1);
             }
    @end_script
    loop    1
    offset    344 550
    bbox 0 0 0 0
    delay    5
    frame    data/chars/players/Helpers/Ally/Mikey_Stand01.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Stand02.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Stand01.gif
   
anim    idle1
    @script
    void self = getlocalvar("self");
            if(getentityproperty(self, "health")<=0)  {
                damageentity(self, self, 100, 1, 1);
             }
    @end_script
    loop    1
    offset    344 550
    bbox 0 0 0 0
    range 0 30
    delay    5
    frame    data/chars/players/Helpers/Ally/Mikey_Stand01.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Stand02.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Stand01.gif
   
anim    walk
    loop    1
    offset    344 550
    bbox    0 0 0 0
    range 30 90
    delay    5
    frame    data/chars/players/Helpers/Ally/Mikey_Walk01.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Walk02.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Walk03.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Walk04.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Walk05.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Walk06.gif
    frame    data/chars/players/Helpers/Ally/Mikey_Walk07.gif
   
anim    attack1  
    fastattack    1
    loop    0
    offset    344 550
    bbox 0 0 0 0
    range 0 29
    delay    4
    frame    data/chars/players/Helpers/Ally/Mikey_SKill1_01.gif
    frame    data/chars/players/Helpers/Ally/Mikey_SKill1_02.gif
    frame    data/chars/players/Helpers/Ally/Mikey_SKill1_03.gif
    attack1 378 359 146 163 10 0 0 0 20 15
    delay    8
    frame    data/chars/players/Helpers/Ally/Mikey_SKill1_04.gif
    attack  0 0 0 0 0 0 0 0 0 0
    delay    4
    frame    data/chars/players/Helpers/Ally/Mikey_SKill1_05.gif
 
Last edited:
You should remove toflip and remove from Mikey's header cause those aren't needed for NPCs (and most entities actually).

Try giving Mikey PAIN, FALL and RISE animation. Just use temp sprites such as idle sprites.
 
You should remove toflip and remove from Mikey's header cause those aren't needed for NPCs (and most entities actually).

Try giving Mikey PAIN, FALL and RISE animation. Just use temp sprites such as idle sprites.
I added PAIN, FALL and RISE animations and removed toflip and remove off the header but result is still the same.
Thank you
 
Strange... how do you exactly spawn Mikey?

Hmmm...
turndelay 0 3

Mikey would need TURN animation to use this command. Does he have one?

BTW this thread is for discussing Scripted Select screen not for discussing NPC summon problem. So if you have more question about the latter, please start new thread :)
 
Strange... how do you exactly spawn Mikey?

Hmmm...


Mikey would need TURN animation to use this command. Does he have one?

BTW this thread is for discussing Scripted Select screen not for discussing NPC summon problem. So if you have more question about the latter, please start new thread :)
I don't have TURN animation or turndelay.
Thank you for trying to help me and sorry for hi-jacking your thread. I have had time to look over your Scripted Select Screen sample yet. I'm sure I'll have questions after I do.
I can only learn 1 thing at a time 😀.
I'll create a new thread with the title
How to spawn a NPC anytime in a level/stage?
I'll chat to you over there,
Thank you so much
 
This is way too off-topic here and we're supposed to discuss about scripted select screen instead of summoning NPC. Can @danno or @DCurrent make this off-topic a new thread for this?
 
This is way too off-topic here and we're supposed to discuss about scripted select screen instead of summoning NPC. Can @danno or @DCurrent make this off-topic a new thread for this?
My apology. I was afraid there might be a thread about spawning the NPC, so I didn't want to create another thread to avoid overloading the site.
I just created a new thread here:
Thank you all
 
Back
Top Bottom