I am trying to create a conversation system between the player and NPCs for my RPG flash game I am making. For some non-quest NPCs the dialog they have will be processed within the map XML structure. However, for quest-related NPCs I am going to create individual files to represent the control structure (if statements, etc) that represent the required decisions to display the correct text.
For my messaging class, I have an if-statement to govern whether a file gets included or not, which is based on the NPC and whether they are a quest related NPC or not. Well, when I have my include file which is linked to the NPC I get an error because it is saying that it cannot find the file I am looking for.
My code looks like this:
if (npc.quest) {
//include "/assets/cactaur01.as";
include "/assets/"+npc.q_file+".as";
}
So my issue is, for the non-quest NPCs, the class is bypassing the if statement and trying to include a null file.
My second problem is, the class is being parsed at run-time instead of an on-demand basis. Basically the class gets instantiated (new messagewindow) whenever the player talks (presses enter) to an NPC, and the class is instantiated with the object reference for the NPC in question. However, at run-time the class is going through this for every NPC (although it does not display anything).
I hope that I have explained my issues fully and concisely.