1.1 --- a/plugins/include/entity_prop_stocks.inc Sun Feb 08 15:40:48 2009 -0500
1.2 +++ b/plugins/include/entity_prop_stocks.inc Wed Feb 18 02:19:22 2009 -0600
1.3 @@ -170,9 +170,27 @@
1.4 */
1.5 stock GetEntityFlags(entity)
1.6 {
1.7 - return GetEntProp(entity, Prop_Data, "m_fFlags");
1.8 + static bool:gotconfig = false;
1.9 + static String:datamap[32];
1.10 +
1.11 + if (!gotconfig)
1.12 + {
1.13 + new Handle:gc = LoadGameConfigFile("core.games");
1.14 + new bool:exists = GameConfGetKeyValue(gc, "m_fFlags", datamap, sizeof(datamap));
1.15 + CloseHandle(gc);
1.16 +
1.17 + if (!exists)
1.18 + {
1.19 + strcopy(datamap, sizeof(datamap), "m_fFlags");
1.20 + }
1.21 +
1.22 + gotconfig = true;
1.23 + }
1.24 +
1.25 + return GetEntProp(entity, Prop_Data, datamap);
1.26 }
1.27
1.28 +
1.29 /**
1.30 * Gets an entity's movetype.
1.31 *
1.32 @@ -182,8 +200,24 @@
1.33 */
1.34 stock MoveType:GetEntityMoveType(entity)
1.35 {
1.36 - new offset = GetEntSendPropOffs(entity, "movetype");
1.37 - return MoveType:GetEntData(entity, offset, 1);
1.38 + static bool:gotconfig = false;
1.39 + static String:datamap[32];
1.40 +
1.41 + if (!gotconfig)
1.42 + {
1.43 + new Handle:gc = LoadGameConfigFile("core.games");
1.44 + new bool:exists = GameConfGetKeyValue(gc, "m_MoveType", datamap, sizeof(datamap));
1.45 + CloseHandle(gc);
1.46 +
1.47 + if (!exists)
1.48 + {
1.49 + strcopy(datamap, sizeof(datamap), "m_MoveType");
1.50 + }
1.51 +
1.52 + gotconfig = true;
1.53 + }
1.54 +
1.55 + return MoveType:GetEntProp(entity, Prop_Data, datamap);
1.56 }
1.57
1.58 /**
1.59 @@ -196,8 +230,24 @@
1.60 */
1.61 stock SetEntityMoveType(entity, MoveType:mt)
1.62 {
1.63 - new offset = GetEntSendPropOffs(entity, "movetype");
1.64 - SetEntData(entity, offset, mt, 1, true);
1.65 + static bool:gotconfig = false;
1.66 + static String:datamap[32];
1.67 +
1.68 + if (!gotconfig)
1.69 + {
1.70 + new Handle:gc = LoadGameConfigFile("core.games");
1.71 + new bool:exists = GameConfGetKeyValue(gc, "m_MoveType", datamap, sizeof(datamap));
1.72 + CloseHandle(gc);
1.73 +
1.74 + if (!exists)
1.75 + {
1.76 + strcopy(datamap, sizeof(datamap), "m_MoveType");
1.77 + }
1.78 +
1.79 + gotconfig = true;
1.80 + }
1.81 +
1.82 + SetEntProp(entity, Prop_Data, datamap, mt);
1.83 }
1.84
1.85 /**
1.86 @@ -209,7 +259,24 @@
1.87 */
1.88 stock RenderMode:GetEntityRenderMode(entity)
1.89 {
1.90 - return RenderMode:GetEntProp(entity, Prop_Send, "m_nRenderMode", 1);
1.91 + static bool:gotconfig = false;
1.92 + static String:prop[32];
1.93 +
1.94 + if (!gotconfig)
1.95 + {
1.96 + new Handle:gc = LoadGameConfigFile("core.games");
1.97 + new bool:exists = GameConfGetKeyValue(gc, "m_nRenderMode", prop, sizeof(prop));
1.98 + CloseHandle(gc);
1.99 +
1.100 + if (!exists)
1.101 + {
1.102 + strcopy(prop, sizeof(prop), "m_nRenderMode");
1.103 + }
1.104 +
1.105 + gotconfig = true;
1.106 + }
1.107 +
1.108 + return RenderMode:GetEntProp(entity, Prop_Send, prop, 1);
1.109 }
1.110
1.111 /**
1.112 @@ -222,7 +289,24 @@
1.113 */
1.114 stock SetEntityRenderMode(entity, RenderMode:mode)
1.115 {
1.116 - SetEntProp(entity, Prop_Send, "m_nRenderMode", mode, 1);
1.117 + static bool:gotconfig = false;
1.118 + static String:prop[32];
1.119 +
1.120 + if (!gotconfig)
1.121 + {
1.122 + new Handle:gc = LoadGameConfigFile("core.games");
1.123 + new bool:exists = GameConfGetKeyValue(gc, "m_nRenderMode", prop, sizeof(prop));
1.124 + CloseHandle(gc);
1.125 +
1.126 + if (!exists)
1.127 + {
1.128 + strcopy(prop, sizeof(prop), "m_nRenderMode");
1.129 + }
1.130 +
1.131 + gotconfig = true;
1.132 + }
1.133 +
1.134 + SetEntProp(entity, Prop_Send, prop, mode, 1);
1.135 }
1.136
1.137 /**
1.138 @@ -234,7 +318,24 @@
1.139 */
1.140 stock RenderFx:GetEntityRenderFx(entity)
1.141 {
1.142 - return RenderFx:GetEntProp(entity, Prop_Send, "m_nRenderFX", 1);
1.143 + static bool:gotconfig = false;
1.144 + static String:prop[32];
1.145 +
1.146 + if (!gotconfig)
1.147 + {
1.148 + new Handle:gc = LoadGameConfigFile("core.games");
1.149 + new bool:exists = GameConfGetKeyValue(gc, "m_nRenderFX", prop, sizeof(prop));
1.150 + CloseHandle(gc);
1.151 +
1.152 + if (!exists)
1.153 + {
1.154 + strcopy(prop, sizeof(prop), "m_nRenderFX");
1.155 + }
1.156 +
1.157 + gotconfig = true;
1.158 + }
1.159 +
1.160 + return RenderFx:GetEntProp(entity, Prop_Send, prop, 1);
1.161 }
1.162
1.163 /**
1.164 @@ -247,7 +348,24 @@
1.165 */
1.166 stock SetEntityRenderFx(entity, RenderFx:fx)
1.167 {
1.168 - SetEntProp(entity, Prop_Send, "m_nRenderFX", fx, 1);
1.169 + static bool:gotconfig = false;
1.170 + static String:prop[32];
1.171 +
1.172 + if (!gotconfig)
1.173 + {
1.174 + new Handle:gc = LoadGameConfigFile("core.games");
1.175 + new bool:exists = GameConfGetKeyValue(gc, "m_nRenderFX", prop, sizeof(prop));
1.176 + CloseHandle(gc);
1.177 +
1.178 + if (!exists)
1.179 + {
1.180 + strcopy(prop, sizeof(prop), "m_nRenderFX");
1.181 + }
1.182 +
1.183 + gotconfig = true;
1.184 + }
1.185 +
1.186 + SetEntProp(entity, Prop_Send, prop, fx, 1);
1.187 }
1.188
1.189 /**
1.190 @@ -263,15 +381,36 @@
1.191 */
1.192 stock SetEntityRenderColor(entity, r=255, g=255, b=255, a=255)
1.193 {
1.194 - new offset = GetEntSendPropOffs(entity, "m_clrRender");
1.195 + static bool:gotconfig = false;
1.196 + static String:prop[32];
1.197 +
1.198 + if (!gotconfig)
1.199 + {
1.200 + new Handle:gc = LoadGameConfigFile("core.games");
1.201 + new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", prop, sizeof(prop));
1.202 + CloseHandle(gc);
1.203 +
1.204 + if (!exists)
1.205 + {
1.206 + strcopy(prop, sizeof(prop), "m_clrRender");
1.207 + }
1.208 +
1.209 + gotconfig = true;
1.210 + }
1.211 +
1.212 + new offset = GetEntSendPropOffs(entity, prop);
1.213 +
1.214 + if (offset <= 0)
1.215 + {
1.216 + ThrowError("SetEntityRenderColor not supported by this mod");
1.217 + }
1.218 +
1.219 SetEntData(entity, offset, r, 1, true);
1.220 SetEntData(entity, offset + 1, g, 1, true);
1.221 SetEntData(entity, offset + 2, b, 1, true);
1.222 SetEntData(entity, offset + 3, a, 1, true);
1.223 }
1.224
1.225 -/* GuessSDKVersion */
1.226 -
1.227 /**
1.228 * Gets an entity's gravity.
1.229 *
1.230 @@ -281,7 +420,24 @@
1.231 */
1.232 stock Float:GetEntityGravity(entity)
1.233 {
1.234 - return GetEntPropFloat(entity, Prop_Data, "m_flGravity");
1.235 + static bool:gotconfig = false;
1.236 + static String:datamap[32];
1.237 +
1.238 + if (!gotconfig)
1.239 + {
1.240 + new Handle:gc = LoadGameConfigFile("core.games");
1.241 + new bool:exists = GameConfGetKeyValue(gc, "m_flGravity", datamap, sizeof(datamap));
1.242 + CloseHandle(gc);
1.243 +
1.244 + if (!exists)
1.245 + {
1.246 + strcopy(datamap, sizeof(datamap), "m_flGravity");
1.247 + }
1.248 +
1.249 + gotconfig = true;
1.250 + }
1.251 +
1.252 + return GetEntPropFloat(entity, Prop_Data, datamap);
1.253 }
1.254
1.255 /**
1.256 @@ -294,7 +450,24 @@
1.257 */
1.258 stock SetEntityGravity(entity, Float:amount)
1.259 {
1.260 - SetEntPropFloat(entity, Prop_Data, "m_flGravity", amount);
1.261 + static bool:gotconfig = false;
1.262 + static String:datamap[32];
1.263 +
1.264 + if (!gotconfig)
1.265 + {
1.266 + new Handle:gc = LoadGameConfigFile("core.games");
1.267 + new bool:exists = GameConfGetKeyValue(gc, "m_flGravity", datamap, sizeof(datamap));
1.268 + CloseHandle(gc);
1.269 +
1.270 + if (!exists)
1.271 + {
1.272 + strcopy(datamap, sizeof(datamap), "m_flGravity");
1.273 + }
1.274 +
1.275 + gotconfig = true;
1.276 + }
1.277 +
1.278 + SetEntPropFloat(entity, Prop_Data, datamap, amount);
1.279 }
1.280
1.281 /**
1.282 @@ -307,7 +480,50 @@
1.283 */
1.284 stock SetEntityHealth(entity, amount)
1.285 {
1.286 - SetEntProp(entity, Prop_Send, "m_iHealth", amount);
1.287 + static bool:gotconfig = false;
1.288 + static String:prop[32];
1.289 +
1.290 + if (!gotconfig)
1.291 + {
1.292 + new Handle:gc = LoadGameConfigFile("core.games");
1.293 + new bool:exists = GameConfGetKeyValue(gc, "m_iHealth", prop, sizeof(prop));
1.294 + CloseHandle(gc);
1.295 +
1.296 + if (!exists)
1.297 + {
1.298 + strcopy(prop, sizeof(prop), "m_iHeath");
1.299 + }
1.300 +
1.301 + gotconfig = true;
1.302 + }
1.303 +
1.304 + decl String:cls[64];
1.305 + new PropFieldType:type;
1.306 + new offset;
1.307 +
1.308 + if (!GetEntityNetClass(ent, cls, sizeof(cls)))
1.309 + {
1.310 + ThrowError("SetEntityHealth not supported by this mod: Could not get serverclass name");
1.311 + return;
1.312 + }
1.313 +
1.314 + offset = FindSendPropInfo(cls, prop, type);
1.315 +
1.316 + if (offset <= 0)
1.317 + {
1.318 + ThrowError("SetEntityHealth not supported by this mod");
1.319 + return;
1.320 + }
1.321 +
1.322 + /* Dark Messiah uses a float for the health instead an integer */
1.323 + if (type == PropField_Float)
1.324 + {
1.325 + SetEntDataFloat(entity, offset, float(amount));
1.326 + }
1.327 + else
1.328 + {
1.329 + SetEntProp(entity, prop, amount);
1.330 + }
1.331 }
1.332
1.333 /**
1.334 @@ -320,5 +536,22 @@
1.335 */
1.336 stock GetClientButtons(client)
1.337 {
1.338 - return GetEntProp(client, Prop_Data, "m_nButtons");
1.339 + static bool:gotconfig = false;
1.340 + static String:datamap[32];
1.341 +
1.342 + if (!gotconfig)
1.343 + {
1.344 + new Handle:gc = LoadGameConfigFile("core.games");
1.345 + new bool:exists = GameConfGetKeyValue(gc, "m_nButtons", datamap, sizeof(datamap));
1.346 + CloseHandle(gc);
1.347 +
1.348 + if (!exists)
1.349 + {
1.350 + strcopy(datamap, sizeof(datamap), "m_nButtons");
1.351 + }
1.352 +
1.353 + gotconfig = true;
1.354 + }
1.355 +
1.356 + return GetEntProp(client, Prop_Data, datamap);
1.357 }