gzdoom-gles/src/g_strife/a_rebels.cpp
Randy Heit e5572a1c4e - Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
  loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
  support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
  with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
  on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
  scope than before. The skipped entry is assumed to always be at 248, and
  it is assumed that all Shader Model 1.4 cards suffer from this. That's
  because all SM1.4 cards are based on variants of the ATI R200 core, and the
  RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
  other flavors of the R200 are any different. (Interesting note: With the
  Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
  debug Direct3D 9 runtime, but it works perfectly fine with the retail
  Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
  math inside pixel shaders. That would explain perfectly why I can't use
  constants greater than 1 with PS1.4 and why it can't do an exact mapping to
  every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
  "color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
  completely setup, meaning that Shader Model 1.4 cards could not change
  resolution.
- I have decided to let remap palettes specify variable alpha values for
  their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
  reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
  when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
  (Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
  gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
  unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
  being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
  accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
  multiple script scanner states can be stored without being forced to do so
  recursively. I think I might be taking advantage of that in the near
  future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
  * Fixed: When using even length values in drawnumber it would cap to a 98
    value instead of a 99 as intended.
  * The SBarInfo parser can now accept negatives for coordinates. This
    doesn't allow much right now, but later I plan to add better fullscreen
    hud support in which the negatives will be more useful. This also cleans
    up the source a bit since all calls for (x, y) coordinates are with the
    function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
  software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
  space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
  STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
  gets blended with the background, since that seems like a good idea for
  reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
  Since the ERenderStyle enumeration was getting rather unwieldy, I converted
  it into a new FRenderStyle structure that lets each parameter of the
  blending equation be set separately. This simplified the set up for the
  blend quite a bit, and it means a number of new combinations are available
  by setting the parameters properly.


SVN r710 (trunk)
2008-01-25 23:57:44 +00:00

322 lines
9.5 KiB
C++

#include "actor.h"
#include "m_random.h"
#include "a_action.h"
#include "p_local.h"
#include "p_enemy.h"
#include "s_sound.h"
#include "gi.h"
#include "a_sharedglobal.h"
#include "a_strifeglobal.h"
static FRandom pr_shootgun ("ShootGun");
void A_ShootGun (AActor *);
void A_TossGib (AActor *);
void A_Beacon (AActor *);
// Base class for the rebels ------------------------------------------------
class ARebel : public AStrifeHumanoid
{
DECLARE_ACTOR (ARebel, AStrifeHumanoid)
};
FState ARebel::States[] =
{
#define S_REBEL_STND 0
S_NORMAL (HMN1, 'P', 5, A_Look2, &States[S_REBEL_STND]),
S_NORMAL (HMN1, 'Q', 8, NULL, &States[S_REBEL_STND]),
S_NORMAL (HMN1, 'R', 8, NULL, &States[S_REBEL_STND]),
#define S_REBEL_WAND (S_REBEL_STND+3)
S_NORMAL (HMN1, 'A', 6, A_Wander, &States[S_REBEL_WAND+1]),
S_NORMAL (HMN1, 'B', 6, A_Wander, &States[S_REBEL_WAND+2]),
S_NORMAL (HMN1, 'C', 6, A_Wander, &States[S_REBEL_WAND+3]),
S_NORMAL (HMN1, 'D', 6, A_Wander, &States[S_REBEL_WAND+4]),
S_NORMAL (HMN1, 'A', 6, A_Wander, &States[S_REBEL_WAND+5]),
S_NORMAL (HMN1, 'B', 6, A_Wander, &States[S_REBEL_WAND+6]),
S_NORMAL (HMN1, 'C', 6, A_Wander, &States[S_REBEL_WAND+7]),
S_NORMAL (HMN1, 'D', 6, A_Wander, &States[S_REBEL_STND]),
#define S_REBEL_CHASE (S_REBEL_WAND+8)
S_NORMAL (HMN1, 'A', 3, A_Chase, &States[S_REBEL_CHASE+1]),
S_NORMAL (HMN1, 'A', 3, A_Chase, &States[S_REBEL_CHASE+2]),
S_NORMAL (HMN1, 'B', 3, A_Chase, &States[S_REBEL_CHASE+3]),
S_NORMAL (HMN1, 'B', 3, A_Chase, &States[S_REBEL_CHASE+4]),
S_NORMAL (HMN1, 'C', 3, A_Chase, &States[S_REBEL_CHASE+5]),
S_NORMAL (HMN1, 'C', 3, A_Chase, &States[S_REBEL_CHASE+6]),
S_NORMAL (HMN1, 'D', 3, A_Chase, &States[S_REBEL_CHASE+7]),
S_NORMAL (HMN1, 'D', 3, A_Chase, &States[S_REBEL_CHASE]),
#define S_REBEL_ATK (S_REBEL_CHASE+8)
S_NORMAL (HMN1, 'E', 10, A_FaceTarget, &States[S_REBEL_ATK+1]),
S_BRIGHT (HMN1, 'F', 10, A_ShootGun, &States[S_REBEL_ATK+2]),
S_NORMAL (HMN1, 'E', 10, A_ShootGun, &States[S_REBEL_CHASE]),
#define S_REBEL_PAIN (S_REBEL_ATK+3)
S_NORMAL (HMN1, 'O', 3, NULL, &States[S_REBEL_PAIN+1]),
S_NORMAL (HMN1, 'O', 3, A_Pain, &States[S_REBEL_CHASE]),
#define S_REBEL_DIE (S_REBEL_PAIN+2)
S_NORMAL (HMN1, 'G', 5, NULL, &States[S_REBEL_DIE+1]),
S_NORMAL (HMN1, 'H', 5, A_Scream, &States[S_REBEL_DIE+2]),
S_NORMAL (HMN1, 'I', 3, A_NoBlocking, &States[S_REBEL_DIE+3]),
S_NORMAL (HMN1, 'J', 4, NULL, &States[S_REBEL_DIE+4]),
S_NORMAL (HMN1, 'K', 3, NULL, &States[S_REBEL_DIE+5]),
S_NORMAL (HMN1, 'L', 3, NULL, &States[S_REBEL_DIE+6]),
S_NORMAL (HMN1, 'M', 3, NULL, &States[S_REBEL_DIE+7]),
S_NORMAL (HMN1, 'N', -1, NULL, NULL),
#define S_REBEL_XDIE (S_REBEL_DIE+8)
S_NORMAL (RGIB, 'A', 4, A_TossGib, &States[S_REBEL_XDIE+1]),
S_NORMAL (RGIB, 'B', 4, A_XScream, &States[S_REBEL_XDIE+2]),
S_NORMAL (RGIB, 'C', 3, A_NoBlocking, &States[S_REBEL_XDIE+3]),
S_NORMAL (RGIB, 'D', 3, A_TossGib, &States[S_REBEL_XDIE+4]),
S_NORMAL (RGIB, 'E', 3, A_TossGib, &States[S_REBEL_XDIE+5]),
S_NORMAL (RGIB, 'F', 3, A_TossGib, &States[S_REBEL_XDIE+6]),
S_NORMAL (RGIB, 'G', 3, NULL, &States[S_REBEL_XDIE+7]),
S_NORMAL (RGIB, 'H', 1400, NULL, NULL)
};
IMPLEMENT_ACTOR (ARebel, Strife, -1, 0)
PROP_SpawnState (S_REBEL_STND)
PROP_SeeState (S_REBEL_CHASE)
PROP_PainState (S_REBEL_PAIN)
PROP_MissileState (S_REBEL_ATK)
PROP_DeathState (S_REBEL_DIE)
PROP_XDeathState (S_REBEL_XDIE)
PROP_SpawnHealth (60)
PROP_PainChance (250)
PROP_SpeedFixed (8)
PROP_RadiusFixed (20)
PROP_HeightFixed (56)
PROP_Flags (MF_SOLID|MF_SHOOTABLE|MF_FRIENDLY)
PROP_Flags2 (MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_PUSHWALL|MF2_MCROSS)
PROP_Flags3 (MF3_ISMONSTER)
PROP_Flags4 (MF4_NOSPLASHALERT)
PROP_MinMissileChance (150)
PROP_Tag ("Rebel")
PROP_SeeSound ("rebel/sight")
PROP_PainSound ("rebel/pain")
PROP_DeathSound ("rebel/death")
PROP_ActiveSound ("rebel/active")
PROP_Obituary ("$OB_REBEL")
END_DEFAULTS
//============================================================================
//
// A_ShootGun
//
//============================================================================
void A_ShootGun (AActor *self)
{
int pitch;
if (self->target == NULL)
return;
S_Sound (self, CHAN_WEAPON, "monsters/rifle", 1, ATTN_NORM);
A_FaceTarget (self);
pitch = P_AimLineAttack (self, self->angle, MISSILERANGE);
P_LineAttack (self, self->angle + (pr_shootgun.Random2() << 19),
MISSILERANGE, pitch,
3*(pr_shootgun() % 5 + 1), NAME_None, RUNTIME_CLASS(AStrifePuff));
}
// Rebel 1 ------------------------------------------------------------------
class ARebel1 : public ARebel
{
DECLARE_STATELESS_ACTOR (ARebel1, ARebel)
public:
void NoBlockingSet ();
};
IMPLEMENT_STATELESS_ACTOR (ARebel1, Strife, 9, 0)
PROP_StrifeType (43)
PROP_StrifeTeaserType (42)
PROP_StrifeTeaserType2 (43)
END_DEFAULTS
//============================================================================
//
// ARebel1 :: NoBlockingSet
//
// Only this type of rebel drops bullet clips by default.
//
//============================================================================
void ARebel1::NoBlockingSet ()
{
P_DropItem (this, "ClipOfBullets", -1, 256);
}
// Rebel 2 ------------------------------------------------------------------
class ARebel2 : public ARebel
{
DECLARE_STATELESS_ACTOR (ARebel2, ARebel)
};
IMPLEMENT_STATELESS_ACTOR (ARebel2, Strife, 144, 0)
PROP_StrifeType (44)
PROP_StrifeTeaserType (43)
PROP_StrifeTeaserType2 (44)
END_DEFAULTS
// Rebel 3 ------------------------------------------------------------------
class ARebel3 : public ARebel
{
DECLARE_STATELESS_ACTOR (ARebel3, ARebel)
};
IMPLEMENT_STATELESS_ACTOR (ARebel3, Strife, 145, 0)
PROP_StrifeType (45)
PROP_StrifeTeaserType (44)
PROP_StrifeTeaserType2 (45)
END_DEFAULTS
// Rebel 4 ------------------------------------------------------------------
class ARebel4 : public ARebel
{
DECLARE_STATELESS_ACTOR (ARebel4, ARebel)
};
IMPLEMENT_STATELESS_ACTOR (ARebel4, Strife, 149, 0)
PROP_StrifeType (46)
PROP_StrifeTeaserType (45)
PROP_StrifeTeaserType2 (46)
END_DEFAULTS
// Rebel 5 ------------------------------------------------------------------
class ARebel5 : public ARebel
{
DECLARE_STATELESS_ACTOR (ARebel5, ARebel)
};
IMPLEMENT_STATELESS_ACTOR (ARebel5, Strife, 150, 0)
PROP_StrifeType (47)
PROP_StrifeTeaserType (46)
PROP_StrifeTeaserType2 (47)
END_DEFAULTS
// Rebel 6 ------------------------------------------------------------------
class ARebel6 : public ARebel
{
DECLARE_STATELESS_ACTOR (ARebel6, ARebel)
};
IMPLEMENT_STATELESS_ACTOR (ARebel6, Strife, 151, 0)
PROP_StrifeType (48)
PROP_StrifeTeaserType (47)
PROP_StrifeTeaserType2 (48)
END_DEFAULTS
// Teleporter Beacon --------------------------------------------------------
class ATeleporterBeacon : public AInventory
{
DECLARE_ACTOR (ATeleporterBeacon, AInventory)
public:
bool Use (bool pickup);
};
FState ATeleporterBeacon::States[] =
{
S_NORMAL (BEAC, 'A', -1, NULL, NULL),
S_NORMAL (BEAC, 'A', 30, NULL, &States[2]),
S_NORMAL (BEAC, 'A', 160, A_Beacon, &States[1])
};
IMPLEMENT_ACTOR (ATeleporterBeacon, Strife, 10, 0)
PROP_StrifeType (166)
PROP_SpawnHealth (5)
PROP_SpawnState (0)
PROP_SeeState (1)
PROP_RadiusFixed (16)
PROP_HeightFixed (16)
PROP_Inventory_MaxAmount (3)
PROP_Flags (MF_SPECIAL|MF_DROPPED)
PROP_Inventory_FlagsSet (IF_INVBAR)
PROP_Inventory_Icon ("I_BEAC")
PROP_Tag ("Teleporter_Beacon")
PROP_Inventory_PickupMessage("$TXT_BEACON")
END_DEFAULTS
bool ATeleporterBeacon::Use (bool pickup)
{
AInventory *drop;
// Increase the amount by one so that when DropInventory decrements it,
// the actor will have the same number of beacons that he started with.
// When we return to UseInventory, it will take care of decrementing
// Amount again and disposing of this item if there are no more.
Amount++;
drop = Owner->DropInventory (this);
if (drop == NULL)
{
Amount--;
return false;
}
else
{
drop->SetState (drop->SeeState);
drop->target = Owner;
return true;
}
}
void A_Beacon (AActor *self)
{
AActor *owner = self->target;
ARebel *rebel;
angle_t an;
rebel = Spawn<ARebel1> (self->x, self->y, ONFLOORZ, ALLOW_REPLACE);
if (!P_TryMove (rebel, rebel->x, rebel->y, true))
{
rebel->Destroy ();
return;
}
// Once the rebels start teleporting in, you can't pick up the beacon anymore.
self->flags &= ~MF_SPECIAL;
static_cast<AInventory *>(self)->DropTime = 0;
// Set up the new rebel.
rebel->threshold = BASETHRESHOLD;
rebel->target = NULL;
rebel->flags4 |= MF4_INCOMBAT;
rebel->LastHeard = owner; // Make sure the rebels look for targets
if (deathmatch)
{
rebel->health *= 2;
}
if (owner != NULL)
{
// Rebels are the same color as their owner
rebel->Translation = owner->Translation;
rebel->FriendPlayer = owner->player != NULL ? BYTE(owner->player - players + 1) : 0;
// Set the rebel's target to whatever last hurt the player, so long as it's not
// one of the player's other rebels.
if (owner->target != NULL && !rebel->IsFriend (owner->target))
{
rebel->target = owner->target;
}
}
rebel->SetState (rebel->SeeState);
rebel->angle = self->angle;
an = self->angle >> ANGLETOFINESHIFT;
Spawn<ATeleportFog> (rebel->x + 20*finecosine[an], rebel->y + 20*finesine[an], rebel->z + TELEFOGHEIGHT, ALLOW_REPLACE);
if (--self->health < 0)
{
self->Destroy ();
}
}