PDA

View Full Version : An ffc, item, and global script that together..



Gleeok
11-27-2007, 12:31 AM
...does absolutely nothing!



What it's supposed to do:



Use an item to call an ffc,

once the ffc touches an enemy it triggers a global int(true), and stores the enemy's X and Y in more global integers.

then the global script takes over duties and loads the appropriate npc, x and y of that npc, and holds the npc at the spot it came into contact with the ffc. (paralyzes up to 4 enemies at once.)

the ffc part appears to work just fine, and within the enemy loop it triggers global variabe is_held true. here is an example of that:



if(is_held1 == false){
statue1 = current_enemy_number;
held1_x = current_enemy->X;
held1_y = current_enemy->Y;
is_held1 = true; }




Here is the entire global script in question:



//GLOBAL VARS


int manifo_level = 4; // statue
int manifo_exp = 0;

int statue1;
int statue2;
int statue3;
int statue4;

bool is_held1 = false;
bool is_held2 = false;
bool is_held3 = false;
bool is_held4 = false;

int held1_x; int held1_y;
int held2_x; int held2_y;
int held3_x; int held3_y;
int held4_x; int held4_y;


global script Doomsday{

void run(){


npc paralyze1;
npc paralyze2;
npc paralyze3;
npc paralyze4;

bool set_statue1 = false;
bool set_statue2 = false;
bool set_statue3 = false;
bool set_statue4 = false;

bool manifo_init1 = false;
bool manifo_init2 = false;
bool manifo_init3 = false;
bool manifo_init4 = false;


while(true){



//===============================
// MANIFO SPELL EFFECT
//===============================

if(is_held1){
if(manifo_init1 == false){
npc paralyze1 = Screen->LoadNPC(statue1);
set_statue1 = true; manifo_init1 = true;
}
else{
if(set_statue1){

if(paralyze1->isValid()){

paralyze1->X = held1_x;
paralyze1->Y = held1_y;
}
else{
set_statue1 = false;
manifo_init1 = false;
is_held1 = false;
}
}
}
}
if(manifo_level >= 2){
if(is_held2){
if(manifo_init2 == false){
npc paralyze2 = Screen->LoadNPC(statue2);
set_statue2 = true; manifo_init2 = true;
}
else{
if(set_statue2){

if(paralyze2->isValid()){

paralyze2->X = held2_x;
paralyze2->Y = held2_y;
}
else{
set_statue2 = false;
manifo_init2 = false;
is_held2 = false;
}
}
}
}
if(manifo_level >= 3){
if(is_held3){
if(manifo_init3 == false){
npc paralyze3 = Screen->LoadNPC(statue3);
set_statue3 = true; manifo_init3 = true;
}
else{
if(set_statue3){

if(paralyze3->isValid()){

paralyze3->X = held3_x;
paralyze3->Y = held3_y;
}
else{
set_statue3 = false;
manifo_init3 = false;
is_held3 = false;
}
}
}
}
if(manifo_level == 4){
if(is_held4){
if(manifo_init4 == false){
npc paralyze4 = Screen->LoadNPC(statue4);
set_statue4 = true; manifo_init4 = true;
}
else{
if(set_statue4){

if(paralyze4->isValid()){

paralyze4->X = held4_x;
paralyze4->Y = held4_y;
}
else{
set_statue4 = false;
manifo_init4 = false;
is_held4 = false;
}
}
}
}
}
}
} // end manifo hold

Waitframe();
}
}
}


The problem with doing this stuff is, it's hard to figure out the problem when something goes horribly wrong.

Contribute to the "save the Gleeok mental agony" foundation..?

DarkDragon
11-27-2007, 12:38 AM
Whenever I get a script that behaves completely unexpectedly I liberally sprinkle Trace()s to get a better idea of what's going on.

I do that when debugging ZC too ;)

Gleeok
11-27-2007, 01:08 AM
Whenever I get a script that behaves completely unexpectedly I liberally sprinkle Trace()s to get a better idea of what's going on.

I do that when debugging ZC too ;)

Oh! Now that your here, I need to know how trace() works.

Every time I tried it, nothing usefull printed to allegro...which means:

-I am using it wrong, or..
-I have no idea how to actually use it.

I suspect it's both.

This would be usefull for like at least five scripts I have that do absolutely nothing. :lol:

DarkDragon
11-27-2007, 01:20 AM
It prints whatever is passed to it to allegro.log. If nothing is being printed, the Trace is not being reached.

Gleeok
11-27-2007, 02:13 AM
It's telling me it can't match trace(bool)..
does trace only work with floats and int? Do I have to change all the globals to integers?


if(is_held1){ Trace(is_held1);

DarkDragon
11-27-2007, 02:20 AM
Yes, Trace takes in floats.

Gleeok
11-27-2007, 03:33 AM
Aarg!!! Your gonna love this. ;) I finally traced it to this Line:


if(paralyze1->isValid()){

paralyze1->X = held1_x;
paralyze1->Y = held1_y;
}

Paralyze1 was invalid yet Trace(statue1);came back 1. As it should, because there was only 1 npc on the screen I tested this on.

Thus:

npc paralyze1 = Screen->LoadNPC(statue1);
should return Screen->LoadNPC(1);


So I removed the line :


if(paralyze1->isValid){

But instead I got:



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




Trace(held1_x);Trace(held1_y);

The 145, 32 means that the enemy X, and Y are indeed being saved in held1_x,y.


The enemy should be held at 145,32....



...???

DarkDragon
11-27-2007, 03:37 AM
It's a bug. Already fixed in the next build http://www.armageddongames.net/forums/showthread.php?t=100380

Gleeok
11-28-2007, 02:29 AM
Well it didn't work on screen enemies 2-10 also so I rewrote it within th ffc script itself instead of using the global, and changed the global vars to non global, and it worked fine right from the get-go.

Maybe there's something funky going on with global npc pointers?