shithub: choc

Download patch

ref: 24f03cab91845012a6e7e035175e2e52f1a04ff7
parent: d112932e1efaa6588ed7276021847a28eb596900
author: Samuel Villareal <svkaiser@gmail.com>
date: Mon Sep 6 23:43:41 EDT 2010

+ P_DialogStart implemented
+ Initial dialog interaction implemented

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

--- 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 @@
 // 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 @@
 {
     // 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
--- a/src/strife/p_dialog.h
+++ b/src/strife/p_dialog.h
@@ -71,6 +71,8 @@
     mapdlgchoice_t choices[MDLG_MAXCHOICES];
 } mapdialog_t;
 
+void P_DialogStart(player_t *player);
+
 
 #endif
 
--- 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 @@
     {
 	if (!player->usedown)
 	{
+            P_DialogStart(player);  // villsa [STRIFE]
 	    P_UseLines (player);
 	    player->usedown = true;
 	}