summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Haley2010-09-08 04:44:56 +0000
committerJames Haley2010-09-08 04:44:56 +0000
commitbdcfa27ef342b4e6b92be1481da8497a0d5cadb7 (patch)
tree519c2e58684f7950fddc84b789316759c72e6f3b /src
parent36a895288c03cf6ff8c801bf74301fbf93b96bed (diff)
downloadchocolate-doom-bdcfa27ef342b4e6b92be1481da8497a0d5cadb7.tar.gz
chocolate-doom-bdcfa27ef342b4e6b92be1481da8497a0d5cadb7.tar.bz2
chocolate-doom-bdcfa27ef342b4e6b92be1481da8497a0d5cadb7.zip
Proper dialog jumptoconv logic, and more commenting in P_DialogStart.
Subversion-branch: /branches/strife-branch Subversion-revision: 2040
Diffstat (limited to 'src')
-rw-r--r--src/strife/p_dialog.c103
1 files changed, 61 insertions, 42 deletions
diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c
index e2460f0d..51903f4e 100644
--- a/src/strife/p_dialog.c
+++ b/src/strife/p_dialog.c
@@ -510,7 +510,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(mobjtype_t type)
+mapdialog_t *P_DialogFind(mobjtype_t type, int jumptoconv)
{
int i;
@@ -518,7 +518,12 @@ mapdialog_t *P_DialogFind(mobjtype_t type)
for(i = 0; i < numleveldialogs; i++)
{
if(type == leveldialogs[i].speakerid)
- return &leveldialogs[i];
+ {
+ if(jumptoconv <= 1)
+ return &leveldialogs[i];
+ else
+ --jumptoconv;
+ }
}
// check SCRIPT00 dialogs next
@@ -773,6 +778,7 @@ void P_DialogStart(player_t *player)
int rnd = 0;
mapdialog_t* dialog;
char* byetext;
+ int jumptoconv;
if(menuactive || netgame)
return;
@@ -786,59 +792,71 @@ void P_DialogStart(player_t *player)
P_AimLineAttack(player->mo, player->mo->angle - (ANG90/16), (128*FRACUNIT));
}
- if(linetarget)
- {
- // already in combat, can't talk to it
- if(linetarget->flags & MF_INCOMBAT)
- return;
-
- dialogtalker = linetarget;
-
- // play a sound
- if(player = &players[consoleplayer])
- S_StartSound(0, sfx_radio);
-
- linetarget->target = player->mo;
- dialogtalker->reactiontime = 2;
- dialogtalkerangle = dialogtalker->angle;
-
- // face towards player
- A_FaceTarget(linetarget);
- // face towards NPC's direction
- player->mo->angle = R_PointToAngle2(
- player->mo->x,
- player->mo->y,
- dialogtalker->x,
- dialogtalker->y);
+ if(!linetarget)
+ return;
- dialogplayer = player;
- }
- else
- return;
+ // already in combat, can't talk to it
+ if(linetarget->flags & MF_INCOMBAT)
+ return;
+
+ // set pointer to the character talking
+ dialogtalker = linetarget;
+
+ // play a sound
+ if(player == &players[consoleplayer])
+ S_StartSound(0, sfx_radio);
+
+ linetarget->target = player->mo; // target the player
+ dialogtalker->reactiontime = 2; // set reactiontime
+ dialogtalkerangle = dialogtalker->angle; // remember original angle
+
+ // face talker towards player
+ A_FaceTarget(dialogtalker);
+
+ // face towards NPC's direction
+ player->mo->angle = R_PointToAngle2(player->mo->x,
+ player->mo->y,
+ dialogtalker->x,
+ dialogtalker->y);
+ // 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;
// check item requirements
- for(i = 0; i < MDLG_MAXITEMS; i++)
+ while(1)
{
- currentdialog = P_DialogFind(linetarget->type);
+ int i = 0;
+ currentdialog = P_DialogFind(linetarget->type, jumptoconv);
- // dialog's jumptoconv equal to 0?
- if(currentdialog[i].jumptoconv == 0)
+ // dialog's jumptoconv equal to 0? There's nothing to jump to.
+ if(currentdialog->jumptoconv == 0)
break;
- for(j = 0; j < MDLG_MAXITEMS; j++)
+ do
{
- dialog = &currentdialog[j];
- if(dialog->checkitem[j] != 0 &&
- P_PlayerHasItem(dialogtalker, dialog->checkitem[j]) < 1)
- {
- currentdialog = dialog;
+ // if the item is non-zero, the player must have at least one in his
+ // or her inventory
+ if(currentdialog->checkitem[i] != 0 &&
+ P_PlayerHasItem(dialogplayer, currentdialog->checkitem[i]) < 1)
break;
- }
+ ++i;
}
+ while(i < MDLG_MAXITEMS);
+
+ if(i < MDLG_MAXITEMS) // didn't find them all? this is our dialog!
+ break;
+
+ jumptoconv = currentdialog->jumptoconv;
}
M_DialogDimMsg(20, 28, currentdialog->text, 0);
dialogtext = P_DialogGetMsg(currentdialog->text);
+
+ // get states
dialogtalkerstates = P_DialogGetStates(linetarget->type);
// have talker greet the player
@@ -850,8 +868,9 @@ void P_DialogStart(player_t *player)
dialogname = currentdialog->name;
else
{
+ // use a fallback:
if(mobjinfo[linetarget->type].name)
- dialogname = mobjinfo[linetarget->type].name;
+ dialogname = mobjinfo[linetarget->type].name; // mobjtype name
else
dialogname = "Person"; // default name
}