Solved NPC Spawn enemy sequance.

Question that is answered or resolved.

kdo

Member
Hi guys, I need to make a NPC spawn a sequence of enemies as normally done in the level file, this should happen when the player hits the npc. Does anyone have any idea how I can do this? Has anyone done anything like this before?
 
Mmm.... let me get this clear:
You have an NPC spawned followed by a group of enemy spawns in level text. The group isn't spawned yet.
You want it that if player hits the NPC, that group is allowed to be spawned right?

I could imagine some tricks with pros and cons but before that may I know what is exactly you're making here?
 
Mmm.... let me get this clear:
You have an NPC spawned followed by a group of enemy spawns in level text. The group isn't spawned yet.
You want it that if player hits the NPC, that group is allowed to be spawned right?

I could imagine some tricks with pros and cons but before that may I know what is exactly you're making here?
I have a stage with just the npc spawned by level text. The Idea is, If player hit the npc a Quest start, the Quest is defeat a group of enemy spawned by the npc. When the player kill ALL enemys the Quest is over in the same stage where It started.
 
Thanks for the answer :D

So if player doesn't hit this NPC, player is stuck in the level right? IOW hitting the NPC is a must to complete the level.

One way to do this is by spawn an invisible enemy before the NPC is spawned. When NPC is hit, that enemy is killed to allow next enemy group to be spawned.
 
Thank you Bloodbane, I understand your idea, but I believe it would work for the first quest, because the level is open so the player can walk forward or backward everywhere since the beginning of the game. Would it be possible to spawn the sequence of enemies called by a script?
 
It's doable :D but remember 2 things:
1. Enemies spawned by script are fixed. You'll have to modify NPC's text to change spawned enemy.
2. Enemies spawned by script aren't affected by group. IOW you could spawn more than last group limits :sneaky:.

Anyways, when you mentioned sequence, does that mean you want enemy to appear one by one?
 
Yes, the anemys can appear one by one or in groups of 4, or more, so after player beat this group of enemy another enemy group appear, after some enemys a sub Boss and a Boss appears, fake ,they are Just stronger enemys, and after finish tem the player still in the same level and go finde another npc to Begin a New "Quest".
 
I've made a what you'd call draft for this quest giver NPC in this example enemy below.

I'm aware it's not NPC but I'm going to modify it later into an NPC :sneaky:.
This is just an example to show my idea on how to implement this quest giver.
This enemy is immune to all attacks. When attacked, he'll summon enemies in groups. He'll wait until all summoned enemies are defeated before summoning another one. He'll repeat this until 5 groups are defeated before he removes himself.
You may need to use your own sprites to test this.

Try this concept and tell me if this is what you asked :cool:
 

Attachments

I trying to use tha script but engine crashes, the log show the menssage: Failed to parse script file: 'data/scripts/enemy.c'!

I have the enemy.c inside the script folder, but iam using an old engine version to port for consoles, i could be the problem... or my enemy.c file.:cry:
 
Please read the log again and find the other error message before or after Failed to parse script file: 'data/scripts/enemy.c'

I think you're missing a function in enemy.c but I'm only guessing 😅.
 
There were missing the libary folder with basic.h, spawn.h and target.h. Now i have it in the script folder, but after that the engine crashes again, but now the log shows some problems that hasnt before, if i remove the entity that use the script the game starts with no problem.

Log

Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 5103616 Bytes

debug:nativeWidth, nativeHeight, bpp 1920, 1080, 32
OpenBoR v3.0 Build , Compile Date: Nov 2 2014

Game Selected: ./Paks/bor.pak

FileCaching System Init...... Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video............. 320x240 (Mode: 0, Depth: 8 Bit)

Loading menu.txt............. Done!
Loading fonts................ 1 2 3 4 5 6 Done!
Timer init................... Done!
Initialize Sound..............
Loading sprites.............. Done!
Loading level order.......... Done!
Loading model constants...... Done!
Loading script settings...... Done!
Loading scripts.............. Done!
Loading models...............

Cacheing 'agnes' from data/chars/agnes/agnes.txt
Cacheing 'Empty' from data/npcs/empty/empty.txt
Cacheing 'hunter' from data/enems/hunt/hunt.txt
Cacheing 'shot' from data/enems/hunt/shot.txt
Cacheing 'Dust01' from data/chars/misc/dust/dust01/dust01.txt
Cacheing 'flash' from data/chars/misc/flash/flash.txt
Cacheing 'fall' from data/chars/misc/fall/fall.txt
Cacheing 'land1' from data/chars/misc/land/land1.txt
Cacheing 'mission' from data/chars/venus/mission.txt
Cacheing 'neon1' from data/npcs/teste/neon1.txt
Cacheing 'neon2' from data/npcs/teste/neon2.txt
Cacheing 'neon3' from data/npcs/teste/neon3.txt
Cacheing 'neon4' from data/npcs/teste/neon4.txt
Cacheing 'teste' from data/npcs/teste/teste.txt
Cacheing 'seg' from data/npcs/seg/seg.txt
Cacheing 'anim' from data/npcs/anim/anim.txt
Cacheing 'zoe' from data/chars/zoe/zoe.txt
Cacheing 'hdoor' from data/npcs/hdoor/hdoor.txt
Cacheing 'hdoorb' from data/npcs/hdoor/hdoorb.txt
Cacheing 'luna' from data/chars/luna/luna.txt
Cacheing 'black' from data/chars/venus/bk.txt
Cacheing 'car' from data/npcs/car/car.txt

Loading 'Agnes' from data/chars/agnes/agnes.txt
Loading 'shot' from data/enems/hunt/shot.txt
Loading 'Dust01' from data/chars/misc/dust/dust01/dust01.txt
Loading 'Flash' from data/chars/misc/flash/flash.txt
Loading 'fall' from data/chars/misc/fall/fall.txt
Loading 'land1' from data/chars/misc/land/land1.txt
Loading 'mission' from data/chars/venus/mission.txt
Loading 'zoe' from data/chars/zoe/zoe.txt
Loading 'luna' from data/chars/luna/luna.txt
Loading 'bk' from data/chars/venus/bk.txt

Loading models............... Done!
Object engine init........... Done!
Input init................... No Joystick(s) Found!
Done!
Create blending tables....... Done!
Save settings so far........ Done!



Can't play music file ''
Level Loading: 'data/levels/stg2.txt'
Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 44498944 Bytes

Loading 'Empty' from data/npcs/empty/empty.txt
Loading 'teste' from data/npcs/teste/teste.txt
Loading 'neon1' from data/npcs/teste/neon1.txt
Loading 'neon2' from data/npcs/teste/neon2.txt
Loading 'neon3' from data/npcs/teste/neon3.txt
Loading 'neon4' from data/npcs/teste/neon4.txt
 
The engine chrashes again, now with this log

Script compile error: can't find function 'spawn04'

Script compile error in 'animationscript': spawn04 line 32, column 12

********** An Error Occurred **********
* Shutting Down *

Can't compile script 'animationscript' data/npcs/seg/seg.txt
 
Here's spawn04 for spawn.h library:
C:
void spawn04(void vName, float fX, float fY, float fZ)
{
    //Spawns entity based on left screen edge and center of playing field
    //
    //vName: Model name of entity to be spawned in.
    //fX: X distance relative to left edge
    //fY: Y height from ground
      //fZ: Z location adjustment

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int Direction = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int Screen = openborvariant("hResolution"); // Get screen width

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

   if (Direction == 0){ //Is entity facing left?                 
      fX = Screen-fX; //Reverse X direction to match facing and screen length
   }

      fZ = fZ+(openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z") )/2 ;

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX + XPos, fZ, fY); //Set spawn location.
    return vSpawn; //Return spawn.
}
 
The engine crashes again....

take a look at log.

log

Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 5107712 Bytes

debug:nativeWidth, nativeHeight, bpp 1920, 1080, 32
OpenBoR v3.0 Build , Compile Date: Nov 2 2014

Game Selected: ./Paks/bor.pak

FileCaching System Init...... Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video............. 320x240 (Mode: 0, Depth: 8 Bit)

Loading menu.txt............. Done!
Loading fonts................ 1 2 3 4 5 6 Done!
Timer init................... Done!
Initialize Sound..............
Loading sprites.............. Done!
Loading level order.......... Done!
Loading model constants...... Done!
Loading script settings...... Done!
Loading scripts.............. Done!
Loading models...............

Cacheing 'agnes' from data/chars/agnes/agnes.txt
Cacheing 'Empty' from data/npcs/empty/empty.txt
Cacheing 'hunter' from data/enems/hunt/hunt.txt
Cacheing 'shot' from data/enems/hunt/shot.txt
Cacheing 'Dust01' from data/chars/misc/dust/dust01/dust01.txt
Cacheing 'flash' from data/chars/misc/flash/flash.txt
Cacheing 'fall' from data/chars/misc/fall/fall.txt
Cacheing 'land1' from data/chars/misc/land/land1.txt
Cacheing 'mission' from data/chars/venus/mission.txt
Cacheing 'neon1' from data/npcs/teste/neon1.txt
Cacheing 'neon2' from data/npcs/teste/neon2.txt
Cacheing 'neon3' from data/npcs/teste/neon3.txt
Cacheing 'neon4' from data/npcs/teste/neon4.txt
Cacheing 'teste' from data/npcs/teste/teste.txt
Cacheing 'seg' from data/npcs/seg/seg.txt
Cacheing 'anim' from data/npcs/anim/anim.txt
Cacheing 'zoe' from data/chars/zoe/zoe.txt
Cacheing 'hdoor' from data/npcs/hdoor/hdoor.txt
Cacheing 'hdoorb' from data/npcs/hdoor/hdoorb.txt
Cacheing 'luna' from data/chars/luna/luna.txt
Cacheing 'black' from data/chars/venus/bk.txt
Cacheing 'car' from data/npcs/car/car.txt

Loading 'Agnes' from data/chars/agnes/agnes.txt
Loading 'shot' from data/enems/hunt/shot.txt
Loading 'Dust01' from data/chars/misc/dust/dust01/dust01.txt
Loading 'Flash' from data/chars/misc/flash/flash.txt
Loading 'fall' from data/chars/misc/fall/fall.txt
Loading 'land1' from data/chars/misc/land/land1.txt
WARNING: data/chars/venus/mission.txt tries to load a nonnumeric value at offset, where a number is expected!
erroneus string: offset
Loading 'mission' from data/chars/venus/mission.txt
Loading 'zoe' from data/chars/zoe/zoe.txt
Loading 'luna' from data/chars/luna/luna.txt
Loading 'bk' from data/chars/venus/bk.txt

Loading models............... Done!
Object engine init........... Done!
Input init................... No Joystick(s) Found!
Done!
Create blending tables....... Done!
Save settings so far........ Done!



Can't play music file ''
Level Loading: 'data/levels/stg2.txt'
Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 44793856 Bytes

Loading 'Empty' from data/npcs/empty/empty.txt
Loading 'teste' from data/npcs/teste/teste.txt
Loading 'neon1' from data/npcs/teste/neon1.txt
Loading 'neon2' from data/npcs/teste/neon2.txt
Loading 'neon3' from data/npcs/teste/neon3.txt
Loading 'neon4' from data/npcs/teste/neon4.txt
void spawn04(void vName, float fX, float fY, float fZ)
{
//Spawns entity based on left screen edge and center of playing field
//
//vName: Model name of entity to be spawned in.
//fX: X distance relative to left edge
//fY: Y height from ground
//fZ: Z location adjustment

void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
int Direction = getentityproperty(self, "direction");
int XPos = openborvariant("xpos"); //Get screen edge's position
int Screen = openborvariant("hResolution"); // Get screen width

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

if (Direction == 0){ //Is entity facing left?
fX = Screen-fX; //Reverse X direction to match facing and screen length
}

fZ = fZ+(openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z") )/2 ;

vSpawn = spawn(); //Spawn in entity.

changeentityproperty(vSpawn, "position", fX + XPos, fZ, fY); //Set spawn location.
return vSpawn; //Return spawn.
}
Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 47517696 Bytes

Release level data...........Level Unloading: 'data/levels/stg2.txt'
Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 47521792 Bytes

Done.
Total Ram: 2147483647 Bytes
Free Ram: 2147483647 Bytes
Used Ram: 46653440 Bytes

Done!
Release graphics data........ Done!
Release game data............

Unload 'Agnes' ............done.
Unload 'shot' ............done.
Unload 'Dust01' ............done.
Unload 'Flash' ............done.
Unload 'fall' ............done.
Unload 'land1' ............done.
Unload 'mission' ............done.
Unload 'zoe' ............done.
Unload 'luna' ............done.
Unload 'bk' ............done.
Unload 'Empty' ............done.
Unload 'teste' ............done.
Unload 'neon1' ............done.
Unload 'neon2' ............done.
Unload 'neon3' ............done.
Unload 'neon4' ............done.
Unload 'seg' ............done.

Release game data............ Done!
Release timer................ Done!
Release input hardware....... Done!
Release sound system......... Done!
Release FileCaching System... Done!

**************** Done *****************

Can't compile script 'animationscript' data/npcs/seg/seg.txt
 
Another error...

Script compile error in 'animationscript': shooter2 line 288, column 3

********** An Error Occurred **********
* Shutting Down *
 
Thank you Bloodbane, but i have no sucess with it...

log:

Script compile error: can't find function 'spawnscreen'

Script compile error in 'animationscript': spawnscreen line 15, column 12

********** An Error Occurred **********
* Shutting Down *

Can't compile script 'animationscript' data/npcs/seg/seg.txt
 
Back
Top Bottom