shithub: choc

Download patch

ref: 95482c25b1e0ec85c90a9150c6c1da4a6aff1046
parent: 4c569339b73b05a6bb3a0420ee88c06b30c726ad
author: James Haley <haleyjd@hotmail.com>
date: Wed Sep 8 22:08:43 EDT 2010

Changed mobj_t::allegiance to mobj_t::miscdata due to the fact it has
two completely different uses. Finished P_DialogDoChoice; dialog is now
virtually 100% functional (just needs finished inventory to really do
much beyond initial dialogs or getting "no" messages from everybody).

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

--- a/src/strife/p_dialog.c
+++ b/src/strife/p_dialog.c
@@ -31,6 +31,7 @@
 #include "z_zone.h"
 #include "w_wad.h"
 #include "deh_str.h"
+#include "d_main.h"
 #include "d_player.h"
 #include "doomstat.h"
 #include "m_random.h"
@@ -67,6 +68,10 @@
 // are subtitled on screen or not. Defaults to off.
 boolean dialogshowtext = false;
 
+// The global mission objective buffer. This gets written to and read from file,
+// and is set by dialogs and line actions.
+char mission_objective[OBJECTIVE_LEN];
+
 //
 // Static Globals
 //
@@ -784,19 +789,21 @@
 //
 void P_DialogDoChoice(int choice)
 {
-#if 0
-    int i = 0;
+    int i = 0, nextdialog = 0;
     boolean candochoice = true;
-    char *message;
+    char *message = NULL;
+    mapdlgchoice_t *currentchoice;
 
     if(choice == -1)
         choice = dialogmenu.numitems - 1;
 
+    currentchoice = &(currentdialog->choices[choice]);
+
     // I_StartVoice(0); -- verify (should stop previous voice I believe)
     do
     {
-        if(P_PlayerHasItem(dialogplayer, currentdialog->choices[choice].needitems[i]) <
-            currentdialog->choices[choice].needamounts[i])
+        if(P_PlayerHasItem(dialogplayer, currentchoice->needitems[i]) <
+                                         currentchoice->needamounts[i])
         {
             candochoice = false; // nope, missing something
         }
@@ -808,11 +815,11 @@
     {
         int item;
 
-        message = currentdialog->choices[choice].textok;
+        message = currentchoice->textok;
         if(dialogtalkerstates->yes)
             P_SetMobjState(dialogtalker, dialogtalkerstates->yes);
 
-        item = currentdialog->choices[choice].giveitem;
+        item = currentchoice->giveitem;
         if(item < 0 || 
            P_GiveItemToPlayer(dialogplayer, 
                               states[mobjinfo[item].spawnstate].sprite, 
@@ -823,8 +830,8 @@
             do
             {
                 P_TakeDialogItem(dialogplayer, 
-                    currentdialog->choices[choice].needitems[count],
-                    currentdialog->choices[choice].needamounts[count]);
+                                 currentchoice->needitems[count],
+                                 currentchoice->needamounts[count]);
                 ++count;
             }
             while(count < 3);
@@ -832,12 +839,15 @@
         else
             message = "You seem to have enough!";
 
-        // TODO: more....
+        // store next dialog into the talking actor
+        nextdialog = currentchoice->next;
+        if(nextdialog != 0)
+            dialogtalker->miscdata = (byte)(abs(nextdialog));
     }
     else
     {
         // not successful
-        message = currentdialog->choices[choice].textno;
+        message = currentchoice->textno;
         if(dialogtalkerstates->no)
             P_SetMobjState(dialogtalker, dialogtalkerstates->no);
     }
@@ -844,20 +854,26 @@
     
     if(choice != dialogmenu.numitems - 1)
     {
-        // TODO: ...
+        int objective;
+        char *objlump;
+
+        if((objective = currentchoice->objective))
+        {
+            sprintf(mission_objective, "log%i", objective);
+            objlump = W_CacheLumpName(mission_objective, PU_CACHE);
+            strncpy(mission_objective, objlump, 300);
+        }
+        dialogplayer->message = message;
     }
 
     dialogtalker->angle = dialogtalkerangle;
     dialogplayer->st_update = true;
     M_ClearMenus();
-    /*
-    if(v15 >= 0 || gameaction == ga_victory) // Macil hack
+
+    if(nextdialog >= 0 || gameaction == ga_victory) // Macil hack
         menuindialog = false;
     else
-    */
         P_DialogStart(dialogplayer);
-    // TODO: ...
-#endif
 }
 
 //
@@ -916,10 +932,8 @@
     // set pointer to player talking
     dialogplayer = player;
 
-    // haleyjd: This seems to be an artifact of early development where they
-    // meant to make all this work in multiplayer. By doing this, a thing
-    // could have given different initial dialogs to each player.
-    jumptoconv = linetarget->allegiance;
+    // haleyjd 09/08/10: get any stored dialog state from this object
+    jumptoconv = linetarget->miscdata;
 
     // check item requirements
     while(1)
--- a/src/strife/p_dialog.h
+++ b/src/strife/p_dialog.h
@@ -31,6 +31,8 @@
 #ifndef P_DIALOG_H__
 #define P_DIALOG_H__
 
+#define OBJECTIVE_LEN       300
+
 #define MDLG_CHOICELEN      32
 #define MDLG_MSGLEN         80
 #define MDLG_NAMELEN        16
--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -722,7 +722,7 @@
     sector_t*   sector;
     angle_t     an;
     fixed_t     dist;
-    mobj_t  *   master = players[actor->allegiance].mo;
+    mobj_t  *   master = players[actor->miscdata].mo;
 
     // haleyjd 09/05/10: handle Allies
     if(actor->flags & MF_ALLY)
@@ -734,7 +734,7 @@
             // allegiance. Other allies do it unconditionally.
             if(master && master->target && 
                (master->target->type != MT_REBEL1 ||
-                master->target->allegiance != actor->allegiance))
+                master->target->miscdata != actor->miscdata))
             {
                 actor->target = master->target;
             }
@@ -747,7 +747,7 @@
                 // friendly Rebel or the allied player.
                 if(!linetarget ||
                     actor->target->type == MT_REBEL1 &&
-                    actor->target->allegiance == actor->allegiance ||
+                    actor->target->miscdata == actor->miscdata ||
                     actor->target == master)
                 {
                     actor->target = NULL;
--- a/src/strife/p_mobj.h
+++ b/src/strife/p_mobj.h
@@ -325,8 +325,10 @@
     // Thing being chased/attacked for tracers.
     struct mobj_s*      tracer;
 
-    // [STRIFE] haleyjd 09/05/10: allegiance, for friends and teleport beacons
-    byte                allegiance;
+    // [STRIFE] haleyjd 09/05/10: 
+    // * In multiplayer this stores allegiance, for friends and teleport beacons
+    // * In single-player this tracks dialog state.
+    byte                miscdata;
     
 } mobj_t;