Merge commit 'ec5817869592660af6837b9f4e20ed140972a2b2' into scripting

Conflicts:
	src/p_enemy.cpp
	src/p_enemy.h
	wadsrc/static/actors/constants.txt

(Scripting branch update part 1)
This commit is contained in:
Christoph Oelckers 2015-04-28 09:34:51 +02:00
commit 56989d3422
19 changed files with 170 additions and 58 deletions

View File

@ -694,7 +694,7 @@ void C_DoCommand (const char *cmd, int keynum)
}
else
{
Printf ("Unknown command \"%.*s\"\n", len, beg);
Printf ("Unknown command \"%.*s\"\n", (int)len, beg);
}
}
}

View File

@ -2509,6 +2509,12 @@ static bool DoDehPatch()
Printf (PRINT_BOLD, "\"%s\" is an old and unsupported DeHackEd patch\n", PatchFile);
return false;
}
// fix for broken WolfenDoom patches which contain \0 characters in some places.
for (int i = 0; i < PatchSize; i++)
{
if (PatchFile[i] == 0) PatchFile[i] = ' ';
}
PatchPt = strchr (PatchFile, '\n');
while ((cont = GetLine()) == 1)
{

View File

@ -951,7 +951,7 @@ void NetUpdate (void)
newtics = nowtime - gametime;
gametime = nowtime;
if (newtics <= 0 || pauseext) // nothing new to update or window paused
if (newtics <= 0) // nothing new to update
{
GetPackets ();
return;
@ -1810,6 +1810,7 @@ void TryRunTics (void)
// If paused, do not eat more CPU time than we need, because it
// will all be wasted anyway.
if (pauseext) r_NoInterpolate = true;
bool doWait = cl_capfps || r_NoInterpolate /*|| netgame*/;
// get real tics
@ -1934,7 +1935,7 @@ void TryRunTics (void)
C_Ticker ();
M_Ticker ();
I_GetTime (true);
G_Ticker ();
if (!pauseext) G_Ticker();
gametic++;
NetUpdate (); // check for new console commands

View File

@ -301,14 +301,14 @@ void APathFollower::Tick ()
bJustStepped = false;
if (CurrNode->args[2])
{
HoldTime = gametic + CurrNode->args[2] * TICRATE / 8;
HoldTime = level.time + CurrNode->args[2] * TICRATE / 8;
x = CurrNode->x;
y = CurrNode->y;
z = CurrNode->z;
}
}
if (HoldTime > gametic)
if (HoldTime > level.time)
return;
// Splines must have a previous node.

View File

@ -1418,6 +1418,8 @@ bool AInventory::TryPickupRestricted (AActor *&toucher)
bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
{
TObjPtr<AInventory> Invstack = Inventory; // A pointer of the inventories item stack.
// unmorphed versions of a currently morphed actor cannot pick up anything.
if (toucher->flags & MF_UNMORPHED) return false;
@ -1438,7 +1440,27 @@ bool AInventory::CallTryPickup (AActor *toucher, AActor **toucher_return)
GoAwayAndDie();
}
if (res) GiveQuest(toucher);
if (res)
{
GiveQuest(toucher);
// Transfer all inventory accross that the old object had, if requested.
if ((ItemFlags & IF_TRANSFER))
{
while (Invstack)
{
AInventory* titem = Invstack;
Invstack = titem->Inventory;
if (titem->Owner == this)
{
if (!titem->CallTryPickup(toucher)) // The object no longer can exist
{
titem->Destroy();
}
}
}
}
}
return res;
}

View File

@ -127,7 +127,7 @@ enum
IF_NOSCREENFLASH = 1<<21, // No pickup flash on the player's screen
IF_TOSSED = 1<<22, // Was spawned by P_DropItem (i.e. as a monster drop)
IF_ALWAYSRESPAWN = 1<<23, // Always respawn, regardless of dmflag
IF_TRANSFER = 1<<24, // All inventory items that the inventory item contains is also transfered to the pickuper
};

View File

@ -196,9 +196,9 @@ bool DOptionMenu::MenuEvent (int mkey, bool fromcontroller)
--mDesc->mSelectedItem;
if (mDesc->mScrollPos > 0 &&
mDesc->mSelectedItem == mDesc->mScrollTop + mDesc->mScrollPos)
mDesc->mSelectedItem <= mDesc->mScrollTop + mDesc->mScrollPos)
{
mDesc->mScrollPos--;
mDesc->mScrollPos = MAX(mDesc->mSelectedItem - mDesc->mScrollTop - 1, 0);
}
if (mDesc->mSelectedItem < 0)

View File

@ -2742,7 +2742,14 @@ void A_Chase(VMFrameStack *stack, AActor *self)
// A_FaceTracer
//
//=============================================================================
void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch)
enum FAF_Flags
{
FAF_BOTTOM = 1,
FAF_MIDDLE = 2,
FAF_TOP = 4,
FAF_NODISTFACTOR = 8,
};
void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags)
{
if (!other)
return;
@ -2765,28 +2772,28 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch)
{
if (self->angle - other_angle < ANGLE_180)
{
self->angle -= max_turn;
self->angle -= max_turn + ang_offset;
}
else
{
self->angle += max_turn;
self->angle += max_turn + ang_offset;
}
}
else
{
if (other_angle - self->angle < ANGLE_180)
{
self->angle += max_turn;
self->angle += max_turn + ang_offset;
}
else
{
self->angle -= max_turn;
self->angle -= max_turn + ang_offset;
}
}
}
else
{
self->angle = other_angle;
self->angle = other_angle + ang_offset;
}
// [DH] Now set pitch. In order to maintain compatibility, this can be
@ -2797,18 +2804,31 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch)
// result is only used in a ratio.
double dist_x = other->x - self->x;
double dist_y = other->y - self->y;
// Positioning ala missile spawning, 32 units above foot level
fixed_t source_z = self->z + 32*FRACUNIT + self->GetBobOffset();
fixed_t target_z = other->z + 32*FRACUNIT + other->GetBobOffset();
// If the target z is above the target's head, reposition to the middle of
// its body.
if (target_z >= other->z + other->height)
{
target_z = other->z + other->height / 2;
target_z = other->z + (other->height / 2);
}
//Note there is no +32*FRACUNIT on purpose. This is for customization sake.
//If one doesn't want this behavior, just don't use FAF_BOTTOM.
if (flags & FAF_BOTTOM)
target_z = other->z + other->GetBobOffset();
if (flags & FAF_MIDDLE)
target_z = other->z + (other->height / 2) + other->GetBobOffset();
if (flags & FAF_TOP)
target_z = other->z + (other->height) + other->GetBobOffset();
if (!flags & FAF_NODISTFACTOR)
target_z += pitch_offset;
double dist_z = target_z - source_z;
double dist = sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z);
int other_pitch = (int)rad2bam(asin(dist_z / dist));
if (max_pitch != 0)
@ -2828,8 +2848,12 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch)
{
self->pitch = other_pitch;
}
if (flags & FAF_NODISTFACTOR)
self->pitch += pitch_offset;
}
// This will never work well if the turn angle is limited.
if (max_turn == 0 && (self->angle == other_angle) && other->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE) )
{
@ -2837,19 +2861,19 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch)
}
}
void A_FaceTarget (AActor *self, angle_t max_turn, angle_t max_pitch)
void A_FaceTarget(AActor *self, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags)
{
A_Face(self, self->target, max_turn, max_pitch);
A_Face(self, self->target, max_turn, max_pitch, ang_offset, pitch_offset, flags);
}
void A_FaceMaster (AActor *self, angle_t max_turn, angle_t max_pitch)
void A_FaceMaster(AActor *self, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags)
{
A_Face(self, self->master, max_turn, max_pitch);
A_Face(self, self->master, max_turn, max_pitch, ang_offset, pitch_offset, flags);
}
void A_FaceTracer (AActor *self, angle_t max_turn, angle_t max_pitch)
void A_FaceTracer(AActor *self, angle_t max_turn, angle_t max_pitch, angle_t ang_offset, angle_t pitch_offset, int flags)
{
A_Face(self, self->tracer, max_turn, max_pitch);
A_Face(self, self->tracer, max_turn, max_pitch, ang_offset, pitch_offset, flags);
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget)
@ -2857,8 +2881,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTarget)
PARAM_ACTION_PROLOGUE;
PARAM_ANGLE_OPT(max_turn) { max_turn = 0; }
PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; }
PARAM_ANGLE_OPT(ang_offset) { max_turn = 0; }
PARAM_ANGLE_OPT(pitch_offset) { max_turn = 0; }
PARAM_INT_OPT(flags) { max_turn = 0; }
A_FaceTarget(self, max_turn, max_pitch);
A_FaceTarget(self, max_turn, max_pitch, ang_offset, pitch_offset, flags);
return 0;
}
@ -2867,8 +2894,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMaster)
PARAM_ACTION_PROLOGUE;
PARAM_ANGLE_OPT(max_turn) { max_turn = 0; }
PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; }
PARAM_ANGLE_OPT(ang_offset) { max_turn = 0; }
PARAM_ANGLE_OPT(pitch_offset) { max_turn = 0; }
PARAM_INT_OPT(flags) { max_turn = 0; }
A_FaceMaster(self, max_turn, max_pitch);
A_FaceMaster(self, max_turn, max_pitch, ang_offset, pitch_offset, flags);
return 0;
}
@ -2877,8 +2907,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceTracer)
PARAM_ACTION_PROLOGUE;
PARAM_ANGLE_OPT(max_turn) { max_turn = 0; }
PARAM_ANGLE_OPT(max_pitch) { max_pitch = 270; }
PARAM_ANGLE_OPT(ang_offset) { max_turn = 0; }
PARAM_ANGLE_OPT(pitch_offset) { max_turn = 0; }
PARAM_INT_OPT(flags) { max_turn = 0; }
A_FaceTracer(self, max_turn, max_pitch);
A_FaceTracer(self, max_turn, max_pitch, ang_offset, pitch_offset, flags);
return 0;
}

View File

@ -72,8 +72,8 @@ DECLARE_ACTION(A_FreezeDeathChunks)
void A_BossDeath(AActor *self);
void A_Chase(VMFrameStack *stack, AActor *self);
void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270);
void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270);
void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0);
void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0);
bool A_RaiseMobj (AActor *, fixed_t speed);
bool A_SinkMobj (AActor *, fixed_t speed);

View File

@ -681,6 +681,7 @@ void AActor::RemoveInventory (AInventory *item)
*invp = item->Inventory;
item->DetachFromOwner ();
item->Owner = NULL;
item->Inventory = NULL;
break;
}
}
@ -2063,8 +2064,6 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
// Don't change the angle if there's THRUREFLECT on the monster.
if (!(BlockingMobj->flags7 & MF7_THRUREFLECT))
{
//int dir;
//angle_t delta;
angle = R_PointToAngle2(BlockingMobj->x, BlockingMobj->y, mo->x, mo->y);
bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle));
// Change angle for deflection/reflection
@ -2091,7 +2090,15 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
}
else
{
if (BlockingMobj->flags7 & MF7_MIRRORREFLECT && (tg || blockingtg))
{
mo->angle += ANGLE_180;
mo->velx = -mo->velx / 2;
mo->vely = -mo->vely / 2;
mo->velz = -mo->velz / 2;
}
else
{
mo->angle = angle;
angle >>= ANGLETOFINESHIFT;
mo->velx = FixedMul(mo->Speed >> 1, finecosine[angle]);
@ -2099,6 +2106,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
mo->velz = -mo->velz / 2;
}
}
}
else
{
goto explode;
@ -3040,11 +3048,8 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle)
{
if (flags2 & MF2_DONTREFLECT) return true;
if (thing->flags7 & MF7_THRUREFLECT) return false;
if (thing->flags7 & MF7_MIRRORREFLECT)
angle += ANGLE_180;
// Change angle for reflection
else if (thing->flags4&MF4_SHIELDREFLECT)
if (thing->flags4&MF4_SHIELDREFLECT)
{
// Shield reflection (from the Centaur
if (abs (angle - thing->angle)>>24 > 45)
@ -3067,15 +3072,23 @@ bool AActor::AdjustReflectionAngle (AActor *thing, angle_t &angle)
else
angle -= ANG45;
}
else if (thing->flags7 & MF7_AIMREFLECT)
else
{
angle += ANGLE_1 * ((pr_reflect() % 16) - 8);
}
//Always check for AIMREFLECT, no matter what else is checked above.
if (thing->flags7 & MF7_AIMREFLECT)
{
if (this->target != NULL)
{
A_Face(this, this->target);
}
else if (thing->target != NULL)
{
A_Face(this, thing->target);
}
else
angle += ANGLE_1 * ((pr_reflect()%16)-8);
}
return false;
}

View File

@ -676,7 +676,7 @@ void DPolyDoor::Tick ()
break;
case PODOOR_SWING:
if (poly->RotatePolyobj (m_Speed))
if (m_Dist <= 0 || poly->RotatePolyobj (m_Speed))
{
absSpeed = abs (m_Speed);
if (m_Dist == -1)

View File

@ -66,10 +66,20 @@ void I_ShutdownGraphics ()
}
if (Video)
delete Video, Video = NULL;
SDL_QuitSubSystem (SDL_INIT_VIDEO);
}
void I_InitGraphics ()
{
if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0)
{
I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError());
return;
}
Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver());
UCVarValue val;
val.Bool = !!Args->CheckParm ("-devparm");

View File

@ -1,4 +1,4 @@
#include <SDL_joystick.h>
#include <SDL.h>
#include "doomdef.h"
#include "templates.h"
@ -266,11 +266,16 @@ static SDLInputJoystickManager *JoystickManager;
void I_StartupJoysticks()
{
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0)
JoystickManager = new SDLInputJoystickManager();
}
void I_ShutdownJoysticks()
{
if(JoystickManager)
{
delete JoystickManager;
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
}
}
void I_GetJoysticks(TArray<IJoystickConfig *> &sticks)

View File

@ -265,14 +265,13 @@ int main (int argc, char **argv)
setlocale (LC_ALL, "C");
if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1)
if (SDL_Init (0) < 0)
{
fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError());
return -1;
}
atterm (SDL_Quit);
printf("Using video driver %s\n", SDL_GetCurrentVideoDriver());
printf("\n");
try

View File

@ -195,6 +195,9 @@ fixed_t I_GetTimeFrac (uint32 *ms)
void I_InitTimer ()
{
if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0)
I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError());
I_GetTime = I_GetTimeSelect;
I_WaitForTic = I_WaitForTicSelect;
I_FreezeTime = I_FreezeTimeSelect;
@ -202,5 +205,5 @@ void I_InitTimer ()
void I_ShutdownTimer ()
{
SDL_QuitSubSystem(SDL_INIT_TIMER);
}

View File

@ -581,9 +581,18 @@ void FWadFile::SkinHack ()
namespc++;
}
}
if (lump->Name[0] == 'M' &&
if ((lump->Name[0] == 'M' &&
lump->Name[1] == 'A' &&
lump->Name[2] == 'P')
lump->Name[2] == 'P' &&
lump->Name[3] >= '0' && lump->Name[3] <= '9' &&
lump->Name[4] >= '0' && lump->Name[4] <= '9' &&
lump->Name[5] >= '\0')
||
(lump->Name[0] == 'E' &&
lump->Name[1] >= '0' && lump->Name[1] <= '9' &&
lump->Name[2] == 'M' &&
lump->Name[3] >= '0' && lump->Name[3] <= '9' &&
lump->Name[4] >= '\0'))
{
hasmap = true;
}

View File

@ -323,6 +323,7 @@ static FFlagDef InventoryFlags[] =
DEFINE_FLAG(IF, NOSCREENFLASH, AInventory, ItemFlags),
DEFINE_FLAG(IF, TOSSED, AInventory, ItemFlags),
DEFINE_FLAG(IF, ALWAYSRESPAWN, AInventory, ItemFlags),
DEFINE_FLAG(IF, TRANSFER, AInventory, ItemFlags),
DEFINE_DEPRECATED_FLAG(PICKUPFLASH),
DEFINE_DEPRECATED_FLAG(INTERHUBSTRIP),};

View File

@ -50,9 +50,9 @@ ACTOR Actor native //: Thinker
action native A_XScream();
action native A_Look();
action native A_Chase(state melee = "*", state missile = "none", int flags = 0);
action native A_FaceTarget(float max_turn = 0, float max_pitch = 270);
action native A_FaceTracer(float max_turn = 0, float max_pitch = 270);
action native A_FaceMaster(float max_turn = 0, float max_pitch = 270);
action native A_FaceTarget(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0);
action native A_FaceTracer(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0);
action native A_FaceMaster(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0);
action native A_PosAttack();
action native A_Scream();
action native A_SPosAttack();

View File

@ -446,3 +446,13 @@ enum
FTF_REMOVE = 1 << 0,
FTF_CLAMP = 1 << 1,
};
// Flags for A_Face*
enum
{
FAF_BOTTOM = 1,
FAF_MIDDLE = 2,
FAF_TOP = 4,
FAF_NODISTFACTOR = 8,
};