From 33249ff833675d2527197ebcea23d7080c64c8b4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Jul 2009 05:56:20 +0000 Subject: [PATCH] - Added Gez's CheckActorProperty submission. SVN r1709 (trunk) --- docs/rh-log.txt | 5 ++++- src/p_acs.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ src/p_acs.h | 1 + 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 47c9a4991e..a4b040074f 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ -July 4, 2009 (Changes by Graf Zahl) +July 5, 2009 (Changes by Graf Zahl) +- Added Gez's CheckActorProperty submission. + +July 4, 2009 (Changes by Graf Zahl) - Added code submissions for non-piercing railguns and new skill options. July 3, 2009 diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 0109036aad..b60db3152c 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2409,6 +2409,7 @@ enum APROP_SpawnHealth = 17, APROP_Dropped = 18, APROP_Notarget = 19, + APROP_Species = 20, }; // These are needed for ACS's APROP_RenderStyle @@ -2557,6 +2558,10 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) case APROP_ActiveSound: actor->ActiveSound = FBehavior::StaticLookupString(value); break; + + case APROP_Species: + actor->Species = FBehavior::StaticLookupString(value); + break; } } @@ -2625,6 +2630,53 @@ int DLevelScript::GetActorProperty (int tid, int property) } } + + +int DLevelScript::CheckActorProperty (int tid, int property, int value) +{ + AActor *actor = SingleActorFromTID (tid, activator); + const char *string = NULL; + if (actor == NULL) + { + return 0; + } + switch (property) + { + // Default + default: return 0; + + // Straightforward integer values: + case APROP_Health: + case APROP_Speed: + case APROP_Damage: + case APROP_Alpha: + case APROP_RenderStyle: + case APROP_Gravity: + case APROP_SpawnHealth: + case APROP_JumpZ: + return (GetActorProperty(tid, property) == value); + + // Boolean values need to compare to a binary version of value + case APROP_Ambush: + case APROP_Dropped: + case APROP_ChaseGoal: + case APROP_Frightened: + case APROP_Friendly: + case APROP_Notarget: + return (GetActorProperty(tid, property) == (!!value)); + + // Strings are not covered by GetActorProperty, so make the check here + case APROP_SeeSound: string = actor->SeeSound; break; + case APROP_AttackSound: string = actor->AttackSound; break; + case APROP_PainSound: string = actor->PainSound; break; + case APROP_DeathSound: string = actor->DeathSound; break; + case APROP_ActiveSound: string = actor->ActiveSound; break; + case APROP_Species: string = actor->GetSpecies(); break; + } + if (string == NULL) string = ""; + return (!stricmp(string, FBehavior::StaticLookupString(value))); +} + enum { // These are the original inputs sent by the player. @@ -2804,6 +2856,7 @@ enum EACSFunctions ACSF_GetArmorType, ACSF_SpawnSpotForced, ACSF_SpawnSpotFacingForced, + ACSF_CheckActorProperty, }; int DLevelScript::SideFromID(int id, int side) @@ -2968,6 +3021,9 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) case ACSF_SpawnSpotFacingForced: return DoSpawnSpotFacing(args[0], args[1], args[2], true); + case ACSF_CheckActorProperty: + return (CheckActorProperty(args[0], args[1], args[2])); + default: break; } diff --git a/src/p_acs.h b/src/p_acs.h index 824777972a..7e4777a46f 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -725,6 +725,7 @@ protected: void SetActorProperty (int tid, int property, int value); void DoSetActorProperty (AActor *actor, int property, int value); int GetActorProperty (int tid, int property); + int CheckActorProperty (int tid, int property, int value); int GetPlayerInput (int playernum, int inputnum); int LineFromID(int id);