diff --git a/docs/rh-log.txt b/docs/rh-log.txt index cfa6a827a..49f07a82d 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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. diff --git a/src/p_acs.cpp b/src/p_acs.cpp index ac3bfff10..9cb2afe92 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2873,6 +2873,7 @@ enum EACSFunctions ACSF_SpawnSpotForced, ACSF_SpawnSpotFacingForced, ACSF_CheckActorProperty, + ACSF_SetActorVelocity, }; int DLevelScript::SideFromID(int id, int side) @@ -3054,6 +3055,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 iterator (args[0]); + + while ( (actor = iterator.Next ()) ) + { + P_Thing_SetVelocity(actor, args[1], args[2], args[3], !!args[4]); + } + } + return 0; default: break; diff --git a/src/p_local.h b/src/p_local.h index 75f0c2bff..e2d628e58 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -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); diff --git a/src/p_things.cpp b/src/p_things.cpp index 2d5ebd558..d09cba9ec 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -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) {