Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

NPC Pointers in latest build

28 replies · 5,725 views · Started 11 December 2007

My enemy->X and enemy->Y pointers seem to be completely broken in the new build, is anyone else getting this?

* Mild optimization to accessing NPC and Item pointer in scripts.
It's not this is it?

I only say that because my custom boss which manipulates a couple of enemies worked absolutely fandabbydosey in the last build, but now the enemies seem to feel it necessary to stay at (0,0). I haven't changed the script.

At least I can access Initial Data nowadays though.

EDIT: OK, this is the case, because I opened the same file up in 679, and they were fine.
I never knew you could just skip back builds like that! :O

Anyway, could someone please move this to the bug forum?

Ah nuts to me.

I'd take a bug that makes you constantly urinate over one that disables my bosses any day. ...)_( ....what?

Fraid I don't have any scripted items.

Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!

I had this for quite a large number of pages.

Joe123 wrote:CreateNPC. I've never had much luck with LoadNPC

Before your loop(s), insert Waitframes(4); just before the e = Screen->LoadNPC(); part. It takes about that long to load the Screen enemy.

Here's another problem i've encountered with pointers as well:


npc ninja;

if(boss == 0){
npc ninja = Screen->CreateNPC(255);
ninja->HP = enemyHP;
}
if(boss != 0){
Waitframes(4);
npc ninja = Screen->LoadNPC(boss);
ninja->HP = enemyHP;
}

while(true){

ninja->X = this->X;
ninja->Y = this->Y;

This is with build 675 also, and what happens is the enemy stays at 0,0 regardless of boss. (it's D2 variable)
But if I remove the if statements then it works fine..

example1st_quest sorry, I forgot to rename it...and you will apparently randomly "leap" untill Link can set things right.😉 I dunno, the global test script is erased but it's still saved in the buffer somehow. You might have to Quit->continue,for 675...well it should work in any beta.

As for Joe's problem, I don't know if it's the same thing or not.

Here is a file where I'm having problems. The bosses are on map 5, the level 4 cheat is '4'. If 'goto' dmap 7, screen 13 that should work.

It seems that this issue is intermittent, and I think I might have had it in build 679 aswell...

Gleeok wrote:Here's another problem i've encountered with pointers as well:

npc ninja;

if(boss == 0){
npc ninja = Screen->CreateNPC(255);
ninja->HP = enemyHP;
}
if(boss != 0){
Waitframes(4);
npc ninja = Screen->LoadNPC(boss);
ninja->HP = enemyHP;
}

while(true){

ninja->X = this->X;
ninja->Y = this->Y;

This is with build 675 also, and what happens is the enemy stays at 0,0 regardless of boss. (it's D2 variable)
But if I remove the if statements then it works fine..

That's not a bug. You're redeclaring the variable "ninja" inside the if blocks, which then shadows the outside "ninja" variable. You want


npc ninja;

if(boss == 0){
ninja = Screen->CreateNPC(255);
ninja->HP = enemyHP;
}
if(boss != 0){
Waitframes(4);
ninja = Screen->LoadNPC(boss);
ninja->HP = enemyHP;
}

while(true){

ninja->X = this->X;
ninja->Y = this->Y;

As for your example quest, Joe123, I'm not seeing anything go wrong with that custom boss. Is there a simpler example you could give me where things go wrong?

Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!
Script attempted to reference a nonexistent NPC!

Aaaaaaaaaaaaaaaaaaaaaahh!!!!!!!!!!!!!!

...oh noes. My boss broke. 😞
It worked fine in 675 but stopped working in 697 (or the earlier one)

Umm, I'll try to get everything here...let's see...

Hp of boss stuff:

		npc ghosted_enemy = Screen->CreateNPC(enemy_id);
ghosted_enemy->HP = enemy_hp;
ghosted_enemy->X = -16;
ghosted_enemy->Y = -16;

and the firing script:

//=======================================
// FFC SCRIPT FLAMETHROWER
//D0- minions to spawn (id number)
//D1- HP of the summoner
//D2- Max enemies on screen at once
//=======================================

ffc script Flamethrower{

void run(int enemy_id, int enemyHP, int enemy_swarm){

int enemy_number = 0;
npc enemy;

int slow_slowdown = 0;
bool death = false;

Waitframes(4);

npc fire_master = Screen->LoadNPC(1);
npc firestorm;
fire_master->HP = enemyHP;

while(true){

if(fire_master->isValid()){

this->X = fire_master->X; this->Y = fire_master->Y;

if(Screen->NumNPCs() < enemy_swarm){ npc firestorm = Screen->CreateNPC(enemy_id);}

firestorm->X = this->X;
firestorm->Y = this->Y;
}
else{ death = true;}

enemy_number = Screen->NumNPCs();

int tx = this->X;
int ty = this->Y;

while(enemy_number > 1){

enemy = Screen->LoadNPC(enemy_number);
enemy->X = tx; enemy->Y = ty;

if(death){
enemy->HP = 0;
enemy->X = -16;
enemy->Y = -16;
}
enemy_number--;

if(enemy_number == 25 || enemy_number == 50 || enemy_number == 75){ Waitframe();}
}
Waitframe();
}
}
}

What happens it the enemy dies by itself somehow. Initially it's hidden off the screen at -16, -16, then centers it on the ffc and attacks.

I think enemies were changed to instantly die if they are outside of the screen. That's probably your problem.

* If an enemy is moved more than 32 pixels out of the screen's bounds, it is removed. If you wanted a means for scripts to instantly remove enemies, I suppose this is it. ( _L_, 2007-12-03 02:38:48 )

Aarg! Well that's just great _L_, what was wrong with enemy->HP=0;?

Now I have -7 bosses that don't work at all. How are you supposed to hide enemies from Link's weapons now? Sticking it at -16, -16 was the best way to do this, now they die instantly.

:sadsadface:

[/rant].....
...

....
OK, perhaps the bug is that the boundary set is off a bit or needs to be increased a tad, 'cause they are dying at -16.

I thought that was his intent also, but it didn't really fix the bug did it?
The enemies still fly off the screen, which looks awful, and they now don't return instead of before when they did.
I don't see how that solved the problem at all...

Ah, I see now. Another problem is rotating ffc's with ghosted enemies attached to them, or patras. When they leave the screen the ghosted enemy is killed thus removing the ffc via !NPC->isValid(){ or the eyes die. Perhaps only kill enemies that have a propensity to leave the screen and get stuck outside of it, like leevers for example. That might not be the best fix because of the amount of work involved. There have been a few threads dealing with the enemy issue, perhaps an update to a couple of the "problem enemies" movement patterns when at screens edge?

Gleeok?
Did you look at my script?

Sorry to be annoying but I really need help and I thought you'd be good to go to.

Joe123 wrote:I thought that was his intent also, but it didn't really fix the bug did it?
The enemies still fly off the screen, which looks awful, and they now don't return instead of before when they did.
I don't see how that solved the problem at all...

joe, stop picking on L for attempting to fix a issue but not working out the best solution at the time >.> no one is perfect and the way you word your post is quite offensive.

also what was done back then doesnt take into account what has been done now. IE: his decision and line of thought would have been based on the immediate future at the time of the bug fix.

I wasn't trying to be insulting, sorry if I was, that was just how I saw it.
I think _L_'s done great things for the system. Some of the things (such as 'changing the floatiness of Link's jump) are damned irritating, but I've worked round that and I'm sure I can work such other changes if he makes them.

Just I don't personally see how what he did solves the problem.

But haven't the patra kids always left the screen?
How about in the original where the Tektite's would actually jump up on the subscreen, isn't this broken now too?
Maybe this needs to be changed back and dealt with from another angle?
You first had _L_ change the behavior and then DN come in and change it to try and correct the other change......
Seems like a can of worms has been unleashed.

'have _L_ change the behaviour' wouldn't be how I put what I did 😕
I posted a bug, and that's how _L_ fixed it.
I'm just saying I don't think it's really fixed very well.
I agree that what _L_ did is probably a good precaution for specific cases, perhaps that patra kid one (I don't really understand what's happening there), where enemies leave because of extraordinary means, but when you paralyze a hard coded enemy that was in The Legend of Zelda and then hit it with the sword and it flies off the screen, never to return, well it's not exactly consistent with Z1 and I personally don't think that it looks good, and I would say that it's a bug.

I don't want to start a big argument here.

The tektite thing's been fixed by the way, via the 'Subscreen Appears Above Sprites' (I think) quest rule.

Howabout some clever copy/paste action of some enemies existing movement, and add some else for flavor?

hmm...I guess I really don't have any good suggestions, I'm just repeating myself at this point.

Joe123 wrote:'have _L_ change the behaviour' wouldn't be how I put what I did 😕
I posted a bug, and that's how _L_ fixed it.
I'm just saying I don't think it's really fixed very well.
I agree that what _L_ did is probably a good precaution for specific cases, perhaps that patra kid one (I don't really understand what's happening there), where enemies leave because of extraordinary means, but when you paralyze a hard coded enemy that was in The Legend of Zelda and then hit it with the sword and it flies off the screen, never to return, well it's not exactly consistent with Z1 and I personally don't think that it looks good, and I would say that it's a bug.

I don't want to start a big argument here.

The tektite thing's been fixed by the way, via the 'Subscreen Appears Above Sprites' (I think) quest rule.

I'm not disagreeing with you, I pointed out the tektite's because as soon as they are made to not function as they did in the original, then you will have ZcAmazing and others pointing out inconsistencies which will put it all in a never ending loop, and stop a final release.

when I said "You first had _L_ change the behavior"
I didn't mean YOU, I meant what first happened was.... and then that....

Ah ok, sorry.

Looks like DN's fixed it now anyway:
* fixed the bug where enemies could be knocked off the edge of the screen.