mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
Add PickActor ACS function.
This commit is contained in:
parent
16a380f82a
commit
313b229319
3 changed files with 80 additions and 0 deletions
|
@ -4368,6 +4368,7 @@ enum EACSFunctions
|
|||
ACSF_ChangeActorPitch, // 80
|
||||
ACSF_GetArmorInfo,
|
||||
ACSF_DropInventory,
|
||||
ACSF_PickActor,
|
||||
|
||||
/* Zandronum's - these must be skipped when we reach 99!
|
||||
-100:ResetMap(0),
|
||||
|
@ -5593,6 +5594,38 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
}
|
||||
break;
|
||||
|
||||
case ACSF_PickActor:
|
||||
if (argCount >= 5)
|
||||
{
|
||||
actor = SingleActorFromTID(args[0], activator);
|
||||
if (actor == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD actorMask = MF_SHOOTABLE;
|
||||
if (argCount >= 6) {
|
||||
actorMask = args[5];
|
||||
}
|
||||
|
||||
DWORD wallMask = ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN;
|
||||
if (argCount >= 7) {
|
||||
wallMask = args[6];
|
||||
}
|
||||
|
||||
AActor* pickedActor = P_LinePickActor(actor, args[1] << 16, args[3], args[2] << 16, actorMask, wallMask);
|
||||
if (pickedActor == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pickedActor->RemoveFromHash();
|
||||
pickedActor->tid = args[4];
|
||||
pickedActor->AddToHash();
|
||||
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -462,6 +462,7 @@ enum // P_LineAttack flags
|
|||
|
||||
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, const PClass *pufftype, int flags = 0, AActor **victim = NULL, int *actualdamage = NULL);
|
||||
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, int flags = 0, AActor **victim = NULL, int *actualdamage = NULL);
|
||||
AActor *P_LinePickActor (AActor *t1, angle_t angle, fixed_t distance, int pitch, DWORD actorMask, DWORD wallMask);
|
||||
void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch);
|
||||
void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch);
|
||||
void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version
|
||||
|
|
|
@ -3783,6 +3783,52 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// P_LinePickActor
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch,
|
||||
DWORD actorMask, DWORD wallMask)
|
||||
{
|
||||
fixed_t vx, vy, vz, shootz;
|
||||
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT;
|
||||
|
||||
vx = FixedMul(finecosine[pitch], finecosine[angle]);
|
||||
vy = FixedMul(finecosine[pitch], finesine[angle]);
|
||||
vz = -finesine[pitch];
|
||||
|
||||
shootz = t1->z - t1->floorclip + (t1->height >> 1);
|
||||
if (t1->player != NULL)
|
||||
{
|
||||
shootz += FixedMul(t1->player->mo->AttackZOffset, t1->player->crouchfactor);
|
||||
}
|
||||
else
|
||||
{
|
||||
shootz += 8 * FRACUNIT;
|
||||
}
|
||||
|
||||
FTraceResults trace;
|
||||
Origin TData;
|
||||
|
||||
TData.Caller = t1;
|
||||
TData.hitGhosts = true;
|
||||
|
||||
if (Trace(t1->x, t1->y, shootz, t1->Sector, vx, vy, vz, distance,
|
||||
actorMask, wallMask, t1, trace, TRACE_NoSky, CheckForActor, &TData))
|
||||
{
|
||||
if (trace.HitType == TRACE_HitActor)
|
||||
{
|
||||
return trace.Actor;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue