From 8a8f195464231e8eb4291928d2ce9673060e0a49 Mon Sep 17 00:00:00 2001 From: Samuel Villareal Date: Tue, 7 Sep 2010 06:25:38 +0000 Subject: + P_DialogStart implemented + Dialogs are now loaded through G_DoLoadLevel Subversion-branch: /branches/strife-branch Subversion-revision: 2033 --- src/strife/g_game.c | 2 + src/strife/m_menu.h | 3 ++ src/strife/p_dialog.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++- src/strife/p_dialog.h | 1 + 4 files changed, 111 insertions(+), 2 deletions(-) (limited to 'src/strife') diff --git a/src/strife/g_game.c b/src/strife/g_game.c index 49c4ef24..aff55f8c 100644 --- a/src/strife/g_game.c +++ b/src/strife/g_game.c @@ -695,6 +695,8 @@ void G_DoLoadLevel (void) { players[consoleplayer].message = "Press escape to quit."; } + + P_DialogLoad(); // villsa [STRIFE] } diff --git a/src/strife/m_menu.h b/src/strife/m_menu.h index 82848126..b302ea08 100644 --- a/src/strife/m_menu.h +++ b/src/strife/m_menu.h @@ -63,6 +63,9 @@ typedef struct menu_s short lastOn; // last item user was on in menu } menu_t; +extern menu_t* currentMenu; // villsa [STRIFE] made external +extern short itemOn; + // // MENUS // diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c index f4cc2820..4616d0b0 100644 --- a/src/strife/p_dialog.c +++ b/src/strife/p_dialog.c @@ -59,6 +59,9 @@ memcpy(field, ptr, len); \ ptr += len; +#define MAXITEMREQUIREMENTS 3 +#define MAXCHOICES 5 + // // Globals // @@ -101,6 +104,9 @@ angle_t dialogtalkerangle; // The currently active mapdialog object. static mapdialog_t *currentdialog; +// Text at the end of the choices +char dialoglastmsgbuffer[48]; + //============================================================================= // // Dialog State Sets @@ -129,6 +135,9 @@ static dialogstateset_t dialogstatesets[] = // Rogue stored this in a static global rather than making it a define... static int numdialogstatesets = arrlen(dialogstatesets); +// Current dialog talker state +static dialogstateset_t *dialogtalkerstates; + //============================================================================= // // Random Messages @@ -504,7 +513,7 @@ int P_PlayerHasItem(player_t *player, mobjtype_t type) // haleyjd 09/03/10: Looks for a dialog definition matching the given // Script ID # for an mobj. // -mapdialog_t *P_DialogFind(int type) +mapdialog_t *P_DialogFind(mobjtype_t type) { int i; @@ -761,6 +770,13 @@ static void P_DialogDoChoice(int choice) // void P_DialogStart(player_t *player) { + int i = 0; + int j = 0; + int pic; + int rnd = 0; + mapdialog_t* dialog; + char* byetext; + if(menuactive || netgame) return; @@ -801,5 +817,92 @@ void P_DialogStart(player_t *player) dialogplayer = player; } - //**[STRIFE] TODO** + // check item requirements + for(i = 0; i < MAXITEMREQUIREMENTS; i++) + { + currentdialog = P_DialogFind(linetarget->type); + + // dialog's jumptoconv equal to 0? + if(currentdialog[0].jumptoconv == 0) + break; + + for(j = 0; j < MAXITEMREQUIREMENTS; j++) + { + dialog = ¤tdialog[j]; + if(dialog->checkitem1 != 0 && + P_PlayerHasItem(dialogtalker, dialog->checkitem1) < 1) + { + currentdialog = dialog; + break; + } + } + } + + M_DialogDimMsg(20, 28, currentdialog->text, 0); + dialogtext = P_DialogGetMsg(currentdialog->text); + dialogtalkerstates = P_DialogGetStates(linetarget->type); + + // have talker greet the player + if(dialogtalkerstates->greet) + P_SetMobjState(dialogtalker, dialogtalkerstates->greet); + + // get talker's name + if(currentdialog->name[0]) + dialogname = currentdialog->name; + else + { + if(mobjinfo[linetarget->type].name) + dialogname = mobjinfo[linetarget->type].name; + else + dialogname = "Person"; // default name + } + + // setup number of choices to choose from + for(i = 0; i < MAXCHOICES; i++) + { + if(!currentdialog->choices[i].giveitem) + break; + } + + // set number of choices to menu + dialogmenu.numitems = i + 1; + + rnd = M_Random() % 3; + + // setup dialog menu + M_StartControlPanel(); + menupause = 0; + menuindialog = 1; + menupausetime = gametic + 17; + currentMenu = &dialogmenu; + + if(i >= dialogmenu.lastOn) + itemOn = dialogmenu.lastOn; + else + itemOn = 0; + + // get backdrop + pic = W_CheckNumForName(currentdialog->backpic); + dialogbgpiclumpnum = pic; + if(pic != -1) + V_DrawPatchDirect(0, 0, W_CacheLumpNum(pic, PU_CACHE)); + + // get voice + //I_StartVoice(currentdialog->voice); + + // get bye text + switch(rnd) + { + case 2: + byetext = "BYE!"; + break; + case 1: + byetext = "Thanks, Bye!"; + break; + case 0: + byetext = "See you later!"; + break; + } + + sprintf(dialoglastmsgbuffer, "%d) %s", i + 1, byetext); } \ No newline at end of file diff --git a/src/strife/p_dialog.h b/src/strife/p_dialog.h index da02b388..531e3028 100644 --- a/src/strife/p_dialog.h +++ b/src/strife/p_dialog.h @@ -71,6 +71,7 @@ typedef struct mapdialog_s mapdlgchoice_t choices[MDLG_MAXCHOICES]; } mapdialog_t; +void P_DialogLoad(void); void P_DialogStart(player_t *player); -- cgit v1.2.3