Dr_Nomz
Member
I made an awesome dialogue system that works really well for me, and it's all contained in one object, but the thing is it's unmanageable, and I would need to alter each and every little variable to display the correct dialogue option, NPC line, and the coords for where this all appears on screen, along with the coords for the text within the dialogue boxes.
The first thing I should point out is that the topmost box is the dialogue from the NPC, which is whatever they're saying in response to whatever option you chose previously. I don't think I need any help with that part, so just keep in mind that it's at the top of the screen and it doesn't move from there. (It also can't have any other dialogue options overlapping it, or underlapping)
The second is that the screen is going to be 1000(W) x 800(H) and the dialogue boxes are all 500(W) x 100(H) and display in the center of the screen. (so 250px to the right of the screen if their origin is on the left side) This means that there can only be 7 options displaying at any given time, and some must be chosen before others are available.
Finally, the text is drawn overtop of the dialogue boxes, which also have to have their own specific coords, about 10-15 pixels inside the box. (so it doesn't display on the box's border.)
===
Now that you know all that, here's what I need:
First, the dialogue options coords (except the NPC dialogue, since that's fixed in place) should always display at the bottom of the screen, and if there are more options, the extra ones should be displayed 100 pixels above the former. I would also like to determine which options have which place in the lineup, so the end dialogue option can always default to the bottom, and others can have a certain order as well.
Second, I need a better way to sort it all. Using "variables" can get really confusing the bigger this gets, so I could use some advice on how to better sort it using a ds_map or list or something, so it won't be nearly as difficult to keep track of it all and how it works.
If anyone can help me out with that, I would greatly appreciate it, this is really important to my game, and I hope someone can help me with this.
Here's the code I used for reference (added some notes to give you an idea of what certain things do)
The first thing I should point out is that the topmost box is the dialogue from the NPC, which is whatever they're saying in response to whatever option you chose previously. I don't think I need any help with that part, so just keep in mind that it's at the top of the screen and it doesn't move from there. (It also can't have any other dialogue options overlapping it, or underlapping)
The second is that the screen is going to be 1000(W) x 800(H) and the dialogue boxes are all 500(W) x 100(H) and display in the center of the screen. (so 250px to the right of the screen if their origin is on the left side) This means that there can only be 7 options displaying at any given time, and some must be chosen before others are available.
Finally, the text is drawn overtop of the dialogue boxes, which also have to have their own specific coords, about 10-15 pixels inside the box. (so it doesn't display on the box's border.)
===
Now that you know all that, here's what I need:
First, the dialogue options coords (except the NPC dialogue, since that's fixed in place) should always display at the bottom of the screen, and if there are more options, the extra ones should be displayed 100 pixels above the former. I would also like to determine which options have which place in the lineup, so the end dialogue option can always default to the bottom, and others can have a certain order as well.
Second, I need a better way to sort it all. Using "variables" can get really confusing the bigger this gets, so I could use some advice on how to better sort it using a ds_map or list or something, so it won't be nearly as difficult to keep track of it all and how it works.
If anyone can help me out with that, I would greatly appreciate it, this is really important to my game, and I hope someone can help me with this.
Here's the code I used for reference (added some notes to give you an idea of what certain things do)
Code:
var color=c_black;
var x1 = view_xview + 250;
var y1 = view_yview + 700;
var x2 = x1 + 500;
var y2 = y1 + 100;
if hide_self=1{
//NPC Lines
if lines=0{
draw_sprite(spr_Dialogue_Blue,0,x1,y1-700);
draw_set_font(fnt_3);
draw_set_colour(c_navy)
draw_text(x1+12,y1-688,'Hi?');
}
if lines=1{
draw_sprite(spr_Dialogue_Blue,0,x1,y1-700);
draw_set_font(fnt_3);
draw_set_colour(c_navy)
draw_text(x1+12,y1-688,"I'm trying to get in my house but I can't find the key...#So I'm stuck out here until I can find it.");
}
if lines=2{
draw_sprite(spr_Dialogue_Blue,0,x1,y1-700);
draw_set_font(fnt_3);
draw_set_colour(c_navy)
draw_text(x1+12,y1-688,"What the... Yeah that's my key! Where did you find it?#And how did you know it was... nevermind. Thanks.");
}
if lines=3{
draw_sprite(spr_Dialogue_Blue,0,x1,y1-700);
draw_set_font(fnt_3);
draw_set_colour(c_navy)
draw_text(x1+12,y1-688,"Yeah, that's it! Where'd you find it?#Anyway, thanks for finding it for me.");
}
//Dialogue Option:
if hide1=0{ //Variable determines if the option is available, if it is, it's shown here, and can be clicked on.
draw_sprite(spr_Dialogue_Box,0,x1,y1-200); //Draws the dialogue box
if(point_in_rectangle(mouse_x,mouse_y,x1,y1-200,x2,y2-200)){
draw_set_alpha(0.5)
draw_set_color(c_white);
draw_rectangle(x1+5,y1-195,x2-6,y2-206,0);
draw_set_alpha(1)
if(mouse_check_button_pressed(mb_left)){
var KEY_blue=false; //Simple item check, ignore this part.
for(i=0; i<maxItems; i++){
if (global.inventory[i]==8){
KEY_blue=true;
}
}
if KEY_blue=true{
hide1=1; //If item is found, option to give key changes slightly.
hide2=1;
lines=1;
}else{ //This part is important; It sets a bunch of variables to show new dialogue options, or change an existing one.
//It also changes what the NPC is saying. (In the LINES variable)
hide1=1;
hide2=2;
lines=1;
}
}
}
//And THIS is the text drawn on top of the dialogue box. Lets you know what you're
//going to say before you say it.
draw_set_font(fnt_3);
draw_set_colour(color)
draw_text(x1+10,y1-190,'What are you doing?');
}