Solved Spawn Enemies/NPCs Wielding Weapons

Question that is answered or resolved.

Crimsondeath

Active member
Hi to everyone,
I don't know if it's a bug of the engine or my mistake, but I'm trying to spawn entities wielding weapons but just one has it when the level starts:

9CJr4rf.png


Code:
#The two entities here:
spawn    Patrullero #<-- this entity spawns wielding the Shield.
weapon    Patrullero19
coords    240 200 0
at    0

spawn    Patrullero_sentado
coords    270 230 0
flip    1
at    0

spawn    Patrullero_sentado
coords    300 180 0
flip    1
at    0

spawn    Patrullero #<-- this not :(
weapon    Patrullero19
coords    300 270 0
at    0
 
Yes x.x, I think I asked here about a way for add multiple spawn animation to one entity long time ago, but didn't got an answer :( .
Maybe I missed your topic, because we already talked about it many times here.

Anyway, you just need to add some lines of coding when you spawn the entity, like this:

spawn Linda
alias Linn
@script void main() {
performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW10"));
} @end_script

coords 620 199 0
at 0

This will make your entity to spawn into FOLLOW10 anim, for example

edit: btw the links in your signature are broken
 
Maybe I missed your topic, because we already talked about it many times here.

Anyway, you just need to add some lines of coding when you spawn the entity, like this:



This will make your entity to spawn into FOLLOW10 anim, for example

edit: btw the links in your signature are broken
¡Oh sh*t! 🤯

I wish I known this before (I wasted a lot of time x'd)

I think this can work with the weapon wielding issue as well, I can add "weaponframe" to an enemy follow anim frame, that works better.

Thank you so much!
 
oh yeah, it will work too :)
Do you think It could work with the spawn script? :( I tried to modify it a bit adding vAnim, but throws me as "an exception" :(

Code:
void spawn03(void vName, float fX, float fY, float fZ, void vAnim)
{
  //spawn01 (Generic spawner)
  //Damon Vaughn Caskey
  //07/06/2007
  //
  //Spawns entity next to caller.
  //
  //vName: Model name of entity to be spawned in.
  //fX: X location adjustment.
  //fY: Y location adjustment.
  //fZ: Z location adjustment.

  void self = getlocalvar("self"); //Get calling entity.
  void vSpawn; //Spawn object.
  char vAnim; // Animation
  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.
  performattack(vSpawn, openborconstant(vAnim)); // Animation.
    
  return vSpawn; //Return spawn.
}
 
Do you think It could work with the spawn script? :( I tried to modify it a bit adding vAnim, but throws me as "an exception"
But you don't need this script, as everything on that code is already done by the normal spawn with those lines I gave you.

Also, spawnscript needs to be used inside main(). So you would need to make a file an link to it.

But doing this will defeat the proposed of to be flexible...
 
But you don't need this script, as everything on that code is already done by the normal spawn with those lines I gave you.

Also, spawnscript needs to be used inside main(). So you would need to make a file an link to it.

But doing this will defeat the proposed of to be flexible...
What happen is that some enemies are spawn from another entities like that boat:
oGpCPVP.gif


Here is the boat code:
Code:
anim    idle
    loop    1 67 69
    offset    104 53
    delay    1
    move    4
    frame    data/chars/panels/stage3/lancha_e1a.gif
     ...
    frame    data/chars/panels/stage3/lancha_e1a.gif
    @cmd    spawn01 "Brandon_" -29 25 0     #<-- they spawn here xd
    frame    data/chars/panels/stage3/lancha_e.gif
    @cmd    spawn01 "Bryan_" -55 25 0        #<-- and here xd
    frame    data/chars/panels/stage3/lancha_e.gif
    frame    data/chars/panels/stage3/lancha_e.gif
    frame    data/chars/panels/stage3/lancha_e.gif

I need they spawn with their respective follow animation (jumping from the boat), but the script (spawn01) only spawn them with the default spawn animation :( .
 
Last edited:
ah, you would need a different script.

Put this on your animationscript:

C-like:
void spawnAni(void vName, float fX, float fY, float fZ, int Ani, float Vx, float Vy, float Vz)
{
  //spawnB (Generic spawner) + Specific animation + velocities
  //Damon Vaughn Caskey + Douglas Baldan
  //07/06/2007
  //
  //Spawns entity next to caller.
  //
  //vName: Model name of entity to be spawned in.
  //fX: X location adjustment.
  //fZ: Y location adjustment.
      //fY: Z location adjustment.


  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.
          Vx= -Vx; //Reverse X velocity 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.
    if (vSpawn){// safe check


  changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
  changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
  performattack(vSpawn, Ani);
  changeentityproperty(vSpawn, "velocity", Vx, Vy, Vz);
  changeentityproperty(vSpawn, "parent", self); //Set parent.


  return vSpawn; //Return spawn.
  }
}

Usage:

@cmd spawnAni "Brandon_" -29 25 0 openborconstant("ANI_FOLLOW1") 1 2 3

Notes:
- scripts are case sensitive. Its "spawnAni", not "spawnani" or any other variation
- you need to give the animation using openborconstant("ANI_NAMEOFTHEANIMATION")
- the last 3 values are velocities x, y and z. If you don't want any velocity, put NULL()
 
Maybe I missed your topic, because we already talked about it many times here.

Anyway, you just need to add some lines of coding when you spawn the entity, like this:



This will make your entity to spawn into FOLLOW10 anim, for example

edit: btw the links in your signature are broke
It's possible to use that script while using this one?
Code:
spawn a3
health    100
spawnscript data/scripts/noscpos.c
aggression 4
weapon    knu
item coin60
flip 1
coords 73 137
at 0

edit: Also, how would be the case if I want different spawn animations for players? for different stages for example
 
Last edited:
It's possible to use that script while using this one?
No. you can use only one spawnscript per time.
but you can copy the content on that code and paste on the level

edit: Also, how would be the case if I want different spawn animations for players? for different stages for example
That requires a different approach: [Tutorial] Custom Spawn/intro for stages

Currently, I am testing a new method which doesn't requires a custom animation per intro (unless you want something very specific).
 
Hi again,
One question, it's possible that enemies drop the weapons they're wielding?

I use the command "weaploss 1" but when they're knockeddown they don't drop the weapon they have, It just dissapear x.x (even if the weapon exist in the game as an item). They get the weapon by the "Weaponframe" command.
 
Hi again,
One question, it's possible that enemies drop the weapons they're wielding?

I use the command "weaploss 1" but when they're knockeddown they don't drop the weapon they have, It just dissapear x.x (even if the weapon exist in the game as an item). They get the weapon by the "Weaponframe" command.
It’s possible. I can’t check the enemy file right now coz I’m not at home, but check in the video below: one enemy pick a knife offscreen and he’ll drop it on knockdown. Also another enemy and the boss will both drop a knuckle. The boss will even take the cola item:
 
It’s possible. I can’t check the enemy file right now coz I’m not at home, but check in the video below: one enemy pick a knife offscreen and he’ll drop it on knockdown. Also another enemy and the boss will both drop a knuckle. The boss will even take the cola item:
Yeah! when they have the "get" animation to get the weapon in a stage and they drop it when they're knockedown, everything is fine there.

But here enemies get the weapon by "weaponframe" during their "spawn" (follow) animation (using O Ilusionista method):
Code:
#Stage spawn
spawn Bryan
@script void main() {
performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW10"));
} @end_script
coords 280 220 0
at 0
The enemy spawn animation code:
Code:
anim    follow10
            loop    0
            offset    30 90
            bbox    12 0 40 92
            delay    1
            frame    data/chars/perejil/idle.gif
            weaponframe    1 8    # <--- They get the weapon here xd
            frame    data/chars/perejil/idle.gif

When this spawed enemy is knockedown the weapon just disapear :( .
 
they use the weapon too or just drop the weapon?
Check here at around 1:25, purple enemy will use the knuckle and then he’ll go grab a knife. Later at around 2:00 mark, a white enemy will grab a knife, will attack with the knife without throwing it, and then he’ll throw the knife.

@Crimsondeath ohh I don’t think I’m using that script, so I can’t tell about that sorry.
 
@Crimsondeath



why this enemy have so many weapons? can you give more detailed info, what is your enemy weaponframe 8?

C:
weapons {name1} {name2} {name3} {name4} {name5} {original name}
Hi, well the game has many kind of weapons, they can be used for many entities in the game one of them is the enemy "Bryan".

To sort all those weapons I'm using weapnum (Weapon number) so all entities that use (for example) weapon number 8 (a rod) are called with a number: "Bryan8", "Isolda8", etc.

Here is Bryan header code:
Code:
name Bryan
health    40
score    2000
speed 10
type    enemy
shadow    4
paingrab 1
jugglepoints 15
knockdowncount 15
aggression 5
turndelay   12
bounce    1
noquake     1
nodieblink        1
risetime         120
diesound data/sounds/die2.wav
hostile player npc
candamage player npc obstacle
projectilehit   enemy obstacle
weapons none none none none none none none Bryan8 none none none none none none none none none none Bryan

icon    data/chars/perejil/icon.gif
icondie    data/chars/perejil/icond.gif

palette    data/chars/perejil/idle.gif

animationscript  data/scripts/fscript.c

Also Bryan's weapon number 8 header code:
Code:
name Bryan8
type    none
shadow    4
weaploss 1 8
weapnum 8 #<---  here is the weapon number for the entity
jugglepoints 15
knockdowncount 15
atchain    1
thold   20
holdblock 1
blockpain 1
bounce 1
noquake 1
paingrab 1

palette    data/chars/perejil/perejil8//idle.gif

animationscript  data/scripts/fscript.c

And the header of the Weapon:
Code:
name    Palo #(Rod)
type     item
subtype  weapon
counter  2
shadow    2
weapnum  8 #<--- here is the weapon number for the item
weaploss 1 8
typeshot 1

palette data/chars/item/rod/idle1a.gif

Here a small vid of the problem:

The Weapon disappear in the first knockdown hit (at 0:03) instead of being dropped. I gave Bryan the weapon "Palo" (Rod) by "Weaponframe" in his follow animation:
Code:
anim    follow10
    loop    0
    offset    30 90
    bbox    12 0 40 92
    delay    1
    frame    data/chars/perejil/idle.gif
    weaponframe    1 8 #<---  here is the weapon number 8 for calling the rod
    frame    data/chars/perejil/idle.gif

Maybe I'm missing something? :unsure:
 
Back
Top Bottom