Created
September 2, 2010 17:54
-
-
Save icequeenzz/562626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sourcemod> | |
#include <sdktools> | |
#include <sdkhooks> | |
#define VERSION "0.1" | |
new Float:g_pos[3]; | |
new prophealth[MAXPLAYERS+1][70]; | |
new propindex[MAXPLAYERS+1][70000]; | |
new propowner[70000]; | |
public Plugin:myinfo = | |
{ | |
name = "[TF2] FortWars", | |
author = "Icequeenzz", | |
description = "FortWars", | |
version = VERSION, | |
url = "http://www.sourcemod.net" | |
} | |
public OnPluginStart() | |
{ | |
CreateConVar("sm_test_version", VERSION, "test Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); | |
RegAdminCmd("sm_test", Command_Test, ADMFLAG_SLAY); | |
} | |
public OnMapStart() | |
{ | |
new String: map[3]; | |
GetCurrentMap(map, 3); | |
if(StrContains(map, "fw_", false) != -1) | |
{ | |
PrintToChatAll("this is a fortwars map !"); | |
} | |
for(new i = 0; i < MAXPLAYERS+1; i++) | |
{ | |
for(new j = 0; j < 70; j++) | |
{ | |
prophealth[i][j] = -1; | |
} | |
} | |
// check if it is a fortwars map and adjust towards it | |
} | |
public Action:Command_Test(client, args) | |
{ | |
if(!SetTeleportEndPoint(client)) | |
{ | |
PrintToChat(client, "[SM] Could not find spawn point."); | |
return Plugin_Handled; | |
} | |
if(GetEntityCount() >= GetMaxEntities()-32) | |
{ | |
PrintToChat(client, "[SM] Entity limit is reached."); | |
return Plugin_Handled; | |
} | |
PrecacheModel("models/props_farm/concrete_block001.mdl" ,true); | |
new Prop = CreateEntityByName("prop_physics_override"); | |
DispatchKeyValue(Prop, "model", "models/props_farm/concrete_block001.mdl"); | |
if(IsValidEntity(Prop)) | |
{ | |
DispatchSpawn(Prop); | |
g_pos[2] -= 10.0; | |
TeleportEntity(Prop, g_pos, NULL_VECTOR, NULL_VECTOR); | |
AcceptEntityInput(Prop, "DisableMotion"); | |
AcceptEntityInput(Prop, "SetHealth 100"); | |
SDKHook(Prop, SDKHook_OnTakeDamage, OnPropTakeDamage); | |
SetPropHealth(Prop,client,400); | |
propowner[Prop] = client; | |
PrintToChatAll("prop id and client id: %i %N", Prop, client); | |
} | |
TurnProp(client, Prop); | |
return Plugin_Handled; | |
} | |
SetTeleportEndPoint(client) | |
{ | |
decl Float:vAngles[3]; | |
decl Float:vOrigin[3]; | |
decl Float:vBuffer[3]; | |
decl Float:vStart[3]; | |
decl Float:Distance; | |
GetClientEyePosition(client,vOrigin); | |
GetClientEyeAngles(client, vAngles); | |
//get endpoint for teleport | |
new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer); | |
if(TR_DidHit(trace)) | |
{ | |
TR_GetEndPosition(vStart, trace); | |
GetVectorDistance(vOrigin, vStart, false); | |
Distance = -35.0; | |
GetAngleVectors(vAngles, vBuffer, NULL_VECTOR, NULL_VECTOR); | |
g_pos[0] = vStart[0] + (vBuffer[0]*Distance); | |
g_pos[1] = vStart[1] + (vBuffer[1]*Distance); | |
g_pos[2] = vStart[2] + (vBuffer[2]*Distance); | |
} | |
else | |
{ | |
CloseHandle(trace); | |
return false; | |
} | |
CloseHandle(trace); | |
return true; | |
} | |
TurnAtAim(client) | |
{ | |
decl aimprop; | |
if((aimprop = GetClientAimTarget(client, false)) != -1) | |
{ | |
TurnProp(client, aimprop) | |
} | |
else | |
{ | |
// print hud message that u need to aim at a prop. | |
} | |
} | |
TurnProp(client, prop) | |
{ | |
decl Float:vAngles[3]; | |
GetClientEyeAngles(client, vAngles); | |
vAngles[0] = 0.0; | |
vAngles[2] = 0.0; | |
TeleportEntity(prop, NULL_VECTOR, vAngles, NULL_VECTOR); | |
} | |
SetPropHealth(prop,client,health) | |
{ | |
decl index; | |
for(new i = 0; i < 70; i++) | |
{ | |
if(prophealth[client][i] == -1) | |
{ | |
index = i; | |
break; | |
} | |
} | |
PrintToChatAll("index: %i", index); | |
prophealth[client][index] = health; | |
propindex[client][prop] = index; | |
} | |
public bool:TraceEntityFilterPlayer(entity, contentsMask) | |
{ | |
return entity > GetMaxClients() || !entity; | |
} | |
public Action:OnPropTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) | |
{ | |
decl owner; | |
decl location; | |
owner = propowner[victim]; | |
PrintToChatAll("prop id and client id: %i %N", victim, owner); | |
// get at what location the props thats attacked is is stored | |
location = propindex[owner][victim]; | |
PrintToChatAll("location: %i", location); | |
// check if the prop is dead | |
if((prophealth[owner][location] - RoundFloat(damage)) < 0) | |
{ | |
AcceptEntityInput(victim, "Kill"); | |
prophealth[owner][location] = -1; | |
} | |
else | |
{ | |
prophealth[owner][location] = (prophealth[owner][location] - RoundFloat(damage)); | |
decl ocu; | |
ocu = RoundFloat(255/400 * prophealth[owner][location]); | |
PrintToChatAll("ocupacity should be: %i", ocu); | |
SetEntityRenderColor(victim, ocu, ocu, ocu, 255); | |
} | |
} | |
// info | |
as u see propowner and propindex both have arrays of [70000] what can be easely avoided | |
since i know how to but will make a mess of it i will need you | |
concept: | |
every player can build 70 props, we can link the prop ids in a way as propid[maxplayers+1][70] = (index of propindex[ <here]) | |
we prop need another array then to make the indexing work well | |
since on some event we only know what prop gets damages its hard for us to know what number in the health array it is in therefore we need these extra arrays | |
hopefully its kinda clear | |
icy :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment