- Added PinkSilver's SetActorVelocity code submission (with optimizations.)

SVN r1799 (trunk)
This commit is contained in:
Christoph Oelckers 2009-09-06 08:27:18 +00:00
parent e8d1416d81
commit 93f6f1d701
4 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,6 @@
September 6, 2009 (Changes by Graf Zahl)
- Added PinkSilver's SetActorVelocity code submission (with optimizations.)
September 5, 2009
- Added the frandom decorate function, which is exactly like random except
that it works with floating point instead of integers.

View File

@ -2873,6 +2873,7 @@ enum EACSFunctions
ACSF_SpawnSpotForced,
ACSF_SpawnSpotFacingForced,
ACSF_CheckActorProperty,
ACSF_SetActorVelocity,
};
int DLevelScript::SideFromID(int id, int side)
@ -3055,6 +3056,22 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
case ACSF_CheckActorProperty:
return (CheckActorProperty(args[0], args[1], args[2]));
case ACSF_SetActorVelocity:
if (args[0] == 0)
{
P_Thing_SetVelocity(activator, args[1], args[2], args[3], !!args[4]);
}
else
{
TActorIterator<AActor> iterator (args[0]);
while ( (actor = iterator.Next ()) )
{
P_Thing_SetVelocity(actor, args[1], args[2], args[3], !!args[4]);
}
}
return 0;
default:
break;
}

View File

@ -139,6 +139,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_na
bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog);
bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog);
int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type);
void P_Thing_SetVelocity(AActor *actor, fixed_t vx, fixed_t vy, fixed_t vz, bool add);
void P_RemoveThing(AActor * actor);
bool P_Thing_Raise(AActor *thing);

View File

@ -478,6 +478,26 @@ bool P_Thing_Raise(AActor *thing)
return true;
}
void P_Thing_SetVelocity(AActor *actor, fixed_t vx, fixed_t vy, fixed_t vz, bool add)
{
if (actor != NULL)
{
if (!add)
{
actor->velx = actor->vely = actor->velz = 0;
if (actor->player != NULL) actor->player->velx = actor->player->vely = 0;
}
actor->velx += vx;
actor->vely += vy;
actor->velz += vz;
if (actor->player != NULL)
{
actor->player->velx += vx;
actor->player->vely += vy;
}
}
}
CCMD (dumpspawnables)
{