Added support for Dark Messiah engine and game. (no bug, r=me).

The development of this feature would not be possible without the support of the following people from the game's community:
Dylan Riggs, Carl Pettengill, Ed Moreland, and Christian.
This commit is contained in:
Scott Ehlert
2009-02-18 02:19:22 -06:00
parent 15d64b8486
commit bd9fab6cf5
36 changed files with 1523 additions and 74 deletions
+11 -1
View File
@@ -53,9 +53,13 @@ new Handle:g_Cvar_Chatmode = INVALID_HANDLE;
new bool:g_DoColor = true;
new g_GameEngine = SOURCE_SDK_UNKNOWN;
public OnPluginStart()
{
LoadTranslations("common.phrases");
g_GameEngine = GuessSDKVersion();
g_Cvar_Chatmode = CreateConVar("sm_chat_mode", "1", "Allows player's to send messages to admin chat.", 0, true, 0.0, true, 1.0);
@@ -63,7 +67,13 @@ public OnPluginStart()
RegConsoleCmd("say_team", Command_SayAdmin);
RegAdminCmd("sm_say", Command_SmSay, ADMFLAG_CHAT, "sm_say <message> - sends message to all players");
RegAdminCmd("sm_csay", Command_SmCsay, ADMFLAG_CHAT, "sm_csay <message> - sends centered message to all players");
RegAdminCmd("sm_hsay", Command_SmHsay, ADMFLAG_CHAT, "sm_hsay <message> - sends hint message to all players");
/* HintText does not work on Dark Messiah */
if (g_GameEngine != SOURCE_SDK_DARKMESSIAH)
{
RegAdminCmd("sm_hsay", Command_SmHsay, ADMFLAG_CHAT, "sm_hsay <message> - sends hint message to all players");
}
RegAdminCmd("sm_tsay", Command_SmTsay, ADMFLAG_CHAT, "sm_tsay [color] <message> - sends top-left message to all players");
RegAdminCmd("sm_chat", Command_SmChat, ADMFLAG_CHAT, "sm_chat <message> - sends message to admins");
RegAdminCmd("sm_psay", Command_SmPsay, ADMFLAG_CHAT, "sm_psay <name or #userid> <message> - sends private message");
+3
View File
@@ -78,6 +78,8 @@ new UserMsg:g_FadeUserMsgId;
// Serial Generator for Timer Safety
new g_Serial_Gen = 0;
new g_GameEngine = SOURCE_SDK_UNKNOWN;
// Flags used in various timers
#define DEFAULT_TIMER_FLAGS TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE
@@ -100,6 +102,7 @@ public OnPluginStart()
LoadTranslations("common.phrases");
LoadTranslations("funcommands.phrases");
g_GameEngine = GuessSDKVersion();
g_FadeUserMsgId = GetUserMessageId("Fade");
RegisterCvars( );
+20 -2
View File
@@ -157,11 +157,29 @@ public Action:Timer_Freeze(Handle:timer, any:value)
if (g_FreezeTime[client] == 0)
{
UnfreezeClient(client);
PrintHintText(client, "You are now unfrozen.");
/* HintText doesn't work on Dark Messiah */
if (g_GameEngine != SOURCE_SDK_DARKMESSIAH)
{
PrintHintText(client, "You are now unfrozen.");
}
else
{
PrintCenterText(client, "You are now unfrozen.");
}
return Plugin_Stop;
}
if (g_GameEngine != SOURCE_SDK_DARKMESSIAH)
{
PrintHintText(client, "You will be unfrozen in %d seconds.", g_FreezeTime[client]);
}
else
{
PrintCenterText(client, "You will be unfrozen in %d seconds.", g_FreezeTime[client]);
}
PrintHintText(client, "You will be unfrozen in %d seconds.", g_FreezeTime[client]);
g_FreezeTime[client]--;
SetEntityMoveType(client, MOVETYPE_NONE);
SetEntityRenderColor(client, 0, 128, 255, 135);
+249 -16
View File
@@ -170,9 +170,27 @@ enum RenderFx
*/
stock GetEntityFlags(entity)
{
return GetEntProp(entity, Prop_Data, "m_fFlags");
static bool:gotconfig = false;
static String:datamap[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_fFlags", datamap, sizeof(datamap));
CloseHandle(gc);
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_fFlags");
}
gotconfig = true;
}
return GetEntProp(entity, Prop_Data, datamap);
}
/**
* Gets an entity's movetype.
*
@@ -182,8 +200,24 @@ stock GetEntityFlags(entity)
*/
stock MoveType:GetEntityMoveType(entity)
{
new offset = GetEntSendPropOffs(entity, "movetype");
return MoveType:GetEntData(entity, offset, 1);
static bool:gotconfig = false;
static String:datamap[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_MoveType", datamap, sizeof(datamap));
CloseHandle(gc);
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_MoveType");
}
gotconfig = true;
}
return MoveType:GetEntProp(entity, Prop_Data, datamap);
}
/**
@@ -196,8 +230,24 @@ stock MoveType:GetEntityMoveType(entity)
*/
stock SetEntityMoveType(entity, MoveType:mt)
{
new offset = GetEntSendPropOffs(entity, "movetype");
SetEntData(entity, offset, mt, 1, true);
static bool:gotconfig = false;
static String:datamap[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_MoveType", datamap, sizeof(datamap));
CloseHandle(gc);
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_MoveType");
}
gotconfig = true;
}
SetEntProp(entity, Prop_Data, datamap, mt);
}
/**
@@ -209,7 +259,24 @@ stock SetEntityMoveType(entity, MoveType:mt)
*/
stock RenderMode:GetEntityRenderMode(entity)
{
return RenderMode:GetEntProp(entity, Prop_Send, "m_nRenderMode", 1);
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_nRenderMode", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_nRenderMode");
}
gotconfig = true;
}
return RenderMode:GetEntProp(entity, Prop_Send, prop, 1);
}
/**
@@ -222,7 +289,24 @@ stock RenderMode:GetEntityRenderMode(entity)
*/
stock SetEntityRenderMode(entity, RenderMode:mode)
{
SetEntProp(entity, Prop_Send, "m_nRenderMode", mode, 1);
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_nRenderMode", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_nRenderMode");
}
gotconfig = true;
}
SetEntProp(entity, Prop_Send, prop, mode, 1);
}
/**
@@ -234,7 +318,24 @@ stock SetEntityRenderMode(entity, RenderMode:mode)
*/
stock RenderFx:GetEntityRenderFx(entity)
{
return RenderFx:GetEntProp(entity, Prop_Send, "m_nRenderFX", 1);
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_nRenderFX", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_nRenderFX");
}
gotconfig = true;
}
return RenderFx:GetEntProp(entity, Prop_Send, prop, 1);
}
/**
@@ -247,7 +348,24 @@ stock RenderFx:GetEntityRenderFx(entity)
*/
stock SetEntityRenderFx(entity, RenderFx:fx)
{
SetEntProp(entity, Prop_Send, "m_nRenderFX", fx, 1);
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_nRenderFX", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_nRenderFX");
}
gotconfig = true;
}
SetEntProp(entity, Prop_Send, prop, fx, 1);
}
/**
@@ -263,15 +381,36 @@ stock SetEntityRenderFx(entity, RenderFx:fx)
*/
stock SetEntityRenderColor(entity, r=255, g=255, b=255, a=255)
{
new offset = GetEntSendPropOffs(entity, "m_clrRender");
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_clrRender");
}
gotconfig = true;
}
new offset = GetEntSendPropOffs(entity, prop);
if (offset <= 0)
{
ThrowError("SetEntityRenderColor not supported by this mod");
}
SetEntData(entity, offset, r, 1, true);
SetEntData(entity, offset + 1, g, 1, true);
SetEntData(entity, offset + 2, b, 1, true);
SetEntData(entity, offset + 3, a, 1, true);
}
/* GuessSDKVersion */
/**
* Gets an entity's gravity.
*
@@ -281,7 +420,24 @@ stock SetEntityRenderColor(entity, r=255, g=255, b=255, a=255)
*/
stock Float:GetEntityGravity(entity)
{
return GetEntPropFloat(entity, Prop_Data, "m_flGravity");
static bool:gotconfig = false;
static String:datamap[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_flGravity", datamap, sizeof(datamap));
CloseHandle(gc);
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_flGravity");
}
gotconfig = true;
}
return GetEntPropFloat(entity, Prop_Data, datamap);
}
/**
@@ -294,7 +450,24 @@ stock Float:GetEntityGravity(entity)
*/
stock SetEntityGravity(entity, Float:amount)
{
SetEntPropFloat(entity, Prop_Data, "m_flGravity", amount);
static bool:gotconfig = false;
static String:datamap[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_flGravity", datamap, sizeof(datamap));
CloseHandle(gc);
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_flGravity");
}
gotconfig = true;
}
SetEntPropFloat(entity, Prop_Data, datamap, amount);
}
/**
@@ -307,7 +480,50 @@ stock SetEntityGravity(entity, Float:amount)
*/
stock SetEntityHealth(entity, amount)
{
SetEntProp(entity, Prop_Send, "m_iHealth", amount);
static bool:gotconfig = false;
static String:prop[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_iHealth", prop, sizeof(prop));
CloseHandle(gc);
if (!exists)
{
strcopy(prop, sizeof(prop), "m_iHeath");
}
gotconfig = true;
}
decl String:cls[64];
new PropFieldType:type;
new offset;
if (!GetEntityNetClass(ent, cls, sizeof(cls)))
{
ThrowError("SetEntityHealth not supported by this mod: Could not get serverclass name");
return;
}
offset = FindSendPropInfo(cls, prop, type);
if (offset <= 0)
{
ThrowError("SetEntityHealth not supported by this mod");
return;
}
/* Dark Messiah uses a float for the health instead an integer */
if (type == PropField_Float)
{
SetEntDataFloat(entity, offset, float(amount));
}
else
{
SetEntProp(entity, prop, amount);
}
}
/**
@@ -320,5 +536,22 @@ stock SetEntityHealth(entity, amount)
*/
stock GetClientButtons(client)
{
return GetEntProp(client, Prop_Data, "m_nButtons");
static bool:gotconfig = false;
static String:datamap[32];
if (!gotconfig)
{
new Handle:gc = LoadGameConfigFile("core.games");
new bool:exists = GameConfGetKeyValue(gc, "m_nButtons", datamap, sizeof(datamap));
CloseHandle(gc);
if (!exists)
{
strcopy(datamap, sizeof(datamap), "m_nButtons");
}
gotconfig = true;
}
return GetEntProp(client, Prop_Data, datamap);
}
+1
View File
@@ -37,6 +37,7 @@
#define SOURCE_SDK_UNKNOWN 0 /**< Could not determine the engine version */
#define SOURCE_SDK_ORIGINAL 10 /**< Original Source engine (still used by "The Ship") */
#define SOURCE_SDK_DARKMESSIAH 15 /**< Modified version of original engine used by Dark Messiah (no SDK) */
#define SOURCE_SDK_EPISODE1 20 /**< SDK+Engine released after Episode 1 */
#define SOURCE_SDK_EPISODE2 30 /**< SDK+Engine released after Episode 2/Orange Box */
#define SOURCE_SDK_LEFT4DEAD 40 /**< Engine released after Left 4 Dead (no SDK yet) */