shithub: choc

Download patch

ref: 8a8f195464231e8eb4291928d2ce9673060e0a49
parent: 0442df12e5164d4e8109e9e7177ae936d282b557
author: Samuel Villareal <[email protected]>
date: Tue Sep 7 02:25:38 EDT 2010

+ P_DialogStart implemented
+ Dialogs are now loaded through G_DoLoadLevel

Subversion-branch: /branches/strife-branch
Subversion-revision: 2033

--- a/src/strife/g_game.c
+++ b/src/strife/g_game.c
@@ -695,6 +695,8 @@
     {
         players[consoleplayer].message = "Press escape to quit.";
     }
+
+    P_DialogLoad(); // villsa [STRIFE]
 } 
  
 
--- a/src/strife/m_menu.h
+++ b/src/strife/m_menu.h
@@ -63,6 +63,9 @@
     short		lastOn;		// last item user was on in menu
 } menu_t;
 
+extern menu_t*	currentMenu;    // villsa [STRIFE] made external
+extern short itemOn;
+
 //
 // MENUS
 //
--- 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 @@
 // 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 @@
 // 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 @@
 // 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 @@
 //
 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 @@
         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 = &currentdialog[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
--- a/src/strife/p_dialog.h
+++ b/src/strife/p_dialog.h
@@ -71,6 +71,7 @@
     mapdlgchoice_t choices[MDLG_MAXCHOICES];
 } mapdialog_t;
 
+void P_DialogLoad(void);
 void P_DialogStart(player_t *player);