Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Enemy are alive after level_load #379265
07/31/11 11:15
07/31/11 11:15
Joined: Mar 2011
Posts: 38
P
parsgame Offline OP
Newbie
parsgame  Offline OP
Newbie
P

Joined: Mar 2011
Posts: 38
Hi
I have 10 enemies in my level.I kill for example five of them and go to next level.and now when I come back to prev level all of them are alive again.but I want that the rest of them just became alive.
Please help me if you know what should I do?

Re: Enemy are alive after level_load [Re: parsgame] #379266
07/31/11 11:23
07/31/11 11:23
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
save the stats of the enemies into a file

Code:
var killed_e[50]

[...]

//enemy killed
killed_e[id_of_enemy] = 1;

[...]

var fhandle = file_open_write("levelname_here.something");
var i;
for(i=0; i<50; i++)
{
    file_var_write(fhandle, killed_e[i]);
}
file_close(fhandle);



now.. after level_load, you read out the file:
Code:
var fhandle = file_open_read("levelname_again.something");
var i;
for(i=0; i<50; i++)
{
    killed_e[i] = file_var_read(fhandle);
    if(killed_e[i] == 1)
    {
        //call enemy death code
    }
}
file_close(fhandle);



^^


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Enemy are alive after level_load [Re: Espér] #379267
07/31/11 11:33
07/31/11 11:33
Joined: Mar 2011
Posts: 38
P
parsgame Offline OP
Newbie
parsgame  Offline OP
Newbie
P

Joined: Mar 2011
Posts: 38
thank you but what is id_of_enemy?

Re: Enemy are alive after level_load [Re: parsgame] #379268
07/31/11 11:39
07/31/11 11:39
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
when you create the enemies.. give em a skill

f.e.
Code:
#define id skill1

var ids_given = 1;

ent_create(blabla);


action enemy()
{
    my.id = ids_given;
    ids_given += 1;
    [...]

    //enemy death
    killed_e[my.id] = 1;
}



and after level_load, when you readout the file.. just ask with a loop and ent_next for the entities *.id, if it´s the same as the i from the for loop.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Enemy are alive after level_load [Re: Espér] #379271
07/31/11 12:03
07/31/11 12:03
Joined: Mar 2011
Posts: 38
P
parsgame Offline OP
Newbie
parsgame  Offline OP
Newbie
P

Joined: Mar 2011
Posts: 38
I got many errors!Can I use this code in A7?
This is for read out but what should type for ent_remove(?)?
Code:
function level_choose(level_var)
{
[...]
if(level_var==7){	
        level_load(bighome_level);
	var fhandle = file_open_read("bighome_level.txt");
	var i;
	for(i=0; i<50; i++)
	  {
		killed_e[i] = file_var_read(fhandle);
		if(killed_e[i] == 1)
	   	 {
	    	ent_remove("what should i add here?!");
	    	 }
	   }
	file_close(fhandle);
        return;}
}



and here I save it to a file,But I use this function for all of my enemies.
Code:
function AI_die() 
{

	proc_kill(1);
	/////////save kardan enemyhaye morde dar file
	killed_e[my._ENEMY_ID] = 1;
	var fhandle=file_open_write("bighome_level.txt");
	var i;
	for(i=0; i<50; i++)
	{
		file_var_write(fhandle, killed_e[i]);
	}
	file_close(fhandle);
	[...]


also i dont create the enemies during levels.

Last edited by parsgame; 07/31/11 12:21.
Re: Enemy are alive after level_load [Re: parsgame] #379273
07/31/11 12:27
07/31/11 12:27
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
yes.. but you made many mistakes xD
I just made example codes..

The saving code needs to be set before loading a new level.. not after killing something.
after level_load, you need to set a wait of 2 frames.

for ent_remove, you need to make a loop, including ent_next to scan all entities of the level, and ask for their id.

try replacing your ent_remove with this:
Code:
for(you = ent_next(NULL); you; you = ent_next(you)) 
    if(killed_e[you._ENEMY_ID] == 1) // scan for ids and for the stat
    {
      ent_remove(you);
    }
  }




Be careful.. the array (killed_e) needs to be big enough to store ALL Level Entities.

When there are 3000 Enemies on your greatest map.. the killed_e needs to be
var killed_e[3001]; //global
to be sure theres enough space for the ids.


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Enemy are alive after level_load [Re: Espér] #379274
07/31/11 12:40
07/31/11 12:40
Joined: Mar 2011
Posts: 38
P
parsgame Offline OP
Newbie
parsgame  Offline OP
Newbie
P

Joined: Mar 2011
Posts: 38
thank you very much for your quickly answer
but another question
should I add trees and stones to killed_e or just the actions with my.id = ids_given;?
and should I set save code in main function before level_load?
in for() comment the engine give this error
number of brackets
is same comment in cscript and c-lite?

Last edited by parsgame; 07/31/11 13:10.
Re: Enemy are alive after level_load [Re: parsgame] #379277
07/31/11 14:50
07/31/11 14:50
Joined: Mar 2011
Posts: 38
P
parsgame Offline OP
Newbie
parsgame  Offline OP
Newbie
P

Joined: Mar 2011
Posts: 38
I use for comment like below but the engine give number of bracket error
Code:
for(countme=1;countme<10;countme++)
	{
			file_var_write(fhandle, ids_given);
	}


what is wrong?

Re: Enemy are alive after level_load [Re: parsgame] #379280
07/31/11 16:52
07/31/11 16:52
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
can you show me the complete function?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Enemy are alive after level_load [Re: Espér] #379282
07/31/11 17:04
07/31/11 17:04
Joined: Mar 2011
Posts: 38
P
parsgame Offline OP
Newbie
parsgame  Offline OP
Newbie
P

Joined: Mar 2011
Posts: 38
i give error with for loop commend!
this the reading code
Code:
var killed_e[4];
function level_choose(level_var)
{
[...]
	level_load(bighome_level);
		var fhandle;
		fhandle=file_open_read("bighome_level.txt");
		var i;
		for(i=0; i<4; i++)
		{
			killed_e[i] = file_var_read(fhandle);
			for(you = ent_next(NULL); you; you = ent_next(you)) 
			if(killed_e[you.ids_given] == 1) // scan for ids and for the stat
			{
				ent_remove(you);
			}
		}
	
file_close(fhandle);*/
//return;
}



Last edited by parsgame; 07/31/11 17:06.
Page 1 of 2 1 2

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1