2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** thingdef.cpp
|
|
|
|
**
|
|
|
|
** Code pointers for Actor definitions
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 2002-2006 Christoph Oelckers
|
|
|
|
** Copyright 2004-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
** 4. When not used as part of ZDoom or a ZDoom derivative, this code will be
|
|
|
|
** covered by the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
** your option) any later version.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gi.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "sc_man.h"
|
|
|
|
#include "tarray.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "r_draw.h"
|
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "decallib.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "c_console.h"
|
|
|
|
#include "doomerrors.h"
|
|
|
|
#include "a_sharedglobal.h"
|
2007-05-28 14:46:49 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2006-09-17 10:43:51 +00:00
|
|
|
#include "v_video.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "v_font.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "doomstat.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "v_palette.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
static FRandom pr_camissile ("CustomActorfire");
|
|
|
|
static FRandom pr_camelee ("CustomMelee");
|
|
|
|
static FRandom pr_cabullet ("CustomBullet");
|
|
|
|
static FRandom pr_cajump ("CustomJump");
|
|
|
|
static FRandom pr_cwbullet ("CustomWpBullet");
|
|
|
|
static FRandom pr_cwjump ("CustomWpJump");
|
|
|
|
static FRandom pr_cwpunch ("CustomWpPunch");
|
|
|
|
static FRandom pr_grenade ("ThrowGrenade");
|
|
|
|
static FRandom pr_crailgun ("CustomRailgun");
|
|
|
|
static FRandom pr_spawndebris ("SpawnDebris");
|
2006-11-27 21:51:36 +00:00
|
|
|
static FRandom pr_spawnitemex ("SpawnItemEx");
|
2006-05-15 15:28:46 +00:00
|
|
|
static FRandom pr_burst ("Burst");
|
2009-06-06 12:46:35 +00:00
|
|
|
static FRandom pr_monsterrefire ("MonsterRefire");
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
2006-03-03 03:57:01 +00:00
|
|
|
// ACustomInventory :: CallStateChain
|
|
|
|
//
|
2006-02-24 04:48:15 +00:00
|
|
|
// Executes the code pointers in a chain of states
|
|
|
|
// until there is no next state
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-03-03 03:57:01 +00:00
|
|
|
bool ACustomInventory::CallStateChain (AActor *actor, FState * State)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-25 07:48:52 +00:00
|
|
|
StateCallData StateCall;
|
2006-02-24 04:48:15 +00:00
|
|
|
bool result = false;
|
2006-03-03 03:57:01 +00:00
|
|
|
int counter = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-20 14:27:44 +00:00
|
|
|
StateCall.Item = this;
|
2006-05-26 08:19:39 +00:00
|
|
|
while (State != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Assume success. The code pointer will set this to false if necessary
|
2008-08-12 14:30:07 +00:00
|
|
|
StateCall.State = State;
|
|
|
|
StateCall.Result = true;
|
2009-01-06 00:03:18 +00:00
|
|
|
if (State->CallAction(actor, this, &StateCall))
|
2006-08-27 08:51:01 +00:00
|
|
|
{
|
|
|
|
// collect all the results. Even one successful call signifies overall success.
|
|
|
|
result |= StateCall.Result;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Since there are no delays it is a good idea to check for infinite loops here!
|
|
|
|
counter++;
|
2006-03-03 03:57:01 +00:00
|
|
|
if (counter >= 10000) break;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-26 08:19:39 +00:00
|
|
|
if (StateCall.State == State)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Abort immediately if the state jumps to itself!
|
2006-05-26 08:19:39 +00:00
|
|
|
if (State == State->GetNextState())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// If both variables are still the same there was no jump
|
|
|
|
// so we must advance to the next state.
|
2006-05-26 08:19:39 +00:00
|
|
|
State = State->GetNextState();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
State = StateCall.State;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Simple flag changers
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SetSolid)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
self->flags |= MF_SOLID;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_UnsetSolid)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
self->flags &= ~MF_SOLID;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SetFloat)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
self->flags |= MF_FLOAT;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_UnsetFloat)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
self->flags &= ~(MF_FLOAT|MF_INFLOAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Customizable attack functions which use actor parameters.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
static void DoAttack (AActor *self, bool domelee, bool domissile,
|
|
|
|
int MeleeDamage, FSoundID MeleeSound, const PClass *MissileType,fixed_t MissileHeight)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (self->target == NULL) return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
if (domelee && MeleeDamage>0 && self->CheckMeleeRange ())
|
|
|
|
{
|
|
|
|
int damage = pr_camelee.HitDice(MeleeDamage);
|
2008-06-15 02:25:09 +00:00
|
|
|
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj (self->target, self, self, damage, NAME_Melee);
|
2006-02-24 04:48:15 +00:00
|
|
|
P_TraceBleed (damage, self->target, self);
|
|
|
|
}
|
2008-08-12 14:30:07 +00:00
|
|
|
else if (domissile && MissileType != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-12 14:30:07 +00:00
|
|
|
// This seemingly senseless code is needed for proper aiming.
|
|
|
|
self->z+=MissileHeight-32*FRACUNIT;
|
|
|
|
AActor * missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, self, self->target, MissileType, false);
|
|
|
|
self->z-=MissileHeight-32*FRACUNIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
if (missile)
|
|
|
|
{
|
|
|
|
// automatic handling of seeker missiles
|
|
|
|
if (missile->flags2&MF2_SEEKERMISSILE)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-12 14:30:07 +00:00
|
|
|
missile->tracer=self->target;
|
|
|
|
}
|
|
|
|
// set the health value so that the missile works properly
|
|
|
|
if (missile->flags4&MF4_SPECTRAL)
|
|
|
|
{
|
|
|
|
missile->health=-2;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-12 14:30:07 +00:00
|
|
|
P_CheckMissileSpawn(missile);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_MeleeAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-12 14:30:07 +00:00
|
|
|
int MeleeDamage = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeDamage, 0);
|
|
|
|
FSoundID MeleeSound = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeSound, 0);
|
|
|
|
DoAttack(self, true, false, MeleeDamage, MeleeSound, NULL, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_MissileAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-12 14:30:07 +00:00
|
|
|
const PClass *MissileType=PClass::FindClass((ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None));
|
|
|
|
fixed_t MissileHeight= self->GetClass()->Meta.GetMetaFixed (ACMETA_MissileHeight, 32*FRACUNIT);
|
|
|
|
DoAttack(self, false, true, 0, 0, MissileType, MissileHeight);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ComboAttack)
|
|
|
|
{
|
2008-08-12 14:30:07 +00:00
|
|
|
int MeleeDamage = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeDamage, 0);
|
|
|
|
FSoundID MeleeSound = self->GetClass()->Meta.GetMetaInt (ACMETA_MeleeSound, 0);
|
|
|
|
const PClass *MissileType=PClass::FindClass((ENamedName) self->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None));
|
|
|
|
fixed_t MissileHeight= self->GetClass()->Meta.GetMetaFixed (ACMETA_MissileHeight, 32*FRACUNIT);
|
|
|
|
DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight);
|
2008-08-10 20:48:55 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BasicAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(4);
|
|
|
|
ACTION_PARAM_INT(MeleeDamage, 0);
|
|
|
|
ACTION_PARAM_SOUND(MeleeSound, 1);
|
|
|
|
ACTION_PARAM_CLASS(MissileType, 2);
|
|
|
|
ACTION_PARAM_FIXED(MissileHeight, 3);
|
2008-08-12 14:30:07 +00:00
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
if (MissileType == NULL) return;
|
2008-08-13 22:54:24 +00:00
|
|
|
DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
2009-04-14 09:06:03 +00:00
|
|
|
// Custom sound functions.
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-04-14 09:06:03 +00:00
|
|
|
ACTION_PARAM_START(5);
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_SOUND(soundid, 0);
|
2009-04-14 09:06:03 +00:00
|
|
|
ACTION_PARAM_INT(channel, 1);
|
|
|
|
ACTION_PARAM_FLOAT(volume, 2);
|
|
|
|
ACTION_PARAM_BOOL(looping, 3);
|
|
|
|
ACTION_PARAM_FLOAT(attenuation, 4);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-04-14 09:06:03 +00:00
|
|
|
if (!looping)
|
|
|
|
{
|
|
|
|
S_Sound (self, channel, soundid, volume, attenuation);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!S_IsActorPlayingSomething (self, channel&7, soundid))
|
|
|
|
{
|
|
|
|
S_Sound (self, channel | CHAN_LOOP, soundid, volume, attenuation);
|
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2009-04-14 09:06:03 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
2009-04-14 09:06:03 +00:00
|
|
|
ACTION_PARAM_INT(slot, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-04-14 09:06:03 +00:00
|
|
|
S_StopSound(self, slot);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2009-04-14 09:06:03 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// These come from a time when DECORATE constants did not exist yet and
|
|
|
|
// the sound interface was less flexible. As a result the parameters are
|
|
|
|
// not optimal and these functions have been deprecated in favor of extending
|
|
|
|
// A_PlaySound and A_StopSound.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayWeaponSound)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-04-14 09:06:03 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_SOUND(soundid, 0);
|
|
|
|
|
|
|
|
S_Sound (self, CHAN_WEAPON, soundid, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlaySoundEx)
|
2006-08-31 00:16:12 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(4);
|
|
|
|
ACTION_PARAM_SOUND(soundid, 0);
|
|
|
|
ACTION_PARAM_NAME(channel, 1);
|
|
|
|
ACTION_PARAM_BOOL(looping, 2);
|
|
|
|
ACTION_PARAM_INT(attenuation_raw, 3);
|
2007-12-28 11:17:52 +00:00
|
|
|
|
2009-05-15 10:39:40 +00:00
|
|
|
float attenuation;
|
2007-12-28 11:17:52 +00:00
|
|
|
switch (attenuation_raw)
|
|
|
|
{
|
2008-03-21 05:13:59 +00:00
|
|
|
case -1: attenuation = ATTN_STATIC; break; // drop off rapidly
|
2007-12-28 11:17:52 +00:00
|
|
|
default:
|
2008-03-21 05:13:59 +00:00
|
|
|
case 0: attenuation = ATTN_NORM; break; // normal
|
|
|
|
case 1:
|
|
|
|
case 2: attenuation = ATTN_NONE; break; // full volume
|
2007-12-28 11:17:52 +00:00
|
|
|
}
|
2006-08-31 00:16:12 +00:00
|
|
|
|
|
|
|
if (channel < NAME_Auto || channel > NAME_SoundSlot7)
|
|
|
|
{
|
|
|
|
channel = NAME_Auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!looping)
|
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
S_Sound (self, int(channel) - NAME_Auto, soundid, 1, attenuation);
|
2006-08-31 00:16:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
if (!S_IsActorPlayingSomething (self, int(channel) - NAME_Auto, soundid))
|
2006-08-31 00:16:12 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
S_Sound (self, (int(channel) - NAME_Auto) | CHAN_LOOP, soundid, 1, attenuation);
|
2006-08-31 00:16:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StopSoundEx)
|
2006-08-31 00:16:12 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_NAME(channel, 0);
|
2006-08-31 00:16:12 +00:00
|
|
|
|
|
|
|
if (channel > NAME_Auto && channel <= NAME_SoundSlot7)
|
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
S_StopSound (self, int(channel) - NAME_Auto);
|
2006-08-31 00:16:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Generic seeker missile function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(ang1, 0);
|
|
|
|
ACTION_PARAM_INT(ang2, 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
P_SeekerMissile(self, clamp<int>(ang1, 0, 90) * ANGLE_1, clamp<int>(ang2, 0, 90) * ANGLE_1);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Hitscan attack with a customizable amount of bullets (specified in damage)
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-13 22:54:24 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int bangle;
|
|
|
|
int slope;
|
|
|
|
|
|
|
|
if (!self->target) return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
bangle = self->angle;
|
|
|
|
|
|
|
|
slope = P_AimLineAttack (self, bangle, MISSILERANGE);
|
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
- Added the ACS commands
ReplaceTextures (str old_texture, str new_texture, optional bool not_lower,
optional bool not_mid, optional bool not_upper, optional bool not_floor,
optional bool not_ceiling); and
SectorDamage (int tag, int amount, str type, bool players_only, bool in_air,
str protection_item, bool subclasses_okay);
- Added the vid_nowidescreen cvar to disable widescreen aspect ratio
correction. When this is enabled, the only display ratio available is 4:3
(and 5:4 if vid_tft is set).
- Added support for setting an actor's damage property to an expression
through decorate. Just enclose it within parentheses, and the expression
will be evaluated exactly as-is without the normal Doom damage calculation.
So if you want something that does exactly 6 damage, use a "Damage (6)"
property. To deal normal Doom missile damage, you can use
"Damage (random(1,8)*6)" instead of "Damage 6".
- Moved InvFirst and InvSel into APlayerPawn so that they can be consistantly
maintained by ObtainInventory.
SVN r288 (trunk)
2006-08-12 02:30:57 +00:00
|
|
|
for (i = self->GetMissileDamage (0, 1); i > 0; --i)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int angle = bangle + (pr_cabullet.Random2() << 20);
|
|
|
|
int damage = ((pr_cabullet()%5)+1)*3;
|
|
|
|
P_LineAttack(self, angle, MISSILERANGE, slope, damage,
|
2006-11-04 13:06:42 +00:00
|
|
|
NAME_None, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-05 22:08:57 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Do the state jump
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-10-25 17:38:00 +00:00
|
|
|
static void DoJump(AActor * self, FState * CallingState, FState *jumpto, StateCallData *statecall)
|
2007-01-05 22:08:57 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
if (jumpto == NULL) return;
|
2006-11-05 21:46:28 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
if (statecall != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
statecall->State = jumpto;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-09-25 07:48:52 +00:00
|
|
|
else if (self->player != NULL && CallingState == self->player->psprites[ps_weapon].state)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-11-05 21:46:28 +00:00
|
|
|
P_SetPsprite(self->player, ps_weapon, jumpto);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-09-25 07:48:52 +00:00
|
|
|
else if (self->player != NULL && CallingState == self->player->psprites[ps_flash].state)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-11-05 21:46:28 +00:00
|
|
|
P_SetPsprite(self->player, ps_flash, jumpto);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
else if (CallingState == self->state)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-11-05 21:46:28 +00:00
|
|
|
self->SetState (jumpto);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// something went very wrong. This should never happen.
|
|
|
|
assert(false);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
|
|
|
|
// This is just to avoid having to directly reference the internally defined
|
|
|
|
// CallingState and statecall parameters in the code below.
|
|
|
|
#define ACTION_JUMP(offset) DoJump(self, CallingState, offset, statecall)
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(3);
|
2008-10-25 17:38:00 +00:00
|
|
|
ACTION_PARAM_INT(count, 0);
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_INT(maxchance, 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (count >= 2 && (maxchance >= 256 || pr_cajump() < maxchance))
|
2006-10-24 02:32:12 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
int jumps = 2 + (count == 2? 0 : (pr_cajump() % (count - 1)));
|
|
|
|
ACTION_PARAM_STATE(jumpto, jumps);
|
|
|
|
ACTION_JUMP(jumpto);
|
2006-10-24 02:32:12 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2006-10-24 02:32:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfHealthLower)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(health, 0);
|
|
|
|
ACTION_PARAM_STATE(jump, 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
if (self->health < health) ACTION_JUMP(jump);
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_FIXED(dist, 0);
|
|
|
|
ACTION_PARAM_STATE(jump, 1);
|
|
|
|
|
|
|
|
AActor *target;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!self->player)
|
|
|
|
{
|
|
|
|
target=self->target;
|
|
|
|
}
|
|
|
|
else
|
2006-03-12 22:04:49 +00:00
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
// Does the player aim at something that can be shot?
|
2008-04-10 14:38:43 +00:00
|
|
|
P_BulletSlope(self, &target);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// No target - no jump
|
|
|
|
if (target==NULL) return;
|
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (P_AproxDistance(self->x-target->x, self->y-target->y) < dist &&
|
2008-03-19 09:53:23 +00:00
|
|
|
( (self->z > target->z && self->z - (target->z + target->height) < dist) ||
|
|
|
|
(self->z <=target->z && target->z - (self->z + self->height) < dist)
|
|
|
|
)
|
|
|
|
)
|
2008-08-14 08:52:55 +00:00
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-10-25 17:38:00 +00:00
|
|
|
void DoJumpIfInventory(AActor * owner, DECLARE_PARAMINFO)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(3);
|
|
|
|
ACTION_PARAM_CLASS(Type, 0);
|
|
|
|
ACTION_PARAM_INT(ItemAmount, 1);
|
|
|
|
ACTION_PARAM_STATE(JumpOffset, 2);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2006-12-06 10:38:47 +00:00
|
|
|
if (!Type || owner == NULL) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
AInventory * Item=owner->FindInventory(Type);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (Item)
|
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
if (ItemAmount>0 && Item->Amount>=ItemAmount) ACTION_JUMP(JumpOffset);
|
|
|
|
else if (Item->Amount>=Item->MaxAmount) ACTION_JUMP(JumpOffset);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInventory)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
DoJumpIfInventory(self, PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetInventory)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
DoJumpIfInventory(self->target, PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-06-05 20:23:47 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfArmorType)
|
|
|
|
{
|
|
|
|
ACTION_PARAM_START(3);
|
|
|
|
ACTION_PARAM_NAME(Type, 0);
|
|
|
|
ACTION_PARAM_STATE(JumpOffset, 1);
|
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
|
|
|
ABasicArmor * armor = (ABasicArmor *) self->FindInventory(NAME_BasicArmor);
|
|
|
|
|
|
|
|
if (armor && armor->ArmorType == Type)
|
|
|
|
ACTION_JUMP(JumpOffset);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Parameterized version of A_Explode
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(4);
|
|
|
|
ACTION_PARAM_INT(damage, 0);
|
2008-08-16 08:11:39 +00:00
|
|
|
ACTION_PARAM_INT(distance, 1);
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_BOOL(hurtSource, 2);
|
|
|
|
ACTION_PARAM_BOOL(alert, 3);
|
2008-08-12 20:19:47 +00:00
|
|
|
|
|
|
|
if (damage < 0) // get parameters from metadata
|
2006-07-29 10:47:14 +00:00
|
|
|
{
|
|
|
|
damage = self->GetClass()->Meta.GetMetaInt (ACMETA_ExplosionDamage, 128);
|
|
|
|
distance = self->GetClass()->Meta.GetMetaInt (ACMETA_ExplosionRadius, damage);
|
|
|
|
hurtSource = !self->GetClass()->Meta.GetMetaInt (ACMETA_DontHurtShooter);
|
2008-08-05 17:58:38 +00:00
|
|
|
alert = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-12 20:19:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (distance <= 0) distance = damage;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
P_RadiusAttack (self, self->target, damage, distance, self->DamageType, hurtSource);
|
|
|
|
if (self->z <= self->floorz + (distance<<FRACBITS))
|
|
|
|
{
|
|
|
|
P_HitFloor (self);
|
|
|
|
}
|
2008-08-05 17:58:38 +00:00
|
|
|
if (alert && self->target != NULL && self->target->player != NULL)
|
|
|
|
{
|
|
|
|
validcount++;
|
|
|
|
P_RecursiveSound (self->Sector, self->target, false, 0);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-07-02 21:58:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_RadiusThrust
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust)
|
2006-07-02 21:58:10 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(3);
|
|
|
|
ACTION_PARAM_INT(force, 0);
|
|
|
|
ACTION_PARAM_FIXED(distance, 1);
|
|
|
|
ACTION_PARAM_BOOL(affectSource, 2);
|
2008-08-12 20:19:47 +00:00
|
|
|
|
|
|
|
if (force <= 0) force = 128;
|
|
|
|
if (distance <= 0) distance = force;
|
2006-07-02 21:58:10 +00:00
|
|
|
|
2006-08-10 21:03:17 +00:00
|
|
|
P_RadiusAttack (self, self->target, force, distance, self->DamageType, affectSource, false);
|
2006-07-02 21:58:10 +00:00
|
|
|
if (self->z <= self->floorz + (distance<<FRACBITS))
|
|
|
|
{
|
|
|
|
P_HitFloor (self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Execute a line special / script
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CallSpecial)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(6);
|
|
|
|
ACTION_PARAM_INT(special, 0);
|
|
|
|
ACTION_PARAM_INT(arg1, 1);
|
|
|
|
ACTION_PARAM_INT(arg2, 2);
|
|
|
|
ACTION_PARAM_INT(arg3, 3);
|
|
|
|
ACTION_PARAM_INT(arg4, 4);
|
|
|
|
ACTION_PARAM_INT(arg5, 5);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
bool res = !!LineSpecials[special](NULL, self, false, arg1, arg2, arg3, arg4, arg5);
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Checks whether this actor is a missile
|
|
|
|
// Unfortunately this was buggy in older versions of the code and many
|
|
|
|
// released DECORATE monsters rely on this bug so it can only be fixed
|
|
|
|
// with an optional flag
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
inline static bool isMissile(AActor * self, bool precise=true)
|
|
|
|
{
|
|
|
|
return self->flags&MF_MISSILE || (precise && self->GetDefault()->flags&MF_MISSILE);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// The ultimate code pointer: Fully customizable missiles!
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2006-11-25 12:25:05 +00:00
|
|
|
enum CM_Flags
|
|
|
|
{
|
|
|
|
CMF_AIMMODE = 3,
|
|
|
|
CMF_TRACKOWNER = 4,
|
|
|
|
CMF_CHECKTARGETDEAD = 8,
|
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(6);
|
|
|
|
ACTION_PARAM_CLASS(ti, 0);
|
|
|
|
ACTION_PARAM_FIXED(SpawnHeight, 1);
|
|
|
|
ACTION_PARAM_INT(Spawnofs_XY, 2);
|
|
|
|
ACTION_PARAM_ANGLE(Angle, 3);
|
|
|
|
ACTION_PARAM_INT(flags, 4);
|
|
|
|
ACTION_PARAM_ANGLE(pitch, 5);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-11-25 12:25:05 +00:00
|
|
|
int aimmode = flags & CMF_AIMMODE;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
AActor * targ;
|
|
|
|
AActor * missile;
|
|
|
|
|
|
|
|
if (self->target != NULL || aimmode==2)
|
|
|
|
{
|
|
|
|
if (ti)
|
|
|
|
{
|
|
|
|
angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT;
|
|
|
|
fixed_t x = Spawnofs_XY * finecosine[ang];
|
|
|
|
fixed_t y = Spawnofs_XY * finesine[ang];
|
2006-05-14 14:30:13 +00:00
|
|
|
fixed_t z = SpawnHeight - 32*FRACUNIT + (self->player? self->player->crouchoffset : 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-11-25 12:25:05 +00:00
|
|
|
switch (aimmode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2006-04-12 03:03:58 +00:00
|
|
|
default:
|
2006-02-24 04:48:15 +00:00
|
|
|
// same adjustment as above (in all 3 directions this time) - for better aiming!
|
|
|
|
self->x+=x;
|
|
|
|
self->y+=y;
|
|
|
|
self->z+=z;
|
2008-07-05 10:17:10 +00:00
|
|
|
missile = P_SpawnMissileXYZ(self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false);
|
2006-02-24 04:48:15 +00:00
|
|
|
self->x-=x;
|
|
|
|
self->y-=y;
|
|
|
|
self->z-=z;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2008-07-05 10:17:10 +00:00
|
|
|
missile = P_SpawnMissileXYZ(self->x+x, self->y+y, self->z+SpawnHeight, self, self->target, ti, false);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2008-03-20 21:12:03 +00:00
|
|
|
self->x+=x;
|
|
|
|
self->y+=y;
|
2008-07-05 10:17:10 +00:00
|
|
|
missile = P_SpawnMissileAngleZSpeed(self, self->z+SpawnHeight, ti, self->angle, 0, GetDefaultByType(ti)->Speed, self, false);
|
2008-03-20 21:12:03 +00:00
|
|
|
self->x-=x;
|
|
|
|
self->y-=y;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// It is not necessary to use the correct angle here.
|
|
|
|
// The only important thing is that the horizontal momentum is correct.
|
|
|
|
// Therefore use 0 as the missile's angle and simplify the calculations accordingly.
|
|
|
|
// The actual momentum vector is set below.
|
|
|
|
if (missile)
|
|
|
|
{
|
|
|
|
fixed_t vx = finecosine[pitch>>ANGLETOFINESHIFT];
|
|
|
|
fixed_t vz = finesine[pitch>>ANGLETOFINESHIFT];
|
|
|
|
|
|
|
|
missile->momx = FixedMul (vx, missile->Speed);
|
|
|
|
missile->momy = 0;
|
|
|
|
missile->momz = FixedMul (vz, missile->Speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (missile)
|
|
|
|
{
|
|
|
|
// Use the actual momentum instead of the missile's Speed property
|
|
|
|
// so that this can handle missiles with a high vertical velocity
|
|
|
|
// component properly.
|
2007-01-19 02:00:39 +00:00
|
|
|
FVector3 velocity (missile->momx, missile->momy, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-01-19 02:00:39 +00:00
|
|
|
fixed_t missilespeed = (fixed_t)velocity.Length();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
missile->angle += Angle;
|
|
|
|
ang = missile->angle >> ANGLETOFINESHIFT;
|
|
|
|
missile->momx = FixedMul (missilespeed, finecosine[ang]);
|
|
|
|
missile->momy = FixedMul (missilespeed, finesine[ang]);
|
|
|
|
|
|
|
|
// handle projectile shooting projectiles - track the
|
|
|
|
// links back to a real owner
|
2006-11-25 12:25:05 +00:00
|
|
|
if (isMissile(self, !!(flags & CMF_TRACKOWNER)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor * owner=self ;//->target;
|
2006-11-25 12:25:05 +00:00
|
|
|
while (isMissile(owner, !!(flags & CMF_TRACKOWNER)) && owner->target) owner=owner->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
targ=owner;
|
|
|
|
missile->target=owner;
|
|
|
|
// automatic handling of seeker missiles
|
|
|
|
if (self->flags & missile->flags2 & MF2_SEEKERMISSILE)
|
|
|
|
{
|
|
|
|
missile->tracer=self->tracer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (missile->flags2&MF2_SEEKERMISSILE)
|
|
|
|
{
|
|
|
|
// automatic handling of seeker missiles
|
|
|
|
missile->tracer=self->target;
|
|
|
|
}
|
|
|
|
// set the health value so that the missile works properly
|
|
|
|
if (missile->flags4&MF4_SPECTRAL)
|
|
|
|
{
|
|
|
|
missile->health=-2;
|
|
|
|
}
|
2008-07-05 10:17:10 +00:00
|
|
|
P_CheckMissileSpawn(missile);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-25 12:25:05 +00:00
|
|
|
else if (flags & CMF_CHECKTARGETDEAD)
|
|
|
|
{
|
|
|
|
// Target is dead and the attack shall be aborted.
|
|
|
|
if (self->SeeState != NULL) self->SetState(self->SeeState);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// An even more customizable hitscan attack
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(7);
|
|
|
|
ACTION_PARAM_ANGLE(Spread_XY, 0);
|
|
|
|
ACTION_PARAM_ANGLE(Spread_Z, 1);
|
|
|
|
ACTION_PARAM_INT(NumBullets, 2);
|
|
|
|
ACTION_PARAM_INT(DamagePerBullet, 3);
|
|
|
|
ACTION_PARAM_CLASS(pufftype, 4);
|
|
|
|
ACTION_PARAM_FIXED(Range, 5);
|
|
|
|
ACTION_PARAM_BOOL(AimFacing, 6);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if(Range==0) Range=MISSILERANGE;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int bangle;
|
|
|
|
int bslope;
|
|
|
|
|
2007-12-28 11:17:52 +00:00
|
|
|
if (self->target || AimFacing)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-12-28 11:17:52 +00:00
|
|
|
if (!AimFacing) A_FaceTarget (self);
|
2006-02-24 04:48:15 +00:00
|
|
|
bangle = self->angle;
|
|
|
|
|
2006-11-04 13:06:42 +00:00
|
|
|
if (!pufftype) pufftype = PClass::FindClass(NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
bslope = P_AimLineAttack (self, bangle, MISSILERANGE);
|
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i=0 ; i<NumBullets ; i++)
|
|
|
|
{
|
|
|
|
int angle = bangle + pr_cabullet.Random2() * (Spread_XY / 255);
|
|
|
|
int slope = bslope + pr_cabullet.Random2() * (Spread_Z / 255);
|
|
|
|
int damage = ((pr_cabullet()%3)+1) * DamagePerBullet;
|
|
|
|
P_LineAttack(self, angle, Range, slope, damage, GetDefaultByType(pufftype)->DamageType, pufftype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-07 00:27:22 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A fully customizable melee attack
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMeleeAttack)
|
2006-05-07 00:27:22 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(5);
|
|
|
|
ACTION_PARAM_INT(damage, 0);
|
|
|
|
ACTION_PARAM_SOUND(MeleeSound, 1);
|
|
|
|
ACTION_PARAM_SOUND(MissSound, 2);
|
|
|
|
ACTION_PARAM_NAME(DamageType, 3);
|
|
|
|
ACTION_PARAM_BOOL(bleed, 4);
|
2006-05-07 00:27:22 +00:00
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type
|
2006-05-07 00:27:22 +00:00
|
|
|
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
if (self->CheckMeleeRange ())
|
|
|
|
{
|
2008-06-15 02:25:09 +00:00
|
|
|
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj (self->target, self, self, damage, DamageType);
|
2006-05-07 00:27:22 +00:00
|
|
|
if (bleed) P_TraceBleed (damage, self->target, self);
|
|
|
|
}
|
2006-11-25 12:25:05 +00:00
|
|
|
else
|
|
|
|
{
|
2008-06-15 02:25:09 +00:00
|
|
|
if (MissSound) S_Sound (self, CHAN_WEAPON, MissSound, 1, ATTN_NORM);
|
2006-11-25 12:25:05 +00:00
|
|
|
}
|
2006-05-07 00:27:22 +00:00
|
|
|
}
|
|
|
|
|
2006-11-27 00:01:30 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A fully customizable combo attack
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomComboAttack)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(6);
|
|
|
|
ACTION_PARAM_CLASS(ti, 0);
|
|
|
|
ACTION_PARAM_FIXED(SpawnHeight, 1);
|
|
|
|
ACTION_PARAM_INT(damage, 2);
|
|
|
|
ACTION_PARAM_SOUND(MeleeSound, 3);
|
|
|
|
ACTION_PARAM_NAME(DamageType, 4);
|
|
|
|
ACTION_PARAM_BOOL(bleed, 5);
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
if (!self->target)
|
|
|
|
return;
|
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
if (self->CheckMeleeRange ())
|
|
|
|
{
|
|
|
|
if (DamageType==NAME_None) DamageType = NAME_Melee; // Melee is the default type
|
2008-06-15 02:25:09 +00:00
|
|
|
if (MeleeSound) S_Sound (self, CHAN_WEAPON, MeleeSound, 1, ATTN_NORM);
|
2006-11-27 00:01:30 +00:00
|
|
|
P_DamageMobj (self->target, self, self, damage, DamageType);
|
|
|
|
if (bleed) P_TraceBleed (damage, self->target, self);
|
|
|
|
}
|
2008-08-13 22:54:24 +00:00
|
|
|
else if (ti)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
// This seemingly senseless code is needed for proper aiming.
|
|
|
|
self->z+=SpawnHeight-32*FRACUNIT;
|
|
|
|
AActor * missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false);
|
|
|
|
self->z-=SpawnHeight-32*FRACUNIT;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (missile)
|
|
|
|
{
|
|
|
|
// automatic handling of seeker missiles
|
|
|
|
if (missile->flags2&MF2_SEEKERMISSILE)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
missile->tracer=self->target;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
2008-08-13 22:54:24 +00:00
|
|
|
// set the health value so that the missile works properly
|
|
|
|
if (missile->flags4&MF4_SPECTRAL)
|
|
|
|
{
|
|
|
|
missile->health=-2;
|
|
|
|
}
|
|
|
|
P_CheckMissileSpawn(missile);
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfNoAmmo)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
2006-12-06 10:38:47 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
if (!ACTION_CALL_FROM_WEAPON()) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!self->player->ReadyWeapon->CheckAmmo(self->player->ReadyWeapon->bAltFire, false, true))
|
2008-08-14 08:52:55 +00:00
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// An even more customizable hitscan attack
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(7);
|
|
|
|
ACTION_PARAM_ANGLE(Spread_XY, 0);
|
|
|
|
ACTION_PARAM_ANGLE(Spread_Z, 1);
|
|
|
|
ACTION_PARAM_INT(NumberOfBullets, 2);
|
|
|
|
ACTION_PARAM_INT(DamagePerBullet, 3);
|
|
|
|
ACTION_PARAM_CLASS(PuffType, 4);
|
|
|
|
ACTION_PARAM_BOOL(UseAmmo, 5);
|
|
|
|
ACTION_PARAM_FIXED(Range, 6);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (!self->player) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
player_t * player=self->player;
|
|
|
|
AWeapon * weapon=player->ReadyWeapon;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int bangle;
|
|
|
|
int bslope;
|
|
|
|
|
2006-04-15 15:00:29 +00:00
|
|
|
if (UseAmmo && weapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Range == 0) Range = PLAYERMISSILERANGE;
|
|
|
|
|
|
|
|
static_cast<APlayerPawn *>(self)->PlayAttacking2 ();
|
|
|
|
|
2008-04-10 14:38:43 +00:00
|
|
|
bslope = P_BulletSlope(self);
|
2006-02-24 04:48:15 +00:00
|
|
|
bangle = self->angle;
|
|
|
|
|
2006-11-04 13:06:42 +00:00
|
|
|
if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if ((NumberOfBullets==1 && !player->refire) || NumberOfBullets==0)
|
|
|
|
{
|
|
|
|
int damage = ((pr_cwbullet()%3)+1)*DamagePerBullet;
|
|
|
|
P_LineAttack(self, bangle, Range, bslope, damage, GetDefaultByType(PuffType)->DamageType, PuffType);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (NumberOfBullets == -1) NumberOfBullets = 1;
|
|
|
|
for (i=0 ; i<NumberOfBullets ; i++)
|
|
|
|
{
|
|
|
|
int angle = bangle + pr_cwbullet.Random2() * (Spread_XY / 255);
|
|
|
|
int slope = bslope + pr_cwbullet.Random2() * (Spread_Z / 255);
|
|
|
|
int damage = ((pr_cwbullet()%3)+1) * DamagePerBullet;
|
|
|
|
P_LineAttack(self, angle, Range, slope, damage, GetDefaultByType(PuffType)->DamageType, PuffType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_FireProjectile
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(6);
|
|
|
|
ACTION_PARAM_CLASS(ti, 0);
|
|
|
|
ACTION_PARAM_ANGLE(Angle, 1);
|
|
|
|
ACTION_PARAM_BOOL(UseAmmo, 2);
|
|
|
|
ACTION_PARAM_INT(SpawnOfs_XY, 3);
|
|
|
|
ACTION_PARAM_FIXED(SpawnHeight, 4);
|
|
|
|
ACTION_PARAM_BOOL(AimAtAngle, 5);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (!self->player) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
player_t *player=self->player;
|
|
|
|
AWeapon * weapon=player->ReadyWeapon;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor *linetarget;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-15 15:00:29 +00:00
|
|
|
if (UseAmmo && weapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ti)
|
|
|
|
{
|
|
|
|
angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT;
|
|
|
|
fixed_t x = SpawnOfs_XY * finecosine[ang];
|
|
|
|
fixed_t y = SpawnOfs_XY * finesine[ang];
|
|
|
|
fixed_t z = SpawnHeight;
|
2006-08-17 09:54:42 +00:00
|
|
|
fixed_t shootangle = self->angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-08-17 09:54:42 +00:00
|
|
|
if (AimAtAngle) shootangle+=Angle;
|
|
|
|
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
// automatic handling of seeker missiles
|
|
|
|
if (misl)
|
|
|
|
{
|
|
|
|
if (linetarget && misl->flags2&MF2_SEEKERMISSILE) misl->tracer=linetarget;
|
2006-08-17 09:54:42 +00:00
|
|
|
if (!AimAtAngle)
|
|
|
|
{
|
|
|
|
// This original implementation is to aim straight ahead and then offset
|
|
|
|
// the angle from the resulting direction.
|
2007-01-19 02:00:39 +00:00
|
|
|
FVector3 velocity(misl->momx, misl->momy, 0);
|
|
|
|
fixed_t missilespeed = (fixed_t)velocity.Length();
|
2006-08-17 09:54:42 +00:00
|
|
|
misl->angle += Angle;
|
|
|
|
angle_t an = misl->angle >> ANGLETOFINESHIFT;
|
|
|
|
misl->momx = FixedMul (missilespeed, finecosine[an]);
|
|
|
|
misl->momy = FixedMul (missilespeed, finesine[an]);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_CustomPunch
|
|
|
|
//
|
|
|
|
// Berserk is not handled here. That can be done with A_CheckIfInventory
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(5);
|
|
|
|
ACTION_PARAM_INT(Damage, 0);
|
|
|
|
ACTION_PARAM_BOOL(norandom, 1);
|
|
|
|
ACTION_PARAM_BOOL(UseAmmo, 2);
|
|
|
|
ACTION_PARAM_CLASS(PuffType, 3);
|
|
|
|
ACTION_PARAM_FIXED(Range, 4);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (!self->player) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
player_t *player=self->player;
|
|
|
|
AWeapon * weapon=player->ReadyWeapon;
|
|
|
|
|
|
|
|
|
|
|
|
angle_t angle;
|
|
|
|
int pitch;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor * linetarget;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!norandom) Damage *= (pr_cwpunch()%8+1);
|
|
|
|
|
|
|
|
angle = self->angle + (pr_cwpunch.Random2() << 18);
|
2006-06-07 20:53:40 +00:00
|
|
|
if (Range == 0) Range = MELEERANGE;
|
2008-04-10 14:38:43 +00:00
|
|
|
pitch = P_AimLineAttack (self, angle, Range, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// only use ammo when actually hitting something!
|
2006-04-15 15:00:29 +00:00
|
|
|
if (UseAmmo && linetarget && weapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
|
|
|
|
}
|
|
|
|
|
2006-11-04 13:06:42 +00:00
|
|
|
if (!PuffType) PuffType = PClass::FindClass(NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-04-04 14:31:20 +00:00
|
|
|
P_LineAttack (self, angle, Range, pitch, Damage, GetDefaultByType(PuffType)->DamageType, PuffType, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// turn to face target
|
|
|
|
if (linetarget)
|
|
|
|
{
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
self->angle = R_PointToAngle2 (self->x,
|
|
|
|
self->y,
|
|
|
|
linetarget->x,
|
|
|
|
linetarget->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// customizable railgun attack function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RailAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(8);
|
|
|
|
ACTION_PARAM_INT(Damage, 0);
|
|
|
|
ACTION_PARAM_INT(Spawnofs_XY, 1);
|
|
|
|
ACTION_PARAM_BOOL(UseAmmo, 2);
|
|
|
|
ACTION_PARAM_COLOR(Color1, 3);
|
|
|
|
ACTION_PARAM_COLOR(Color2, 4);
|
|
|
|
ACTION_PARAM_BOOL(Silent, 5);
|
|
|
|
ACTION_PARAM_FLOAT(MaxDiff, 6);
|
2008-10-28 22:33:00 +00:00
|
|
|
ACTION_PARAM_CLASS(PuffType, 7);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (!self->player) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
AWeapon * weapon=self->player->ReadyWeapon;
|
|
|
|
|
|
|
|
// only use ammo when actually hitting something!
|
2006-04-15 15:00:29 +00:00
|
|
|
if (UseAmmo)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true)) return; // out of ammo
|
|
|
|
}
|
|
|
|
|
2008-10-28 22:33:00 +00:00
|
|
|
P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, Silent, PuffType);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// also for monsters
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2009-01-01 15:09:49 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CRF_DONTAIM = 0,
|
|
|
|
CRF_AIMPARALLEL = 1,
|
|
|
|
CRF_AIMDIRECT = 2
|
|
|
|
};
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(8);
|
|
|
|
ACTION_PARAM_INT(Damage, 0);
|
|
|
|
ACTION_PARAM_INT(Spawnofs_XY, 1);
|
|
|
|
ACTION_PARAM_COLOR(Color1, 2);
|
|
|
|
ACTION_PARAM_COLOR(Color2, 3);
|
|
|
|
ACTION_PARAM_BOOL(Silent, 4);
|
2009-01-01 15:09:49 +00:00
|
|
|
ACTION_PARAM_INT(aim, 5);
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_FLOAT(MaxDiff, 6);
|
2008-10-28 22:33:00 +00:00
|
|
|
ACTION_PARAM_CLASS(PuffType, 7);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-01-01 15:09:49 +00:00
|
|
|
fixed_t saved_x = self->x;
|
|
|
|
fixed_t saved_y = self->y;
|
|
|
|
angle_t saved_angle = self->angle;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (aim && self->target == NULL)
|
- 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
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Andy Baker's stealth monsters
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->flags & MF_STEALTH)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->visdir = 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags &= ~MF_AMBUSH;
|
- 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
|
|
|
|
2009-01-01 15:09:49 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (aim)
|
|
|
|
{
|
2009-01-01 15:09:49 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->angle = R_PointToAngle2 (self->x,
|
|
|
|
self->y,
|
|
|
|
self->target->x,
|
|
|
|
self->target->y);
|
2009-01-01 15:09:49 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Let the aim trail behind the player
|
|
|
|
if (aim)
|
|
|
|
{
|
2009-01-01 15:09:49 +00:00
|
|
|
saved_angle = self->angle = R_PointToAngle2 (self->x, self->y,
|
2008-08-10 20:48:55 +00:00
|
|
|
self->target->x - self->target->momx * 3,
|
|
|
|
self->target->y - self->target->momy * 3);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-01-01 15:09:49 +00:00
|
|
|
if (aim == CRF_AIMDIRECT)
|
|
|
|
{
|
|
|
|
// Tricky: We must offset to the angle of the current position
|
|
|
|
// but then change the angle again to ensure proper aim.
|
|
|
|
self->x += Spawnofs_XY * finecosine[self->angle];
|
|
|
|
self->y += Spawnofs_XY * finesine[self->angle];
|
|
|
|
Spawnofs_XY = 0;
|
|
|
|
self->angle = R_PointToAngle2 (self->x, self->y,
|
|
|
|
self->target->x - self->target->momx * 3,
|
|
|
|
self->target->y - self->target->momy * 3);
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->target->flags & MF_SHADOW)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-01-01 15:09:49 +00:00
|
|
|
angle_t rnd = pr_crailgun.Random2() << 21;
|
|
|
|
self->angle += rnd;
|
|
|
|
saved_angle = rnd;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-01 15:09:49 +00:00
|
|
|
angle_t angle = (self->angle - ANG90) >> ANGLETOFINESHIFT;
|
|
|
|
|
2008-10-28 22:33:00 +00:00
|
|
|
P_RailAttack (self, Damage, Spawnofs_XY, Color1, Color2, MaxDiff, Silent, PuffType);
|
2009-01-01 15:09:49 +00:00
|
|
|
|
|
|
|
self->x = saved_x;
|
|
|
|
self->y = saved_y;
|
|
|
|
self->angle = saved_angle;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
2006-04-11 08:36:23 +00:00
|
|
|
// DoGiveInventory
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
static void DoGiveInventory(AActor * receiver, DECLARE_PARAMINFO)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_CLASS(mi, 0);
|
|
|
|
ACTION_PARAM_INT(amount, 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
bool res=true;
|
|
|
|
if (receiver == NULL) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (amount==0) amount=1;
|
|
|
|
if (mi)
|
|
|
|
{
|
2006-07-16 09:10:45 +00:00
|
|
|
AInventory *item = static_cast<AInventory *>(Spawn (mi, 0, 0, 0, NO_REPLACE));
|
2006-04-09 19:34:35 +00:00
|
|
|
if (item->IsKindOf(RUNTIME_CLASS(AHealth)))
|
|
|
|
{
|
|
|
|
item->Amount *= amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->Amount = amount;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
item->flags |= MF_DROPPED;
|
|
|
|
if (item->flags & MF_COUNTITEM)
|
|
|
|
{
|
|
|
|
item->flags&=~MF_COUNTITEM;
|
|
|
|
level.total_items--;
|
|
|
|
}
|
2008-09-13 22:08:41 +00:00
|
|
|
if (!item->CallTryPickup (receiver))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
item->Destroy ();
|
2006-09-25 07:48:52 +00:00
|
|
|
res = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-09-25 07:48:52 +00:00
|
|
|
else res = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-09-25 07:48:52 +00:00
|
|
|
else res = false;
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveInventory)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
DoGiveInventory(self, PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveToTarget)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
DoGiveInventory(self->target, PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2006-04-11 08:36:23 +00:00
|
|
|
// A_TakeInventory
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
void DoTakeInventory(AActor * receiver, DECLARE_PARAMINFO)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_CLASS(item, 0);
|
|
|
|
ACTION_PARAM_INT(amount, 1);
|
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
if (item == NULL || receiver == NULL) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
bool res = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-12-25 13:43:11 +00:00
|
|
|
AInventory * inv = receiver->FindInventory(item);
|
|
|
|
|
|
|
|
if (inv && !inv->IsKindOf(RUNTIME_CLASS(AHexenArmor)))
|
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
if (inv->Amount > 0)
|
|
|
|
{
|
|
|
|
res = true;
|
|
|
|
}
|
2006-12-25 13:43:11 +00:00
|
|
|
if (!amount || amount>=inv->Amount)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2007-10-05 08:04:38 +00:00
|
|
|
if (inv->ItemFlags&IF_KEEPDEPLETED) inv->Amount=0;
|
2006-12-25 13:43:11 +00:00
|
|
|
else inv->Destroy();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-12-25 13:43:11 +00:00
|
|
|
else inv->Amount-=amount;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeInventory)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
DoTakeInventory(self, PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TakeFromTarget)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
DoTakeInventory(self->target, PUSH_PARAMINFO);
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
2006-11-27 00:01:30 +00:00
|
|
|
// Common code for A_SpawnItem and A_SpawnItemEx
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-06-02 16:56:53 +00:00
|
|
|
enum SIX_Flags
|
|
|
|
{
|
|
|
|
SIXF_TRANSFERTRANSLATION=1,
|
|
|
|
SIXF_ABSOLUTEPOSITION=2,
|
|
|
|
SIXF_ABSOLUTEANGLE=4,
|
|
|
|
SIXF_ABSOLUTEMOMENTUM=8,
|
|
|
|
SIXF_SETMASTER=16,
|
|
|
|
SIXF_NOCHECKPOSITION=32,
|
|
|
|
SIXF_TELEFRAG=64,
|
|
|
|
// 128 is used by Skulltag!
|
|
|
|
SIXF_TRANSFERAMBUSHFLAG=256,
|
2009-05-30 08:56:40 +00:00
|
|
|
SIXF_TRANSFERPITCH=512,
|
2009-06-07 20:10:05 +00:00
|
|
|
SIXF_TRANSFERPOINTERS=1024,
|
2008-06-02 16:56:53 +00:00
|
|
|
};
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
static bool InitSpawnedItem(AActor *self, AActor *mo, int flags)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2006-07-13 03:34:50 +00:00
|
|
|
if (mo)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor * originator = self;
|
|
|
|
|
2008-06-02 16:56:53 +00:00
|
|
|
if ((flags & SIXF_TRANSFERTRANSLATION) && !(mo->flags2 & MF2_DONTTRANSLATE))
|
2006-08-17 00:19:26 +00:00
|
|
|
{
|
|
|
|
mo->Translation = self->Translation;
|
|
|
|
}
|
2009-06-07 20:10:05 +00:00
|
|
|
if (flags & SIXF_TRANSFERPOINTERS)
|
|
|
|
{
|
|
|
|
mo->target = self->target;
|
|
|
|
mo->master = self->master; // This will be overridden later if SIXF_SETMASTER is set
|
|
|
|
mo->tracer = self->tracer;
|
|
|
|
}
|
2006-08-17 00:19:26 +00:00
|
|
|
|
2006-05-24 13:11:30 +00:00
|
|
|
mo->angle=self->angle;
|
2009-05-30 08:56:40 +00:00
|
|
|
if (flags & SIXF_TRANSFERPITCH) mo->pitch = self->pitch;
|
2006-04-11 08:36:23 +00:00
|
|
|
while (originator && isMissile(originator)) originator = originator->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-06-02 16:56:53 +00:00
|
|
|
if (flags & SIXF_TELEFRAG)
|
|
|
|
{
|
|
|
|
P_TeleportMove(mo, mo->x, mo->y, mo->z, true);
|
|
|
|
// This is needed to ensure consistent behavior.
|
|
|
|
// Otherwise it will only spawn if nothing gets telefragged
|
|
|
|
flags |= SIXF_NOCHECKPOSITION;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo->flags3&MF3_ISMONSTER)
|
|
|
|
{
|
2008-06-02 16:56:53 +00:00
|
|
|
if (!(flags&SIXF_NOCHECKPOSITION) && !P_TestMobjLocation(mo))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// The monster is blocked so don't spawn it at all!
|
2006-04-16 13:29:50 +00:00
|
|
|
if (mo->CountsAsKill()) level.total_monsters--;
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->Destroy();
|
2008-08-14 08:52:55 +00:00
|
|
|
return false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (originator)
|
|
|
|
{
|
|
|
|
if (originator->flags3&MF3_ISMONSTER)
|
|
|
|
{
|
2006-04-11 08:36:23 +00:00
|
|
|
// If this is a monster transfer all friendliness information
|
|
|
|
mo->CopyFriendliness(originator, true);
|
2008-06-02 16:56:53 +00:00
|
|
|
if (flags&SIXF_SETMASTER) mo->master = originator; // don't let it attack you (optional)!
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (originator->player)
|
|
|
|
{
|
|
|
|
// A player always spawns a monster friendly to him
|
|
|
|
mo->flags|=MF_FRIENDLY;
|
2009-05-15 10:39:40 +00:00
|
|
|
mo->FriendPlayer = int(originator->player-players+1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
AActor * attacker=originator->player->attacker;
|
|
|
|
if (attacker)
|
|
|
|
{
|
|
|
|
if (!(attacker->flags&MF_FRIENDLY) ||
|
|
|
|
(deathmatch && attacker->FriendPlayer!=0 && attacker->FriendPlayer!=mo->FriendPlayer))
|
|
|
|
{
|
|
|
|
// Target the monster which last attacked the player
|
2008-06-22 09:13:19 +00:00
|
|
|
mo->LastHeard = mo->target = attacker;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-07 20:10:05 +00:00
|
|
|
else if (!(flags & SIXF_TRANSFERPOINTERS))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// If this is a missile or something else set the target to the originator
|
|
|
|
mo->target=originator? originator : self;
|
|
|
|
}
|
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
return true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-11-27 00:01:30 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SpawnItem
|
|
|
|
//
|
|
|
|
// Spawns an item in front of the caller like Heretic's time bomb
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItem)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(5);
|
|
|
|
ACTION_PARAM_CLASS(missile, 0);
|
|
|
|
ACTION_PARAM_FIXED(distance, 1);
|
|
|
|
ACTION_PARAM_FIXED(zheight, 2);
|
|
|
|
ACTION_PARAM_BOOL(useammo, 3);
|
|
|
|
ACTION_PARAM_BOOL(transfer_translation, 4);
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
if (!missile)
|
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false);
|
2006-11-27 00:01:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't spawn monsters if this actor has been massacred
|
|
|
|
if (self->DamageType == NAME_Massacre && GetDefaultByType(missile)->flags3&MF3_ISMONSTER) return;
|
|
|
|
|
|
|
|
if (distance==0)
|
|
|
|
{
|
|
|
|
// use the minimum distance that does not result in an overlap
|
|
|
|
distance=(self->radius+GetDefaultByType(missile)->radius)>>FRACBITS;
|
|
|
|
}
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
if (ACTION_CALL_FROM_WEAPON())
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
|
|
|
// Used from a weapon so use some ammo
|
|
|
|
AWeapon * weapon=self->player->ReadyWeapon;
|
|
|
|
|
|
|
|
if (!weapon) return;
|
|
|
|
if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
AActor * mo = Spawn( missile,
|
|
|
|
self->x + FixedMul(distance, finecosine[self->angle>>ANGLETOFINESHIFT]),
|
|
|
|
self->y + FixedMul(distance, finesine[self->angle>>ANGLETOFINESHIFT]),
|
|
|
|
self->z - self->floorclip + zheight, ALLOW_REPLACE);
|
|
|
|
|
2008-06-02 16:56:53 +00:00
|
|
|
int flags = (transfer_translation? SIXF_TRANSFERTRANSLATION:0) + (useammo? SIXF_SETMASTER:0);
|
2008-08-14 08:52:55 +00:00
|
|
|
bool res = InitSpawnedItem(self, mo, flags);
|
|
|
|
ACTION_SET_RESULT(res); // for an inventory item's use state
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SpawnItemEx
|
|
|
|
//
|
|
|
|
// Enhanced spawning function
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnItemEx)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(10);
|
|
|
|
ACTION_PARAM_CLASS(missile, 0);
|
|
|
|
ACTION_PARAM_FIXED(xofs, 1);
|
|
|
|
ACTION_PARAM_FIXED(yofs, 2);
|
|
|
|
ACTION_PARAM_FIXED(zofs, 3);
|
|
|
|
ACTION_PARAM_FIXED(xmom, 4);
|
|
|
|
ACTION_PARAM_FIXED(ymom, 5);
|
|
|
|
ACTION_PARAM_FIXED(zmom, 6);
|
|
|
|
ACTION_PARAM_ANGLE(Angle, 7);
|
|
|
|
ACTION_PARAM_INT(flags, 8);
|
|
|
|
ACTION_PARAM_INT(chance, 9);
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
if (!missile)
|
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false);
|
2006-11-27 00:01:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-11-27 21:51:36 +00:00
|
|
|
if (chance > 0 && pr_spawnitemex()<chance) return;
|
|
|
|
|
2006-11-27 00:01:30 +00:00
|
|
|
// Don't spawn monsters if this actor has been massacred
|
|
|
|
if (self->DamageType == NAME_Massacre && GetDefaultByType(missile)->flags3&MF3_ISMONSTER) return;
|
|
|
|
|
2006-11-27 21:51:36 +00:00
|
|
|
fixed_t x,y;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
if (!(flags & SIXF_ABSOLUTEANGLE))
|
|
|
|
{
|
|
|
|
Angle += self->angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
angle_t ang = Angle >> ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
if (flags & SIXF_ABSOLUTEPOSITION)
|
|
|
|
{
|
|
|
|
x = self->x + xofs;
|
|
|
|
y = self->y + yofs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// in relative mode negative y values mean 'left' and positive ones mean 'right'
|
|
|
|
// This is the inverse orientation of the absolute mode!
|
|
|
|
x = self->x + FixedMul(xofs, finecosine[ang]) + FixedMul(yofs, finesine[ang]);
|
|
|
|
y = self->y + FixedMul(xofs, finesine[ang]) - FixedMul(yofs, finecosine[ang]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & SIXF_ABSOLUTEMOMENTUM))
|
|
|
|
{
|
|
|
|
// Same orientation issue here!
|
|
|
|
fixed_t newxmom = FixedMul(xmom, finecosine[ang]) + FixedMul(ymom, finesine[ang]);
|
|
|
|
ymom = FixedMul(xmom, finesine[ang]) - FixedMul(ymom, finecosine[ang]);
|
|
|
|
xmom = newxmom;
|
|
|
|
}
|
|
|
|
|
2008-06-12 10:08:50 +00:00
|
|
|
AActor * mo = Spawn( missile, x, y, self->z - self->floorclip + zofs, ALLOW_REPLACE);
|
2008-08-14 08:52:55 +00:00
|
|
|
bool res = InitSpawnedItem(self, mo, flags);
|
|
|
|
ACTION_SET_RESULT(res); // for an inventory item's use state
|
2006-11-27 00:01:30 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->momx=xmom;
|
|
|
|
mo->momy=ymom;
|
|
|
|
mo->momz=zmom;
|
|
|
|
mo->angle=Angle;
|
2008-03-29 22:59:41 +00:00
|
|
|
if (flags & SIXF_TRANSFERAMBUSHFLAG) mo->flags = (mo->flags&~MF_AMBUSH) | (self->flags & MF_AMBUSH);
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_ThrowGrenade
|
|
|
|
//
|
|
|
|
// Throws a grenade (like Hexen's fighter flechette)
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ThrowGrenade)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(5);
|
|
|
|
ACTION_PARAM_CLASS(missile, 0);
|
|
|
|
ACTION_PARAM_FIXED(zheight, 1);
|
|
|
|
ACTION_PARAM_FIXED(xymom, 2);
|
|
|
|
ACTION_PARAM_FIXED(zmom, 3);
|
|
|
|
ACTION_PARAM_BOOL(useammo, 4);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
if (missile == NULL) return;
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
if (ACTION_CALL_FROM_WEAPON())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Used from a weapon so use some ammo
|
|
|
|
AWeapon * weapon=self->player->ReadyWeapon;
|
|
|
|
|
|
|
|
if (!weapon) return;
|
|
|
|
if (useammo && !weapon->DepleteAmmo(weapon->bAltFire)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AActor * bo;
|
|
|
|
|
2006-05-14 14:30:13 +00:00
|
|
|
bo = Spawn(missile, self->x, self->y,
|
2006-07-16 09:10:45 +00:00
|
|
|
self->z - self->floorclip + zheight + 35*FRACUNIT + (self->player? self->player->crouchoffset : 0),
|
|
|
|
ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (bo)
|
|
|
|
{
|
|
|
|
int pitch = self->pitch;
|
|
|
|
|
2006-11-25 12:25:05 +00:00
|
|
|
P_PlaySpawnSound(bo, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (xymom) bo->Speed=xymom;
|
|
|
|
bo->angle = self->angle+(((pr_grenade()&7)-4)<<24);
|
|
|
|
bo->momz = zmom + 2*finesine[pitch>>ANGLETOFINESHIFT];
|
|
|
|
bo->z += 2 * finesine[pitch>>ANGLETOFINESHIFT];
|
|
|
|
P_ThrustMobj(bo, bo->angle, bo->Speed);
|
|
|
|
bo->momx += self->momx>>1;
|
|
|
|
bo->momy += self->momy>>1;
|
|
|
|
bo->target= self;
|
2006-04-11 08:36:23 +00:00
|
|
|
if (bo->flags4&MF4_RANDOMIZE)
|
|
|
|
{
|
|
|
|
bo->tics -= pr_grenade()&3;
|
|
|
|
if (bo->tics<1) bo->tics=1;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
P_CheckMissileSpawn (bo);
|
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
else ACTION_SET_RESULT(false);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Recoil
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Recoil)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_FIXED(xymom, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
angle_t angle = self->angle + ANG180;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle >>= ANGLETOFINESHIFT;
|
2008-08-10 20:48:55 +00:00
|
|
|
self->momx += FixedMul (xymom, finecosine[angle]);
|
|
|
|
self->momy += FixedMul (xymom, finesine[angle]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SelectWeapon
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SelectWeapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_CLASS(cls, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
if (cls == NULL || self->player == NULL)
|
|
|
|
{
|
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
return;
|
|
|
|
}
|
2008-08-13 22:54:24 +00:00
|
|
|
|
|
|
|
AWeapon * weaponitem = static_cast<AWeapon*>(self->FindInventory(cls));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (weaponitem != NULL && weaponitem->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->player->ReadyWeapon != weaponitem)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->player->PendingWeapon = weaponitem;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
else ACTION_SET_RESULT(false);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-11-04 13:06:42 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Print
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2006-09-17 10:43:51 +00:00
|
|
|
EXTERN_CVAR(Float, con_midtime)
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Print)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(3);
|
|
|
|
ACTION_PARAM_STRING(text, 0);
|
|
|
|
ACTION_PARAM_FLOAT(time, 1);
|
|
|
|
ACTION_PARAM_NAME(fontname, 2);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->CheckLocalView (consoleplayer) ||
|
|
|
|
(self->target!=NULL && self->target->CheckLocalView (consoleplayer)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-09-17 10:43:51 +00:00
|
|
|
float saved = con_midtime;
|
2008-11-27 17:43:36 +00:00
|
|
|
FFont *font = NULL;
|
2006-09-17 10:43:51 +00:00
|
|
|
|
|
|
|
if (fontname != NAME_None)
|
|
|
|
{
|
2008-11-27 17:43:36 +00:00
|
|
|
font = V_GetFont(fontname);
|
2006-09-17 10:43:51 +00:00
|
|
|
}
|
|
|
|
if (time > 0)
|
|
|
|
{
|
|
|
|
con_midtime = time;
|
|
|
|
}
|
|
|
|
|
2008-11-27 17:43:36 +00:00
|
|
|
C_MidPrint(font != NULL ? font : SmallFont, text);
|
2006-09-17 10:43:51 +00:00
|
|
|
con_midtime = saved;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetTranslucent
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTranslucent)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_FIXED(alpha, 0);
|
|
|
|
ACTION_PARAM_INT(mode, 1);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
mode = mode == 0 ? STYLE_Translucent : mode == 2 ? STYLE_Fuzzy : STYLE_Add;
|
|
|
|
|
- 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
|
|
|
self->RenderStyle.Flags &= ~STYLEF_Alpha1;
|
|
|
|
self->alpha = clamp<fixed_t>(alpha, 0, FRACUNIT);
|
|
|
|
self->RenderStyle = ERenderStyle(mode);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_FadeIn
|
|
|
|
//
|
|
|
|
// Fades the actor in
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeIn)
|
2006-04-11 08:36:23 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_FIXED(reduce, 0);
|
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
if (reduce == 0) reduce = FRACUNIT/10;
|
|
|
|
|
- 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
|
|
|
self->RenderStyle.Flags &= ~STYLEF_Alpha1;
|
2006-04-11 08:36:23 +00:00
|
|
|
self->alpha += reduce;
|
|
|
|
//if (self->alpha<=0) self->Destroy();
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_FadeOut
|
|
|
|
//
|
|
|
|
// fades the actor out and destroys it when done
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeOut)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-06-07 22:13:16 +00:00
|
|
|
ACTION_PARAM_START(2);
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_FIXED(reduce, 0);
|
2009-06-07 22:13:16 +00:00
|
|
|
ACTION_PARAM_BOOL(remove, 1);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (reduce == 0) reduce = FRACUNIT/10;
|
|
|
|
|
- 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
|
|
|
self->RenderStyle.Flags &= ~STYLEF_Alpha1;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->alpha -= reduce;
|
2009-06-07 22:13:16 +00:00
|
|
|
if (self->alpha<=0 && remove) self->Destroy();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SpawnDebris
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
AActor * mo;
|
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(4);
|
|
|
|
ACTION_PARAM_CLASS(debris, 0);
|
|
|
|
ACTION_PARAM_BOOL(transfer_translation, 1);
|
|
|
|
ACTION_PARAM_FIXED(mult_h, 2);
|
|
|
|
ACTION_PARAM_FIXED(mult_v, 3);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (debris == NULL) return;
|
|
|
|
|
2006-12-06 10:38:47 +00:00
|
|
|
// only positive values make sense here
|
|
|
|
if (mult_v<=0) mult_v=FRACUNIT;
|
|
|
|
if (mult_h<=0) mult_h=FRACUNIT;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < GetDefaultByType(debris)->health; i++)
|
|
|
|
{
|
|
|
|
mo = Spawn(debris, self->x+((pr_spawndebris()-128)<<12),
|
|
|
|
self->y+((pr_spawndebris()-128)<<12),
|
2006-07-16 09:10:45 +00:00
|
|
|
self->z+(pr_spawndebris()*self->height/256), ALLOW_REPLACE);
|
2006-08-17 00:19:26 +00:00
|
|
|
if (mo && transfer_translation)
|
|
|
|
{
|
|
|
|
mo->Translation = self->Translation;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo && i < mo->GetClass()->ActorInfo->NumOwnedStates)
|
|
|
|
{
|
|
|
|
mo->SetState (mo->GetClass()->ActorInfo->OwnedStates + i);
|
2006-12-06 10:38:47 +00:00
|
|
|
mo->momz = FixedMul(mult_v, ((pr_spawndebris()&7)+5)*FRACUNIT);
|
|
|
|
mo->momx = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6));
|
|
|
|
mo->momy = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckSight
|
|
|
|
// jumps if no player can see this actor
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSight)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2006-12-06 10:38:47 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
for (int i=0;i<MAXPLAYERS;i++)
|
|
|
|
{
|
|
|
|
if (playeringame[i] && P_CheckSight(players[i].camera,self,true)) return;
|
|
|
|
}
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Inventory drop
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropInventory)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_CLASS(drop, 0);
|
2006-12-25 13:43:11 +00:00
|
|
|
|
2008-10-25 17:38:00 +00:00
|
|
|
if (drop)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-10-25 17:38:00 +00:00
|
|
|
AInventory * inv = self->FindInventory(drop);
|
|
|
|
if (inv)
|
|
|
|
{
|
|
|
|
self->DropInventory(inv);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetBlend
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetBlend)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(4);
|
|
|
|
ACTION_PARAM_COLOR(color, 0);
|
|
|
|
ACTION_PARAM_FLOAT(alpha, 1);
|
|
|
|
ACTION_PARAM_INT(tics, 2);
|
|
|
|
ACTION_PARAM_COLOR(color2, 3);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-16 04:19:20 +00:00
|
|
|
if (color == MAKEARGB(255,255,255,255)) color=0;
|
|
|
|
if (color2 == MAKEARGB(255,255,255,255)) color2=0;
|
2006-04-11 08:36:23 +00:00
|
|
|
if (!color2.a)
|
|
|
|
color2 = color;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-11 08:36:23 +00:00
|
|
|
new DFlashFader(color.r/255.0f, color.g/255.0f, color.b/255.0f, alpha,
|
|
|
|
color2.r/255.0f, color2.g/255.0f, color2.b/255.0f, 0,
|
|
|
|
(float)tics/TICRATE, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
2006-04-11 08:36:23 +00:00
|
|
|
// A_JumpIf
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIf)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_BOOL(expression, 0);
|
|
|
|
ACTION_PARAM_STATE(jump, 1);
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
if (expression) ACTION_JUMP(jump);
|
2006-12-06 10:38:47 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_KillMaster
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KillMaster)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-06-11 11:28:48 +00:00
|
|
|
if (self->master != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj(self->master, self, self, self->master->health, NAME_None, DMG_NO_ARMOR);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_KillChildren
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KillChildren)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor * mo;
|
|
|
|
|
2006-05-22 01:34:07 +00:00
|
|
|
while ( (mo = it.Next()) )
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (mo->master == self)
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
P_DamageMobj(mo, self, self, mo->health, NAME_None, DMG_NO_ARMOR);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-18 22:15:05 +00:00
|
|
|
|
2008-12-06 10:22:37 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_KillSiblings
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KillSiblings)
|
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor * mo;
|
|
|
|
|
|
|
|
while ( (mo = it.Next()) )
|
|
|
|
{
|
|
|
|
if (mo->master == self->master && mo != self)
|
|
|
|
{
|
|
|
|
P_DamageMobj(mo, self, self, mo->health, NAME_None, DMG_NO_ARMOR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-03 14:54:48 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CountdownArg
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg)
|
2006-05-03 14:54:48 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_INT(cnt, 0);
|
2006-05-03 14:54:48 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (cnt<0 || cnt>=5) return;
|
|
|
|
if (!self->args[cnt]--)
|
2006-05-03 14:54:48 +00:00
|
|
|
{
|
2006-05-07 23:55:17 +00:00
|
|
|
if (self->flags&MF_MISSILE)
|
|
|
|
{
|
2006-10-22 10:32:41 +00:00
|
|
|
P_ExplodeMissile(self, NULL, NULL);
|
2006-05-07 23:55:17 +00:00
|
|
|
}
|
|
|
|
else if (self->flags&MF_SHOOTABLE)
|
|
|
|
{
|
2009-05-23 08:30:36 +00:00
|
|
|
P_DamageMobj (self, NULL, NULL, self->health, NAME_None, DMG_FORCED);
|
2006-05-07 23:55:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-31 14:53:21 +00:00
|
|
|
self->SetState(self->FindState(NAME_Death));
|
2006-05-07 23:55:17 +00:00
|
|
|
}
|
2006-05-03 14:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-05-15 15:28:46 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_Burst
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst)
|
2006-05-15 15:28:46 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_CLASS(chunk, 0);
|
|
|
|
|
2006-05-15 15:28:46 +00:00
|
|
|
int i, numChunks;
|
|
|
|
AActor * mo;
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2006-05-15 15:28:46 +00:00
|
|
|
if (chunk == NULL) return;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->momx = self->momy = self->momz = 0;
|
|
|
|
self->height = self->GetDefault()->height;
|
2006-05-15 15:28:46 +00:00
|
|
|
|
|
|
|
// [RH] In Hexen, this creates a random number of shards (range [24,56])
|
2008-08-10 20:48:55 +00:00
|
|
|
// with no relation to the size of the self shattering. I think it should
|
2006-05-15 15:28:46 +00:00
|
|
|
// base the number of shards on the size of the dead thing, so bigger
|
|
|
|
// things break up into more shards than smaller things.
|
2008-08-10 20:48:55 +00:00
|
|
|
// An self with radius 20 and height 64 creates ~40 chunks.
|
|
|
|
numChunks = MAX<int> (4, (self->radius>>FRACBITS)*(self->height>>FRACBITS)/32);
|
2006-05-15 15:28:46 +00:00
|
|
|
i = (pr_burst.Random2()) % (numChunks/4);
|
|
|
|
for (i = MAX (24, numChunks + i); i >= 0; i--)
|
|
|
|
{
|
|
|
|
mo = Spawn(chunk,
|
2008-08-10 20:48:55 +00:00
|
|
|
self->x + (((pr_burst()-128)*self->radius)>>7),
|
|
|
|
self->y + (((pr_burst()-128)*self->radius)>>7),
|
|
|
|
self->z + (pr_burst()*self->height/255), ALLOW_REPLACE);
|
2006-05-15 15:28:46 +00:00
|
|
|
|
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->momz = FixedDiv(mo->z-self->z, self->height)<<2;
|
2006-05-15 15:28:46 +00:00
|
|
|
mo->momx = pr_burst.Random2 () << (FRACBITS-7);
|
|
|
|
mo->momy = pr_burst.Random2 () << (FRACBITS-7);
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->RenderStyle = self->RenderStyle;
|
|
|
|
mo->alpha = self->alpha;
|
|
|
|
mo->CopyFriendliness(self, true);
|
2006-05-15 15:28:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Do some stuff to make this more useful outside Hexen
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->flags4 & MF4_BOSSDEATH)
|
2006-05-15 15:28:46 +00:00
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_BossDeath, self);
|
2006-05-15 15:28:46 +00:00
|
|
|
}
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_NoBlocking, self);
|
2006-05-15 15:28:46 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->Destroy ();
|
2006-05-15 15:28:46 +00:00
|
|
|
}
|
|
|
|
|
2006-07-13 10:17:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckFloor
|
|
|
|
// [GRB] Jumps if actor is standing on floor
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFloor)
|
2006-07-13 10:17:56 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
2006-07-13 10:17:56 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2008-08-13 22:54:24 +00:00
|
|
|
if (self->z <= self->floorz)
|
2006-07-13 10:17:56 +00:00
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2006-07-13 10:17:56 +00:00
|
|
|
}
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2006-07-13 10:17:56 +00:00
|
|
|
}
|
2006-10-22 10:32:41 +00:00
|
|
|
|
2009-04-23 23:20:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckCeiling
|
|
|
|
// [GZ] Totally copied on A_CheckFloor, jumps if actor touches ceiling
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling)
|
|
|
|
{
|
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
|
|
|
|
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
if (self->z+self->height >= self->ceilingz) // Height needs to be counted
|
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:32:41 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Stop
|
|
|
|
// resets all momentum of the actor to 0
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Stop)
|
2006-10-22 10:32:41 +00:00
|
|
|
{
|
|
|
|
self->momx = self->momy = self->momz = 0;
|
2008-07-05 10:17:10 +00:00
|
|
|
if (self->player && self->player->mo == self && !(self->player->cheats & CF_PREDICTING))
|
|
|
|
{
|
|
|
|
self->player->mo->PlayIdle ();
|
|
|
|
self->player->momx = self->player->momy = 0;
|
|
|
|
}
|
|
|
|
|
2006-10-22 10:32:41 +00:00
|
|
|
}
|
2006-11-04 13:06:42 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Respawn
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
|
2006-11-04 13:06:42 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_BOOL(fog, 0);
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
fixed_t x = self->SpawnPoint[0];
|
|
|
|
fixed_t y = self->SpawnPoint[1];
|
2006-11-04 13:06:42 +00:00
|
|
|
sector_t *sec;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags |= MF_SOLID;
|
2007-12-25 10:07:58 +00:00
|
|
|
sec = P_PointInSector (x, y);
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetOrigin (x, y, sec->floorplane.ZatPoint (x, y));
|
|
|
|
self->height = self->GetDefault()->height;
|
|
|
|
if (P_TestMobjLocation (self))
|
2006-11-04 13:06:42 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
AActor *defs = self->GetDefault();
|
|
|
|
self->health = defs->health;
|
2006-11-04 13:06:42 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags = (defs->flags & ~MF_FRIENDLY) | (self->flags & MF_FRIENDLY);
|
|
|
|
self->flags2 = defs->flags2;
|
|
|
|
self->flags3 = (defs->flags3 & ~(MF3_NOSIGHTCHECK | MF3_HUNTPLAYERS)) | (self->flags3 & (MF3_NOSIGHTCHECK | MF3_HUNTPLAYERS));
|
|
|
|
self->flags4 = (defs->flags4 & ~MF4_NOHATEPLAYERS) | (self->flags4 & MF4_NOHATEPLAYERS);
|
|
|
|
self->flags5 = defs->flags5;
|
|
|
|
self->SetState (self->SpawnState);
|
|
|
|
self->renderflags &= ~RF_INVISIBLE;
|
2006-11-04 13:06:42 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
if (fog)
|
2006-11-04 13:06:42 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
Spawn<ATeleportFog> (x, y, self->z + TELEFOGHEIGHT, ALLOW_REPLACE);
|
2006-11-04 13:06:42 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->CountsAsKill()) level.total_monsters++;
|
2006-11-04 13:06:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags &= ~MF_SOLID;
|
2006-11-04 13:06:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-04 22:26:04 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_PlayerSkinCheck
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PlayerSkinCheck)
|
2006-11-04 22:26:04 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->player != NULL &&
|
|
|
|
skins[self->player->userinfo.skin].othergame)
|
2006-11-04 22:26:04 +00:00
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2006-11-04 22:26:04 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-20 14:27:44 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetGravity
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetGravity)
|
2007-01-20 14:27:44 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_FIXED(val, 0);
|
2007-01-20 14:27:44 +00:00
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
self->gravity = clamp<fixed_t> (val, 0, FRACUNIT*10);
|
2007-01-20 14:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-20 20:37:06 +00:00
|
|
|
// [KS] *** Start of my modifications ***
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_ClearTarget
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ClearTarget)
|
2007-12-20 20:37:06 +00:00
|
|
|
{
|
2007-12-26 05:03:14 +00:00
|
|
|
self->target = NULL;
|
|
|
|
self->LastHeard = NULL;
|
|
|
|
self->lastenemy = NULL;
|
2007-12-20 20:37:06 +00:00
|
|
|
}
|
|
|
|
|
2007-12-23 21:56:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
2008-05-15 17:16:32 +00:00
|
|
|
// A_JumpIfTargetInLOS (state label, optional fixed fov, optional bool
|
|
|
|
// projectiletarget)
|
|
|
|
//
|
2007-12-26 05:03:14 +00:00
|
|
|
// Jumps if the actor can see its target, or if the player has a linetarget.
|
2008-05-15 17:16:32 +00:00
|
|
|
// ProjectileTarget affects how projectiles are treated. If set, it will use
|
|
|
|
// the target of the projectile for seekers, and ignore the target for
|
|
|
|
// normal projectiles. If not set, it will use the missile's owner instead
|
|
|
|
// (the default).
|
2007-12-23 21:56:46 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
|
2007-12-23 21:56:46 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(3);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
|
|
|
ACTION_PARAM_ANGLE(fov, 1);
|
|
|
|
ACTION_PARAM_BOOL(projtarg, 2);
|
2008-08-12 20:19:47 +00:00
|
|
|
|
2007-12-23 21:56:46 +00:00
|
|
|
angle_t an;
|
2008-05-15 17:16:32 +00:00
|
|
|
AActor *target;
|
2007-12-23 21:56:46 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2007-12-23 21:56:46 +00:00
|
|
|
|
|
|
|
if (!self->player)
|
|
|
|
{
|
2008-05-15 17:16:32 +00:00
|
|
|
if (self->flags & MF_MISSILE && projtarg)
|
|
|
|
{
|
|
|
|
if (self->flags2 & MF2_SEEKERMISSILE)
|
|
|
|
target = self->tracer;
|
|
|
|
else
|
|
|
|
target = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target = self->target;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case.
|
2007-12-23 21:56:46 +00:00
|
|
|
|
|
|
|
if (!P_CheckSight (self, target, 1))
|
2008-05-15 17:16:32 +00:00
|
|
|
return;
|
2007-12-23 21:56:46 +00:00
|
|
|
|
|
|
|
if (fov && (fov < ANGLE_MAX))
|
|
|
|
{
|
|
|
|
an = R_PointToAngle2 (self->x,
|
|
|
|
self->y,
|
|
|
|
target->x,
|
|
|
|
target->y)
|
|
|
|
- self->angle;
|
|
|
|
|
|
|
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
|
|
|
{
|
|
|
|
return; // [KS] Outside of FOV - return
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Does the player aim at something that can be shot?
|
2008-04-10 14:38:43 +00:00
|
|
|
P_BulletSlope(self, &target);
|
2007-12-23 21:56:46 +00:00
|
|
|
}
|
|
|
|
|
2008-05-15 17:16:32 +00:00
|
|
|
if (!target) return;
|
2007-12-23 21:56:46 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2007-12-23 21:56:46 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 23:39:08 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_JumpIfInTargetLOS (state label, optional fixed fov, optional bool
|
|
|
|
// projectiletarget)
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
|
|
|
|
{
|
|
|
|
ACTION_PARAM_START(3);
|
|
|
|
ACTION_PARAM_STATE(jump, 0);
|
|
|
|
ACTION_PARAM_ANGLE(fov, 1);
|
|
|
|
ACTION_PARAM_BOOL(projtarg, 2);
|
|
|
|
|
|
|
|
angle_t an;
|
|
|
|
AActor *target;
|
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
|
|
|
if (self->flags & MF_MISSILE && projtarg)
|
|
|
|
{
|
|
|
|
if (self->flags2 & MF2_SEEKERMISSILE)
|
|
|
|
target = self->tracer;
|
|
|
|
else
|
|
|
|
target = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target = self->target;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!target) return; // [KS] Let's not call P_CheckSight unnecessarily in this case.
|
|
|
|
|
|
|
|
if (!P_CheckSight (target, self, 1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (fov && (fov < ANGLE_MAX))
|
|
|
|
{
|
|
|
|
an = R_PointToAngle2 (self->x,
|
|
|
|
self->y,
|
|
|
|
target->x,
|
|
|
|
target->y)
|
|
|
|
- self->angle;
|
|
|
|
|
|
|
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
|
|
|
{
|
|
|
|
return; // [KS] Outside of FOV - return
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-29 22:59:41 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_DamageMaster (int amount)
|
|
|
|
// Damages the master of this child by the specified amount. Negative values heal.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageMaster)
|
2008-03-29 22:59:41 +00:00
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(amount, 0);
|
|
|
|
ACTION_PARAM_NAME(DamageType, 1);
|
2008-03-29 22:59:41 +00:00
|
|
|
|
|
|
|
if (self->master != NULL)
|
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
|
|
|
P_DamageMobj(self->master, self, self, amount, DamageType, DMG_NO_ARMOR);
|
|
|
|
}
|
|
|
|
else if (amount < 0)
|
|
|
|
{
|
|
|
|
amount = -amount;
|
|
|
|
P_GiveBody(self->master, amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_DamageChildren (amount)
|
|
|
|
// Damages the children of this master by the specified amount. Negative values heal.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageChildren)
|
2008-03-29 22:59:41 +00:00
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor * mo;
|
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(amount, 0);
|
|
|
|
ACTION_PARAM_NAME(DamageType, 1);
|
2008-03-29 22:59:41 +00:00
|
|
|
|
|
|
|
while ( (mo = it.Next()) )
|
|
|
|
{
|
|
|
|
if (mo->master == self)
|
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
|
|
|
P_DamageMobj(mo, self, self, amount, DamageType, DMG_NO_ARMOR);
|
|
|
|
}
|
|
|
|
else if (amount < 0)
|
|
|
|
{
|
|
|
|
amount = -amount;
|
|
|
|
P_GiveBody(mo, amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-26 05:03:14 +00:00
|
|
|
// [KS] *** End of my modifications ***
|
2008-06-22 09:13:19 +00:00
|
|
|
|
2008-12-06 10:22:37 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_DamageSiblings (amount)
|
|
|
|
// Damages the siblings of this master by the specified amount. Negative values heal.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DamageSiblings)
|
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor * mo;
|
|
|
|
|
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(amount, 0);
|
|
|
|
ACTION_PARAM_NAME(DamageType, 1);
|
|
|
|
|
|
|
|
while ( (mo = it.Next()) )
|
|
|
|
{
|
|
|
|
if (mo->master == self->master && mo != self)
|
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
|
|
|
P_DamageMobj(mo, self, self, amount, DamageType, DMG_NO_ARMOR);
|
|
|
|
}
|
|
|
|
else if (amount < 0)
|
|
|
|
{
|
|
|
|
amount = -amount;
|
|
|
|
P_GiveBody(mo, amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-22 09:13:19 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Modified code pointer from Skulltag
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckForReload)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
|
|
|
if ( self->player == NULL || self->player->ReadyWeapon == NULL )
|
|
|
|
return;
|
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(count, 0);
|
|
|
|
ACTION_PARAM_STATE(jump, 1);
|
2008-08-21 08:04:21 +00:00
|
|
|
ACTION_PARAM_BOOL(dontincrement, 2)
|
|
|
|
|
|
|
|
if (count <= 0) return;
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2008-06-22 09:13:19 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2008-08-21 08:04:21 +00:00
|
|
|
|
|
|
|
int ReloadCounter = weapon->ReloadCounter;
|
|
|
|
if(!dontincrement || ReloadCounter != 0)
|
|
|
|
ReloadCounter = (weapon->ReloadCounter+1) % count;
|
|
|
|
else // 0 % 1 = 1? So how do we check if the weapon was never fired? We should only do this when we're not incrementing the counter though.
|
|
|
|
ReloadCounter = 1;
|
|
|
|
|
2008-06-22 09:13:19 +00:00
|
|
|
// If we have not made our last shot...
|
2008-08-21 08:04:21 +00:00
|
|
|
if (ReloadCounter != 0)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
|
|
|
// Go back to the refire frames, instead of continuing on to the reload frames.
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We need to reload. However, don't reload if we're out of ammo.
|
|
|
|
weapon->CheckAmmo( false, false );
|
|
|
|
}
|
2008-08-21 08:04:21 +00:00
|
|
|
|
|
|
|
if(!dontincrement)
|
|
|
|
weapon->ReloadCounter = ReloadCounter;
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Resets the counter for the above function
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ResetReloadCounter)
|
2008-06-22 09:13:19 +00:00
|
|
|
{
|
|
|
|
if ( self->player == NULL || self->player->ReadyWeapon == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
|
|
|
weapon->ReloadCounter = 0;
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_ChangeFlag
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag)
|
|
|
|
{
|
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_STRING(flagname, 0);
|
|
|
|
ACTION_PARAM_BOOL(expression, 1);
|
|
|
|
|
|
|
|
const char *dot = strchr (flagname, '.');
|
|
|
|
FFlagDef *fd;
|
|
|
|
const PClass *cls = self->GetClass();
|
|
|
|
|
|
|
|
if (dot != NULL)
|
|
|
|
{
|
|
|
|
FString part1(flagname, dot-flagname);
|
|
|
|
fd = FindFlag (cls, part1, dot+1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fd = FindFlag (cls, flagname, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fd != NULL)
|
|
|
|
{
|
2008-11-14 23:12:15 +00:00
|
|
|
bool kill_before, kill_after;
|
2009-03-29 08:55:15 +00:00
|
|
|
INTBOOL item_before, item_after;
|
2008-11-14 23:12:15 +00:00
|
|
|
|
|
|
|
kill_before = self->CountsAsKill();
|
2009-03-29 08:55:15 +00:00
|
|
|
item_before = self->flags & MF_COUNTITEM;
|
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
if (fd->structoffset == -1)
|
|
|
|
{
|
|
|
|
HandleDeprecatedFlags(self, cls->ActorInfo, expression, fd->flagbit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-29 08:55:15 +00:00
|
|
|
DWORD *flagp = (DWORD*) (((char*)self) + fd->structoffset);
|
|
|
|
|
|
|
|
// If these 2 flags get changed we need to update the blockmap and sector links.
|
|
|
|
bool linkchange = flagp == &self->flags && (fd->flagbit == MF_NOBLOCKMAP || fd->flagbit == MF_NOSECTOR);
|
2008-09-21 18:02:38 +00:00
|
|
|
|
2009-03-29 08:55:15 +00:00
|
|
|
if (linkchange) self->UnlinkFromWorld();
|
2008-11-14 23:12:15 +00:00
|
|
|
if (expression)
|
|
|
|
{
|
|
|
|
*flagp |= fd->flagbit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*flagp &= ~fd->flagbit;
|
|
|
|
}
|
2009-03-29 08:55:15 +00:00
|
|
|
if (linkchange) self->LinkToWorld();
|
2008-11-14 23:12:15 +00:00
|
|
|
}
|
|
|
|
kill_after = self->CountsAsKill();
|
2009-03-29 08:55:15 +00:00
|
|
|
item_after = self->flags & MF_COUNTITEM;
|
2008-11-14 23:12:15 +00:00
|
|
|
// Was this monster previously worth a kill but no longer is?
|
|
|
|
// Or vice versa?
|
|
|
|
if (kill_before != kill_after)
|
|
|
|
{
|
|
|
|
if (kill_after)
|
|
|
|
{ // It counts as a kill now.
|
|
|
|
level.total_monsters++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // It no longer counts as a kill.
|
|
|
|
level.total_monsters--;
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
2009-03-29 08:55:15 +00:00
|
|
|
// same for items
|
|
|
|
if (item_before != item_after)
|
|
|
|
{
|
|
|
|
if (item_after)
|
|
|
|
{ // It counts as an item now.
|
|
|
|
level.total_items++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // It no longer counts as an item
|
|
|
|
level.total_items--;
|
|
|
|
}
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Printf("Unknown flag '%s' in '%s'\n", flagname, cls->TypeName.GetChars());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-06 10:22:37 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RemoveMaster
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_RemoveMaster)
|
|
|
|
{
|
|
|
|
if (self->master != NULL)
|
|
|
|
{
|
|
|
|
P_RemoveThing(self->master);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RemoveChildren
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveChildren)
|
|
|
|
{
|
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor * mo;
|
|
|
|
ACTION_PARAM_START(1);
|
|
|
|
ACTION_PARAM_BOOL(removeall,0);
|
|
|
|
|
|
|
|
while ( (mo = it.Next()) )
|
|
|
|
{
|
|
|
|
if ( ( mo->master == self ) && ( ( mo->health <= 0 ) || removeall) )
|
|
|
|
{
|
|
|
|
P_RemoveThing(mo);
|
|
|
|
}
|
|
|
|
}
|
2009-06-06 12:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// keep firing unless target got out of sight
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire)
|
|
|
|
{
|
|
|
|
ACTION_PARAM_START(2);
|
|
|
|
ACTION_PARAM_INT(prob, 0);
|
|
|
|
ACTION_PARAM_STATE(jump, 1);
|
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
A_FaceTarget (self);
|
|
|
|
|
|
|
|
if (pr_monsterrefire() < prob)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!self->target
|
|
|
|
|| P_HitFriend (self)
|
|
|
|
|| self->target->health <= 0
|
|
|
|
|| !P_CheckSight (self, self->target, 0) )
|
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|