Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef DEFINE const int;
- typedef CONFIG const int;
- CONFIG NUM_MAPS = 1;
- CONFIG NUM_BOOL_PER_INT = 8; //May be able to go safely up to 16... 8 is safe though
- //
- DEFINE NUM_ENEMY_PER_SCREEN = 10;
- DEFINE NUM_ENEMY_PER_MAP = NUM_ENEMY_PER_SCREEN * 128;
- DEFINE NUM_ENEMIES = NUM_MAPS * NUM_ENEMY_PER_MAP;
- DEFINE NUM_BOOL = NUM_ENEMIES/NUM_BOOL_PER_INT;
- int enemyStore[NUM_ENEMIES];//Do not modify
- int enemyDead[NUM_BOOL];//Do not modify
- //Each index of this is the enemy from that screen index of the current screen. Make sure to check their `->isValid()` before using!
- npc screenEnemies[10];
- //Call this before `while(true)` in global active
- void __loadEnemiesFromQuest()
- {
- for(int map = 1; map <= NUM_MAPS; ++map)
- {
- for(int screen = 0x00; screen < 0x80; ++screen)
- {
- mapdata m = Game->LoadMapData(map,screen);
- for(int q = 0; q < 10; ++q)
- {
- enemyStore[(map*NUM_ENEMY_PER_MAP)+(screen*NUM_ENEMY_PER_SCREEN)+q] = m->Enemy[q];
- m->Enemy[q] = 0;
- }
- }
- }
- }
- //Call this somewhere in your global active, to check if enemies are dead, and make them stay dead permanently.
- //Make sure it is called AFTER spawnEnemies()!!!
- void __checkEnemyDeath()
- {
- if(Link->Action == LA_SCROLLING) return;
- for(int q = 0; q < 10; ++q)
- {
- if(!screenEnemies[q]->isValid())
- {
- killEnemy(q);
- }
- }
- }
- void killEnemy(int map, int screen, int index)
- {
- int temp = (map*NUM_ENEMY_PER_MAP)+(screen*NUM_ENEMY_PER_SCREEN)+index;
- enemyDead[Floor(temp/8.0)] |= 1<<(temp%8);
- }
- void killEnemy(int index)
- {
- killEnemy(Game->GetCurMap(), Game->GetCurScreen(), index);
- }
- void reviveEnemy(int map, int screen, int index)
- {
- int temp = (map*NUM_ENEMY_PER_MAP)+(screen*NUM_ENEMY_PER_SCREEN)+index;
- enemyDead[Floor(temp/8.0)] &= ~(1<<(temp%8));
- }
- void reviveEnemy(int index)
- {
- reviveEnemy(Game->GetCurMap(), Game->GetCurScreen(), index);
- }
- bool isDead(int map, int screen, int index)
- {
- int temp = (map*NUM_ENEMY_PER_MAP)+(screen*NUM_ENEMY_PER_SCREEN)+index;
- return (enemyDead[Floor(temp/8.0)] & (1<<(temp%8))) > 0;
- }
- bool isDead(int index)
- {
- isDead(Game->GetCurMap(), Game->GetCurScreen(), index);
- }
- void spawnEnemies()
- {
- if(Link->Action == LA_SCROLLING) return;
- DEFINE MAPINDEX = (Game->GetCurMap()*NUM_ENEMY_PER_MAP)+(Game->GetCurScreen()*NUM_ENEMY_PER_SCREEN)
- for(int q = 0; q < 10; ++q)
- {
- if(enemyStore[MAPINDEX+q] && !isDead(q))
- {
- npc n = Screen->CreateNPC(enemyStore[MAPINDEX+q]);
- positionEnemy(n, q);
- screenEnemies[q] = n;
- }
- else
- {
- screenEnemies[q] = Debug->Null();
- }
- }
- }
- void positionEnemy(npc n, int index)
- {
- //Write your own code here for positioning enemies which spawn. Each enemy will be passed to this function.
- //The index is the enemy's screen index, for things like enemy placement flags to be checked.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement