foxygit / doom Log in
commit 24f03cab91845012a6e7e035175e2e52f1a04ff7
Author:     Samuel Villareal <svkaiser@gmail.com>
AuthorDate: Tue Sep 7 03:43:41 2010 +0000
Commit:     Samuel Villareal <svkaiser@gmail.com>
CommitDate: Tue Sep 7 03:43:41 2010 +0000

    + P_DialogStart implemented
    + Initial dialog interaction implemented

    Subversion-branch: /branches/strife-branch
    Subversion-revision: 2031
---
 src/strife/p_dialog.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/strife/p_dialog.h |  2 ++
 src/strife/p_user.c   |  3 ++-
 3 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c
index 853fe15b..f4cc2820 100644
--- a/src/strife/p_dialog.c
+++ b/src/strife/p_dialog.c
@@ -37,7 +37,8 @@
 #include "m_menu.h"
 #include "r_main.h"
 #include "v_video.h"
-
+#include "p_local.h"
+#include "sounds.h"
 #include "p_dialog.h"

 //
@@ -94,6 +95,9 @@ player_t *dialogplayer;
 // The object to which the player is speaking.
 mobj_t   *dialogtalker;

+// The talker's current angle
+angle_t dialogtalkerangle;
+
 // The currently active mapdialog object.
 static mapdialog_t *currentdialog;

@@ -749,3 +753,53 @@ static void P_DialogDoChoice(int choice)
 {
     // STRIFE-TODO
 }
+
+//
+// P_DialogStart
+//
+// villsa [STRIFE] New function
+//
+void P_DialogStart(player_t *player)
+{
+    if(menuactive || netgame)
+        return;
+
+    // are we facing towards our NPC?
+    P_AimLineAttack(player->mo, player->mo->angle, (128*FRACUNIT));
+    if(!linetarget)
+    {
+        P_AimLineAttack(player->mo, player->mo->angle + (ANG90/16), (128*FRACUNIT));
+        if(!linetarget)
+            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);
+
+        dialogplayer = player;
+    }
+
+    //**[STRIFE] TODO**
+}
\ No newline at end of file
diff --git a/src/strife/p_dialog.h b/src/strife/p_dialog.h
index 3da79ba8..da02b388 100644
--- a/src/strife/p_dialog.h
+++ b/src/strife/p_dialog.h
@@ -71,6 +71,8 @@ typedef struct mapdialog_s
     mapdlgchoice_t choices[MDLG_MAXCHOICES];
 } mapdialog_t;

+void P_DialogStart(player_t *player);
+

 #endif

diff --git a/src/strife/p_user.c b/src/strife/p_user.c
index 12bc686f..a7836f0d 100644
--- a/src/strife/p_user.c
+++ b/src/strife/p_user.c
@@ -33,7 +33,7 @@
 #include "d_event.h"

 #include "p_local.h"
-
+#include "p_dialog.h"   // villsa [STRIFE]
 #include "doomstat.h"


@@ -401,6 +401,7 @@ void P_PlayerThink (player_t* player)
     {
 	if (!player->usedown)
 	{
+            P_DialogStart(player);  // villsa [STRIFE]
 	    P_UseLines (player);
 	    player->usedown = true;
 	}