shithub: choc

Download patch

ref: ad87636e1296e525f3a3979e5f0d00d16f2c54fc
parent: 993520eecddbdddddb1a562646c755e1efd0fa29
author: Samuel Villareal <[email protected]>
date: Sat Sep 11 03:48:27 EDT 2010

+ P_GivePower update
+ Power tics implemented
+ Power enums implemented
+ More inventory functions implemented

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

--- a/src/strife/doomdef.h
+++ b/src/strife/doomdef.h
@@ -185,14 +185,15 @@
 
 
 // Power up artifacts.
+// villsa [STRIFE]
 typedef enum
 {
-    pw_invulnerability,
     pw_strength,
     pw_invisibility,
     pw_ironfeet,
     pw_allmap,
-    pw_infrared,
+    pw_communicator,
+    pw_targeter,
     NUMPOWERS
     
 } powertype_t;
@@ -206,10 +207,10 @@
 //
 typedef enum
 {
-    INVULNTICS	= (30*TICRATE),
-    INVISTICS	= (60*TICRATE),
-    INFRATICS	= (120*TICRATE),
-    IRONTICS	= (60*TICRATE)
+    INVISTICS	= (55*TICRATE), // villsa [STRIFE] changed from 60 to 55
+    IRONTICS	= (80*TICRATE), // villsa [STRIFE] changed from 60 to 80
+    PMUPTICS    = (80*TICRATE), // villsa [STRIFE]
+    TARGTICS    = (160*TICRATE),// villsa [STRIFE]
     
 } powerduration_t;
 
--- a/src/strife/p_dialog.c
+++ b/src/strife/p_dialog.c
@@ -915,14 +915,14 @@
 
         // communicator
         case SPR_COMM:
-            //if(!P_GivePower(player)) // [STRIFE] TODO
-            //  return false;
+            if(!P_GivePower(player, pw_communicator))
+                return false;
         break;
 
         // map
         case SPR_PMAP:
-            //if(!P_GivePower(player)) // [STRIFE] TODO
-            //  return false;
+            if(!P_GivePower(player, pw_allmap))
+                return false;
         break;
 
         // rifle
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -273,16 +273,16 @@
 //
 // P_GiveCard
 //
-void
-P_GiveCard
-( player_t*	player,
-  card_t	card )
+boolean P_GiveCard(player_t* player, card_t card)
 {
     if (player->cards[card])
-	return;
+	return false;
     
-    player->bonuscount = BONUSADD;
+    // villsa [STRIFE] multiply by 2
+    player->bonuscount = BONUSADD * 2;
     player->cards[card] = 1;
+
+    return true;
 }
 
 
@@ -289,46 +289,64 @@
 //
 // P_GivePower
 //
-boolean
-P_GivePower
-( player_t*	player,
-  int /*powertype_t*/	power )
+boolean P_GivePower(player_t* player, powertype_t power)
 {
-    if (power == pw_invulnerability)
+    // villsa [STRIFE]
+    if(power == pw_targeter)
     {
-	player->powers[power] = INVULNTICS;
-	return true;
+        player->powers[power] = TARGTICS;
+        P_SetPsprite(player, ps_targcenter, S_TRGT_00); // 10
+        P_SetPsprite(player, ps_targleft, S_TRGT_01); // 11
+        P_SetPsprite(player, ps_targright, S_TRGT_02); // 12
+
+        player->psprites[ps_targcenter].sx  = (160*FRACUNIT);
+        player->psprites[ps_targleft].sy    = (100*FRACUNIT);
+        player->psprites[ps_targcenter].sy  = (100*FRACUNIT);
+        player->psprites[ps_targright].sy   = (100*FRACUNIT);
+        return true;
     }
-    
-    if (power == pw_invisibility)
+
+    if(power == pw_invisibility)
     {
-	player->powers[power] = INVISTICS;
-	player->mo->flags |= MF_SHADOW;
-	return true;
+        player->powers[power] = INVISTICS;
+        player->mo->flags |= MF_SHADOW;
+        return true;
     }
-    
-    if (power == pw_infrared)
+
+    if(power == pw_ironfeet)
     {
-	player->powers[power] = INFRATICS;
-	return true;
+        player->powers[power] = IRONTICS;
+        return true;
     }
-    
-    if (power == pw_ironfeet)
+
+    if(power == pw_strength)
     {
-	player->powers[power] = IRONTICS;
-	return true;
+        P_GiveBody(player, 100);
+        player->powers[power] = 1;
+        return true;
     }
-    
-    if (power == pw_strength)
+
+    // villsa [STRIFE]
+    if(power == pw_allmap)
     {
-	P_GiveBody (player, 100);
-	player->powers[power] = 1;
-	return true;
+        if(gamemap < 40)
+            player->mapstate[gamemap] = 1;
+
+        player->powers[power] = 1;
+        return true;
     }
-	
+
+    // villsa [STRIFE]
+    if(power == pw_communicator)
+    {
+        player->powers[power] = 1;
+        return true;
+    }
+
+
     if (player->powers[power])
-	return false;	// already got it
-		
+        return false;	// already got it
+
     player->powers[power] = 1;
     return true;
 }
@@ -864,13 +882,10 @@
 	
 
 	// Below certain threshold,
-	// ignore damage in GOD mode, or with INVUL power.
-	if ( damage < 1000
-	     && ( (player->cheats&CF_GODMODE)
-		  || player->powers[pw_invulnerability] ) )
-	{
-	    return;
-	}
+	// ignore damage in GOD mode.
+        // villsa [STRIFE] removed pw_invulnerability check
+	if(damage < 1000 && (player->cheats & CF_GODMODE))
+            return;
 	
 	if (player->armortype)
 	{
--- a/src/strife/p_pspr.h
+++ b/src/strife/p_pspr.h
@@ -63,9 +63,9 @@
 {
     ps_weapon,
     ps_flash,
+    ps_targcenter,  // villsa [STRIFE]
     ps_targleft,    // villsa [STRIFE]
     ps_targright,   // villsa [STRIFE]
-    ps_targcenter,  // villsa [STRIFE]
     NUMPSPRITES
 
 } psprnum_t;
--- a/src/strife/p_user.c
+++ b/src/strife/p_user.c
@@ -31,8 +31,8 @@
 
 #include "doomdef.h"
 #include "d_event.h"
-
 #include "p_local.h"
+#include "sounds.h"     // villsa [STRIFE]
 #include "p_dialog.h"   // villsa [STRIFE]
 #include "doomstat.h"
 
@@ -47,6 +47,8 @@
 
 
 void P_DropInventoryItem(player_t* player, int sprite); // villsa [STRIFE]
+boolean P_ItemBehavior(player_t* player, int item);     // villsa [STRIFE]
+static char useinventorymsg[44];    // villsa [STRIFE]
 
 //
 // Movement.
@@ -469,15 +471,17 @@
     if (player->powers[pw_strength])
 	player->powers[pw_strength]++;	
 		
-    if (player->powers[pw_invulnerability])
-	player->powers[pw_invulnerability]--;
+    // villsa [STRIFE] unused
+    /*if (player->powers[pw_invulnerability])
+	player->powers[pw_invulnerability]--;*/
 
     if (player->powers[pw_invisibility])
 	if (! --player->powers[pw_invisibility] )
 	    player->mo->flags &= ~MF_SHADOW;
 			
-    if (player->powers[pw_infrared])
-	player->powers[pw_infrared]--;
+    // villsa [STRIFE] unused
+    /*if (player->powers[pw_infrared])
+	player->powers[pw_infrared]--;*/
 		
     if (player->powers[pw_ironfeet])
 	player->powers[pw_ironfeet]--;
@@ -657,9 +661,201 @@
 }
 
 //
+// P_TossDegninOre
+// villsa [STRIFE] new function
+//
+boolean P_TossDegninOre(player_t* player)
+{
+    angle_t angle;
+    mobj_t* mo;
+    mobj_t* ore;
+    fixed_t x;
+    fixed_t y;
+    fixed_t z;
+    fixed_t dist;
+
+    angle = player->mo->angle >> ANGLETOFINESHIFT;
+
+    if(angle < 7618 && angle >= 6718)
+        angle = 7618;
+
+    else if(angle < 5570 && angle >= 4670)
+        angle = 5570;
+
+    else if(angle < 3522 && angle >= 2622)
+        angle = 3522;
+
+    else if(angle < 1474 && angle >= 574)
+        angle = 1474;
+
+    mo = player->mo;
+    dist = mobjinfo[MT_DEGNINORE].radius + mo->info->radius + (4*FRACUNIT);
+
+    x = mo->x + FixedMul(finecosine[angle], dist);
+    y = mo->y + FixedMul(finesine[angle], dist);
+    z = mo->z + (10*FRACUNIT);
+    ore = P_SpawnMobj(x, y, z, MT_DEGNINORE);
+
+    if(P_CheckPosition(ore, x, y))
+    {
+        ore->target = mo;
+        ore->angle = (angle << ANGLETOFINESHIFT);
+        ore->momx = FixedMul(finecosine[angle], (5*FRACUNIT));
+        ore->momy = FixedMul(finesine[angle], (5*FRACUNIT));
+        ore->momz = FRACUNIT;
+        return true;
+    }
+    else
+        P_RemoveMobj(ore);
+
+    return false;
+}
+
+//
+// P_SpawnTeleportBeacon
+// villsa [STRIFE] new function
+//
+boolean P_SpawnTeleportBeacon(player_t* player)
+{
+    angle_t angle;
+    int r;
+    mobj_t* mo;
+    mobj_t* beacon;
+    fixed_t x;
+    fixed_t y;
+    fixed_t z;
+    fixed_t dist;
+
+    angle = player->mo->angle;
+    r = P_Random();
+    angle = (angle + ((r - P_Random()) << 18)) >> ANGLETOFINESHIFT;
+
+    if(angle < 7618 && angle >= 6718)
+        angle = 7618;
+
+    else if(angle < 5570 && angle >= 4670)
+        angle = 5570;
+
+    else if(angle < 3522 && angle >= 2622)
+        angle = 3522;
+
+    else if(angle < 1474 && angle >= 574)
+        angle = 1474;
+
+    mo = player->mo;
+    dist = mobjinfo[MT_BEACON].radius + mo->info->radius + (4*FRACUNIT);
+
+    x = mo->x + FixedMul(finecosine[angle], dist);
+    y = mo->y + FixedMul(finesine[angle], dist);
+    z = mo->z + (10*FRACUNIT);
+    beacon = P_SpawnMobj(x, y, z, MT_BEACON);
+
+    if(P_CheckPosition(beacon, x, y))
+    {
+        beacon->target = mo;
+        beacon->miscdata = mo->miscdata;
+        beacon->angle = (angle << ANGLETOFINESHIFT);
+        beacon->momx = FixedMul(finecosine[angle], (5*FRACUNIT));
+        beacon->momy = FixedMul(finesine[angle], (5*FRACUNIT));
+        beacon->momz = FRACUNIT;
+        P_SetMobjState(beacon, beacon->info->seestate);
+        return true;
+    }
+    else
+        P_RemoveMobj(beacon);
+
+    return false;
+}
+
+//
 // P_UseInventoryItem
 // villsa [STRIFE] new function
 //
 boolean P_UseInventoryItem(player_t* player, int item)
 {
+    int i;
+    char* name;
+
+    if(player->cheats & CF_ONFIRE)
+        return false;
+
+    for(i = 0; i < player->numinventory; i++)
+    {
+        if(item != player->inventory[i].sprite)
+            continue;
+
+        if(!P_ItemBehavior(player, item))
+            return false;
+
+        name = P_RemoveInventoryItem(player, i, 1);
+        if(name == NULL)
+            name = "Item";
+
+        sprintf(useinventorymsg, "You used the %s.", name);
+        player->message = useinventorymsg;
+
+        if(player == &players[consoleplayer])
+            S_StartSound(NULL, sfx_itemup);
+
+        return true;
+    }
+    
+    return false;
+}
+
+//
+// P_ItemBehavior
+// villsa [STRIFE] new function
+//
+boolean P_ItemBehavior(player_t* player, int item)
+{
+    switch(item)
+    {
+    case SPR_ARM1:  // 136
+        return P_GiveArmor(player, 2);
+        break;
+
+    case SPR_ARM2:  // 137
+        return P_GiveArmor(player, 1);
+        break;
+
+    case SPR_SHD1:  // 186
+        return P_GivePower(player, pw_invisibility);
+        break;
+
+    case SPR_MASK:  // 187
+        return P_GivePower(player, pw_ironfeet);
+        break;
+
+    case SPR_PMUP:  // 191
+        if(!player->powers[pw_allmap])
+        {
+            player->message = "The scanner won't work without a map!";
+            return false;
+        }
+        player->powers[pw_allmap] = PMUPTICS;
+        break;
+
+    case SPR_STMP:  // 180
+        return P_GiveBody(player, 10);
+        break;
+
+    case SPR_MDKT:  // 181
+        return P_GiveBody(player, 25);
+        break;
+
+    case SPR_FULL:  // 130
+        return P_GiveBody(player, 200);
+        break;
+
+    case SPR_BEAC:  // 135
+        return P_SpawnTeleportBeacon(player);
+        break;
+
+    case SPR_TARG:  // 108
+        return P_GivePower(player, pw_targeter);
+        break;
+    }
+
+    return true;
 }
\ No newline at end of file
--- a/src/strife/st_stuff.c
+++ b/src/strife/st_stuff.c
@@ -462,7 +462,7 @@
       {
           // villsa [STRIFE] unused
 	//plyr->weaponowned[wp_chainsaw] = true;
-	plyr->powers[pw_invulnerability] = true;
+	//plyr->powers[pw_invulnerability] = true;
 	plyr->message = DEH_String(STSTR_CHOPPERS);
       }
       // 'mypos' for player position