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 "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"
|
2010-07-23 21:55:01 +00:00
|
|
|
#include "g_shared/a_specialspot.h"
|
2011-06-07 23:05:24 +00:00
|
|
|
#include "actorptrselect.h"
|
2012-03-30 04:28:10 +00:00
|
|
|
#include "m_bbox.h"
|
2013-03-13 11:27:30 +00:00
|
|
|
#include "r_data/r_translate.h"
|
2013-03-23 02:55:59 +00:00
|
|
|
#include "p_trace.h"
|
2013-07-14 12:33:45 +00:00
|
|
|
#include "gstrings.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");
|
2010-07-25 10:17:16 +00:00
|
|
|
static FRandom pr_teleport("A_Teleport");
|
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
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
bool ACustomInventory::CallStateChain (AActor *actor, FState *state)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
INTBOOL result = false;
|
2006-03-03 03:57:01 +00:00
|
|
|
int counter = 0;
|
2012-07-17 05:31:41 +00:00
|
|
|
int retval, numret;
|
|
|
|
VMReturn ret;
|
|
|
|
ret.IntAt(&retval);
|
|
|
|
VMValue params[3] = { actor, this, 0 };
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
this->flags5 |= MF5_INSTATECALL;
|
|
|
|
FState *savedstate = this->state;
|
|
|
|
|
|
|
|
while (state != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
this->state = state;
|
|
|
|
|
|
|
|
if (state->ActionFunc != NULL)
|
2006-08-27 08:51:01 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
VMFrameStack stack;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
params[2] = VMValue(state, ATAG_STATE);
|
|
|
|
retval = true; // assume success
|
|
|
|
numret = stack.Call(state->ActionFunc, params, countof(params), &ret, 1);
|
|
|
|
// As long as even one state succeeds, the whole chain succeeds unless aborted below.
|
|
|
|
result |= retval;
|
|
|
|
}
|
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
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
if (this->state == state)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
FState *next = state->GetNextState();
|
|
|
|
|
|
|
|
if (state == next)
|
|
|
|
{ // Abort immediately if the state jumps to itself!
|
|
|
|
result = false;
|
|
|
|
break;
|
2006-05-26 08:19:39 +00:00
|
|
|
}
|
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.
|
2012-07-17 05:31:41 +00:00
|
|
|
state = next;
|
2006-05-26 08:19:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
state = this->state;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
this->flags5 &= ~MF5_INSTATECALL;
|
|
|
|
this->state = savedstate;
|
|
|
|
return !!result;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2011-03-18 08:02:23 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_RearrangePointers
|
|
|
|
//
|
|
|
|
// Allow an actor to change its relationship to other actors by
|
|
|
|
// copying pointers freely between TARGET MASTER and TRACER.
|
|
|
|
// Can also assign null value, but does not duplicate A_ClearTarget.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RearrangePointers)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (ptr_target);
|
|
|
|
PARAM_INT_OPT (ptr_master) { ptr_master = AAPTR_DEFAULT; }
|
|
|
|
PARAM_INT_OPT (ptr_tracer) { ptr_tracer = AAPTR_TRACER; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
2011-03-18 08:02:23 +00:00
|
|
|
|
|
|
|
// Rearrange pointers internally
|
|
|
|
|
|
|
|
// Fetch all values before modification, so that all fields can get original values
|
|
|
|
AActor
|
|
|
|
*gettarget = self->target,
|
|
|
|
*getmaster = self->master,
|
|
|
|
*gettracer = self->tracer;
|
|
|
|
|
|
|
|
switch (ptr_target) // pick the new target
|
|
|
|
{
|
|
|
|
case AAPTR_MASTER:
|
|
|
|
self->target = getmaster;
|
|
|
|
if (!(PTROP_UNSAFETARGET & flags)) VerifyTargetChain(self);
|
|
|
|
break;
|
|
|
|
case AAPTR_TRACER:
|
|
|
|
self->target = gettracer;
|
|
|
|
if (!(PTROP_UNSAFETARGET & flags)) VerifyTargetChain(self);
|
|
|
|
break;
|
|
|
|
case AAPTR_NULL:
|
|
|
|
self->target = NULL;
|
|
|
|
// THIS IS NOT "A_ClearTarget", so no other targeting info is removed
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// presently permitting non-monsters to set master
|
|
|
|
switch (ptr_master) // pick the new master
|
|
|
|
{
|
|
|
|
case AAPTR_TARGET:
|
|
|
|
self->master = gettarget;
|
|
|
|
if (!(PTROP_UNSAFEMASTER & flags)) VerifyMasterChain(self);
|
|
|
|
break;
|
|
|
|
case AAPTR_TRACER:
|
|
|
|
self->master = gettracer;
|
|
|
|
if (!(PTROP_UNSAFEMASTER & flags)) VerifyMasterChain(self);
|
|
|
|
break;
|
|
|
|
case AAPTR_NULL:
|
|
|
|
self->master = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ptr_tracer) // pick the new tracer
|
|
|
|
{
|
|
|
|
case AAPTR_TARGET:
|
|
|
|
self->tracer = gettarget;
|
|
|
|
break; // no verification deemed necessary; the engine never follows a tracer chain(?)
|
|
|
|
case AAPTR_MASTER:
|
|
|
|
self->tracer = getmaster;
|
|
|
|
break; // no verification deemed necessary; the engine never follows a tracer chain(?)
|
|
|
|
case AAPTR_NULL:
|
|
|
|
self->tracer = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2011-03-18 08:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_TransferPointer
|
|
|
|
//
|
|
|
|
// Copy one pointer (MASTER, TARGET or TRACER) from this actor (SELF),
|
2011-06-13 10:22:47 +00:00
|
|
|
// or from this actor's MASTER, TARGET or TRACER.
|
2011-03-18 08:02:23 +00:00
|
|
|
//
|
|
|
|
// You can copy any one of that actor's pointers
|
|
|
|
//
|
|
|
|
// Assign the copied pointer to any one pointer in SELF,
|
|
|
|
// MASTER, TARGET or TRACER.
|
|
|
|
//
|
|
|
|
// Any attempt to make an actor point to itself will replace the pointer
|
|
|
|
// with a null value.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_TransferPointer)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (ptr_source);
|
|
|
|
PARAM_INT (ptr_recipient);
|
|
|
|
PARAM_INT (ptr_sourcefield);
|
|
|
|
PARAM_INT_OPT (ptr_recipientfield) { ptr_recipientfield = AAPTR_DEFAULT; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
2011-03-18 08:02:23 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
AActor *source, *recipient;
|
2011-03-18 08:02:23 +00:00
|
|
|
|
|
|
|
// Exchange pointers with actors to whom you have pointers (or with yourself, if you must)
|
2011-06-13 10:22:47 +00:00
|
|
|
source = COPY_AAPTR(self, ptr_source);
|
2012-07-14 03:04:41 +00:00
|
|
|
recipient = COPY_AAPTR(self, ptr_recipient); // pick an actor to store the provided pointer value
|
|
|
|
if (recipient == NULL)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-18 08:02:23 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
// convert source from dataprovider to data
|
2011-06-13 10:22:47 +00:00
|
|
|
source = COPY_AAPTR(source, ptr_sourcefield);
|
2012-07-14 03:04:41 +00:00
|
|
|
if (source == recipient)
|
|
|
|
{ // The recepient should not acquire a pointer to itself; will write NULL}
|
|
|
|
source = NULL;
|
|
|
|
}
|
|
|
|
if (ptr_recipientfield == AAPTR_DEFAULT)
|
|
|
|
{ // If default: Write to same field as data was read from
|
|
|
|
ptr_recipientfield = ptr_sourcefield;
|
|
|
|
}
|
|
|
|
ASSIGN_AAPTR(recipient, ptr_recipientfield, source, flags);
|
|
|
|
return 0;
|
2011-03-18 08:02:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_CopyFriendliness
|
|
|
|
//
|
|
|
|
// Join forces with one of the actors you are pointing to (MASTER by default)
|
|
|
|
//
|
|
|
|
// Normal CopyFriendliness reassigns health. This function will not.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CopyFriendliness)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT (ptr_source) { ptr_source = AAPTR_MASTER; }
|
2011-03-18 08:02:23 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (self->player != NULL)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-18 08:02:23 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
AActor *source = COPY_AAPTR(self, ptr_source);
|
|
|
|
if (source != NULL)
|
|
|
|
{ // No change in current target or health
|
|
|
|
self->CopyFriendliness(source, false, false);
|
|
|
|
}
|
|
|
|
return 0;
|
2011-03-18 08:02:23 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->flags |= MF_SOLID;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_UnsetSolid)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->flags &= ~MF_SOLID;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SetFloat)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->flags |= MF_FLOAT;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_UnsetFloat)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
self->flags &= ~(MF_FLOAT|MF_INFLOAT);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Customizable attack functions which use actor parameters.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2008-08-12 14:30:07 +00:00
|
|
|
static void DoAttack (AActor *self, bool domelee, bool domissile,
|
2010-04-03 04:07:17 +00:00
|
|
|
int MeleeDamage, FSoundID MeleeSound, PClassActor *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);
|
2013-01-02 04:39:59 +00:00
|
|
|
int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee);
|
|
|
|
P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
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.
|
- Add the bob offset to the missiles spawned by P_SpawnMissile(), P_SpawnMissileAngle(), P_SpawnMissileAngleSpeed(), A_MissileAttack, A_ComboAttack, A_BasicAttack, A_CustomMissile, A_CustomComboAttack, A_ThrowGrenade, A_SpawnDebris, and A_Burst.
- Add the bob offset to the value returned by GetActorZ.
SVN r3795 (trunk)
2012-07-30 00:05:24 +00:00
|
|
|
self->z += MissileHeight + self->GetBobOffset() - 32*FRACUNIT;
|
2010-04-03 04:07:17 +00:00
|
|
|
AActor *missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, self, self->target, MissileType, false);
|
- Add the bob offset to the missiles spawned by P_SpawnMissile(), P_SpawnMissileAngle(), P_SpawnMissileAngleSpeed(), A_MissileAttack, A_ComboAttack, A_BasicAttack, A_CustomMissile, A_CustomComboAttack, A_ThrowGrenade, A_SpawnDebris, and A_Burst.
- Add the bob offset to the value returned by GetActorZ.
SVN r3795 (trunk)
2012-07-30 00:05:24 +00:00
|
|
|
self->z -= MissileHeight + self->GetBobOffset() - 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;
|
|
|
|
}
|
2013-03-21 03:06:04 +00:00
|
|
|
P_CheckMissileSpawn(missile, self->radius);
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-03-25 20:38:00 +00:00
|
|
|
int MeleeDamage = self->GetClass()->MeleeDamage;
|
|
|
|
FSoundID MeleeSound = self->GetClass()->MeleeSound;
|
2008-08-12 14:30:07 +00:00
|
|
|
DoAttack(self, true, false, MeleeDamage, MeleeSound, NULL, 0);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-03-25 20:38:00 +00:00
|
|
|
PClassActor *MissileType = PClass::FindActor(self->GetClass()->MissileName);
|
|
|
|
fixed_t MissileHeight = self->GetClass()->MissileHeight;
|
2008-08-12 14:30:07 +00:00
|
|
|
DoAttack(self, false, true, 0, 0, MissileType, MissileHeight);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_ComboAttack)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-03-25 20:38:00 +00:00
|
|
|
int MeleeDamage = self->GetClass()->MeleeDamage;
|
|
|
|
FSoundID MeleeSound = self->GetClass()->MeleeSound;
|
|
|
|
PClassActor *MissileType = PClass::FindActor(self->GetClass()->MissileName);
|
|
|
|
fixed_t MissileHeight = self->GetClass()->MissileHeight;
|
2008-08-12 14:30:07 +00:00
|
|
|
DoAttack(self, true, true, MeleeDamage, MeleeSound, MissileType, MissileHeight);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (melee_damage);
|
|
|
|
PARAM_SOUND (melee_sound);
|
|
|
|
PARAM_CLASS (missile_type, AActor);
|
|
|
|
PARAM_FIXED (missile_height);
|
2008-08-12 14:30:07 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile_type != NULL)
|
|
|
|
{
|
|
|
|
DoAttack(self, true, true, melee_damage, melee_sound, missile_type, missile_height);
|
|
|
|
}
|
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_SOUND_OPT (soundid) { soundid = "weapons/pistol"; }
|
|
|
|
PARAM_INT_OPT (channel) { channel = CHAN_BODY; }
|
|
|
|
PARAM_FLOAT_OPT (volume) { volume = 1; }
|
|
|
|
PARAM_BOOL_OPT (looping) { looping = false; }
|
|
|
|
PARAM_FLOAT_OPT (attenuation) { attenuation = ATTN_NORM; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-04-14 09:06:03 +00:00
|
|
|
if (!looping)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
S_Sound (self, channel, soundid, (float)volume, (float)attenuation);
|
2009-04-14 09:06:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!S_IsActorPlayingSomething (self, channel&7, soundid))
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
S_Sound (self, channel | CHAN_LOOP, soundid, (float)volume, (float)attenuation);
|
2009-04-14 09:06:03 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT(slot) { slot = CHAN_VOICE; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-04-14 09:06:03 +00:00
|
|
|
S_StopSound(self, slot);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_SOUND(soundid);
|
2009-04-14 09:06:03 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
S_Sound(self, CHAN_WEAPON, soundid, 1, ATTN_NORM);
|
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_SOUND (soundid);
|
|
|
|
PARAM_NAME (channel);
|
|
|
|
PARAM_BOOL_OPT (looping) { looping = false; }
|
|
|
|
PARAM_INT_OPT (attenuation_raw) { attenuation_raw = 0; }
|
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
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME(channel);
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-08-31 00:16:12 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Generic seeker missile function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2009-10-09 20:54:28 +00:00
|
|
|
static FRandom pr_seekermissile ("SeekerMissile");
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SMF_LOOK = 1,
|
2010-04-10 11:12:29 +00:00
|
|
|
SMF_PRECISE = 2,
|
2011-11-24 04:27:47 +00:00
|
|
|
SMF_CURSPEED = 4,
|
2009-10-09 20:54:28 +00:00
|
|
|
};
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SeekerMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT(ang1);
|
|
|
|
PARAM_INT(ang2);
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_INT_OPT(flags) { flags = 0; }
|
|
|
|
PARAM_INT_OPT(chance) { chance = 50; }
|
|
|
|
PARAM_INT_OPT(distance) { distance = 10; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-10-09 20:54:28 +00:00
|
|
|
if ((flags & SMF_LOOK) && (self->tracer == 0) && (pr_seekermissile()<chance))
|
|
|
|
{
|
2012-04-19 03:22:06 +00:00
|
|
|
self->tracer = P_RoughMonsterSearch (self, distance, true);
|
|
|
|
}
|
|
|
|
if (!P_SeekerMissile(self, clamp<int>(ang1, 0, 90) * ANGLE_1, clamp<int>(ang2, 0, 90) * ANGLE_1, !!(flags & SMF_PRECISE), !!(flags & SMF_CURSPEED)))
|
|
|
|
{
|
|
|
|
if (flags & SMF_LOOK)
|
|
|
|
{ // This monster is no longer seekable, so let us look for another one next time.
|
|
|
|
self->tracer = NULL;
|
|
|
|
}
|
2009-10-09 20:54:28 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
int i;
|
|
|
|
int bangle;
|
|
|
|
int slope;
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!self->target) return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
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,
|
2012-06-17 03:18:26 +00:00
|
|
|
NAME_Hitscan, NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2007-01-05 22:08:57 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Do the state jump
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2012-07-17 05:31:41 +00:00
|
|
|
static void DoJump(AActor *self, AActor *stateowner, FState *callingstate, FState *jumpto)
|
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
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
if (stateowner->flags5 & MF5_INSTATECALL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
stateowner->state = jumpto;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +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
|
|
|
}
|
2010-02-12 06:04:57 +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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
else if (callingstate == self->state)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-10-23 03:19:17 +00:00
|
|
|
// Rather than using self->SetState(jumpto) to set the state,
|
|
|
|
// set the state directly. Since this function is only called by
|
|
|
|
// action functions, which are only called by SetState(), we
|
|
|
|
// know that somewhere above us in the stack, a SetState()
|
|
|
|
// call is waiting for us to return. We use the flag OF_StateChanged
|
|
|
|
// to cause it to bypass the normal next state mechanism and use
|
|
|
|
// the one we set here instead.
|
|
|
|
self->state = jumpto;
|
|
|
|
self->ObjectFlags |= OF_StateChanged;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
else
|
2012-07-17 05:31:41 +00:00
|
|
|
{ // something went very wrong. This should never happen.
|
2008-08-14 08:52:55 +00:00
|
|
|
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.
|
2012-07-17 05:31:41 +00:00
|
|
|
#define ACTION_JUMP(offset) DoJump(self, stateowner, callingstate, offset)
|
2008-08-14 08:52:55 +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_Jump)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT(maxchance) { maxchance = 256; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-14 19:59:21 +00:00
|
|
|
paramnum++; // Increment paramnum to point at the first jump target
|
|
|
|
int count = numparam - paramnum;
|
2010-02-12 06:04:57 +00:00
|
|
|
if (count > 0 && (maxchance >= 256 || pr_cajump() < maxchance))
|
2006-10-24 02:32:12 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
int jumpnum = (count == 1 ? 0 : (pr_cajump() % count));
|
2010-02-14 19:59:21 +00:00
|
|
|
PARAM_STATE_AT(paramnum + jumpnum, jumpto);
|
2008-10-25 17:38:00 +00:00
|
|
|
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!
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (health);
|
|
|
|
PARAM_STATE (jump);
|
2006-09-25 07:48:52 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->health < health)
|
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2012-09-06 03:36:25 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetOutsideMeleeRange)
|
|
|
|
{
|
2012-10-17 04:24:54 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
2012-09-06 03:36:25 +00:00
|
|
|
|
|
|
|
if (!self->CheckMeleeRange())
|
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2012-10-17 04:24:54 +00:00
|
|
|
return numret;
|
2012-09-06 03:36:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInsideMeleeRange)
|
|
|
|
{
|
2012-10-17 04:24:54 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
2012-09-06 03:36:25 +00:00
|
|
|
|
|
|
|
if (self->CheckMeleeRange())
|
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2012-10-17 04:24:54 +00:00
|
|
|
return numret;
|
2012-09-06 03:36:25 +00:00
|
|
|
}
|
2012-10-17 04:24:54 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2012-07-17 05:31:41 +00:00
|
|
|
static int DoJumpIfCloser(AActor *target, VM_ARGS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED (dist);
|
|
|
|
PARAM_STATE (jump);
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2010-05-14 02:34:25 +00:00
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
|
|
|
// No target - no jump
|
|
|
|
if (target != NULL && P_AproxDistance(self->x-target->x, self->y-target->y) < dist &&
|
|
|
|
( (self->z > target->z && self->z - (target->z + target->height) < dist) ||
|
|
|
|
(self->z <=target->z && target->z - (self->z + self->height) < dist)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-05-14 02:34:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfCloser)
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2008-08-13 22:54:24 +00:00
|
|
|
AActor *target;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->player == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
target = self->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoJumpIfCloser(target, VM_ARGS_NAMES);
|
2010-05-14 02:34:25 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-05-14 02:34:25 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTracerCloser)
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoJumpIfCloser(self->tracer, VM_ARGS_NAMES);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-05-14 02:34:25 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfMasterCloser)
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoJumpIfCloser(self->master, VM_ARGS_NAMES);
|
2010-05-14 02:34:25 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// State jump function
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2012-07-17 05:31:41 +00:00
|
|
|
int DoJumpIfInventory(AActor *owner, AActor *self, AActor *stateowner, FState *callingstate, VMValue *param, int numparam, VMReturn *ret, int numret)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-14 19:59:21 +00:00
|
|
|
int paramnum = NAP-1;
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_CLASS (itemtype, AInventory);
|
|
|
|
PARAM_INT (itemamount);
|
|
|
|
PARAM_STATE (label);
|
|
|
|
PARAM_INT_OPT (setowner) { setowner = AAPTR_DEFAULT; }
|
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
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (itemtype == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-07-14 03:04:41 +00:00
|
|
|
}
|
|
|
|
owner = COPY_AAPTR(owner, setowner);
|
|
|
|
if (owner == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-07-14 03:04:41 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
AInventory *item = owner->FindInventory(itemtype);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (item)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (itemamount > 0)
|
2009-09-02 02:35:20 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (item->Amount >= itemamount)
|
|
|
|
ACTION_JUMP(label);
|
2009-09-02 02:35:20 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
else if (item->Amount >= item->MaxAmount)
|
2009-09-02 02:35:20 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
ACTION_JUMP(label);
|
2009-09-02 02:35:20 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoJumpIfInventory(self, self, stateowner, callingstate, param, numparam, ret, numret);
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoJumpIfInventory(self->target, self, stateowner, callingstate, param, numparam, ret, numret);
|
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)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (type);
|
|
|
|
PARAM_STATE (label);
|
|
|
|
PARAM_INT_OPT(amount) { amount = 1; }
|
2009-06-05 20:23:47 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
ABasicArmor *armor = (ABasicArmor *)self->FindInventory(NAME_BasicArmor);
|
2009-06-05 20:23:47 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (armor && armor->ArmorType == type && armor->Amount >= amount)
|
|
|
|
ACTION_JUMP(label);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-06-05 20:23:47 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Parameterized version of A_Explode
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-08-30 04:01:50 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
XF_HURTSOURCE = 1,
|
|
|
|
XF_NOTMISSILE = 4,
|
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_INT_OPT (damage) { damage = -1; }
|
|
|
|
PARAM_INT_OPT (distance) { distance = -1; }
|
2012-10-17 04:24:54 +00:00
|
|
|
PARAM_INT_OPT (flags) { flags = XF_HURTSOURCE; }
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_BOOL_OPT (alert) { alert = false; }
|
|
|
|
PARAM_INT_OPT (fulldmgdistance) { fulldmgdistance = 0; }
|
|
|
|
PARAM_INT_OPT (nails) { nails = 0; }
|
|
|
|
PARAM_INT_OPT (naildamage) { naildamage = 10; }
|
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor("BulletPuff"); }
|
2008-08-12 20:19:47 +00:00
|
|
|
|
|
|
|
if (damage < 0) // get parameters from metadata
|
2006-07-29 10:47:14 +00:00
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
damage = self->GetClass()->ExplosionDamage;
|
|
|
|
distance = self->GetClass()->ExplosionRadius;
|
2012-10-17 04:24:54 +00:00
|
|
|
flags = !self->GetClass()->DontHurtShooter;
|
2008-08-05 17:58:38 +00:00
|
|
|
alert = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-10-27 02:13:53 +00:00
|
|
|
if (distance <= 0) distance = damage;
|
|
|
|
|
2009-09-14 19:44:14 +00:00
|
|
|
// NailBomb effect, from SMMU but not from its source code: instead it was implemented and
|
|
|
|
// generalized from the documentation at http://www.doomworld.com/eternity/engine/codeptrs.html
|
|
|
|
|
|
|
|
if (nails)
|
|
|
|
{
|
|
|
|
angle_t ang;
|
|
|
|
for (int i = 0; i < nails; i++)
|
|
|
|
{
|
|
|
|
ang = i*(ANGLE_MAX/nails);
|
|
|
|
// Comparing the results of a test wad with Eternity, it seems A_NailBomb does not aim
|
|
|
|
P_LineAttack (self, ang, MISSILERANGE, 0,
|
|
|
|
//P_AimLineAttack (self, ang, MISSILERANGE),
|
2012-06-17 03:18:26 +00:00
|
|
|
naildamage, NAME_Hitscan, pufftype);
|
2009-09-14 19:44:14 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-08-30 04:01:50 +00:00
|
|
|
P_RadiusAttack (self, self->target, damage, distance, self->DamageType, flags, fulldmgdistance);
|
2009-10-17 11:30:44 +00:00
|
|
|
P_CheckSplash(self, distance<<FRACBITS);
|
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);
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-07-02 21:58:10 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_RadiusThrust
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2012-08-30 04:01:50 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
RTF_AFFECTSOURCE = 1,
|
|
|
|
RTF_NOIMPACTDAMAGE = 2,
|
|
|
|
RTF_NOTMISSILE = 4,
|
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust)
|
2006-07-02 21:58:10 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_INT_OPT (force) { force = 128; }
|
|
|
|
PARAM_INT_OPT (distance) { distance = -1; }
|
2012-10-17 04:24:54 +00:00
|
|
|
PARAM_INT_OPT (flags) { flags = RTF_AFFECTSOURCE; }
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_INT_OPT (fullthrustdistance) { fullthrustdistance = 0; }
|
2008-08-12 20:19:47 +00:00
|
|
|
|
2011-05-11 04:29:19 +00:00
|
|
|
bool sourcenothrust = false;
|
2008-08-12 20:19:47 +00:00
|
|
|
|
2013-03-20 02:41:59 +00:00
|
|
|
if (force == 0) force = 128;
|
|
|
|
if (distance <= 0) distance = abs(force);
|
2006-07-02 21:58:10 +00:00
|
|
|
|
2011-05-11 04:29:19 +00:00
|
|
|
// Temporarily negate MF2_NODMGTHRUST on the shooter, since it renders this function useless.
|
2012-08-30 04:01:50 +00:00
|
|
|
if (!(flags & RTF_NOTMISSILE) && self->target != NULL && self->target->flags2 & MF2_NODMGTHRUST)
|
2011-05-11 04:29:19 +00:00
|
|
|
{
|
|
|
|
sourcenothrust = true;
|
|
|
|
self->target->flags2 &= ~MF2_NODMGTHRUST;
|
|
|
|
}
|
|
|
|
|
2012-08-30 04:01:50 +00:00
|
|
|
P_RadiusAttack (self, self->target, force, distance, self->DamageType, flags | RADF_NODAMAGE, fullthrustdistance);
|
2011-05-11 04:29:19 +00:00
|
|
|
P_CheckSplash(self, distance << FRACBITS);
|
|
|
|
|
|
|
|
if (sourcenothrust)
|
|
|
|
{
|
|
|
|
self->target->flags2 |= MF2_NODMGTHRUST;
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-07-02 21:58:10 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (special);
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (arg3) { arg3 = 0; }
|
|
|
|
PARAM_INT_OPT (arg4) { arg4 = 0; }
|
|
|
|
PARAM_INT_OPT (arg5) { arg5 = 0; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2011-02-13 10:18:28 +00:00
|
|
|
bool res = !!P_ExecuteSpecial(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);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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,
|
2012-04-07 12:36:39 +00:00
|
|
|
|
|
|
|
CMF_ABSOLUTEPITCH = 16,
|
|
|
|
CMF_OFFSETPITCH = 32,
|
|
|
|
CMF_SAVEPITCH = 64,
|
|
|
|
|
|
|
|
CMF_ABSOLUTEANGLE = 128
|
2006-11-25 12:25:05 +00:00
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (ti, AActor);
|
|
|
|
PARAM_FIXED_OPT (spawnheight) { spawnheight = 32*FRACUNIT; }
|
|
|
|
PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; }
|
|
|
|
PARAM_ANGLE_OPT (angle) { angle = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
2012-10-26 20:12:55 +00:00
|
|
|
PARAM_ANGLE_OPT (pitch) { pitch = 0; }
|
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;
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->target != NULL || aimmode == 2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (ti)
|
|
|
|
{
|
|
|
|
angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT;
|
2010-02-12 06:04:57 +00:00
|
|
|
fixed_t x = spawnofs_xy * finecosine[ang];
|
|
|
|
fixed_t y = spawnofs_xy * finesine[ang];
|
2012-10-17 04:24:54 +00:00
|
|
|
fixed_t z = spawnheight + self->GetBobOffset() - 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!
|
2010-02-12 06:04:57 +00:00
|
|
|
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);
|
2010-02-12 06:04:57 +00:00
|
|
|
self->x -= x;
|
|
|
|
self->y -= y;
|
|
|
|
self->z -= z;
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2012-10-17 04:24:54 +00:00
|
|
|
missile = P_SpawnMissileXYZ(self->x+x, self->y+y, self->z + self->GetBobOffset() + spawnheight, self, self->target, ti, false);
|
2006-02-24 04:48:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2010-02-12 06:04:57 +00:00
|
|
|
self->x += x;
|
|
|
|
self->y += y;
|
2012-10-17 04:24:54 +00:00
|
|
|
missile = P_SpawnMissileAngleZSpeed(self, self->z + self->GetBobOffset() + spawnheight, ti, self->angle, 0, GetDefaultByType(ti)->Speed, self, false);
|
- Add the bob offset to the missiles spawned by P_SpawnMissile(), P_SpawnMissileAngle(), P_SpawnMissileAngleSpeed(), A_MissileAttack, A_ComboAttack, A_BasicAttack, A_CustomMissile, A_CustomComboAttack, A_ThrowGrenade, A_SpawnDebris, and A_Burst.
- Add the bob offset to the value returned by GetActorZ.
SVN r3795 (trunk)
2012-07-30 00:05:24 +00:00
|
|
|
self->x -= x;
|
2010-02-12 06:04:57 +00:00
|
|
|
self->y -= y;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-04-07 12:36:39 +00:00
|
|
|
flags |= CMF_ABSOLUTEPITCH;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
// Use the actual velocity instead of the missile's Speed property
|
2006-02-24 04:48:15 +00:00
|
|
|
// so that this can handle missiles with a high vertical velocity
|
|
|
|
// component properly.
|
|
|
|
|
2012-04-07 12:36:39 +00:00
|
|
|
fixed_t missilespeed;
|
|
|
|
|
|
|
|
if ( (CMF_ABSOLUTEPITCH|CMF_OFFSETPITCH) & flags)
|
|
|
|
{
|
|
|
|
if (CMF_OFFSETPITCH & flags)
|
|
|
|
{
|
|
|
|
FVector2 velocity (missile->velx, missile->vely);
|
|
|
|
pitch += R_PointToAngle2(0,0, (fixed_t)velocity.Length(), missile->velz);
|
|
|
|
}
|
|
|
|
ang = pitch >> ANGLETOFINESHIFT;
|
2012-04-15 02:43:37 +00:00
|
|
|
missilespeed = abs(FixedMul(finecosine[ang], missile->Speed));
|
2012-04-07 12:36:39 +00:00
|
|
|
missile->velz = FixedMul(finesine[ang], missile->Speed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FVector2 velocity (missile->velx, missile->vely);
|
|
|
|
missilespeed = (fixed_t)velocity.Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CMF_SAVEPITCH & flags)
|
|
|
|
{
|
|
|
|
missile->pitch = pitch;
|
|
|
|
// In aimmode 0 and 1 without absolutepitch or offsetpitch, the pitch parameter
|
|
|
|
// contains the unapplied parameter. In that case, it is set as pitch without
|
|
|
|
// otherwise affecting the spawned actor.
|
|
|
|
}
|
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
missile->angle = (CMF_ABSOLUTEANGLE & flags) ? angle : missile->angle + angle ;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
ang = missile->angle >> ANGLETOFINESHIFT;
|
2010-02-12 06:04:57 +00:00
|
|
|
missile->velx = FixedMul(missilespeed, finecosine[ang]);
|
|
|
|
missile->vely = FixedMul(missilespeed, finesine[ang]);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// handle projectile shooting projectiles - track the
|
|
|
|
// links back to a real owner
|
2011-06-13 10:22:47 +00:00
|
|
|
if (self->isMissile(!!(flags & CMF_TRACKOWNER)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
AActor *owner = self ;//->target;
|
|
|
|
while (owner->isMissile(!!(flags & CMF_TRACKOWNER)) && owner->target)
|
2010-02-12 06:04:57 +00:00
|
|
|
owner = owner->target;
|
|
|
|
targ = owner;
|
|
|
|
missile->target = owner;
|
2006-02-24 04:48:15 +00:00
|
|
|
// automatic handling of seeker missiles
|
|
|
|
if (self->flags & missile->flags2 & MF2_SEEKERMISSILE)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
missile->tracer = self->tracer;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
else if (missile->flags2 & MF2_SEEKERMISSILE)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// automatic handling of seeker missiles
|
2010-02-12 06:04:57 +00:00
|
|
|
missile->tracer = self->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-05-13 11:17:27 +00:00
|
|
|
// we must redo the spectral check here because the owner is set after spawning so the FriendPlayer value may be wrong
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile->flags4 & MF4_SPECTRAL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-06-09 04:15:56 +00:00
|
|
|
if (missile->target != NULL)
|
2012-05-13 11:17:27 +00:00
|
|
|
{
|
2012-06-09 04:15:56 +00:00
|
|
|
missile->SetFriendPlayer(missile->target->player);
|
2012-05-13 11:17:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
missile->FriendPlayer = 0;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2013-03-21 03:06:04 +00:00
|
|
|
P_CheckMissileSpawn(missile, self->radius);
|
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.
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->SeeState != NULL)
|
|
|
|
self->SetState(self->SeeState);
|
2006-11-25 12:25:05 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// An even more customizable hitscan attack
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2010-05-12 07:11:56 +00:00
|
|
|
enum CBA_Flags
|
|
|
|
{
|
|
|
|
CBAF_AIMFACING = 1,
|
|
|
|
CBAF_NORANDOM = 2,
|
2010-07-24 06:15:07 +00:00
|
|
|
CBAF_EXPLICITANGLE = 4,
|
2010-08-13 06:22:49 +00:00
|
|
|
CBAF_NOPITCH = 8,
|
2013-03-09 07:09:40 +00:00
|
|
|
CBAF_NORANDOMPUFFZ = 16,
|
2010-05-12 07:11:56 +00:00
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_ANGLE (spread_xy);
|
|
|
|
PARAM_ANGLE (spread_z);
|
|
|
|
PARAM_INT (numbullets);
|
|
|
|
PARAM_INT (damageperbullet);
|
2010-03-24 02:49:37 +00:00
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); }
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_FIXED_OPT (range) { range = MISSILERANGE; }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (range == 0)
|
|
|
|
range = MISSILERANGE;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
int bangle;
|
2011-03-29 05:20:33 +00:00
|
|
|
int bslope = 0;
|
2013-06-07 03:31:30 +00:00
|
|
|
int laflags = (flags & CBAF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (self->target || (flags & CBAF_AIMFACING))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & CBAF_AIMFACING)) A_FaceTarget (self);
|
2006-02-24 04:48:15 +00:00
|
|
|
bangle = self->angle;
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & CBAF_NOPITCH)) bslope = P_AimLineAttack (self, bangle, MISSILERANGE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
|
2010-02-12 06:04:57 +00:00
|
|
|
for (i = 0; i < numbullets; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-07-24 06:15:07 +00:00
|
|
|
int angle = bangle;
|
|
|
|
int slope = bslope;
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (flags & CBAF_EXPLICITANGLE)
|
2010-07-24 06:15:07 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angle += spread_xy;
|
|
|
|
slope += spread_z;
|
2010-07-24 06:15:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angle += pr_cwbullet.Random2() * (spread_xy / 255);
|
|
|
|
slope += pr_cwbullet.Random2() * (spread_z / 255);
|
2010-07-24 06:15:07 +00:00
|
|
|
}
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
int damage = damageperbullet;
|
2010-05-12 07:11:56 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & CBAF_NORANDOM))
|
2010-05-12 07:11:56 +00:00
|
|
|
damage *= ((pr_cabullet()%3)+1);
|
|
|
|
|
2013-06-07 03:31:30 +00:00
|
|
|
P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT (damage) { damage = 0; }
|
|
|
|
PARAM_SOUND_OPT (meleesound) { meleesound = 0; }
|
|
|
|
PARAM_SOUND_OPT (misssound) { misssound = 0; }
|
|
|
|
PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; }
|
|
|
|
PARAM_BOOL_OPT (bleed) { bleed = true; }
|
2006-05-07 00:27:22 +00:00
|
|
|
|
2010-02-12 06:04:57 +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)
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-05-07 00:27:22 +00:00
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
if (self->CheckMeleeRange ())
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (meleesound)
|
|
|
|
S_Sound (self, CHAN_WEAPON, meleesound, 1, ATTN_NORM);
|
2013-06-07 03:31:30 +00:00
|
|
|
int newdam = P_DamageMobj (self->target, self, self, damage, damagetype);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (bleed)
|
2013-06-07 03:31:30 +00:00
|
|
|
P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
|
2006-05-07 00:27:22 +00:00
|
|
|
}
|
2006-11-25 12:25:05 +00:00
|
|
|
else
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (misssound)
|
|
|
|
S_Sound (self, CHAN_WEAPON, misssound, 1, ATTN_NORM);
|
2006-11-25 12:25:05 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (ti, AActor);
|
|
|
|
PARAM_FIXED (spawnheight);
|
|
|
|
PARAM_INT (damage);
|
|
|
|
PARAM_SOUND_OPT (meleesound) { meleesound = 0; }
|
|
|
|
PARAM_NAME_OPT (damagetype) { damagetype = NAME_Melee; }
|
|
|
|
PARAM_BOOL_OPT (bleed) { bleed = true; }
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
if (!self->target)
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
A_FaceTarget (self);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->CheckMeleeRange())
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (damagetype == NAME_None)
|
|
|
|
damagetype = NAME_Melee; // Melee is the default type
|
|
|
|
if (meleesound)
|
|
|
|
S_Sound (self, CHAN_WEAPON, meleesound, 1, ATTN_NORM);
|
2013-06-07 03:31:30 +00:00
|
|
|
int newdam = P_DamageMobj (self->target, self, self, damage, damagetype);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (bleed)
|
2013-06-07 03:31:30 +00:00
|
|
|
P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self);
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
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.
|
2012-10-17 04:24:54 +00:00
|
|
|
self->z += spawnheight + self->GetBobOffset() - 32*FRACUNIT;
|
- Add the bob offset to the missiles spawned by P_SpawnMissile(), P_SpawnMissileAngle(), P_SpawnMissileAngleSpeed(), A_MissileAttack, A_ComboAttack, A_BasicAttack, A_CustomMissile, A_CustomComboAttack, A_ThrowGrenade, A_SpawnDebris, and A_Burst.
- Add the bob offset to the value returned by GetActorZ.
SVN r3795 (trunk)
2012-07-30 00:05:24 +00:00
|
|
|
AActor *missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, self, self->target, ti, false);
|
2012-10-17 04:24:54 +00:00
|
|
|
self->z -= spawnheight + self->GetBobOffset() - 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
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile->flags2 & MF2_SEEKERMISSILE)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
missile->tracer = self->target;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
2013-03-21 03:06:04 +00:00
|
|
|
P_CheckMissileSpawn(missile, self->radius);
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
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!
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!ACTION_CALL_FROM_WEAPON())
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// An even more customizable hitscan attack
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2010-05-12 07:11:56 +00:00
|
|
|
enum FB_Flags
|
|
|
|
{
|
|
|
|
FBF_USEAMMO = 1,
|
|
|
|
FBF_NORANDOM = 2,
|
2010-05-14 02:18:27 +00:00
|
|
|
FBF_EXPLICITANGLE = 4,
|
2010-08-13 06:22:49 +00:00
|
|
|
FBF_NOPITCH = 8,
|
2010-08-31 21:24:03 +00:00
|
|
|
FBF_NOFLASH = 16,
|
2013-03-09 07:09:40 +00:00
|
|
|
FBF_NORANDOMPUFFZ = 32,
|
2010-05-12 07:11:56 +00:00
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_ANGLE (spread_xy);
|
|
|
|
PARAM_ANGLE (spread_z);
|
|
|
|
PARAM_INT (numbullets);
|
|
|
|
PARAM_INT (damageperbullet);
|
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_INT_OPT (flags) { flags = FBF_USEAMMO; }
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_FIXED_OPT (range) { range = 0; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!self->player) return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
player_t *player = self->player;
|
|
|
|
AWeapon *weapon = player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
int bangle;
|
2011-03-29 05:20:33 +00:00
|
|
|
int bslope = 0;
|
2013-06-07 03:31:30 +00:00
|
|
|
int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if ((flags & FBF_USEAMMO) && weapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
|
|
|
return 0; // out of ammo
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (range == 0)
|
|
|
|
range = PLAYERMISSILERANGE;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & FBF_NOFLASH)) static_cast<APlayerPawn *>(self)->PlayAttacking2 ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & FBF_NOPITCH)) bslope = P_BulletSlope(self);
|
2006-02-24 04:48:15 +00:00
|
|
|
bangle = self->angle;
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (pufftype == NULL)
|
2010-03-24 02:49:37 +00:00
|
|
|
pufftype = PClass::FindActor(NAME_BulletPuff);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-05-13 02:27:39 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
S_Sound(self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
|
2013-05-13 02:27:39 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if ((numbullets == 1 && !player->refire) || numbullets == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
int damage = damageperbullet;
|
2010-05-12 07:11:56 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & FBF_NORANDOM))
|
2010-05-12 07:11:56 +00:00
|
|
|
damage *= ((pr_cwbullet()%3)+1);
|
|
|
|
|
2013-06-07 03:31:30 +00:00
|
|
|
P_LineAttack(self, bangle, range, bslope, damage, NAME_Hitscan, pufftype, laflags);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (numbullets < 0)
|
|
|
|
numbullets = 1;
|
|
|
|
for (i = 0; i < numbullets; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-05-14 02:18:27 +00:00
|
|
|
int angle = bangle;
|
|
|
|
int slope = bslope;
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (flags & FBF_EXPLICITANGLE)
|
2010-05-14 02:18:27 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angle += spread_xy;
|
|
|
|
slope += spread_z;
|
2010-05-14 02:18:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angle += pr_cwbullet.Random2() * (spread_xy / 255);
|
|
|
|
slope += pr_cwbullet.Random2() * (spread_z / 255);
|
2010-05-14 02:18:27 +00:00
|
|
|
}
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
int damage = damageperbullet;
|
2010-05-12 07:11:56 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (!(flags & FBF_NORANDOM))
|
2010-05-12 07:11:56 +00:00
|
|
|
damage *= ((pr_cwbullet()%3)+1);
|
|
|
|
|
2013-06-07 03:31:30 +00:00
|
|
|
P_LineAttack(self, angle, range, slope, damage, NAME_Hitscan, pufftype, laflags);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (ti, AActor);
|
|
|
|
PARAM_ANGLE_OPT (angle) { angle = 0; }
|
|
|
|
PARAM_BOOL_OPT (useammo) { useammo = true; }
|
|
|
|
PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; }
|
|
|
|
PARAM_FIXED_OPT (spawnheight) { spawnheight = 0; }
|
|
|
|
PARAM_BOOL_OPT (aimatangle) { aimatangle = false; }
|
|
|
|
PARAM_ANGLE_OPT (pitch) { pitch = 0; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!self->player)
|
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +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
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (useammo && weapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
|
|
|
return 0; // out of ammo
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ti)
|
|
|
|
{
|
|
|
|
angle_t ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT;
|
2010-02-12 06:04:57 +00:00
|
|
|
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
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (aimatangle) shootangle += angle;
|
2006-08-17 09:54:42 +00:00
|
|
|
|
2009-06-27 19:37:53 +00:00
|
|
|
// Temporarily adjusts the pitch
|
2010-02-12 06:04:57 +00:00
|
|
|
fixed_t saved_player_pitch = self->pitch;
|
2009-06-27 19:37:53 +00:00
|
|
|
self->pitch -= pitch;
|
2010-02-12 06:04:57 +00:00
|
|
|
AActor *misl = P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &linetarget);
|
|
|
|
self->pitch = saved_player_pitch;
|
2006-02-24 04:48:15 +00:00
|
|
|
// automatic handling of seeker missiles
|
|
|
|
if (misl)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (linetarget && (misl->flags2 & MF2_SEEKERMISSILE))
|
|
|
|
misl->tracer = linetarget;
|
|
|
|
if (!aimatangle)
|
2006-08-17 09:54:42 +00:00
|
|
|
{
|
|
|
|
// This original implementation is to aim straight ahead and then offset
|
|
|
|
// the angle from the resulting direction.
|
2009-06-30 20:57:51 +00:00
|
|
|
FVector3 velocity(misl->velx, misl->vely, 0);
|
2007-01-19 02:00:39 +00:00
|
|
|
fixed_t missilespeed = (fixed_t)velocity.Length();
|
2010-02-12 06:04:57 +00:00
|
|
|
misl->angle += angle;
|
2006-08-17 09:54:42 +00:00
|
|
|
angle_t an = misl->angle >> ANGLETOFINESHIFT;
|
2009-06-30 20:57:51 +00:00
|
|
|
misl->velx = FixedMul (missilespeed, finecosine[an]);
|
|
|
|
misl->vely = FixedMul (missilespeed, finesine[an]);
|
2006-08-17 09:54:42 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_CustomPunch
|
|
|
|
//
|
|
|
|
// Berserk is not handled here. That can be done with A_CheckIfInventory
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2010-06-13 09:06:12 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CPF_USEAMMO = 1,
|
|
|
|
CPF_DAGGER = 2,
|
|
|
|
CPF_PULLIN = 4,
|
2013-03-09 07:09:40 +00:00
|
|
|
CPF_NORANDOMPUFFZ = 8,
|
2010-06-13 09:06:12 +00:00
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (damage);
|
|
|
|
PARAM_BOOL_OPT (norandom) { norandom = false; }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_INT_OPT (flags) { flags = CPF_USEAMMO; }
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; }
|
|
|
|
PARAM_FIXED_OPT (range) { range = 0; }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_FIXED_OPT (lifesteal) { lifesteal = 0; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!self->player)
|
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
player_t *player = self->player;
|
|
|
|
AWeapon *weapon = player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
angle_t angle;
|
|
|
|
int pitch;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor * linetarget;
|
2013-06-24 14:42:43 +00:00
|
|
|
int actualdamage;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!norandom)
|
|
|
|
damage *= pr_cwpunch() % 8 + 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
angle = self->angle + (pr_cwpunch.Random2() << 18);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (range == 0)
|
|
|
|
range = MELEERANGE;
|
|
|
|
pitch = P_AimLineAttack (self, angle, range, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// only use ammo when actually hitting something!
|
2010-06-13 09:06:12 +00:00
|
|
|
if ((flags & CPF_USEAMMO) && linetarget && weapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
|
|
|
return 0; // out of ammo
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (pufftype == NULL)
|
2010-03-24 02:49:37 +00:00
|
|
|
pufftype = PClass::FindActor(NAME_BulletPuff);
|
2013-03-09 07:09:40 +00:00
|
|
|
int puffFlags = LAF_ISMELEEATTACK | (flags & CPF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-06-26 00:23:01 +00:00
|
|
|
P_LineAttack (self, angle, range, pitch, damage, NAME_Melee, pufftype, puffFlags, &linetarget, &actualdamage);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// turn to face target
|
|
|
|
if (linetarget)
|
|
|
|
{
|
2013-06-26 00:23:01 +00:00
|
|
|
if (lifesteal && !(linetarget->flags5 & MF5_DONTDRAIN))
|
|
|
|
P_GiveBody (self, (actualdamage * lifesteal) >> FRACBITS);
|
2010-05-12 07:08:39 +00:00
|
|
|
|
2013-05-12 18:31:36 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
S_Sound (self, CHAN_WEAPON, weapon->AttackSound, 1, ATTN_NORM);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
self->angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y);
|
2010-06-13 09:06:12 +00:00
|
|
|
|
|
|
|
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
|
|
|
|
if (flags & CPF_DAGGER) P_DaggerAlert (self, linetarget);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (damage);
|
|
|
|
PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; }
|
|
|
|
PARAM_BOOL_OPT (useammo) { useammo = true; }
|
|
|
|
PARAM_COLOR_OPT (color1) { color1 = 0; }
|
|
|
|
PARAM_COLOR_OPT (color2) { color2 = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_FLOAT_OPT (maxdiff) { maxdiff = 0; }
|
2010-03-24 02:49:37 +00:00
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ANGLE_OPT (spread_xy) { spread_xy = 0; }
|
|
|
|
PARAM_ANGLE_OPT (spread_z) { spread_z = 0; }
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_FIXED_OPT (range) { range = 0; }
|
|
|
|
PARAM_INT_OPT (duration) { duration = 0; }
|
|
|
|
PARAM_FLOAT_OPT (sparsity) { sparsity = 1; }
|
|
|
|
PARAM_FLOAT_OPT (driftspeed) { driftspeed = 1; }
|
|
|
|
PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; }
|
2013-06-07 03:31:30 +00:00
|
|
|
PARAM_FIXED_OPT (spawnofs_z) { spawnofs_z = 0; }
|
2012-04-07 12:57:44 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (range == 0) range = 8192*FRACUNIT;
|
|
|
|
if (sparsity == 0) sparsity=1.0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (self->player == NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// only use ammo when actually hitting something!
|
2010-02-12 06:04:57 +00:00
|
|
|
if (useammo)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!weapon->DepleteAmmo(weapon->bAltFire, true))
|
|
|
|
return 0; // out of ammo
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 06:27:13 +00:00
|
|
|
angle_t angle;
|
|
|
|
angle_t slope;
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (flags & RAF_EXPLICITANGLE)
|
2010-07-24 06:27:13 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angle = spread_xy;
|
|
|
|
slope = spread_z;
|
2010-07-24 06:27:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angle = pr_crailgun.Random2() * (spread_xy / 255);
|
|
|
|
slope = pr_crailgun.Random2() * (spread_z / 255);
|
2010-07-24 06:27:13 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 03:31:30 +00:00
|
|
|
P_RailAttack (self, damage, spawnofs_xy, spawnofs_z, color1, color2, maxdiff, flags, pufftype, angle, slope, range, duration, sparsity, driftspeed, spawnclass);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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,
|
2010-07-24 06:27:13 +00:00
|
|
|
CRF_AIMDIRECT = 2,
|
|
|
|
CRF_EXPLICITANGLE = 4,
|
2009-01-01 15:09:49 +00:00
|
|
|
};
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (damage);
|
|
|
|
PARAM_INT_OPT (spawnofs_xy) { spawnofs_xy = 0; }
|
|
|
|
PARAM_COLOR_OPT (color1) { color1 = 0; }
|
|
|
|
PARAM_COLOR_OPT (color2) { color2 = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_INT_OPT (aim) { aim = CRF_DONTAIM; }
|
|
|
|
PARAM_FLOAT_OPT (maxdiff) { maxdiff = 0; }
|
2010-03-24 02:49:37 +00:00
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ANGLE_OPT (spread_xy) { spread_xy = 0; }
|
|
|
|
PARAM_ANGLE_OPT (spread_z) { spread_z = 0; }
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_FIXED_OPT (range) { range = 0; }
|
|
|
|
PARAM_INT_OPT (duration) { duration = 0; }
|
|
|
|
PARAM_FLOAT_OPT (sparsity) { sparsity = 1; }
|
|
|
|
PARAM_FLOAT_OPT (driftspeed) { driftspeed = 1; }
|
|
|
|
PARAM_CLASS_OPT (spawnclass, AActor){ spawnclass = NULL; }
|
2013-06-07 03:31:30 +00:00
|
|
|
PARAM_FIXED_OPT (spawnofs_z) { spawnofs_z = 0; }
|
2012-07-14 03:04:41 +00:00
|
|
|
|
|
|
|
if (range == 0) range = 8192*FRACUNIT;
|
|
|
|
if (sparsity == 0) sparsity = 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-10-27 04:16:55 +00:00
|
|
|
AActor *linetarget;
|
|
|
|
|
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;
|
2009-10-27 03:59:29 +00:00
|
|
|
fixed_t saved_pitch = self->pitch;
|
2009-01-01 15:09:49 +00:00
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
- 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
|
|
|
}
|
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)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->angle = R_PointToAngle2 (self->x,
|
|
|
|
self->y,
|
|
|
|
self->target->x,
|
|
|
|
self->target->y);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-03-28 10:51:35 +00:00
|
|
|
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, aim ? self->target : NULL);
|
2009-10-27 04:16:55 +00:00
|
|
|
if (linetarget == NULL && aim)
|
|
|
|
{
|
|
|
|
// We probably won't hit the target, but aim at it anyway so we don't look stupid.
|
|
|
|
FVector2 xydiff(self->target->x - self->x, self->target->y - self->y);
|
|
|
|
double zdiff = (self->target->z + (self->target->height>>1)) -
|
|
|
|
(self->z + (self->height>>1) - self->floorclip);
|
|
|
|
self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI);
|
|
|
|
}
|
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,
|
2009-06-30 20:57:51 +00:00
|
|
|
self->target->x - self->target->velx * 3,
|
|
|
|
self->target->y - self->target->vely * 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.
|
2010-02-12 06:04:57 +00:00
|
|
|
self->x += spawnofs_xy * finecosine[self->angle];
|
|
|
|
self->y += spawnofs_xy * finesine[self->angle];
|
|
|
|
spawnofs_xy = 0;
|
2009-01-01 15:09:49 +00:00
|
|
|
self->angle = R_PointToAngle2 (self->x, self->y,
|
2009-06-30 20:57:51 +00:00
|
|
|
self->target->x - self->target->velx * 3,
|
|
|
|
self->target->y - self->target->vely * 3);
|
2009-01-01 15:09:49 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2010-07-24 06:27:13 +00:00
|
|
|
angle_t angleoffset;
|
|
|
|
angle_t slopeoffset;
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (flags & CRF_EXPLICITANGLE)
|
2010-07-24 06:27:13 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angleoffset = spread_xy;
|
|
|
|
slopeoffset = spread_z;
|
2010-07-24 06:27:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
angleoffset = pr_crailgun.Random2() * (spread_xy / 255);
|
|
|
|
slopeoffset = pr_crailgun.Random2() * (spread_z / 255);
|
2010-07-24 06:27:13 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 03:31:30 +00:00
|
|
|
P_RailAttack (self, damage, spawnofs_xy, spawnofs_z, color1, color2, maxdiff, flags, pufftype, angleoffset, slopeoffset, range, duration, sparsity, driftspeed, spawnclass);
|
2009-01-01 15:09:49 +00:00
|
|
|
|
|
|
|
self->x = saved_x;
|
|
|
|
self->y = saved_y;
|
|
|
|
self->angle = saved_angle;
|
2009-10-27 03:59:29 +00:00
|
|
|
self->pitch = saved_pitch;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
static int DoGiveInventory(AActor *receiver, VM_ARGS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-14 19:59:21 +00:00
|
|
|
int paramnum = NAP-1;
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_CLASS (mi, AInventory);
|
|
|
|
PARAM_INT_OPT (amount) { amount = 1; }
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_INT_OPT (setreceiver) { setreceiver = AAPTR_DEFAULT; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
receiver = COPY_AAPTR(receiver, setreceiver);
|
|
|
|
if (receiver == NULL)
|
2012-07-17 05:31:41 +00:00
|
|
|
{ // If there's nothing to receive it, it's obviously a fail, right?
|
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
return numret;
|
2012-07-14 03:04:41 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
bool res = true;
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (amount <= 0)
|
|
|
|
{
|
|
|
|
amount = 1;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mi)
|
|
|
|
{
|
2010-02-12 06:04:57 +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;
|
2010-09-19 00:06:45 +00:00
|
|
|
item->ClearCounters();
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!item->CallTryPickup(receiver))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
item->Destroy();
|
2006-09-25 07:48:52 +00:00
|
|
|
res = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
res = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = false;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2011-03-18 08:02:23 +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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoGiveInventory(self, VM_ARGS_NAMES);
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoGiveInventory(self->target, VM_ARGS_NAMES);
|
2010-02-12 06:04:57 +00:00
|
|
|
}
|
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
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2010-04-26 02:05:11 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TIF_NOTAKEINFINITE = 1,
|
|
|
|
};
|
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int DoTakeInventory(AActor *receiver, VM_ARGS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-14 19:59:21 +00:00
|
|
|
int paramnum = NAP-1;
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_CLASS (itemtype, AInventory);
|
|
|
|
PARAM_INT_OPT (amount) { amount = 0; }
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_INT_OPT (setreceiver) { setreceiver = AAPTR_DEFAULT; }
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (itemtype == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(true);
|
|
|
|
return numret;
|
2012-07-14 03:04:41 +00:00
|
|
|
}
|
|
|
|
receiver = COPY_AAPTR(receiver, setreceiver);
|
|
|
|
if (receiver == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
return numret;
|
2012-07-14 03:04:41 +00:00
|
|
|
}
|
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
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
AInventory *inv = receiver->FindInventory(itemtype);
|
2006-12-25 13:43:11 +00:00
|
|
|
|
|
|
|
if (inv && !inv->IsKindOf(RUNTIME_CLASS(AHexenArmor)))
|
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
if (inv->Amount > 0)
|
|
|
|
{
|
|
|
|
res = true;
|
|
|
|
}
|
2010-04-26 02:05:11 +00:00
|
|
|
// Do not take ammo if the "no take infinite/take as ammo depletion" flag is set
|
|
|
|
// and infinite ammo is on
|
|
|
|
if (flags & TIF_NOTAKEINFINITE &&
|
|
|
|
((dmflags & DF_INFINITE_AMMO) || (receiver->player->cheats & CF_INFINITEAMMO)) &&
|
|
|
|
inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-04-26 02:05:11 +00:00
|
|
|
// Nothing to do here, except maybe res = false;? Would it make sense?
|
|
|
|
}
|
|
|
|
else 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();
|
2010-02-12 06:04:57 +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);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2011-03-18 08:02:23 +00:00
|
|
|
}
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoTakeInventory(self, VM_ARGS_NAMES);
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-07-17 05:31:41 +00:00
|
|
|
return DoTakeInventory(self->target, VM_ARGS_NAMES);
|
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
|
|
|
//
|
|
|
|
//===========================================================================
|
2013-03-20 03:07:45 +00:00
|
|
|
|
2008-06-02 16:56:53 +00:00
|
|
|
enum SIX_Flags
|
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
SIXF_TRANSFERTRANSLATION = 1 << 0,
|
|
|
|
SIXF_ABSOLUTEPOSITION = 1 << 1,
|
|
|
|
SIXF_ABSOLUTEANGLE = 1 << 2,
|
|
|
|
SIXF_ABSOLUTEVELOCITY = 1 << 3,
|
|
|
|
SIXF_SETMASTER = 1 << 4,
|
|
|
|
SIXF_NOCHECKPOSITION = 1 << 5,
|
|
|
|
SIXF_TELEFRAG = 1 << 6,
|
|
|
|
SIXF_CLIENTSIDE = 1 << 7, // only used by Skulldronum
|
|
|
|
SIXF_TRANSFERAMBUSHFLAG = 1 << 8,
|
|
|
|
SIXF_TRANSFERPITCH = 1 << 9,
|
|
|
|
SIXF_TRANSFERPOINTERS = 1 << 10,
|
|
|
|
SIXF_USEBLOODCOLOR = 1 << 11,
|
|
|
|
SIXF_CLEARCALLERTID = 1 << 12,
|
|
|
|
SIXF_MULTIPLYSPEED = 1 << 13,
|
|
|
|
SIXF_TRANSFERSCALE = 1 << 14,
|
2013-03-23 01:22:37 +00:00
|
|
|
SIXF_TRANSFERSPECIAL = 1 << 15,
|
|
|
|
SIXF_CLEARCALLERSPECIAL = 1 << 16,
|
2008-06-02 16:56:53 +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
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
if (mo == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
AActor *originator = self;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-03-20 03:07:45 +00:00
|
|
|
if (!(mo->flags2 & MF2_DONTTRANSLATE))
|
|
|
|
{
|
|
|
|
if (flags & SIXF_TRANSFERTRANSLATION)
|
2006-08-17 00:19:26 +00:00
|
|
|
{
|
|
|
|
mo->Translation = self->Translation;
|
|
|
|
}
|
2013-03-20 03:07:45 +00:00
|
|
|
else if (flags & SIXF_USEBLOODCOLOR)
|
2009-06-07 20:10:05 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
// [XA] Use the spawning actor's BloodColor to translate the newly-spawned object.
|
|
|
|
PalEntry bloodcolor = self->GetBloodColor();
|
|
|
|
mo->Translation = TRANSLATION(TRANSLATION_Blood, bloodcolor.a);
|
2009-06-07 20:10:05 +00:00
|
|
|
}
|
2013-03-20 03:07:45 +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
|
|
|
|
2013-03-20 03:07:45 +00:00
|
|
|
mo->angle = self->angle;
|
|
|
|
if (flags & SIXF_TRANSFERPITCH)
|
|
|
|
{
|
|
|
|
mo->pitch = self->pitch;
|
|
|
|
}
|
|
|
|
while (originator && originator->isMissile())
|
|
|
|
{
|
|
|
|
originator = originator->target;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-03-20 03:07:45 +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;
|
|
|
|
}
|
|
|
|
if (mo->flags3 & MF3_ISMONSTER)
|
|
|
|
{
|
|
|
|
if (!(flags & SIXF_NOCHECKPOSITION) && !P_TestMobjLocation(mo))
|
2008-06-02 16:56:53 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
// The monster is blocked so don't spawn it at all!
|
|
|
|
mo->ClearCounters();
|
|
|
|
mo->Destroy();
|
|
|
|
return false;
|
2008-06-02 16:56:53 +00:00
|
|
|
}
|
2013-03-20 03:07:45 +00:00
|
|
|
else if (originator)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
if (originator->flags3 & MF3_ISMONSTER)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
// If this is a monster transfer all friendliness information
|
|
|
|
mo->CopyFriendliness(originator, true);
|
|
|
|
if (flags & SIXF_SETMASTER) mo->master = originator; // don't let it attack you (optional)!
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2013-03-20 03:07:45 +00:00
|
|
|
else if (originator->player)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
// A player always spawns a monster friendly to him
|
|
|
|
mo->flags |= MF_FRIENDLY;
|
|
|
|
mo->SetFriendPlayer(originator->player);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-03-20 03:07:45 +00:00
|
|
|
AActor * attacker=originator->player->attacker;
|
|
|
|
if (attacker)
|
|
|
|
{
|
|
|
|
if (!(attacker->flags&MF_FRIENDLY) ||
|
|
|
|
(deathmatch && attacker->FriendPlayer!=0 && attacker->FriendPlayer!=mo->FriendPlayer))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
// Target the monster which last attacked the player
|
|
|
|
mo->LastHeard = mo->target = attacker;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-20 03:07:45 +00:00
|
|
|
else if (!(flags & SIXF_TRANSFERPOINTERS))
|
|
|
|
{
|
|
|
|
// If this is a missile or something else set the target to the originator
|
|
|
|
mo->target = originator ? originator : self;
|
|
|
|
}
|
|
|
|
if (flags & SIXF_TRANSFERSCALE)
|
|
|
|
{
|
|
|
|
mo->scaleX = self->scaleX;
|
|
|
|
mo->scaleY = self->scaleY;
|
|
|
|
}
|
|
|
|
if (flags & SIXF_TRANSFERAMBUSHFLAG)
|
|
|
|
{
|
|
|
|
mo->flags = (mo->flags & ~MF_AMBUSH) | (self->flags & MF_AMBUSH);
|
|
|
|
}
|
|
|
|
if (flags & SIXF_CLEARCALLERTID)
|
|
|
|
{
|
|
|
|
self->RemoveFromHash();
|
|
|
|
self->tid = 0;
|
|
|
|
}
|
2013-03-23 01:22:37 +00:00
|
|
|
if (flags & SIXF_TRANSFERSPECIAL)
|
|
|
|
{
|
|
|
|
mo->special = self->special;
|
|
|
|
memcpy(mo->args, self->args, sizeof(self->args));
|
|
|
|
}
|
|
|
|
if (flags & SIXF_CLEARCALLERSPECIAL)
|
|
|
|
{
|
|
|
|
self->special = 0;
|
|
|
|
memset(self->args, 0, sizeof(self->args));
|
|
|
|
}
|
2013-03-20 03:07:45 +00:00
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-03-24 02:49:37 +00:00
|
|
|
PARAM_CLASS_OPT (missile, AActor) { missile = PClass::FindActor("Unknown"); }
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_FIXED_OPT (distance) { distance = 0; }
|
|
|
|
PARAM_FIXED_OPT (zheight) { zheight = 0; }
|
|
|
|
PARAM_BOOL_OPT (useammo) { useammo = true; }
|
|
|
|
PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; }
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile == NULL)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(true);
|
2006-11-27 00:01:30 +00:00
|
|
|
// Don't spawn monsters if this actor has been massacred
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->DamageType == NAME_Massacre && (GetDefaultByType(missile)->flags3 & MF3_ISMONSTER))
|
2012-07-17 05:31:41 +00:00
|
|
|
{
|
|
|
|
return numret;
|
|
|
|
}
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (distance == 0)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
|
|
|
// use the minimum distance that does not result in an overlap
|
2010-02-12 06:04:57 +00:00
|
|
|
distance = (self->radius + GetDefaultByType(missile)->radius) >> FRACBITS;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
if (ACTION_CALL_FROM_WEAPON())
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
// Used from a weapon, so use some ammo
|
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (weapon == NULL)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-02-12 06:04:57 +00:00
|
|
|
if (useammo && !weapon->DepleteAmmo(weapon->bAltFire))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
AActor *mo = Spawn(missile,
|
2006-11-27 00:01:30 +00:00
|
|
|
self->x + FixedMul(distance, finecosine[self->angle>>ANGLETOFINESHIFT]),
|
|
|
|
self->y + FixedMul(distance, finesine[self->angle>>ANGLETOFINESHIFT]),
|
2012-07-27 02:01:36 +00:00
|
|
|
self->z - self->floorclip + self->GetBobOffset() + zheight, ALLOW_REPLACE);
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2010-02-12 06:04:57 +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
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (missile, AActor);
|
|
|
|
PARAM_FIXED_OPT (xofs) { xofs = 0; }
|
|
|
|
PARAM_FIXED_OPT (yofs) { yofs = 0; }
|
|
|
|
PARAM_FIXED_OPT (zofs) { zofs = 0; }
|
|
|
|
PARAM_FIXED_OPT (xvel) { xvel = 0; }
|
|
|
|
PARAM_FIXED_OPT (yvel) { yvel = 0; }
|
|
|
|
PARAM_FIXED_OPT (zvel) { zvel = 0; }
|
|
|
|
PARAM_ANGLE_OPT (angle) { angle = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_INT_OPT (chance) { chance = 0; }
|
2013-06-07 03:31:30 +00:00
|
|
|
PARAM_INT_OPT (tid) { tid = 0; }
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile == NULL)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_SET_RESULT(false);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(true);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (chance > 0 && pr_spawnitemex() < chance)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-11-27 21:51:36 +00:00
|
|
|
|
2006-11-27 00:01:30 +00:00
|
|
|
// Don't spawn monsters if this actor has been massacred
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->DamageType == NAME_Massacre && (GetDefaultByType(missile)->flags3 & MF3_ISMONSTER))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
fixed_t x, y;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
if (!(flags & SIXF_ABSOLUTEANGLE))
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
angle += self->angle;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
angle_t ang = angle >> ANGLETOFINESHIFT;
|
2006-11-27 00:01:30 +00:00
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
|
2009-06-30 20:57:51 +00:00
|
|
|
if (!(flags & SIXF_ABSOLUTEVELOCITY))
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
|
|
|
// Same orientation issue here!
|
2009-06-30 20:57:51 +00:00
|
|
|
fixed_t newxvel = FixedMul(xvel, finecosine[ang]) + FixedMul(yvel, finesine[ang]);
|
|
|
|
yvel = FixedMul(xvel, finesine[ang]) - FixedMul(yvel, finecosine[ang]);
|
|
|
|
xvel = newxvel;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 03:07:45 +00:00
|
|
|
AActor *mo = Spawn(missile, x, y, self->z - self->floorclip + self->GetBobOffset() + 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
|
2013-03-20 03:07:45 +00:00
|
|
|
if (res)
|
2006-11-27 00:01:30 +00:00
|
|
|
{
|
2013-03-20 03:07:45 +00:00
|
|
|
if (tid != 0)
|
|
|
|
{
|
|
|
|
assert(mo->tid == 0);
|
|
|
|
mo->tid = tid;
|
|
|
|
mo->AddToHash();
|
|
|
|
}
|
|
|
|
if (flags & SIXF_MULTIPLYSPEED)
|
|
|
|
{
|
|
|
|
mo->velx = FixedMul(xvel, mo->Speed);
|
|
|
|
mo->vely = FixedMul(yvel, mo->Speed);
|
|
|
|
mo->velz = FixedMul(zvel, mo->Speed);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mo->velx = xvel;
|
|
|
|
mo->vely = yvel;
|
|
|
|
mo->velz = zvel;
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
mo->angle = angle;
|
2006-11-27 00:01:30 +00:00
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (missile, AActor);
|
|
|
|
PARAM_FIXED_OPT (zheight) { zheight = 0; }
|
|
|
|
PARAM_FIXED_OPT (xyvel) { xyvel = 0; }
|
|
|
|
PARAM_FIXED_OPT (zvel) { zvel = 0; }
|
|
|
|
PARAM_BOOL_OPT (useammo) { useammo = true; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(true);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (missile == NULL)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2008-10-25 17:38:00 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
if (ACTION_CALL_FROM_WEAPON())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
// Used from a weapon, so use some ammo
|
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (weapon == NULL)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-02-12 06:04:57 +00:00
|
|
|
if (useammo && !weapon->DepleteAmmo(weapon->bAltFire))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
AActor *bo;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-14 14:30:13 +00:00
|
|
|
bo = Spawn(missile, self->x, self->y,
|
- Add the bob offset to the missiles spawned by P_SpawnMissile(), P_SpawnMissileAngle(), P_SpawnMissileAngleSpeed(), A_MissileAttack, A_ComboAttack, A_BasicAttack, A_CustomMissile, A_CustomComboAttack, A_ThrowGrenade, A_SpawnDebris, and A_Burst.
- Add the bob offset to the value returned by GetActorZ.
SVN r3795 (trunk)
2012-07-30 00:05:24 +00:00
|
|
|
self->z - self->floorclip + self->GetBobOffset() + zheight + 35*FRACUNIT + (self->player? self->player->crouchoffset : 0),
|
2006-07-16 09:10:45 +00:00
|
|
|
ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (bo)
|
|
|
|
{
|
2006-11-25 12:25:05 +00:00
|
|
|
P_PlaySpawnSound(bo, self);
|
2009-12-31 06:13:47 +00:00
|
|
|
if (xyvel != 0)
|
2009-06-30 20:57:51 +00:00
|
|
|
bo->Speed = xyvel;
|
|
|
|
bo->angle = self->angle + (((pr_grenade()&7) - 4) << 24);
|
2009-12-31 06:13:47 +00:00
|
|
|
|
|
|
|
angle_t pitch = angle_t(-self->pitch) >> ANGLETOFINESHIFT;
|
|
|
|
angle_t angle = bo->angle >> ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
// There are two vectors we are concerned about here: xy and z. We rotate
|
|
|
|
// them separately according to the shooter's pitch and then sum them to
|
|
|
|
// get the final velocity vector to shoot with.
|
|
|
|
|
|
|
|
fixed_t xy_xyscale = FixedMul(bo->Speed, finecosine[pitch]);
|
|
|
|
fixed_t xy_velz = FixedMul(bo->Speed, finesine[pitch]);
|
|
|
|
fixed_t xy_velx = FixedMul(xy_xyscale, finecosine[angle]);
|
|
|
|
fixed_t xy_vely = FixedMul(xy_xyscale, finesine[angle]);
|
|
|
|
|
|
|
|
pitch = angle_t(self->pitch) >> ANGLETOFINESHIFT;
|
|
|
|
fixed_t z_xyscale = FixedMul(zvel, finesine[pitch]);
|
|
|
|
fixed_t z_velz = FixedMul(zvel, finecosine[pitch]);
|
|
|
|
fixed_t z_velx = FixedMul(z_xyscale, finecosine[angle]);
|
|
|
|
fixed_t z_vely = FixedMul(z_xyscale, finesine[angle]);
|
|
|
|
|
|
|
|
bo->velx = xy_velx + z_velx + (self->velx >> 1);
|
|
|
|
bo->vely = xy_vely + z_vely + (self->vely >> 1);
|
|
|
|
bo->velz = xy_velz + z_velz;
|
|
|
|
|
2013-03-21 03:06:04 +00:00
|
|
|
bo->target = self;
|
|
|
|
P_CheckMissileSpawn (bo, self->radius);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED(xyvel);
|
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;
|
2010-02-12 06:04:57 +00:00
|
|
|
self->velx += FixedMul(xyvel, finecosine[angle]);
|
|
|
|
self->vely += FixedMul(xyvel, finesine[angle]);
|
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS(cls, AWeapon);
|
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);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2008-10-25 17:38:00 +00:00
|
|
|
}
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2010-02-12 06:04:57 +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
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(true);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STRING (text);
|
|
|
|
PARAM_FLOAT_OPT (time) { time = 0; }
|
|
|
|
PARAM_NAME_OPT (fontname) { fontname = NAME_None; }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-07-24 02:01:13 +00:00
|
|
|
if (text[0] == '$') text = GStrings(&text[1]);
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->CheckLocalView (consoleplayer) ||
|
2010-02-12 06:04:57 +00:00
|
|
|
(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)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
con_midtime = float(time);
|
2006-09-17 10:43:51 +00:00
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
FString formatted = strbin1(text);
|
|
|
|
C_MidPrint(font != NULL ? font : SmallFont, formatted.GetChars());
|
2006-09-17 10:43:51 +00:00
|
|
|
con_midtime = saved;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-06-13 10:38:38 +00:00
|
|
|
ACTION_SET_RESULT(false); // Prints should never set the result for inventory state chains!
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 19:44:14 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_PrintBold
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PrintBold)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STRING (text);
|
|
|
|
PARAM_FLOAT_OPT (time) { time = 0; }
|
|
|
|
PARAM_NAME_OPT (fontname) { fontname = NAME_None; }
|
2009-09-14 19:44:14 +00:00
|
|
|
|
|
|
|
float saved = con_midtime;
|
|
|
|
FFont *font = NULL;
|
|
|
|
|
2013-07-24 02:01:13 +00:00
|
|
|
if (text[0] == '$') text = GStrings(&text[1]);
|
2009-09-14 19:44:14 +00:00
|
|
|
if (fontname != NAME_None)
|
|
|
|
{
|
|
|
|
font = V_GetFont(fontname);
|
|
|
|
}
|
|
|
|
if (time > 0)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
con_midtime = float(time);
|
2009-09-14 19:44:14 +00:00
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
FString formatted = strbin1(text);
|
|
|
|
C_MidPrintBold(font != NULL ? font : SmallFont, formatted.GetChars());
|
2009-09-14 19:44:14 +00:00
|
|
|
con_midtime = saved;
|
2010-06-13 10:38:38 +00:00
|
|
|
ACTION_SET_RESULT(false); // Prints should never set the result for inventory state chains!
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-09-14 19:44:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Log
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Log)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STRING(text);
|
2013-07-14 12:33:45 +00:00
|
|
|
|
2013-07-24 02:01:13 +00:00
|
|
|
if (text[0] == '$') text = GStrings(&text[1]);
|
2009-09-14 19:44:14 +00:00
|
|
|
Printf("%s\n", text);
|
2010-06-13 10:38:38 +00:00
|
|
|
ACTION_SET_RESULT(false); // Prints should never set the result for inventory state chains!
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-09-14 19:44:14 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2013-07-14 12:33:45 +00:00
|
|
|
//=========================================================================
|
2009-10-25 02:19:51 +00:00
|
|
|
//
|
|
|
|
// A_LogInt
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LogInt)
|
|
|
|
{
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT(num);
|
2009-10-25 02:19:51 +00:00
|
|
|
Printf("%d\n", num);
|
2010-06-13 10:38:38 +00:00
|
|
|
ACTION_SET_RESULT(false); // Prints should never set the result for inventory state chains!
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED (alpha);
|
|
|
|
PARAM_INT_OPT (mode) { mode = 0; }
|
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);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED_OPT(reduce) { reduce = FRACUNIT/10; }
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (reduce == 0)
|
2010-04-26 01:56:25 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
reduce = FRACUNIT/10;
|
2010-04-26 01:56:25 +00:00
|
|
|
}
|
- 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;
|
2010-04-26 01:56:25 +00:00
|
|
|
// Should this clamp alpha to 1.0?
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-04-11 08:36:23 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED_OPT(reduce) { reduce = FRACUNIT/10; }
|
|
|
|
PARAM_BOOL_OPT(remove) { remove = true; }
|
2009-06-07 22:13:16 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (reduce == 0)
|
2010-04-26 01:56:25 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
reduce = FRACUNIT/10;
|
2010-04-26 01:56:25 +00:00
|
|
|
}
|
- 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;
|
2010-04-26 01:56:25 +00:00
|
|
|
if (self->alpha <= 0 && remove)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
self->Destroy();
|
2010-04-26 01:56:25 +00:00
|
|
|
}
|
2010-09-16 03:14:32 +00:00
|
|
|
return 0;
|
2010-04-26 01:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_FadeTo
|
|
|
|
//
|
|
|
|
// fades the actor to a specified transparency by a specified amount and
|
|
|
|
// destroys it if so desired
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeTo)
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED (target);
|
|
|
|
PARAM_FIXED_OPT (amount) { amount = fixed_t(0.1*FRACUNIT); }
|
|
|
|
PARAM_BOOL_OPT (remove) { remove = false; }
|
2010-04-26 01:56:25 +00:00
|
|
|
|
|
|
|
self->RenderStyle.Flags &= ~STYLEF_Alpha1;
|
|
|
|
|
|
|
|
if (self->alpha > target)
|
|
|
|
{
|
|
|
|
self->alpha -= amount;
|
|
|
|
|
|
|
|
if (self->alpha < target)
|
|
|
|
{
|
|
|
|
self->alpha = target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (self->alpha < target)
|
|
|
|
{
|
|
|
|
self->alpha += amount;
|
|
|
|
|
|
|
|
if (self->alpha > target)
|
|
|
|
{
|
|
|
|
self->alpha = target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (self->alpha == target && remove)
|
|
|
|
{
|
|
|
|
self->Destroy();
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 00:01:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Scale(float scalex, optional float scaley)
|
|
|
|
//
|
|
|
|
// Scales the actor's graphics. If scaley is 0, use scalex.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetScale)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED (scalex);
|
|
|
|
PARAM_FIXED_OPT (scaley) { scaley = scalex; }
|
2010-11-08 00:01:21 +00:00
|
|
|
|
|
|
|
self->scaleX = scalex;
|
2012-07-14 03:04:41 +00:00
|
|
|
self->scaleY = scaley;
|
|
|
|
return 0;
|
2010-11-08 00:01:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 22:59:20 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetMass(int mass)
|
|
|
|
//
|
|
|
|
// Sets the actor's mass.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetMass)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (mass);
|
2011-01-14 22:59:20 +00:00
|
|
|
|
|
|
|
self->Mass = mass;
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2011-01-14 22:59:20 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (debris, AActor);
|
|
|
|
PARAM_BOOL_OPT (transfer_translation) { transfer_translation = false; }
|
|
|
|
PARAM_FIXED_OPT (mult_h) { mult_h = FRACUNIT; }
|
|
|
|
PARAM_FIXED_OPT (mult_v) { mult_v = FRACUNIT; }
|
2006-02-24 04:48:15 +00:00
|
|
|
int i;
|
2010-02-12 06:04:57 +00:00
|
|
|
AActor *mo;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (debris == NULL)
|
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-12-06 10:38:47 +00:00
|
|
|
// only positive values make sense here
|
2010-02-12 06:04:57 +00:00
|
|
|
if (mult_v <= 0)
|
|
|
|
mult_v = FRACUNIT;
|
|
|
|
if (mult_h <= 0)
|
|
|
|
mult_h = FRACUNIT;
|
2006-12-06 10:38:47 +00:00
|
|
|
|
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),
|
2012-11-10 03:38:52 +00:00
|
|
|
self->y + ((pr_spawndebris()-128)<<12),
|
|
|
|
self->z + (pr_spawndebris()*self->height/256+self->GetBobOffset()), ALLOW_REPLACE);
|
|
|
|
if (mo)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-11-10 03:38:52 +00:00
|
|
|
if (transfer_translation)
|
|
|
|
{
|
|
|
|
mo->Translation = self->Translation;
|
|
|
|
}
|
2013-06-07 03:31:30 +00:00
|
|
|
if (i < mo->GetClass()->NumOwnedStates)
|
2012-11-10 03:38:52 +00:00
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
mo->SetState (mo->GetClass()->OwnedStates + i);
|
2012-11-10 03:38:52 +00:00
|
|
|
}
|
2009-06-30 20:57:51 +00:00
|
|
|
mo->velz = FixedMul(mult_v, ((pr_spawndebris()&7)+5)*FRACUNIT);
|
|
|
|
mo->velx = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6));
|
|
|
|
mo->vely = FixedMul(mult_h, pr_spawndebris.Random2()<<(FRACBITS-6));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
2008-08-13 22:54:24 +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-12-06 10:38:47 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
for (int i = 0; i < MAXPLAYERS; i++)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2012-03-17 00:52:33 +00:00
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
// Always check sight from each player.
|
|
|
|
if (P_CheckSight(players[i].mo, self, SF_IGNOREVISIBILITY))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-03-17 00:52:33 +00:00
|
|
|
}
|
|
|
|
// If a player is viewing from a non-player, then check that too.
|
|
|
|
if (players[i].camera != NULL && players[i].camera->player == NULL &&
|
|
|
|
P_CheckSight(players[i].camera, self, SF_IGNOREVISIBILITY))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-03-17 00:52:33 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-02-26 00:08:25 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckSightOrRange
|
|
|
|
// Jumps if this actor is out of range of all players *and* out of sight.
|
|
|
|
// Useful for maps with many multi-actor special effects.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2012-03-17 00:52:33 +00:00
|
|
|
static bool DoCheckSightOrRange(AActor *self, AActor *camera, double range)
|
|
|
|
{
|
|
|
|
if (camera == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Check distance first, since it's cheaper than checking sight.
|
|
|
|
double dx = self->x - camera->x;
|
|
|
|
double dy = self->y - camera->y;
|
|
|
|
double dz;
|
|
|
|
fixed_t eyez = (camera->z + camera->height - (camera->height>>2)); // same eye height as P_CheckSight
|
|
|
|
if (eyez > self->z + self->height)
|
|
|
|
{
|
|
|
|
dz = self->z + self->height - eyez;
|
|
|
|
}
|
|
|
|
else if (eyez < self->z)
|
|
|
|
{
|
|
|
|
dz = self->z - eyez;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dz = 0;
|
|
|
|
}
|
|
|
|
if ((dx*dx) + (dy*dy) + (dz*dz) <= range)
|
|
|
|
{ // Within range
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now check LOS.
|
|
|
|
if (P_CheckSight(camera, self, SF_IGNOREVISIBILITY))
|
|
|
|
{ // Visible
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-26 00:08:25 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckSightOrRange)
|
|
|
|
{
|
2010-04-04 04:09:24 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FLOAT(range);
|
|
|
|
PARAM_STATE(jump);
|
2010-02-26 00:08:25 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
|
|
|
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
|
|
|
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
2012-03-17 00:52:33 +00:00
|
|
|
// Always check from each player.
|
|
|
|
if (DoCheckSightOrRange(self, players[i].mo, range))
|
2010-02-26 00:08:25 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-02-26 00:08:25 +00:00
|
|
|
}
|
2012-03-17 00:52:33 +00:00
|
|
|
// If a player is viewing from a non-player, check that too.
|
|
|
|
if (players[i].camera != NULL && players[i].camera->player == NULL &&
|
|
|
|
DoCheckSightOrRange(self, players[i].camera, range))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-02-26 00:08:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 16:45:17 +00:00
|
|
|
ACTION_JUMP(jump);
|
2013-06-26 00:23:01 +00:00
|
|
|
return numret;
|
2013-06-23 16:45:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckRange
|
|
|
|
// Jumps if this actor is out of range of all players.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
static bool DoCheckRange(AActor *self, AActor *camera, double range)
|
|
|
|
{
|
|
|
|
if (camera == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Check distance first, since it's cheaper than checking sight.
|
|
|
|
double dx = self->x - camera->x;
|
|
|
|
double dy = self->y - camera->y;
|
|
|
|
double dz;
|
|
|
|
fixed_t eyez = (camera->z + camera->height - (camera->height>>2)); // same eye height as P_CheckSight
|
|
|
|
if (eyez > self->z + self->height){
|
|
|
|
dz = self->z + self->height - eyez;
|
|
|
|
}
|
|
|
|
else if (eyez < self->z){
|
|
|
|
dz = self->z - eyez;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
dz = 0;
|
|
|
|
}
|
|
|
|
if ((dx*dx) + (dy*dy) + (dz*dz) <= range){
|
|
|
|
// Within range
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckRange)
|
|
|
|
{
|
2013-06-26 00:23:01 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FLOAT(range);
|
|
|
|
PARAM_STATE(jump);
|
2013-06-23 16:45:17 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
|
|
|
range = range * range * (double(FRACUNIT) * FRACUNIT); // no need for square roots
|
|
|
|
for (int i = 0; i < MAXPLAYERS; ++i)
|
|
|
|
{
|
|
|
|
if (playeringame[i])
|
|
|
|
{
|
|
|
|
// Always check from each player.
|
|
|
|
if (DoCheckRange(self, players[i].mo, range))
|
|
|
|
{
|
2013-06-26 00:23:01 +00:00
|
|
|
return numret;
|
2013-06-23 16:45:17 +00:00
|
|
|
}
|
|
|
|
// If a player is viewing from a non-player, check that too.
|
|
|
|
if (players[i].camera != NULL && players[i].camera->player == NULL &&
|
|
|
|
DoCheckRange(self, players[i].camera, range))
|
2012-03-17 00:52:33 +00:00
|
|
|
{
|
2013-06-26 00:23:01 +00:00
|
|
|
return numret;
|
2010-02-26 00:08:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ACTION_JUMP(jump);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS(drop, AInventory);
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
AInventory *inv = self->FindInventory(drop);
|
2008-10-25 17:38:00 +00:00
|
|
|
if (inv)
|
|
|
|
{
|
|
|
|
self->DropInventory(inv);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_COLOR (color);
|
|
|
|
PARAM_FLOAT (alpha);
|
|
|
|
PARAM_INT (tics);
|
|
|
|
PARAM_COLOR_OPT (color2) { color2 = 0; }
|
|
|
|
|
|
|
|
if (color == MAKEARGB(255,255,255,255))
|
|
|
|
color = 0;
|
|
|
|
if (color2 == MAKEARGB(255,255,255,255))
|
|
|
|
color2 = 0;
|
|
|
|
if (color2.a == 0)
|
2006-04-11 08:36:23 +00:00
|
|
|
color2 = color;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
new DFlashFader(color.r/255.f, color.g/255.f, color.b/255.f, float(alpha),
|
|
|
|
color2.r/255.f, color2.g/255.f, color2.b/255.f, 0,
|
|
|
|
float(tics)/TICRATE, self);
|
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_BOOL (condition);
|
|
|
|
PARAM_STATE (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!
|
2010-02-12 06:04:57 +00:00
|
|
|
if (condition)
|
|
|
|
ACTION_JUMP(jump);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_KillMaster
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2009-12-13 04:59:19 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillMaster)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_NAME_OPT(damagetype) { damagetype = NAME_None; }
|
2009-12-13 04:59:19 +00:00
|
|
|
|
2006-06-11 11:28:48 +00:00
|
|
|
if (self->master != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-12-13 05:04:12 +00:00
|
|
|
P_DamageMobj(self->master, self, self, self->master->health, damagetype, DMG_NO_ARMOR | DMG_NO_FACTOR);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_KillChildren
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2009-12-13 04:59:19 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillChildren)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_NAME_OPT(damagetype) { damagetype = NAME_None; }
|
2009-12-13 04:59:19 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
2010-02-12 06:04:57 +00:00
|
|
|
AActor *mo;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-22 01:34:07 +00:00
|
|
|
while ( (mo = it.Next()) )
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (mo->master == self)
|
|
|
|
{
|
2009-12-13 05:04:12 +00:00
|
|
|
P_DamageMobj(mo, self, self, mo->health, damagetype, DMG_NO_ARMOR | DMG_NO_FACTOR);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2009-12-13 04:59:19 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_KillSiblings)
|
2008-12-06 10:22:37 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_NAME_OPT(damagetype) { damagetype = NAME_None; }
|
2009-12-13 04:59:19 +00:00
|
|
|
|
2008-12-06 10:22:37 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
2010-02-12 06:04:57 +00:00
|
|
|
AActor *mo;
|
2008-12-06 10:22:37 +00:00
|
|
|
|
2013-04-30 06:48:53 +00:00
|
|
|
if (self->master != NULL)
|
2008-12-06 10:22:37 +00:00
|
|
|
{
|
2013-04-30 06:48:53 +00:00
|
|
|
while ( (mo = it.Next()) )
|
2008-12-06 10:22:37 +00:00
|
|
|
{
|
2013-04-30 06:48:53 +00:00
|
|
|
if (mo->master == self->master && mo != self)
|
|
|
|
{
|
|
|
|
P_DamageMobj(mo, self, self, mo->health, damagetype, DMG_NO_ARMOR | DMG_NO_FACTOR);
|
|
|
|
}
|
2008-12-06 10:22:37 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-12-06 10:22:37 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT(argnum);
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_STATE_OPT(state) { state = self->FindState(NAME_Death); }
|
2006-05-03 14:54:48 +00:00
|
|
|
|
2012-10-18 03:19:27 +00:00
|
|
|
if (argnum > 0 && argnum < (int)countof(self->args))
|
2006-05-03 14:54:48 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!self->args[argnum]--)
|
2006-05-07 23:55:17 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->flags & MF_MISSILE)
|
|
|
|
{
|
|
|
|
P_ExplodeMissile(self, NULL, NULL);
|
|
|
|
}
|
|
|
|
else if (self->flags & MF_SHOOTABLE)
|
|
|
|
{
|
|
|
|
P_DamageMobj(self, NULL, NULL, self->health, NAME_None, DMG_FORCED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->SetState(self->FindState(NAME_Death));
|
|
|
|
}
|
2006-05-07 23:55:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-16 16:04:19 +00:00
|
|
|
self->SetState(state);
|
2006-05-07 23:55:17 +00:00
|
|
|
}
|
2006-05-03 14:54:48 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS(chunk, AActor);
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2010-04-23 08:12:47 +00:00
|
|
|
int i, numChunks;
|
|
|
|
AActor * mo;
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (chunk == NULL)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2010-04-23 08:12:47 +00:00
|
|
|
|
|
|
|
self->velx = self->vely = self->velz = 0;
|
|
|
|
self->height = self->GetDefault()->height;
|
|
|
|
|
|
|
|
// [RH] In Hexen, this creates a random number of shards (range [24,56])
|
|
|
|
// with no relation to the size of the self shattering. I think it should
|
|
|
|
// base the number of shards on the size of the dead thing, so bigger
|
|
|
|
// things break up into more shards than smaller things.
|
|
|
|
// An self with radius 20 and height 64 creates ~40 chunks.
|
|
|
|
numChunks = MAX<int> (4, (self->radius>>FRACBITS)*(self->height>>FRACBITS)/32);
|
|
|
|
i = (pr_burst.Random2()) % (numChunks/4);
|
|
|
|
for (i = MAX (24, numChunks + i); i >= 0; i--)
|
|
|
|
{
|
|
|
|
mo = Spawn(chunk,
|
|
|
|
self->x + (((pr_burst()-128)*self->radius)>>7),
|
|
|
|
self->y + (((pr_burst()-128)*self->radius)>>7),
|
- Add the bob offset to the missiles spawned by P_SpawnMissile(), P_SpawnMissileAngle(), P_SpawnMissileAngleSpeed(), A_MissileAttack, A_ComboAttack, A_BasicAttack, A_CustomMissile, A_CustomComboAttack, A_ThrowGrenade, A_SpawnDebris, and A_Burst.
- Add the bob offset to the value returned by GetActorZ.
SVN r3795 (trunk)
2012-07-30 00:05:24 +00:00
|
|
|
self->z + (pr_burst()*self->height/255 + self->GetBobOffset()), ALLOW_REPLACE);
|
2010-04-23 08:12:47 +00:00
|
|
|
|
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->velz = FixedDiv(mo->z - self->z, self->height)<<2;
|
|
|
|
mo->velx = pr_burst.Random2 () << (FRACBITS-7);
|
|
|
|
mo->vely = pr_burst.Random2 () << (FRACBITS-7);
|
|
|
|
mo->RenderStyle = self->RenderStyle;
|
|
|
|
mo->alpha = self->alpha;
|
|
|
|
mo->CopyFriendliness(self, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Do some stuff to make this more useful outside Hexen
|
|
|
|
if (self->flags4 & MF4_BOSSDEATH)
|
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_BossDeath, self);
|
2010-04-23 08:12:47 +00:00
|
|
|
}
|
|
|
|
A_Unblock(self, true);
|
2006-05-15 15:28:46 +00:00
|
|
|
|
2010-04-23 08:12:47 +00:00
|
|
|
self->Destroy ();
|
2010-09-16 03:14:32 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
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
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
2010-02-12 06:04:57 +00:00
|
|
|
// [GZ] Totally copied from A_CheckFloor, jumps if actor touches ceiling
|
2009-04-23 23:20:21 +00:00
|
|
|
//
|
2012-07-15 23:00:16 +00:00
|
|
|
|
2009-04-23 23:20:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckCeiling)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
2009-04-23 23:20:21 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false);
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->z + self->height >= self->ceilingz) // Height needs to be counted
|
2009-04-23 23:20:21 +00:00
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-04-23 23:20:21 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 10:32:41 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Stop
|
2009-06-30 20:57:51 +00:00
|
|
|
// resets all velocity of the actor to 0
|
2006-10-22 10:32:41 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_Stop)
|
2006-10-22 10:32:41 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velx = self->vely = self->velz = 0;
|
2008-07-05 10:17:10 +00:00
|
|
|
if (self->player && self->player->mo == self && !(self->player->cheats & CF_PREDICTING))
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
self->player->mo->PlayIdle();
|
|
|
|
self->player->velx = self->player->vely = 0;
|
2008-07-05 10:17:10 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-10-22 10:32:41 +00:00
|
|
|
}
|
2006-11-04 13:06:42 +00:00
|
|
|
|
2009-07-01 01:10:29 +00:00
|
|
|
static void CheckStopped(AActor *self)
|
|
|
|
{
|
|
|
|
if (self->player != NULL &&
|
|
|
|
self->player->mo == self &&
|
|
|
|
!(self->player->cheats & CF_PREDICTING) &&
|
|
|
|
!(self->velx | self->vely | self->velz))
|
|
|
|
{
|
|
|
|
self->player->mo->PlayIdle();
|
|
|
|
self->player->velx = self->player->vely = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-04 13:06:42 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Respawn
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2009-09-15 21:57:51 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
DECLARE_ACTION(A_RestoreSpecialPosition)
|
2012-04-03 04:31:27 +00:00
|
|
|
|
2009-09-15 21:57:51 +00:00
|
|
|
enum RS_Flags
|
|
|
|
{
|
|
|
|
RSF_FOG=1,
|
|
|
|
RSF_KEEPTARGET=2,
|
|
|
|
RSF_TELEFRAG=4,
|
|
|
|
};
|
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
|
2006-11-04 13:06:42 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT(flags) { flags = RSF_FOG; }
|
2008-08-13 22:54:24 +00:00
|
|
|
|
2009-09-15 21:57:51 +00:00
|
|
|
bool oktorespawn = false;
|
2006-11-04 13:06:42 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->flags |= MF_SOLID;
|
|
|
|
self->height = self->GetDefault()->height;
|
2012-04-03 04:31:27 +00:00
|
|
|
CALL_ACTION(A_RestoreSpecialPosition, self);
|
2009-09-15 21:57:51 +00:00
|
|
|
|
|
|
|
if (flags & RSF_TELEFRAG)
|
|
|
|
{
|
|
|
|
// [KS] DIE DIE DIE DIE erm *ahem* =)
|
2012-04-03 04:31:27 +00:00
|
|
|
oktorespawn = P_TeleportMove(self, self->x, self->y, self->z, true);
|
2012-04-06 04:46:45 +00:00
|
|
|
if (oktorespawn)
|
|
|
|
{ // Need to do this over again, since P_TeleportMove() will redo
|
|
|
|
// it with the proper point-on-side calculation.
|
|
|
|
self->UnlinkFromWorld();
|
|
|
|
self->LinkToWorld(true);
|
|
|
|
sector_t *sec = self->Sector;
|
|
|
|
self->dropoffz =
|
|
|
|
self->floorz = sec->floorplane.ZatPoint(self->x, self->y);
|
|
|
|
self->ceilingz = sec->ceilingplane.ZatPoint(self->x, self->y);
|
2012-04-08 05:39:46 +00:00
|
|
|
P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS);
|
2012-04-06 04:46:45 +00:00
|
|
|
}
|
2009-09-15 21:57:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-15 01:59:49 +00:00
|
|
|
oktorespawn = P_CheckPosition(self, self->x, self->y, true);
|
2009-09-15 21:57:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (oktorespawn)
|
2006-11-04 13:06:42 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
AActor *defs = self->GetDefault();
|
|
|
|
self->health = defs->health;
|
2009-09-15 21:57:51 +00:00
|
|
|
|
|
|
|
// [KS] Don't keep target, because it could be self if the monster committed suicide
|
|
|
|
// ...Actually it's better off an option, so you have better control over monster behavior.
|
|
|
|
if (!(flags & RSF_KEEPTARGET))
|
|
|
|
{
|
|
|
|
self->target = NULL;
|
|
|
|
self->LastHeard = NULL;
|
|
|
|
self->lastenemy = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Don't attack yourself (Re: "Marine targets itself after suicide")
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->target == self)
|
|
|
|
self->target = NULL;
|
|
|
|
if (self->lastenemy == self)
|
|
|
|
self->lastenemy = NULL;
|
2009-09-15 21:57:51 +00:00
|
|
|
}
|
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
|
|
|
|
2009-09-15 21:57:51 +00:00
|
|
|
if (flags & RSF_FOG)
|
2006-11-04 13:06:42 +00:00
|
|
|
{
|
2012-04-03 04:31:27 +00:00
|
|
|
Spawn<ATeleportFog> (self->x, self->y, self->z + TELEFOGHEIGHT, ALLOW_REPLACE);
|
2006-11-04 13:06:42 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->CountsAsKill())
|
2012-04-03 04:31:27 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE(jump);
|
2008-08-13 22:54:24 +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-10 20:48:55 +00:00
|
|
|
if (self->player != NULL &&
|
2013-05-12 18:27:03 +00:00
|
|
|
skins[self->player->userinfo.GetSkin()].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
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED(gravity);
|
2007-01-20 14:27:44 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
self->gravity = clamp<fixed_t>(gravity, 0, FRACUNIT*10);
|
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2007-12-26 05:03:14 +00:00
|
|
|
self->target = NULL;
|
|
|
|
self->LastHeard = NULL;
|
|
|
|
self->lastenemy = NULL;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2007-12-20 20:37:06 +00:00
|
|
|
}
|
|
|
|
|
2013-03-23 02:55:59 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckLOF (state jump, int flags = CRF_AIM_VERT|CRF_AIM_HOR,
|
|
|
|
// fixed range = 0, angle angle = 0, angle pitch = 0,
|
|
|
|
// fixed offsetheight = 32, fixed offsetwidth = 0,
|
|
|
|
// int ptr_target = AAPTR_DEFAULT (target) )
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
enum CLOF_flags
|
|
|
|
{
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_NOAIM_VERT = 0x1,
|
|
|
|
CLOFF_NOAIM_HORZ = 0x2,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_JUMPENEMY = 0x4,
|
|
|
|
CLOFF_JUMPFRIEND = 0x8,
|
|
|
|
CLOFF_JUMPOBJECT = 0x10,
|
|
|
|
CLOFF_JUMPNONHOSTILE = 0x20,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_SKIPENEMY = 0x40,
|
|
|
|
CLOFF_SKIPFRIEND = 0x80,
|
|
|
|
CLOFF_SKIPOBJECT = 0x100,
|
|
|
|
CLOFF_SKIPNONHOSTILE = 0x200,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_MUSTBESHOOTABLE = 0x400,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_SKIPTARGET = 0x800,
|
|
|
|
CLOFF_ALLOWNULL = 0x1000,
|
|
|
|
CLOFF_CHECKPARTIAL = 0x2000,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_MUSTBEGHOST = 0x4000,
|
|
|
|
CLOFF_IGNOREGHOST = 0x8000,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_MUSTBESOLID = 0x10000,
|
|
|
|
CLOFF_BEYONDTARGET = 0x20000,
|
2013-03-23 02:55:59 +00:00
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
CLOFF_FROMBASE = 0x40000,
|
|
|
|
CLOFF_MUL_HEIGHT = 0x80000,
|
|
|
|
CLOFF_MUL_WIDTH = 0x100000,
|
|
|
|
|
|
|
|
CLOFF_JUMP_ON_MISS = 0x200000,
|
|
|
|
CLOFF_AIM_VERT_NOOFFSET = 0x400000,
|
2013-03-23 02:55:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LOFData
|
|
|
|
{
|
|
|
|
AActor *Self;
|
|
|
|
AActor *Target;
|
|
|
|
int Flags;
|
2013-03-28 01:29:23 +00:00
|
|
|
bool BadActor;
|
2013-03-23 02:55:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ETraceStatus CheckLOFTraceFunc(FTraceResults &trace, void *userdata)
|
|
|
|
{
|
|
|
|
LOFData *data = (LOFData *)userdata;
|
|
|
|
int flags = data->Flags;
|
|
|
|
|
|
|
|
if (trace.HitType != TRACE_HitActor)
|
|
|
|
{
|
|
|
|
return TRACE_Stop;
|
|
|
|
}
|
|
|
|
if (trace.Actor == data->Target)
|
|
|
|
{
|
|
|
|
if (flags & CLOFF_SKIPTARGET)
|
|
|
|
{
|
|
|
|
if (flags & CLOFF_BEYONDTARGET)
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
|
|
|
return TRACE_Abort;
|
|
|
|
}
|
|
|
|
return TRACE_Stop;
|
|
|
|
}
|
|
|
|
if (flags & CLOFF_MUSTBESHOOTABLE)
|
|
|
|
{ // all shootability checks go here
|
|
|
|
if (!(trace.Actor->flags & MF_SHOOTABLE))
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
|
|
|
if (trace.Actor->flags2 & MF2_NONSHOOTABLE)
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((flags & CLOFF_MUSTBESOLID) && !(trace.Actor->flags & MF_SOLID))
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
|
|
|
if (flags & CLOFF_MUSTBEGHOST)
|
|
|
|
{
|
|
|
|
if (!(trace.Actor->flags3 & MF3_GHOST))
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (flags & CLOFF_IGNOREGHOST)
|
|
|
|
{
|
|
|
|
if (trace.Actor->flags3 & MF3_GHOST)
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
((flags & CLOFF_JUMPENEMY) && data->Self->IsHostile(trace.Actor)) ||
|
|
|
|
((flags & CLOFF_JUMPFRIEND) && data->Self->IsFriend(trace.Actor)) ||
|
|
|
|
((flags & CLOFF_JUMPOBJECT) && !(trace.Actor->flags3 & MF3_ISMONSTER)) ||
|
|
|
|
((flags & CLOFF_JUMPNONHOSTILE) && (trace.Actor->flags3 & MF3_ISMONSTER) && !data->Self->IsHostile(trace.Actor))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return TRACE_Stop;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
((flags & CLOFF_SKIPENEMY) && data->Self->IsHostile(trace.Actor)) ||
|
|
|
|
((flags & CLOFF_SKIPFRIEND) && data->Self->IsFriend(trace.Actor)) ||
|
|
|
|
((flags & CLOFF_SKIPOBJECT) && !(trace.Actor->flags3 & MF3_ISMONSTER)) ||
|
|
|
|
((flags & CLOFF_SKIPNONHOSTILE) && (trace.Actor->flags3 & MF3_ISMONSTER) && !data->Self->IsHostile(trace.Actor))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return TRACE_Skip;
|
|
|
|
}
|
2013-03-28 01:29:23 +00:00
|
|
|
data->BadActor = true;
|
2013-03-23 02:55:59 +00:00
|
|
|
return TRACE_Abort;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
|
|
|
|
{
|
|
|
|
// Check line of fire
|
|
|
|
|
|
|
|
/*
|
|
|
|
Not accounted for / I don't know how it works: FLOORCLIP
|
|
|
|
*/
|
|
|
|
|
|
|
|
AActor *target;
|
|
|
|
fixed_t
|
|
|
|
x1, y1, z1,
|
|
|
|
vx, vy, vz;
|
|
|
|
|
2013-06-07 03:31:30 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE (jump);
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_FIXED_OPT (range) { range = 0; }
|
|
|
|
PARAM_FIXED_OPT (minrange) { minrange = 0; }
|
2013-03-23 02:55:59 +00:00
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
PARAM_ANGLE_OPT (angle) { angle = 0; }
|
|
|
|
PARAM_ANGLE_OPT (pitch) { pitch = 0; }
|
|
|
|
PARAM_FIXED_OPT (offsetheight) { offsetheight = 0; }
|
|
|
|
PARAM_FIXED_OPT (offsetwidth) { offsetwidth = 0; }
|
|
|
|
PARAM_INT_OPT (ptr_target) { ptr_target = AAPTR_DEFAULT; }
|
2013-03-23 02:55:59 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
|
|
|
target = COPY_AAPTR(self, ptr_target == AAPTR_DEFAULT ? AAPTR_TARGET|AAPTR_PLAYER_GETTARGET|AAPTR_NULL : ptr_target); // no player-support by default
|
|
|
|
|
|
|
|
if (flags & CLOFF_MUL_HEIGHT)
|
|
|
|
{
|
|
|
|
if (self->player != NULL)
|
|
|
|
{
|
|
|
|
// Synced with hitscan: self->player->mo->height is strangely conscientious about getting the right actor for player
|
|
|
|
offsetheight = FixedMul(offsetheight, FixedMul (self->player->mo->height, self->player->crouchfactor));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offsetheight = FixedMul(offsetheight, self->height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flags & CLOFF_MUL_WIDTH)
|
|
|
|
{
|
|
|
|
offsetwidth = FixedMul(self->radius, offsetwidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
x1 = self->x;
|
|
|
|
y1 = self->y;
|
|
|
|
z1 = self->z + offsetheight - self->floorclip;
|
|
|
|
|
|
|
|
if (!(flags & CLOFF_FROMBASE))
|
|
|
|
{ // default to hitscan origin
|
|
|
|
|
|
|
|
// Synced with hitscan: self->height is strangely NON-conscientious about getting the right actor for player
|
|
|
|
z1 += (self->height >> 1);
|
|
|
|
if (self->player != NULL)
|
|
|
|
{
|
|
|
|
z1 += FixedMul (self->player->mo->AttackZOffset, self->player->crouchfactor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
z1 += 8*FRACUNIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target)
|
|
|
|
{
|
|
|
|
FVector2 xyvec(target->x - x1, target->y - y1);
|
|
|
|
fixed_t distance = P_AproxDistance((fixed_t)xyvec.Length(), target->z - z1);
|
|
|
|
|
|
|
|
if (range && !(flags & CLOFF_CHECKPARTIAL))
|
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
if (distance > range)
|
|
|
|
return numret;
|
2013-03-23 02:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
angle_t ang;
|
|
|
|
|
|
|
|
if (flags & CLOFF_NOAIM_HORZ)
|
|
|
|
{
|
|
|
|
ang = self->angle;
|
|
|
|
}
|
|
|
|
else ang = R_PointToAngle2 (x1, y1, target->x, target->y);
|
|
|
|
|
|
|
|
angle += ang;
|
|
|
|
|
|
|
|
ang >>= ANGLETOFINESHIFT;
|
|
|
|
x1 += FixedMul(offsetwidth, finesine[ang]);
|
|
|
|
y1 -= FixedMul(offsetwidth, finecosine[ang]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & CLOFF_NOAIM_VERT)
|
|
|
|
{
|
|
|
|
pitch += self->pitch;
|
|
|
|
}
|
2013-03-28 01:29:23 +00:00
|
|
|
else if (flags & CLOFF_AIM_VERT_NOOFFSET)
|
|
|
|
{
|
|
|
|
pitch += R_PointToAngle2 (0,0, (fixed_t)xyvec.Length(), target->z - z1 + offsetheight + target->height / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pitch += R_PointToAngle2 (0,0, (fixed_t)xyvec.Length(), target->z - z1 + target->height / 2);
|
|
|
|
}
|
2013-03-23 02:55:59 +00:00
|
|
|
}
|
|
|
|
else if (flags & CLOFF_ALLOWNULL)
|
|
|
|
{
|
|
|
|
angle += self->angle;
|
|
|
|
pitch += self->pitch;
|
|
|
|
|
|
|
|
angle_t ang = self->angle >> ANGLETOFINESHIFT;
|
|
|
|
x1 += FixedMul(offsetwidth, finesine[ang]);
|
|
|
|
y1 -= FixedMul(offsetwidth, finecosine[ang]);
|
|
|
|
}
|
2013-06-07 03:31:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return numret;
|
|
|
|
}
|
2013-03-23 02:55:59 +00:00
|
|
|
|
|
|
|
angle >>= ANGLETOFINESHIFT;
|
|
|
|
pitch = (0-pitch)>>ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
vx = FixedMul (finecosine[pitch], finecosine[angle]);
|
|
|
|
vy = FixedMul (finecosine[pitch], finesine[angle]);
|
|
|
|
vz = -finesine[pitch];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Variable set:
|
|
|
|
|
|
|
|
jump, flags, target
|
|
|
|
x1,y1,z1 (trace point of origin)
|
|
|
|
vx,vy,vz (trace unit vector)
|
|
|
|
range
|
|
|
|
*/
|
|
|
|
|
|
|
|
sector_t *sec = P_PointInSector(x1, y1);
|
|
|
|
|
|
|
|
if (range == 0)
|
|
|
|
{
|
|
|
|
range = (self->player != NULL) ? PLAYERMISSILERANGE : MISSILERANGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
FTraceResults trace;
|
|
|
|
LOFData lof_data;
|
|
|
|
|
|
|
|
lof_data.Self = self;
|
|
|
|
lof_data.Target = target;
|
|
|
|
lof_data.Flags = flags;
|
2013-03-28 01:29:23 +00:00
|
|
|
lof_data.BadActor = false;
|
2013-03-23 02:55:59 +00:00
|
|
|
|
|
|
|
Trace(x1, y1, z1, sec, vx, vy, vz, range, 0xFFFFFFFF, ML_BLOCKEVERYTHING, self, trace, 0,
|
|
|
|
CheckLOFTraceFunc, &lof_data);
|
|
|
|
|
2013-03-28 01:29:23 +00:00
|
|
|
if (trace.HitType == TRACE_HitActor ||
|
|
|
|
((flags & CLOFF_JUMP_ON_MISS) && !lof_data.BadActor && trace.HitType != TRACE_HitNone))
|
2013-03-23 02:55:59 +00:00
|
|
|
{
|
2013-03-28 01:29:23 +00:00
|
|
|
if (minrange > 0 && trace.Distance < minrange)
|
2013-03-23 02:55:59 +00:00
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
return numret;
|
2013-03-23 02:55:59 +00:00
|
|
|
}
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2013-06-07 03:31:30 +00:00
|
|
|
return numret;
|
2013-03-23 02:55:59 +00:00
|
|
|
}
|
|
|
|
|
2007-12-23 21:56:46 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
2010-07-24 06:30:52 +00:00
|
|
|
// A_JumpIfTargetInLOS (state label, optional fixed fov, optional int flags,
|
|
|
|
// optional fixed dist_max, optional fixed dist_close)
|
2008-05-15 17:16:32 +00:00
|
|
|
//
|
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
|
2010-07-24 06:30:52 +00:00
|
|
|
// (the default). ProjectileTarget is now flag JLOSF_PROJECTILE. dist_max
|
|
|
|
// sets the maximum distance that actor can see, 0 means forever. dist_close
|
|
|
|
// uses special behavior if certain flags are set, 0 means no checks.
|
2007-12-23 21:56:46 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2010-07-24 06:30:52 +00:00
|
|
|
enum JLOS_flags
|
|
|
|
{
|
|
|
|
JLOSF_PROJECTILE=1,
|
|
|
|
JLOSF_NOSIGHT=2,
|
|
|
|
JLOSF_CLOSENOFOV=4,
|
|
|
|
JLOSF_CLOSENOSIGHT=8,
|
|
|
|
JLOSF_CLOSENOJUMP=16,
|
|
|
|
JLOSF_DEADNOJUMP=32,
|
|
|
|
JLOSF_CHECKMASTER=64,
|
2011-06-07 23:05:24 +00:00
|
|
|
JLOSF_TARGETLOS=128,
|
|
|
|
JLOSF_FLIPFOV=256,
|
|
|
|
JLOSF_ALLYNOJUMP=512,
|
2013-01-02 03:17:52 +00:00
|
|
|
JLOSF_COMBATANTONLY=1024,
|
|
|
|
JLOSF_NOAUTOAIM=2048,
|
2010-07-24 06:30:52 +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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE (jump);
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ANGLE_OPT (fov) { fov = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_FIXED_OPT (dist_max) { dist_max = 0; }
|
|
|
|
PARAM_FIXED_OPT (dist_close) { dist_close = 0; }
|
2008-08-12 20:19:47 +00:00
|
|
|
|
2007-12-23 21:56:46 +00:00
|
|
|
angle_t an;
|
2011-06-07 23:05:24 +00:00
|
|
|
AActor *target, *viewport;
|
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
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
bool doCheckSight;
|
|
|
|
|
2007-12-23 21:56:46 +00:00
|
|
|
if (!self->player)
|
|
|
|
{
|
2010-07-24 06:30:52 +00:00
|
|
|
if (flags & JLOSF_CHECKMASTER)
|
|
|
|
{
|
|
|
|
target = self->master;
|
|
|
|
}
|
|
|
|
else if (self->flags & MF_MISSILE && (flags & JLOSF_PROJECTILE))
|
2008-05-15 17:16:32 +00:00
|
|
|
{
|
|
|
|
if (self->flags2 & MF2_SEEKERMISSILE)
|
|
|
|
target = self->tracer;
|
|
|
|
else
|
|
|
|
target = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target = self->target;
|
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (target == NULL)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret; // [KS] Let's not call P_CheckSight unnecessarily in this case.
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if ((flags & JLOSF_DEADNOJUMP) && (target->health <= 0))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
doCheckSight = !(flags & JLOSF_NOSIGHT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Does the player aim at something that can be shot?
|
2013-01-02 03:17:52 +00:00
|
|
|
P_AimLineAttack(self, self->angle, MISSILERANGE, &target, (flags & JLOSF_NOAUTOAIM) ? ANGLE_1/2 : 0);
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
if (!target) return numret;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
switch (flags & (JLOSF_TARGETLOS|JLOSF_FLIPFOV))
|
2010-09-16 03:14:32 +00:00
|
|
|
{
|
2011-06-07 23:05:24 +00:00
|
|
|
case JLOSF_TARGETLOS|JLOSF_FLIPFOV:
|
|
|
|
// target makes sight check, player makes fov check; player has verified fov
|
|
|
|
fov = 0;
|
|
|
|
// fall-through
|
|
|
|
case JLOSF_TARGETLOS:
|
|
|
|
doCheckSight = !(flags & JLOSF_NOSIGHT); // The target is responsible for sight check and fov
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// player has verified sight and fov
|
|
|
|
fov = 0;
|
|
|
|
// fall-through
|
|
|
|
case JLOSF_FLIPFOV: // Player has verified sight, but target must verify fov
|
|
|
|
doCheckSight = false;
|
|
|
|
break;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2011-06-07 23:05:24 +00:00
|
|
|
}
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
// [FDARI] If target is not a combatant, don't jump
|
2012-07-14 03:04:41 +00:00
|
|
|
if ( (flags & JLOSF_COMBATANTONLY) && (!target->player) && !(target->flags3 & MF3_ISMONSTER))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
// [FDARI] If actors share team, don't jump
|
2012-07-14 03:04:41 +00:00
|
|
|
if ((flags & JLOSF_ALLYNOJUMP) && self->IsFriend(target))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
fixed_t distance = P_AproxDistance(target->x - self->x, target->y - self->y);
|
|
|
|
distance = P_AproxDistance(distance, target->z - self->z);
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (dist_max && (distance > dist_max))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (dist_close && (distance < dist_close))
|
|
|
|
{
|
|
|
|
if (flags & JLOSF_CLOSENOJUMP)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2007-12-23 21:56:46 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (flags & JLOSF_CLOSENOFOV)
|
|
|
|
fov = 0;
|
2007-12-23 21:56:46 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (flags & JLOSF_CLOSENOSIGHT)
|
|
|
|
doCheckSight = false;
|
2007-12-23 21:56:46 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (flags & JLOSF_TARGETLOS) { viewport = target; target = self; }
|
|
|
|
else { viewport = self; }
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (doCheckSight && !P_CheckSight (viewport, target, SF_IGNOREVISIBILITY))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (flags & JLOSF_FLIPFOV)
|
|
|
|
{
|
|
|
|
if (viewport == self) { viewport = target; target = self; }
|
|
|
|
else { target = viewport; viewport = self; }
|
|
|
|
}
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (fov && (fov < ANGLE_MAX))
|
|
|
|
{
|
|
|
|
an = R_PointToAngle2 (viewport->x,
|
|
|
|
viewport->y,
|
|
|
|
target->x,
|
|
|
|
target->y)
|
|
|
|
- viewport->angle;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
2010-07-24 06:30:52 +00:00
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret; // [KS] Outside of FOV - return
|
2010-07-24 06:30:52 +00:00
|
|
|
}
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2010-07-24 06:30:52 +00:00
|
|
|
}
|
2007-12-23 21:56:46 +00:00
|
|
|
|
2008-08-14 08:52:55 +00:00
|
|
|
ACTION_JUMP(jump);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2007-12-23 21:56:46 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 23:39:08 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
2010-07-24 06:30:52 +00:00
|
|
|
// A_JumpIfInTargetLOS (state label, optional fixed fov, optional int flags
|
|
|
|
// optional fixed dist_max, optional fixed dist_close)
|
2009-06-08 23:39:08 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE (jump);
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ANGLE_OPT (fov) { fov = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_FIXED_OPT (dist_max) { dist_max = 0; }
|
|
|
|
PARAM_FIXED_OPT (dist_close) { dist_close = 0; }
|
2009-06-08 23:39:08 +00:00
|
|
|
|
|
|
|
angle_t an;
|
|
|
|
AActor *target;
|
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
2010-07-24 06:30:52 +00:00
|
|
|
if (flags & JLOSF_CHECKMASTER)
|
|
|
|
{
|
|
|
|
target = self->master;
|
|
|
|
}
|
|
|
|
else if (self->flags & MF_MISSILE && (flags & JLOSF_PROJECTILE))
|
2009-06-08 23:39:08 +00:00
|
|
|
{
|
|
|
|
if (self->flags2 & MF2_SEEKERMISSILE)
|
|
|
|
target = self->tracer;
|
|
|
|
else
|
|
|
|
target = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
target = self->target;
|
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (target == NULL)
|
2010-09-16 03:14:32 +00:00
|
|
|
{ // [KS] Let's not call P_CheckSight unnecessarily in this case.
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2009-06-08 23:39:08 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if ((flags & JLOSF_DEADNOJUMP) && (target->health <= 0))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2009-06-08 23:39:08 +00:00
|
|
|
|
2010-07-24 06:30:52 +00:00
|
|
|
fixed_t distance = P_AproxDistance(target->x - self->x, target->y - self->y);
|
|
|
|
distance = P_AproxDistance(distance, target->z - self->z);
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (dist_max && (distance > dist_max))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-24 06:30:52 +00:00
|
|
|
|
|
|
|
bool doCheckSight = !(flags & JLOSF_NOSIGHT);
|
|
|
|
|
|
|
|
if (dist_close && (distance < dist_close))
|
|
|
|
{
|
|
|
|
if (flags & JLOSF_CLOSENOJUMP)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-07-24 06:30:52 +00:00
|
|
|
|
|
|
|
if (flags & JLOSF_CLOSENOFOV)
|
|
|
|
fov = 0;
|
|
|
|
|
|
|
|
if (flags & JLOSF_CLOSENOSIGHT)
|
|
|
|
doCheckSight = false;
|
|
|
|
}
|
|
|
|
|
2009-06-08 23:39:08 +00:00
|
|
|
if (fov && (fov < ANGLE_MAX))
|
|
|
|
{
|
2012-04-01 03:41:08 +00:00
|
|
|
an = R_PointToAngle2 (target->x,
|
|
|
|
target->y,
|
|
|
|
self->x,
|
|
|
|
self->y)
|
|
|
|
- target->angle;
|
2009-06-08 23:39:08 +00:00
|
|
|
|
|
|
|
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret; // [KS] Outside of FOV - return
|
2009-06-08 23:39:08 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-01 03:41:08 +00:00
|
|
|
if (doCheckSight && !P_CheckSight (target, self, SF_IGNOREVISIBILITY))
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-04-01 03:41:08 +00:00
|
|
|
|
2009-06-08 23:39:08 +00:00
|
|
|
ACTION_JUMP(jump);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-06-08 23:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (amount);
|
|
|
|
PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; }
|
2008-03-29 22:59:41 +00:00
|
|
|
|
|
|
|
if (self->master != NULL)
|
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
P_DamageMobj(self->master, self, self, amount, damagetype, DMG_NO_ARMOR);
|
2008-03-29 22:59:41 +00:00
|
|
|
}
|
|
|
|
else if (amount < 0)
|
|
|
|
{
|
|
|
|
amount = -amount;
|
|
|
|
P_GiveBody(self->master, amount);
|
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-03-29 22:59:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (amount);
|
|
|
|
PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; }
|
2008-03-29 22:59:41 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
2008-03-29 22:59:41 +00:00
|
|
|
|
|
|
|
while ( (mo = it.Next()) )
|
|
|
|
{
|
|
|
|
if (mo->master == self)
|
|
|
|
{
|
|
|
|
if (amount > 0)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
P_DamageMobj(mo, self, self, amount, damagetype, DMG_NO_ARMOR);
|
2008-03-29 22:59:41 +00:00
|
|
|
}
|
|
|
|
else if (amount < 0)
|
|
|
|
{
|
|
|
|
amount = -amount;
|
|
|
|
P_GiveBody(mo, amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-03-29 22:59:41 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (amount);
|
|
|
|
PARAM_NAME_OPT (damagetype) { damagetype = NAME_None; }
|
2008-12-06 10:22:37 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
2008-12-06 10:22:37 +00:00
|
|
|
|
2013-04-30 06:48:53 +00:00
|
|
|
if (self->master != NULL)
|
2008-12-06 10:22:37 +00:00
|
|
|
{
|
2013-04-30 06:48:53 +00:00
|
|
|
while ( (mo = it.Next()) )
|
2008-12-06 10:22:37 +00:00
|
|
|
{
|
2013-04-30 06:48:53 +00:00
|
|
|
if (mo->master == self->master && mo != self)
|
2008-12-06 10:22:37 +00:00
|
|
|
{
|
2013-04-30 06:48:53 +00:00
|
|
|
if (amount > 0)
|
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
P_DamageMobj(mo, self, self, amount, damagetype, DMG_NO_ARMOR);
|
2013-04-30 06:48:53 +00:00
|
|
|
}
|
|
|
|
else if (amount < 0)
|
|
|
|
{
|
|
|
|
amount = -amount;
|
|
|
|
P_GiveBody(mo, amount);
|
|
|
|
}
|
2008-12-06 10:22:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-12-06 10:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2008-06-22 09:13:19 +00:00
|
|
|
if ( self->player == NULL || self->player->ReadyWeapon == NULL )
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-06-22 09:13:19 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_INT (count);
|
|
|
|
PARAM_STATE (jump);
|
|
|
|
PARAM_BOOL_OPT (dontincrement) { dontincrement = false; }
|
2008-08-21 08:04:21 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (count <= 0)
|
|
|
|
return 0;
|
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;
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!dontincrement || ReloadCounter != 0)
|
2008-08-21 08:04:21 +00:00
|
|
|
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.
|
2010-02-12 06:04:57 +00:00
|
|
|
weapon->CheckAmmo(false, false);
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
2008-08-21 08:04:21 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (!dontincrement)
|
2008-08-21 08:04:21 +00:00
|
|
|
weapon->ReloadCounter = ReloadCounter;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
if (self->player == NULL || self->player->ReadyWeapon == NULL)
|
|
|
|
return 0;
|
2008-06-22 09:13:19 +00:00
|
|
|
|
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
|
|
|
weapon->ReloadCounter = 0;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-06-22 09:13:19 +00:00
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_ChangeFlag
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeFlag)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STRING (flagname);
|
|
|
|
PARAM_BOOL (value);
|
2008-09-21 18:02:38 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
const char *dot = strchr(flagname, '.');
|
2008-09-21 18:02:38 +00:00
|
|
|
FFlagDef *fd;
|
2010-03-24 02:49:37 +00:00
|
|
|
PClassActor *cls = self->GetClass();
|
2008-09-21 18:02:38 +00:00
|
|
|
|
|
|
|
if (dot != NULL)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
FString part1(flagname.GetChars(), dot - flagname);
|
|
|
|
fd = FindFlag(cls, part1, dot + 1);
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
fd = FindFlag(cls, flagname, NULL);
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2010-09-19 00:06:45 +00:00
|
|
|
INTBOOL secret_before, secret_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;
|
2010-09-19 00:06:45 +00:00
|
|
|
secret_before = self->flags5 & MF5_COUNTSECRET;
|
2009-03-29 08:55:15 +00:00
|
|
|
|
2008-09-21 18:02:38 +00:00
|
|
|
if (fd->structoffset == -1)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
HandleDeprecatedFlags(self, cls, value, fd->flagbit);
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
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();
|
2013-06-07 03:31:30 +00:00
|
|
|
ModActorFlag(self, fd, value);
|
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;
|
2010-09-19 00:06:45 +00:00
|
|
|
secret_after = self->flags5 & MF5_COUNTSECRET;
|
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--;
|
|
|
|
}
|
|
|
|
}
|
2010-09-19 00:06:45 +00:00
|
|
|
// and secretd
|
|
|
|
if (secret_before != secret_after)
|
|
|
|
{
|
|
|
|
if (secret_after)
|
|
|
|
{ // It counts as an secret now.
|
|
|
|
level.total_secrets++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // It no longer counts as an secret
|
|
|
|
level.total_secrets--;
|
|
|
|
}
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-18 03:19:27 +00:00
|
|
|
Printf("Unknown flag '%s' in '%s'\n", flagname.GetChars(), cls->TypeName.GetChars());
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_CheckFlag
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckFlag)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STRING (flagname);
|
|
|
|
PARAM_STATE (jumpto);
|
|
|
|
PARAM_INT_OPT (checkpointer) { checkpointer = AAPTR_DEFAULT; }
|
2011-06-07 23:05:24 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
AActor *owner = COPY_AAPTR(self, checkpointer);
|
|
|
|
if (owner == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-07-14 03:04:41 +00:00
|
|
|
}
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
long dot = flagname.IndexOf('.');
|
2011-06-07 23:05:24 +00:00
|
|
|
FFlagDef *fd;
|
2012-07-14 03:04:41 +00:00
|
|
|
PClassActor *cls = owner->GetClass();
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2012-07-14 03:04:41 +00:00
|
|
|
if (dot >= 0)
|
2011-06-07 23:05:24 +00:00
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
FString part1(flagname.Left(dot));
|
|
|
|
fd = FindFlag(cls, part1, flagname.Mid(dot+1));
|
2011-06-07 23:05:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
fd = FindFlag(cls, flagname, NULL);
|
2011-06-07 23:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fd != NULL)
|
|
|
|
{
|
2013-05-05 00:01:51 +00:00
|
|
|
if (CheckActorFlag(owner, fd))
|
2011-06-07 23:05:24 +00:00
|
|
|
{
|
|
|
|
ACTION_JUMP(jumpto);
|
|
|
|
}
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-18 03:19:27 +00:00
|
|
|
Printf("Unknown flag '%s' in '%s'\n", flagname.GetChars(), cls->TypeName.GetChars());
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2008-09-21 18:02:38 +00:00
|
|
|
}
|
|
|
|
|
2011-06-07 23:05:24 +00:00
|
|
|
|
2008-12-06 10:22:37 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RemoveMaster
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_RemoveMaster)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
if (self->master != NULL)
|
|
|
|
{
|
|
|
|
P_RemoveThing(self->master);
|
|
|
|
}
|
|
|
|
return 0;
|
2008-12-06 10:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RemoveChildren
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveChildren)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_BOOL_OPT(removeall) { removeall = false; }
|
2008-12-06 10:22:37 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
|
|
|
|
2013-04-30 02:45:15 +00:00
|
|
|
while ((mo = it.Next()) != NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
2013-04-30 02:45:15 +00:00
|
|
|
if (mo->master == self && (mo->health <= 0 || removeall))
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
|
|
|
P_RemoveThing(mo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2009-06-06 12:46:35 +00:00
|
|
|
}
|
|
|
|
|
2009-07-13 22:07:18 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RemoveSiblings
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RemoveSiblings)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_BOOL_OPT(removeall) { removeall = false; }
|
2009-07-13 22:07:18 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
|
|
|
|
2013-04-30 02:46:47 +00:00
|
|
|
if (self->master != NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
2013-04-30 02:46:47 +00:00
|
|
|
while ((mo = it.Next()) != NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
2013-04-30 02:46:47 +00:00
|
|
|
if (mo->master == self->master && mo != self && (mo->health <= 0 || removeall))
|
|
|
|
{
|
|
|
|
P_RemoveThing(mo);
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2009-07-13 22:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RaiseMaster
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_RaiseMaster)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
if (self->master != NULL)
|
|
|
|
{
|
|
|
|
P_Thing_Raise(self->master);
|
|
|
|
}
|
|
|
|
return 0;
|
2009-07-13 22:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RaiseChildren
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_RaiseChildren)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2009-07-13 22:07:18 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
|
|
|
|
2013-04-30 02:45:15 +00:00
|
|
|
while ((mo = it.Next()) != NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
2013-04-30 02:45:15 +00:00
|
|
|
if (mo->master == self)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
|
|
|
P_Thing_Raise(mo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2009-07-13 22:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_RaiseSiblings
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2009-07-13 22:07:18 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
TThinkerIterator<AActor> it;
|
|
|
|
AActor *mo;
|
|
|
|
|
2013-04-30 02:46:47 +00:00
|
|
|
if (self->master != NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
2013-04-30 02:46:47 +00:00
|
|
|
while ((mo = it.Next()) != NULL)
|
2010-02-12 06:04:57 +00:00
|
|
|
{
|
2013-04-30 02:46:47 +00:00
|
|
|
if (mo->master == self->master && mo != self)
|
|
|
|
{
|
|
|
|
P_Thing_Raise(mo);
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2009-07-13 22:07:18 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 12:46:35 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2009-06-30 21:24:29 +00:00
|
|
|
// A_MonsterRefire
|
|
|
|
//
|
|
|
|
// Keep firing unless target got out of sight
|
2009-06-06 12:46:35 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MonsterRefire)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (prob);
|
|
|
|
PARAM_STATE (jump);
|
2009-06-06 12:46:35 +00:00
|
|
|
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
2010-02-12 06:04:57 +00:00
|
|
|
A_FaceTarget(self);
|
2009-06-06 12:46:35 +00:00
|
|
|
|
|
|
|
if (pr_monsterrefire() < prob)
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-06-06 12:46:35 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->target == NULL
|
2009-06-06 12:46:35 +00:00
|
|
|
|| P_HitFriend (self)
|
|
|
|
|| self->target->health <= 0
|
2010-04-03 07:10:52 +00:00
|
|
|
|| !P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING|SF_SEEPASTSHOOTABLELINES) )
|
2009-06-06 12:46:35 +00:00
|
|
|
{
|
|
|
|
ACTION_JUMP(jump);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-06-06 12:46:35 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 21:24:29 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetAngle
|
|
|
|
//
|
|
|
|
// Set actor's angle (in degrees).
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetAngle)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_ANGLE_OPT(angle) { angle = 0; }
|
2009-06-30 21:24:29 +00:00
|
|
|
self->angle = angle;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-06-30 21:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetPitch
|
|
|
|
//
|
|
|
|
// Set actor's pitch (in degrees).
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2011-12-06 01:25:37 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SPF_FORCECLAMP = 1, // players always clamp
|
|
|
|
};
|
|
|
|
|
2009-06-30 21:24:29 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetPitch)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_ANGLE(pitch);
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_INT_OPT(flags) { flags = 0; }
|
2011-12-06 01:25:37 +00:00
|
|
|
|
|
|
|
if (self->player != NULL || (flags & SPF_FORCECLAMP))
|
|
|
|
{ // clamp the pitch we set
|
|
|
|
int min, max;
|
|
|
|
|
|
|
|
if (self->player != NULL)
|
|
|
|
{
|
|
|
|
min = self->player->MinPitch;
|
|
|
|
max = self->player->MaxPitch;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
min = -ANGLE_90 + (1 << ANGLETOFINESHIFT);
|
|
|
|
max = ANGLE_90 - (1 << ANGLETOFINESHIFT);
|
|
|
|
}
|
|
|
|
pitch = clamp<int>(pitch, min, max);
|
|
|
|
}
|
|
|
|
|
2009-06-30 21:24:29 +00:00
|
|
|
self->pitch = pitch;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-06-30 21:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_ScaleVelocity
|
|
|
|
//
|
|
|
|
// Scale actor's velocity.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ScaleVelocity)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED(scale);
|
2009-06-30 21:24:29 +00:00
|
|
|
|
|
|
|
INTBOOL was_moving = self->velx | self->vely | self->velz;
|
|
|
|
|
|
|
|
self->velx = FixedMul(self->velx, scale);
|
|
|
|
self->vely = FixedMul(self->vely, scale);
|
|
|
|
self->velz = FixedMul(self->velz, scale);
|
|
|
|
|
|
|
|
// If the actor was previously moving but now is not, and is a player,
|
|
|
|
// update its player variables. (See A_Stop.)
|
2009-07-01 01:10:29 +00:00
|
|
|
if (was_moving)
|
2009-06-30 21:24:29 +00:00
|
|
|
{
|
2009-07-01 01:10:29 +00:00
|
|
|
CheckStopped(self);
|
2009-06-30 21:24:29 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-06-30 21:24:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_ChangeVelocity
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ChangeVelocity)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_FIXED_OPT (x) { x = 0; }
|
|
|
|
PARAM_FIXED_OPT (y) { y = 0; }
|
|
|
|
PARAM_FIXED_OPT (z) { z = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
2009-06-30 21:24:29 +00:00
|
|
|
|
2009-07-01 01:10:29 +00:00
|
|
|
INTBOOL was_moving = self->velx | self->vely | self->velz;
|
|
|
|
|
2009-06-30 21:24:29 +00:00
|
|
|
fixed_t vx = x, vy = y, vz = z;
|
|
|
|
fixed_t sina = finesine[self->angle >> ANGLETOFINESHIFT];
|
|
|
|
fixed_t cosa = finecosine[self->angle >> ANGLETOFINESHIFT];
|
|
|
|
|
|
|
|
if (flags & 1) // relative axes - make x, y relative to actor's current angle
|
|
|
|
{
|
|
|
|
vx = DMulScale16(x, cosa, -y, sina);
|
|
|
|
vy = DMulScale16(x, sina, y, cosa);
|
|
|
|
}
|
|
|
|
if (flags & 2) // discard old velocity - replace old velocity with new velocity
|
|
|
|
{
|
|
|
|
self->velx = vx;
|
|
|
|
self->vely = vy;
|
|
|
|
self->velz = vz;
|
|
|
|
}
|
|
|
|
else // add new velocity to old velocity
|
|
|
|
{
|
|
|
|
self->velx += vx;
|
|
|
|
self->vely += vy;
|
|
|
|
self->velz += vz;
|
|
|
|
}
|
2009-07-01 01:10:29 +00:00
|
|
|
|
|
|
|
if (was_moving)
|
|
|
|
{
|
|
|
|
CheckStopped(self);
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-06-30 21:24:29 +00:00
|
|
|
}
|
2009-07-16 22:50:58 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetArg
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetArg)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT(pos);
|
|
|
|
PARAM_INT(value);
|
2009-07-16 22:50:58 +00:00
|
|
|
|
|
|
|
// Set the value of the specified arg
|
|
|
|
if ((size_t)pos < countof(self->args))
|
|
|
|
{
|
|
|
|
self->args[pos] = value;
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-07-16 22:50:58 +00:00
|
|
|
}
|
2009-09-14 19:44:14 +00:00
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetSpecial
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpecial)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (spec);
|
|
|
|
PARAM_INT_OPT (arg0) { arg0 = 0; }
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (arg3) { arg3 = 0; }
|
|
|
|
PARAM_INT_OPT (arg4) { arg4 = 0; }
|
2009-09-14 19:44:14 +00:00
|
|
|
|
|
|
|
self->special = spec;
|
|
|
|
self->args[0] = arg0;
|
|
|
|
self->args[1] = arg1;
|
|
|
|
self->args[2] = arg2;
|
|
|
|
self->args[3] = arg3;
|
|
|
|
self->args[4] = arg4;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-09-14 19:44:14 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 21:41:44 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
2009-10-25 02:19:51 +00:00
|
|
|
// A_SetUserVar
|
2009-09-14 21:41:44 +00:00
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserVar)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_NAME (varname);
|
|
|
|
PARAM_INT (value);
|
2009-09-14 21:41:44 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
PSymbolVariable *var = dyn_cast<PSymbolVariable>(self->GetClass()->Symbols.FindSymbol(varname, true));
|
2009-10-25 02:19:51 +00:00
|
|
|
|
2010-04-03 02:06:51 +00:00
|
|
|
if (var == NULL || !var->bUserVar || var->ValueType.Type != VAL_Int)
|
2009-10-25 02:19:51 +00:00
|
|
|
{
|
|
|
|
Printf("%s is not a user variable in class %s\n", varname.GetChars(),
|
2010-06-06 05:41:09 +00:00
|
|
|
self->GetClass()->TypeName.GetChars());
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
// Set the value of the specified user variable.
|
2010-06-06 05:41:09 +00:00
|
|
|
*(int *)(reinterpret_cast<BYTE *>(self) + var->offset) = value;
|
2010-02-17 04:46:11 +00:00
|
|
|
return 0;
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_SetUserArray
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetUserArray)
|
|
|
|
{
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (varname);
|
|
|
|
PARAM_INT (pos);
|
|
|
|
PARAM_INT (value);
|
2009-10-25 02:19:51 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
PSymbolVariable *var = dyn_cast<PSymbolVariable>(self->GetClass()->Symbols.FindSymbol(varname, true));
|
2009-10-25 02:19:51 +00:00
|
|
|
|
2010-04-03 02:06:51 +00:00
|
|
|
if (var == NULL || !var->bUserVar || var->ValueType.Type != VAL_Array || var->ValueType.BaseType != VAL_Int)
|
2009-10-25 02:19:51 +00:00
|
|
|
{
|
|
|
|
Printf("%s is not a user array in class %s\n", varname.GetChars(),
|
2010-06-06 05:41:09 +00:00
|
|
|
self->GetClass()->TypeName.GetChars());
|
2010-02-17 04:46:11 +00:00
|
|
|
return 0;
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
if (pos < 0 || pos >= var->ValueType.size)
|
|
|
|
{
|
|
|
|
Printf("%d is out of bounds in array %s in class %s\n", pos, varname.GetChars(),
|
2010-06-06 05:41:09 +00:00
|
|
|
self->GetClass()->TypeName.GetChars());
|
2010-02-17 04:46:11 +00:00
|
|
|
return 0;
|
2009-10-25 02:19:51 +00:00
|
|
|
}
|
|
|
|
// Set the value of the specified user array at index pos.
|
2010-06-06 05:41:09 +00:00
|
|
|
((int *)(reinterpret_cast<BYTE *>(self) + var->offset))[pos] = value;
|
2010-09-16 03:14:32 +00:00
|
|
|
return 0;
|
2009-09-14 21:41:44 +00:00
|
|
|
}
|
|
|
|
|
2010-07-23 21:55:01 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Teleport(optional state teleportstate, optional class targettype,
|
|
|
|
// optional class fogtype, optional int flags, optional fixed mindist,
|
|
|
|
// optional fixed maxdist)
|
|
|
|
//
|
|
|
|
// Attempts to teleport to a targettype at least mindist away and at most
|
|
|
|
// maxdist away (0 means unlimited). If successful, spawn a fogtype at old
|
|
|
|
// location and place calling actor in teleportstate.
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
enum T_Flags
|
|
|
|
{
|
|
|
|
TF_TELEFRAG = 1, // Allow telefrag in order to teleport.
|
|
|
|
TF_RANDOMDECIDE = 2, // Randomly fail based on health. (A_Srcr2Decide)
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport)
|
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_STATE_OPT (teleport_state) { teleport_state = NULL; }
|
|
|
|
PARAM_CLASS_OPT (target_type, ASpecialSpot) { target_type = PClass::FindActor("BossSpot"); }
|
|
|
|
PARAM_CLASS_OPT (fog_type, AActor) { fog_type = PClass::FindActor("TeleportFog"); }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_FIXED_OPT (mindist) { mindist = 128 << FRACBITS; }
|
|
|
|
PARAM_FIXED_OPT (maxdist) { maxdist = 128 << FRACBITS; }
|
2010-07-23 21:55:01 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
ACTION_SET_RESULT(true);
|
|
|
|
|
2010-07-23 21:55:01 +00:00
|
|
|
// Randomly choose not to teleport like A_Srcr2Decide.
|
2010-09-16 03:14:32 +00:00
|
|
|
if (flags & TF_RANDOMDECIDE)
|
2010-07-23 21:55:01 +00:00
|
|
|
{
|
|
|
|
static const int chance[] =
|
|
|
|
{
|
|
|
|
192, 120, 120, 120, 64, 64, 32, 16, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int chanceindex = self->health / ((self->SpawnHealth()/8 == 0) ? 1 : self->SpawnHealth()/8);
|
|
|
|
|
|
|
|
if (chanceindex >= countof(chance))
|
|
|
|
{
|
|
|
|
chanceindex = countof(chance) - 1;
|
|
|
|
}
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (pr_teleport() >= chance[chanceindex])
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-23 21:55:01 +00:00
|
|
|
}
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (teleport_state == NULL)
|
2010-07-23 21:55:01 +00:00
|
|
|
{
|
|
|
|
// Default to Teleport.
|
2010-09-16 03:14:32 +00:00
|
|
|
teleport_state = self->FindState("Teleport");
|
2010-07-23 21:55:01 +00:00
|
|
|
// If still nothing, then return.
|
2010-09-16 03:14:32 +00:00
|
|
|
if (teleport_state == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-23 21:55:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DSpotState *state = DSpotState::GetSpotState();
|
2010-09-16 03:14:32 +00:00
|
|
|
if (state == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-23 21:55:01 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (target_type == NULL)
|
|
|
|
{
|
|
|
|
target_type = PClass::FindActor("BossSpot");
|
|
|
|
}
|
2010-07-23 21:55:01 +00:00
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
AActor *spot = state->GetSpotWithMinMaxDistance(target_type, self->x, self->y, mindist, maxdist);
|
|
|
|
if (spot == NULL)
|
|
|
|
{
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2010-09-16 03:14:32 +00:00
|
|
|
}
|
2010-07-23 21:55:01 +00:00
|
|
|
|
|
|
|
fixed_t prevX = self->x;
|
|
|
|
fixed_t prevY = self->y;
|
|
|
|
fixed_t prevZ = self->z;
|
2010-09-16 03:14:32 +00:00
|
|
|
if (P_TeleportMove (self, spot->x, spot->y, spot->z, flags & TF_TELEFRAG))
|
2010-07-23 21:55:01 +00:00
|
|
|
{
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
if (fog_type != NULL)
|
2010-07-23 21:55:01 +00:00
|
|
|
{
|
2010-09-16 03:14:32 +00:00
|
|
|
Spawn(fog_type, prevX, prevY, prevZ, ALLOW_REPLACE);
|
2010-07-23 21:55:01 +00:00
|
|
|
}
|
|
|
|
|
2010-09-16 03:14:32 +00:00
|
|
|
ACTION_JUMP(teleport_state);
|
2010-07-23 21:55:01 +00:00
|
|
|
|
|
|
|
self->z = self->floorz;
|
|
|
|
self->angle = spot->angle;
|
|
|
|
self->velx = self->vely = self->velz = 0;
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-09-14 21:41:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 23:50:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Turn
|
|
|
|
//
|
|
|
|
//===========================================================================
|
2009-09-14 23:28:24 +00:00
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Turn)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2012-10-18 03:19:27 +00:00
|
|
|
PARAM_ANGLE_OPT(angle) { angle = 0; }
|
2009-09-14 23:28:24 +00:00
|
|
|
self->angle += angle;
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2009-09-14 23:28:24 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 23:50:21 +00:00
|
|
|
//===========================================================================
|
2009-10-15 08:25:07 +00:00
|
|
|
//
|
|
|
|
// A_Quake
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Quake)
|
|
|
|
{
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (intensity);
|
|
|
|
PARAM_INT (duration);
|
|
|
|
PARAM_INT (damrad);
|
|
|
|
PARAM_INT (tremrad);
|
|
|
|
PARAM_SOUND_OPT (sound) { sound = "world/quake"; }
|
|
|
|
|
2009-10-15 08:25:07 +00:00
|
|
|
P_StartQuake(self, 0, intensity, duration, damrad, tremrad, sound);
|
2010-02-17 04:46:11 +00:00
|
|
|
return 0;
|
2009-10-15 08:25:07 +00:00
|
|
|
}
|
|
|
|
|
2009-12-25 11:09:56 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_Weave
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdist)
|
|
|
|
{
|
|
|
|
fixed_t newX, newY;
|
|
|
|
int weaveXY, weaveZ;
|
|
|
|
int angle;
|
|
|
|
fixed_t dist;
|
|
|
|
|
|
|
|
weaveXY = self->WeaveIndexXY & 63;
|
|
|
|
weaveZ = self->WeaveIndexZ & 63;
|
|
|
|
angle = (self->angle + ANG90) >> ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
if (xydist != 0 && xyspeed != 0)
|
|
|
|
{
|
2012-07-11 02:50:13 +00:00
|
|
|
dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist);
|
2009-12-25 11:09:56 +00:00
|
|
|
newX = self->x - FixedMul (finecosine[angle], dist);
|
|
|
|
newY = self->y - FixedMul (finesine[angle], dist);
|
|
|
|
weaveXY = (weaveXY + xyspeed) & 63;
|
2012-07-11 02:50:13 +00:00
|
|
|
dist = MulScale13(finesine[weaveXY << BOBTOFINESHIFT], xydist);
|
2009-12-25 11:09:56 +00:00
|
|
|
newX += FixedMul (finecosine[angle], dist);
|
|
|
|
newY += FixedMul (finesine[angle], dist);
|
2012-04-01 11:15:16 +00:00
|
|
|
if (!(self->flags5 & MF5_NOINTERACTION))
|
|
|
|
{
|
|
|
|
P_TryMove (self, newX, newY, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->UnlinkFromWorld ();
|
|
|
|
self->flags |= MF_NOBLOCKMAP;
|
|
|
|
self->x = newX;
|
|
|
|
self->y = newY;
|
|
|
|
self->LinkToWorld ();
|
|
|
|
}
|
2009-12-25 11:09:56 +00:00
|
|
|
self->WeaveIndexXY = weaveXY;
|
|
|
|
}
|
|
|
|
if (zdist != 0 && zspeed != 0)
|
|
|
|
{
|
2012-07-11 02:50:13 +00:00
|
|
|
self->z -= MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist);
|
2009-12-25 11:09:56 +00:00
|
|
|
weaveZ = (weaveZ + zspeed) & 63;
|
2012-07-11 02:50:13 +00:00
|
|
|
self->z += MulScale13(finesine[weaveZ << BOBTOFINESHIFT], zdist);
|
2009-12-25 11:09:56 +00:00
|
|
|
self->WeaveIndexZ = weaveZ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Weave)
|
|
|
|
{
|
2010-02-17 04:46:11 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (xspeed);
|
|
|
|
PARAM_INT (yspeed);
|
|
|
|
PARAM_FIXED (xdist);
|
|
|
|
PARAM_FIXED (ydist);
|
2009-12-25 11:09:56 +00:00
|
|
|
A_Weave(self, xspeed, yspeed, xdist, ydist);
|
2010-02-17 04:46:11 +00:00
|
|
|
return 0;
|
2009-12-25 11:09:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-14 23:50:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// A_LineEffect
|
2009-09-14 23:28:24 +00:00
|
|
|
//
|
|
|
|
// This allows linedef effects to be activated inside deh frames.
|
|
|
|
//
|
2009-09-14 23:50:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
2009-09-14 23:28:24 +00:00
|
|
|
void P_TranslateLineDef (line_t *ld, maplinedef_t *mld);
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LineEffect)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT(special) { special = 0; }
|
|
|
|
PARAM_INT_OPT(tag) { tag = 0; }
|
2009-09-14 23:28:24 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
line_t junk;
|
|
|
|
maplinedef_t oldjunk;
|
2009-09-14 23:28:24 +00:00
|
|
|
bool res = false;
|
|
|
|
if (!(self->flags6 & MF6_LINEDONE)) // Unless already used up
|
|
|
|
{
|
|
|
|
if ((oldjunk.special = special)) // Linedef type
|
|
|
|
{
|
|
|
|
oldjunk.tag = tag; // Sector tag for linedef
|
|
|
|
P_TranslateLineDef(&junk, &oldjunk); // Turn into native type
|
2011-02-13 10:18:28 +00:00
|
|
|
res = !!P_ExecuteSpecial(junk.special, NULL, self, false, junk.args[0],
|
2009-09-14 23:28:24 +00:00
|
|
|
junk.args[1], junk.args[2], junk.args[3], junk.args[4]);
|
|
|
|
if (res && !(junk.flags & ML_REPEAT_SPECIAL)) // If only once,
|
|
|
|
self->flags6 |= MF6_LINEDONE; // no more for this thing
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2009-09-14 23:28:24 +00:00
|
|
|
}
|
2011-05-09 22:10:20 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A Wolf3D-style attack codepointer
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
enum WolfAttackFlags
|
|
|
|
{
|
|
|
|
WAF_NORANDOM = 1,
|
|
|
|
WAF_USEPUFF = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_SOUND_OPT (sound) { sound = "weapons/pistol"; }
|
|
|
|
PARAM_FIXED_OPT (snipe) { snipe = FRACUNIT; }
|
|
|
|
PARAM_INT_OPT (maxdamage) { maxdamage = 64; }
|
|
|
|
PARAM_INT_OPT (blocksize) { blocksize = 128; }
|
|
|
|
PARAM_INT_OPT (pointblank) { pointblank = 2; }
|
|
|
|
PARAM_INT_OPT (longrange) { longrange = 4; }
|
|
|
|
PARAM_FIXED_OPT (runspeed) { runspeed = 160*FRACUNIT; }
|
|
|
|
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor("BulletPuff"); }
|
2011-05-09 22:10:20 +00:00
|
|
|
|
|
|
|
if (!self->target)
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2011-05-09 22:10:20 +00:00
|
|
|
|
|
|
|
// Enemy can't see target
|
|
|
|
if (!P_CheckSight(self, self->target))
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2011-05-09 22:10:20 +00:00
|
|
|
|
|
|
|
A_FaceTarget (self);
|
|
|
|
|
|
|
|
// Target can dodge if it can see enemy
|
|
|
|
angle_t angle = R_PointToAngle2(self->target->x, self->target->y, self->x, self->y) - self->target->angle;
|
|
|
|
angle >>= 24;
|
|
|
|
bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30));
|
|
|
|
|
|
|
|
// Distance check is simplistic
|
|
|
|
fixed_t dx = abs (self->x - self->target->x);
|
|
|
|
fixed_t dy = abs (self->y - self->target->y);
|
|
|
|
fixed_t dz;
|
|
|
|
fixed_t dist = dx > dy ? dx : dy;
|
|
|
|
|
|
|
|
// Some enemies are more precise
|
|
|
|
dist = FixedMul(dist, snipe);
|
|
|
|
|
|
|
|
// Convert distance into integer number of blocks
|
|
|
|
dist >>= FRACBITS;
|
|
|
|
dist /= blocksize;
|
|
|
|
|
|
|
|
// Now for the speed accuracy thingie
|
|
|
|
fixed_t speed = FixedMul(self->target->velx, self->target->velx)
|
|
|
|
+ FixedMul(self->target->vely, self->target->vely)
|
|
|
|
+ FixedMul(self->target->velz, self->target->velz);
|
|
|
|
int hitchance = speed < runspeed ? 256 : 160;
|
|
|
|
|
|
|
|
// Distance accuracy (factoring dodge)
|
|
|
|
hitchance -= dist * (dodge ? 16 : 8);
|
|
|
|
|
|
|
|
// While we're here, we may as well do something for this:
|
|
|
|
if (self->target->flags & MF_SHADOW)
|
|
|
|
{
|
|
|
|
hitchance >>= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The attack itself
|
|
|
|
if (pr_cabullet() < hitchance)
|
|
|
|
{
|
|
|
|
// Compute position for spawning blood/puff
|
|
|
|
dx = self->target->x;
|
|
|
|
dy = self->target->y;
|
|
|
|
dz = self->target->z + (self->target->height>>1);
|
|
|
|
angle = R_PointToAngle2(dx, dy, self->x, self->y);
|
|
|
|
|
|
|
|
dx += FixedMul(self->target->radius, finecosine[angle>>ANGLETOFINESHIFT]);
|
|
|
|
dy += FixedMul(self->target->radius, finesine[angle>>ANGLETOFINESHIFT]);
|
|
|
|
|
|
|
|
int damage = flags & WAF_NORANDOM ? maxdamage : (1 + (pr_cabullet() % maxdamage));
|
|
|
|
if (dist >= pointblank)
|
|
|
|
damage >>= 1;
|
|
|
|
if (dist >= longrange)
|
|
|
|
damage >>= 1;
|
|
|
|
FName mod = NAME_None;
|
|
|
|
bool spawnblood = !((self->target->flags & MF_NOBLOOD)
|
|
|
|
|| (self->target->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)));
|
|
|
|
if (flags & WAF_USEPUFF && pufftype)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
AActor *dpuff = GetDefaultByType(pufftype->GetReplacement());
|
2011-05-09 22:10:20 +00:00
|
|
|
mod = dpuff->DamageType;
|
|
|
|
|
|
|
|
if (dpuff->flags2 & MF2_THRUGHOST && self->target->flags3 & MF3_GHOST)
|
|
|
|
damage = 0;
|
|
|
|
|
2011-09-14 23:24:32 +00:00
|
|
|
if ((0 && dpuff->flags3 & MF3_PUFFONACTORS) || !spawnblood)
|
2011-05-09 22:10:20 +00:00
|
|
|
{
|
|
|
|
spawnblood = false;
|
|
|
|
P_SpawnPuff(self, pufftype, dx, dy, dz, angle, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (self->target->flags3 & MF3_GHOST)
|
|
|
|
damage >>= 2;
|
|
|
|
if (damage)
|
|
|
|
{
|
2013-01-02 04:39:59 +00:00
|
|
|
int newdam = P_DamageMobj(self->target, self, self, damage, mod, DMG_THRUSTLESS);
|
2011-05-09 22:10:20 +00:00
|
|
|
if (spawnblood)
|
|
|
|
{
|
2013-01-02 04:39:59 +00:00
|
|
|
P_SpawnBlood(dx, dy, dz, angle, newdam > 0 ? newdam : damage, self->target);
|
|
|
|
P_TraceBleed(newdam > 0 ? newdam : damage, self->target, R_PointToAngle2(self->x, self->y, dx, dy), 0);
|
2011-05-09 22:10:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// And finally, let's play the sound
|
|
|
|
S_Sound (self, CHAN_WEAPON, sound, 1, ATTN_NORM);
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2011-05-09 22:10:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-14 22:45:42 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_Warp
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
enum WARPF
|
|
|
|
{
|
|
|
|
WARPF_ABSOLUTEOFFSET = 0x1,
|
|
|
|
WARPF_ABSOLUTEANGLE = 0x2,
|
|
|
|
WARPF_USECALLERANGLE = 0x4,
|
|
|
|
|
|
|
|
WARPF_NOCHECKPOSITION = 0x8,
|
|
|
|
|
|
|
|
WARPF_INTERPOLATE = 0x10,
|
|
|
|
WARPF_WARPINTERPOLATION = 0x20,
|
|
|
|
WARPF_COPYINTERPOLATION = 0x40,
|
|
|
|
|
|
|
|
WARPF_STOP = 0x80,
|
|
|
|
WARPF_TOFLOOR = 0x100,
|
|
|
|
WARPF_TESTONLY = 0x200
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT (destination_selector);
|
|
|
|
PARAM_FIXED_OPT (xofs) { xofs = 0; }
|
|
|
|
PARAM_FIXED_OPT (yofs) { yofs = 0; }
|
|
|
|
PARAM_FIXED_OPT (zofs) { zofs = 0; }
|
|
|
|
PARAM_ANGLE_OPT (angle) { angle = 0; }
|
|
|
|
PARAM_INT_OPT (flags) { flags = 0; }
|
|
|
|
PARAM_STATE_OPT (success_state) { success_state = NULL; }
|
2011-06-14 22:45:42 +00:00
|
|
|
|
|
|
|
fixed_t
|
|
|
|
|
|
|
|
oldx,
|
|
|
|
oldy,
|
|
|
|
oldz;
|
|
|
|
|
|
|
|
AActor *reference = COPY_AAPTR(self, destination_selector);
|
|
|
|
|
|
|
|
if (!reference)
|
|
|
|
{
|
|
|
|
ACTION_SET_RESULT(false);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2011-06-14 22:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & WARPF_ABSOLUTEANGLE))
|
|
|
|
{
|
|
|
|
angle += (flags & WARPF_USECALLERANGLE) ? self->angle : reference->angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & WARPF_ABSOLUTEOFFSET))
|
|
|
|
{
|
|
|
|
angle_t fineangle = angle>>ANGLETOFINESHIFT;
|
|
|
|
oldx = xofs;
|
|
|
|
|
|
|
|
// (borrowed from A_SpawnItemEx, assumed workable)
|
|
|
|
// in relative mode negative y values mean 'left' and positive ones mean 'right'
|
|
|
|
// This is the inverse orientation of the absolute mode!
|
|
|
|
|
|
|
|
xofs = FixedMul(oldx, finecosine[fineangle]) + FixedMul(yofs, finesine[fineangle]);
|
|
|
|
yofs = FixedMul(oldx, finesine[fineangle]) - FixedMul(yofs, finecosine[fineangle]);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldx = self->x;
|
|
|
|
oldy = self->y;
|
|
|
|
oldz = self->z;
|
|
|
|
|
|
|
|
if (flags & WARPF_TOFLOOR)
|
|
|
|
{
|
|
|
|
// set correct xy
|
|
|
|
|
|
|
|
self->SetOrigin(
|
|
|
|
reference->x + xofs,
|
|
|
|
reference->y + yofs,
|
|
|
|
reference->z);
|
|
|
|
|
|
|
|
// now the caller's floorz should be appropriate for the assigned xy-position
|
|
|
|
// assigning position again with
|
|
|
|
|
|
|
|
if (zofs)
|
|
|
|
{
|
|
|
|
// extra unlink, link and environment calculation
|
|
|
|
self->SetOrigin(
|
|
|
|
self->x,
|
|
|
|
self->y,
|
|
|
|
self->floorz + zofs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if there is no offset, there should be no ill effect from moving down to the
|
|
|
|
// already identified floor
|
|
|
|
|
|
|
|
// A_Teleport does the same thing anyway
|
|
|
|
self->z = self->floorz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->SetOrigin(
|
|
|
|
reference->x + xofs,
|
|
|
|
reference->y + yofs,
|
|
|
|
reference->z + zofs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((flags & WARPF_NOCHECKPOSITION) || P_TestMobjLocation(self))
|
|
|
|
{
|
|
|
|
if (flags & WARPF_TESTONLY)
|
|
|
|
{
|
|
|
|
self->SetOrigin(oldx, oldy, oldz);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->angle = angle;
|
|
|
|
|
|
|
|
if (flags & WARPF_STOP)
|
|
|
|
{
|
|
|
|
self->velx = 0;
|
|
|
|
self->vely = 0;
|
|
|
|
self->velz = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & WARPF_WARPINTERPOLATION)
|
|
|
|
{
|
|
|
|
self->PrevX += self->x - oldx;
|
|
|
|
self->PrevY += self->y - oldy;
|
|
|
|
self->PrevZ += self->z - oldz;
|
|
|
|
}
|
|
|
|
else if (flags & WARPF_COPYINTERPOLATION)
|
|
|
|
{
|
|
|
|
self->PrevX = self->x + reference->PrevX - reference->x;
|
|
|
|
self->PrevY = self->y + reference->PrevY - reference->y;
|
|
|
|
self->PrevZ = self->z + reference->PrevZ - reference->z;
|
|
|
|
}
|
|
|
|
else if (! (flags & WARPF_INTERPOLATE))
|
|
|
|
{
|
|
|
|
self->PrevX = self->x;
|
|
|
|
self->PrevY = self->y;
|
|
|
|
self->PrevZ = self->z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success_state)
|
|
|
|
{
|
|
|
|
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
|
|
|
|
// in this case, you have the statejump to help you handle all the success anyway.
|
|
|
|
ACTION_JUMP(success_state);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2011-06-14 22:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ACTION_SET_RESULT(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
self->SetOrigin(oldx, oldy, oldz);
|
|
|
|
ACTION_SET_RESULT(false);
|
|
|
|
}
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2011-06-14 22:45:42 +00:00
|
|
|
}
|
2012-02-16 21:49:09 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// ACS_Named* stuff
|
2012-07-15 23:00:16 +00:00
|
|
|
|
2012-02-16 21:49:09 +00:00
|
|
|
//
|
|
|
|
// These are exactly like their un-named line special equivalents, except
|
|
|
|
// they take strings instead of integers to indicate which script to run.
|
|
|
|
// Some of these probably aren't very useful, but they are included for
|
|
|
|
// the sake of completeness.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedExecuteWithResult)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (arg3) { arg3 = 0; }
|
|
|
|
PARAM_INT_OPT (arg4) { arg4 = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_ExecuteWithResult, NULL, self, false, -scriptname, arg1, arg2, arg3, arg4);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedExecute)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (mapnum) { mapnum = 0; }
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (arg3) { arg3 = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_Execute, NULL, self, false, -scriptname, mapnum, arg1, arg2, arg3);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedExecuteAlways)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (mapnum) { mapnum = 0; }
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (arg3) { arg3 = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_ExecuteAlways, NULL, self, false, -scriptname, mapnum, arg1, arg2, arg3);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedLockedExecute)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (mapnum) { mapnum = 0; }
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (lock) { lock = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_LockedExecute, NULL, self, false, -scriptname, mapnum, arg1, arg2, lock);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedLockedExecuteDoor)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (mapnum) { mapnum = 0; }
|
|
|
|
PARAM_INT_OPT (arg1) { arg1 = 0; }
|
|
|
|
PARAM_INT_OPT (arg2) { arg2 = 0; }
|
|
|
|
PARAM_INT_OPT (lock) { lock = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_LockedExecuteDoor, NULL, self, false, -scriptname, mapnum, arg1, arg2, lock);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedSuspend)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (mapnum) { mapnum = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_Suspend, NULL, self, false, -scriptname, mapnum, 0, 0, 0);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ACS_NamedTerminate)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME (scriptname);
|
|
|
|
PARAM_INT_OPT (mapnum) { mapnum = 0; }
|
2012-02-16 21:49:09 +00:00
|
|
|
|
2012-07-17 05:31:41 +00:00
|
|
|
int res = P_ExecuteSpecial(ACS_Terminate, NULL, self, false, -scriptname, mapnum, 0, 0, 0);
|
2012-02-16 21:49:09 +00:00
|
|
|
ACTION_SET_RESULT(res);
|
2012-07-17 05:31:41 +00:00
|
|
|
return numret;
|
2012-02-16 21:49:09 +00:00
|
|
|
}
|
2012-03-30 04:28:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_RadiusGive
|
|
|
|
//
|
|
|
|
// Uses code roughly similar to A_Explode (but without all the compatibility
|
|
|
|
// baggage and damage computation code to give an item to all eligible mobjs
|
|
|
|
// in range.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
enum RadiusGiveFlags
|
|
|
|
{
|
|
|
|
RGF_GIVESELF = 1,
|
|
|
|
RGF_PLAYERS = 2,
|
|
|
|
RGF_MONSTERS = 4,
|
|
|
|
RGF_OBJECTS = 8,
|
|
|
|
RGF_VOODOO = 16,
|
|
|
|
RGF_CORPSES = 32,
|
|
|
|
RGF_MASK = 63,
|
|
|
|
RGF_NOTARGET = 64,
|
|
|
|
RGF_NOTRACER = 128,
|
|
|
|
RGF_NOMASTER = 256,
|
|
|
|
RGF_CUBE = 512,
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusGive)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS (item, AInventory);
|
|
|
|
PARAM_FIXED (distance);
|
|
|
|
PARAM_INT (flags);
|
|
|
|
PARAM_INT_OPT (amount) { amount = 0; }
|
2012-03-30 04:28:10 +00:00
|
|
|
|
|
|
|
// We need a valid item, valid targets, and a valid range
|
|
|
|
if (item == NULL || (flags & RGF_MASK) == 0 || distance <= 0)
|
|
|
|
{
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2012-03-30 04:28:10 +00:00
|
|
|
}
|
|
|
|
if (amount == 0)
|
|
|
|
{
|
|
|
|
amount = 1;
|
|
|
|
}
|
|
|
|
FBlockThingsIterator it(FBoundingBox(self->x, self->y, distance));
|
|
|
|
double distsquared = double(distance) * double(distance);
|
|
|
|
|
|
|
|
AActor *thing;
|
|
|
|
while ((thing = it.Next()))
|
|
|
|
{
|
|
|
|
// Don't give to inventory items
|
|
|
|
if (thing->flags & MF_SPECIAL)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Avoid giving to self unless requested
|
|
|
|
if (thing == self && !(flags & RGF_GIVESELF))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Avoiding special pointers if requested
|
|
|
|
if (((thing == self->target) && (flags & RGF_NOTARGET)) ||
|
|
|
|
((thing == self->tracer) && (flags & RGF_NOTRACER)) ||
|
|
|
|
((thing == self->master) && (flags & RGF_NOMASTER)))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Don't give to dead thing unless requested
|
|
|
|
if (thing->flags & MF_CORPSE)
|
|
|
|
{
|
|
|
|
if (!(flags & RGF_CORPSES))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (thing->health <= 0 || thing->flags6 & MF6_KILLED)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Players, monsters, and other shootable objects
|
|
|
|
if (thing->player)
|
|
|
|
{
|
|
|
|
if ((thing->player->mo == thing) && !(flags & RGF_PLAYERS))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((thing->player->mo != thing) && !(flags & RGF_VOODOO))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (thing->flags3 & MF3_ISMONSTER)
|
|
|
|
{
|
|
|
|
if (!(flags & RGF_MONSTERS))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (thing->flags & MF_SHOOTABLE || thing->flags6 & MF6_VULNERABLE)
|
|
|
|
{
|
|
|
|
if (!(flags & RGF_OBJECTS))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & RGF_CUBE)
|
|
|
|
{ // check if inside a cube
|
|
|
|
if (abs(thing->x - self->x) > distance ||
|
|
|
|
abs(thing->y - self->y) > distance ||
|
|
|
|
abs((thing->z + thing->height/2) - (self->z + self->height/2)) > distance)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // check if inside a sphere
|
|
|
|
TVector3<double> tpos(thing->x, thing->y, thing->z + thing->height/2);
|
|
|
|
TVector3<double> spos(self->x, self->y, self->z + self->height/2);
|
|
|
|
if ((tpos - spos).LengthSquared() > distsquared)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fixed_t dz = abs ((thing->z + thing->height/2) - (self->z + self->height/2));
|
|
|
|
|
|
|
|
if (P_CheckSight (thing, self, SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY))
|
|
|
|
{ // OK to give; target is in direct path
|
|
|
|
AInventory *gift = static_cast<AInventory *>(Spawn (item, 0, 0, 0, NO_REPLACE));
|
|
|
|
if (gift->IsKindOf(RUNTIME_CLASS(AHealth)))
|
|
|
|
{
|
|
|
|
gift->Amount *= amount;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gift->Amount = amount;
|
|
|
|
}
|
|
|
|
gift->flags |= MF_DROPPED;
|
|
|
|
gift->ClearCounters();
|
|
|
|
if (!gift->CallTryPickup (thing))
|
|
|
|
{
|
|
|
|
gift->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-14 03:04:41 +00:00
|
|
|
return 0;
|
2012-03-30 04:28:10 +00:00
|
|
|
}
|
|
|
|
|
2012-08-24 21:02:49 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_SetTics
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics)
|
|
|
|
{
|
2012-10-17 04:24:54 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_INT(tics_to_set);
|
2012-08-24 21:02:49 +00:00
|
|
|
|
|
|
|
self->tics = tics_to_set;
|
2012-10-17 04:24:54 +00:00
|
|
|
return 0;
|
2013-03-13 04:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_SetDamageType
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetDamageType)
|
|
|
|
{
|
2013-06-07 03:31:30 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_NAME(damagetype);
|
2013-03-13 04:04:48 +00:00
|
|
|
|
|
|
|
self->DamageType = damagetype;
|
2013-06-07 03:31:30 +00:00
|
|
|
return 0;
|
2013-03-13 04:04:48 +00:00
|
|
|
}
|