NPCs fail to appear after writing new values to the packfile.
For some reason, just adding the script types after edefSCRIPT and before edefLAST caused all of the values in the enemy editor to corrupt themselves. I'm not sure why.
Thus, instead of mucking with that table, I added an entirely new array for them/
Here's what I've done:
I added:
//zdefs.h
enum { scriptDEF1, scriptDEF2, scriptDEF3, scriptDEF4, criptDEF5, scriptDEF6, scriptDEF7, scriptDEF8, scriptDEF9, scriptDEF10, scriptDEFLAST };
in struct guydata, I added byte scriptdefense[scriptDEFLAST];
//guys.h
Likewise, I added public byte scriptdefense[scriptDEFLAST]; to the guydata struct.
//zq_class.cpp
To writeguys(), I added:
Code:
for(int j=0; j < scriptDEFLAST; j++)
{
if(!p_putc(guysbuf[i].scriptdefense[j],f))
{
new_return(51);
}
}
I further tried this with a return of 50, disabling the misc12 writeout, to verify that it wasn't the return value.
//ffscript
I added all the required ZScript things to the ZScript files. That part does work and writing to, and reading from n->ScripDefense[10] works flawlessly.
//guys.cpp
I added:
Code:
for(int w=0; w < scriptDEFLAST; w++)
scriptdefense[w]=d->scriptdefense[w];
inside enemy::enemy(fix X,fix Y,int Id,int Clk) : sprite()
Finally, I worked on zq_custom.cpp
I added jwin stuff, which does seem to work:
Tables stuff:
Code:
static int enedata_defense3_list[] =
{
193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,-1
};
//
static TABPANEL enedata_tabs[] =
{
{ (char *)"Data 1", D_SELECTED, enedata_data_list, 0, NULL },
{ (char *)"Data 2", 0, enedata_data2_list, 0, NULL },
{ (char *)"Misc. Flags", 0, enedata_flags_list, 0, NULL },
//{ (char *)"Flags 2", 0, enedata_flags2_list, 0, NULL },
{ (char *)"Defenses 1", 0, enedata_defense_list, 0, NULL },
{ (char *)"Defenses 2", 0, enedata_defense2_list, 0, NULL },
{ (char *)"Spawn Flags", 0, enedata_flags3_list, 0, NULL },
{ (char *)"Defenses 3", 0, enedata_defense3_list, 0, NULL },
{ NULL, 0, NULL, 0, NULL }
};
//table
//193 - sccript 1
{ jwin_text_proc, 6, 51, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 1 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 67, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 2 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 83, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 3 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 99, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 4 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 115, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 5 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 131, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 6 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 147, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 7 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 163, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 8 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 179, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 9 Weapon Defense:", NULL, NULL },
{ jwin_text_proc, 6, 196, 80, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Script 10 Weapon Defense:", NULL, NULL },
//203 script 1 pulldown
{ jwin_droplist_proc, 126, 51-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 67-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 83-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 99-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 115-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 131-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 147-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 163-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 179-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ jwin_droplist_proc, 126, 196-4, 115, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &defense_list, NULL, NULL },
{ NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
};
..and in the edit_enemyedit() function:
Code:
//Read in the enemy deences to the editor.
for(int j=0; j <= edefBYRNA; j++)
{
enedata_dlg[j+161].d1 = guysbuf[index].defense[j];
}
enedata_dlg[192].d1 = guysbuf[index].defense[edefSCRIPT];
enedata_dlg[203].d1 = guysbuf[index].scriptdefense[scriptDEF1];
enedata_dlg[204].d1 = guysbuf[index].scriptdefense[scriptDEF2];
enedata_dlg[205].d1 = guysbuf[index].scriptdefense[scriptDEF3];
enedata_dlg[206].d1 = guysbuf[index].scriptdefense[scriptDEF4];
enedata_dlg[207].d1 = guysbuf[index].scriptdefense[scriptDEF5];
enedata_dlg[208].d1 = guysbuf[index].scriptdefense[scriptDEF6];
enedata_dlg[209].d1 = guysbuf[index].scriptdefense[scriptDEF7];
enedata_dlg[210].d1 = guysbuf[index].scriptdefense[scriptDEF8];
enedata_dlg[211].d1 = guysbuf[index].scriptdefense[scriptDEF9];
enedata_dlg[212].d1 = guysbuf[index].scriptdefense[scriptDEF10];
///
//Read in the enemy deences to the editor.
for(int j=0; j <= edefBYRNA; j++)
{
enedata_dlg[j+161].d1 = guysbuf[index].defense[j];
}
enedata_dlg[192].d1 = guysbuf[index].defense[edefSCRIPT];
enedata_dlg[203].d1 = guysbuf[index].scriptdefense[scriptDEF1];
enedata_dlg[204].d1 = guysbuf[index].scriptdefense[scriptDEF2];
enedata_dlg[205].d1 = guysbuf[index].scriptdefense[scriptDEF3];
enedata_dlg[206].d1 = guysbuf[index].scriptdefense[scriptDEF4];
enedata_dlg[207].d1 = guysbuf[index].scriptdefense[scriptDEF5];
enedata_dlg[208].d1 = guysbuf[index].scriptdefense[scriptDEF6];
enedata_dlg[209].d1 = guysbuf[index].scriptdefense[scriptDEF7];
enedata_dlg[210].d1 = guysbuf[index].scriptdefense[scriptDEF8];
enedata_dlg[211].d1 = guysbuf[index].scriptdefense[scriptDEF9];
enedata_dlg[212].d1 = guysbuf[index].scriptdefense[scriptDEF10];
///
//Write enemy defences to the test buffer.
for(int j=0; j <= edefBYRNA; j++)
{
test.defense[j] = enedata_dlg[j+161].d1;
}
test.defense[edefSCRIPT] = enedata_dlg[192].d1;
//test.scriptdefense[scriptDEF1] = enedata_dlg[203].d1;
test.scriptdefense[scriptDEF2] = enedata_dlg[204].d1;
test.scriptdefense[scriptDEF3] = enedata_dlg[205].d1;
test.scriptdefense[scriptDEF4] = enedata_dlg[206].d1;
test.scriptdefense[scriptDEF5] = enedata_dlg[207].d1;
test.scriptdefense[scriptDEF6] = enedata_dlg[208].d1;
test.scriptdefense[scriptDEF7] = enedata_dlg[209].d1;
test.scriptdefense[scriptDEF8] = enedata_dlg[210].d1;
test.scriptdefense[scriptDEF9] = enedata_dlg[211].d1;
//test.scriptdefense[scriptDEF10] = enedata_dlg[212].d1;
What did I miss here?
I do not see anything that should prevent an npc from spawning out of these mods...?!
Yet...somehow when writing the data out to the pack file, all of the npc data is corrupted. Edit an enemy, and load a quest where it has been edited, saved, and reopened, and look at the npc tables.
In the test quest, if you click on the screen to freeze it, you can briefly see that ZC is trying to create an npc object, but can't. It does not return as a valid NPC, meaning that Screen->LoadNPC(1) returns invalid, and it never moves.
Source files, binaries, and a test quest.
If I disable the write-out (zq_class.cpp) though, and I otherwise edit an npc and save, it works as normal.
???