diff options
author | James Haley | 2010-09-02 18:32:38 +0000 |
---|---|---|
committer | James Haley | 2010-09-02 18:32:38 +0000 |
commit | 1c756bd681af926fabdb99c57248e68b776e66fd (patch) | |
tree | 67b9d4ca4117b7f3792ac5ef7fe7eae59165ca28 /src | |
parent | 17eab692669b3a85c8eaea63d841dddb1779aa35 (diff) | |
download | chocolate-doom-1c756bd681af926fabdb99c57248e68b776e66fd.tar.gz chocolate-doom-1c756bd681af926fabdb99c57248e68b776e66fd.tar.bz2 chocolate-doom-1c756bd681af926fabdb99c57248e68b776e66fd.zip |
Added p_dialog module and header. Started work on dialog engine.
Subversion-branch: /branches/strife-branch
Subversion-revision: 2002
Diffstat (limited to 'src')
-rw-r--r-- | src/strife/p_dialog.c | 136 | ||||
-rw-r--r-- | src/strife/p_dialog.h | 71 |
2 files changed, 207 insertions, 0 deletions
diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c new file mode 100644 index 00000000..d22e217b --- /dev/null +++ b/src/strife/p_dialog.c @@ -0,0 +1,136 @@ +// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1996 Rogue Entertainment / Velocity, Inc.
+// Copyright(C) 2010 James Haley, Samuel Villareal
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+// DESCRIPTION:
+//
+// [STRIFE] New Module
+//
+// Dialog Engine for Strife
+//
+//-----------------------------------------------------------------------------
+
+#include "z_zone.h"
+#include "w_wad.h"
+#include "deh_str.h"
+#include "d_player.h"
+#include "doomstat.h"
+
+#include "p_dialog.h"
+
+//
+// Defines and Macros
+//
+
+// haleyjd: size of the original Strife mapdialog_t structure.
+#define ORIG_MAPDIALOG_SIZE 0x5EC
+
+//
+// Static Globals
+//
+
+// True if SCRIPT00 is loaded.
+static boolean script0loaded;
+
+// Number of dialogs defined in the current level's script.
+static int numleveldialogs;
+
+// Pointer to level dialog script data
+static byte *leveldialogptr;
+
+// Pointer to SCRIPT0 data
+static byte *script0ptr;
+
+// Number of dialogs defined in the SCRIPT00 lump.
+static int numscript0dialogs;
+
+//
+// Routines
+//
+
+//
+// P_DialogLoad
+//
+// [STRIFE] New function
+// haleyjd 09/02/10: Loads the dialog script for the current map. Also loads
+// SCRIPT00 if it has not yet been loaded.
+//
+void P_DialogLoad(int eax0, int a2, int a3, int a4)
+{
+ char lumpname[9];
+ int lumpnum;
+
+ // load the SCRIPTxy lump corresponding to MAPxy, if it exists.
+ sprintf(lumpname, DEH_String("script%02d"), gamemap);
+ if((lumpnum = W_CheckNumForName(lumpname)) == -1)
+ numleveldialogs = 0;
+ else
+ {
+ leveldialogptr = W_CacheLumpNum(lumpnum, PU_LEVEL);
+ numleveldialogs = W_LumpLength(lumpnum) / ORIG_MAPDIALOG_SIZE;
+ }
+
+ // also load SCRIPT00 if it has not been loaded yet
+ if(!script0loaded)
+ {
+ script0loaded = true;
+ // BUG: Rogue should have used W_GetNumForName here...
+ lumpnum = W_CheckNumForName(DEH_String("script00"));
+ script0ptr = W_CacheLumpNum(lumpnum, PU_STATIC);
+ numscript0dialogs = W_LumpLength(lumpnum) / ORIG_MAPDIALOG_SIZE;
+ }
+}
+
+//
+// P_PlayerHasItem
+//
+// [STRIFE] New function
+// haleyjd 09/02/10: Checks for inventory items, quest flags, etc. for dialogs.
+// Returns the amount possessed, or 0 if none.
+//
+int P_PlayerHasItem(player_t *player, mobjtype_t type)
+{
+ int i;
+
+ if(type > 0)
+ {
+ // check keys
+ if(type >= MT_KEY_BASE && type < MT_INV_SHADOWARMOR)
+ return 1; // STRIFE-FIXME: wtf is it doing here??? Should be player->cards...
+
+ // check sigil pieces
+ if(type >= MT_SIGIL_A && type <= MT_SIGIL_E)
+ return type - MT_SIGIL_A <= player->sigiltype;
+
+ // check quest tokens
+ if(type >= MT_TOKEN_QUEST1 && type <= MT_TOKEN_QUEST31)
+ return player->questflags & (1 << (type - MT_TOKEN_QUEST1));
+
+ // check inventory
+ for(i = 0; i < 32; i++)
+ {
+ if(type == player->inventory[i].type)
+ return player->inventory[i].amount;
+ }
+ }
+ return 0;
+}
+
diff --git a/src/strife/p_dialog.h b/src/strife/p_dialog.h new file mode 100644 index 00000000..e90f5df4 --- /dev/null +++ b/src/strife/p_dialog.h @@ -0,0 +1,71 @@ +// Emacs style mode select -*- C++ -*-
+//-----------------------------------------------------------------------------
+//
+// Copyright(C) 1993-1996 Id Software, Inc.
+// Copyright(C) 1996 Rogue Entertainment / Velocity, Inc.
+// Copyright(C) 2010 James Haley, Samuel Villareal
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+//
+// DESCRIPTION:
+//
+// [STRIFE] New Module
+//
+// Dialog Engine for Strife
+//
+//-----------------------------------------------------------------------------
+
+#ifndef P_DIALOG_H__
+#define P_DIALOG_H__
+
+typedef struct mapdlgchoice_s
+{
+ int giveitem; // item given when successful
+ int needitem1; // first item needed for success
+ int needitem2; // second item needed for success, if any
+ int needitem3; // third item needed for success, if any
+ int needamount1; // amount of first item needed
+ int needamount2; // amount of second item needed
+ int needamount3; // amount of third item needed
+ char text[32]; // normal text
+ char textok[80]; // message given on success
+ int next; // next dialog?
+ int objective; // ???
+ char textno[80]; // message given on failure
+} mapdlgchoice_t;
+
+typedef struct mapdialog_s
+{
+ int speakerid; // script ID# for thingtype that will use this dialog
+ int dropitem; // item to drop if that thingtype is killed
+ int checkitem1; // first item needed to see this dialog
+ int checkitem2; // second item needed to see this dialog, if any
+ int checkitem3; // third item needed to see this dialog, if any
+ int jumptoconv; // conversation to jump to when... ?
+ char name[16]; // name of speaker
+ char voice[8]; // voice file to play
+ char backpic[8]; // backdrop pic for character, if any
+ char text[320]; // main message text
+
+ mapdlgchoice_t choices[5]; // options that this dialog gives the player
+} mapdialog_t;
+
+
+#endif
+
+// EOF
+
+
|