mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 05:23:20 +00:00
Changes
This commit is contained in:
parent
832ab67665
commit
16868d3d51
12 changed files with 326 additions and 92 deletions
159
scripting/include/jutils.inc
Normal file
159
scripting/include/jutils.inc
Normal file
|
@ -0,0 +1,159 @@
|
|||
#if defined _jutils_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _jutils_included
|
||||
|
||||
#define MODEL_FRANCIS "models/survivors/survivor_biker.mdl"
|
||||
#define MODEL_LOUIS "models/survivors/survivor_manager.mdl"
|
||||
#define MODEL_ZOEY "models/survivors/survivor_teenangst.mdl"
|
||||
#define MODEL_BILL "models/survivors/survivor_namvet.mdl"
|
||||
#define MODEL_NICK "models/survivors/survivor_gambler.mdl"
|
||||
#define MODEL_COACH "models/survivors/survivor_coach.mdl"
|
||||
#define MODEL_ELLIS "models/survivors/survivor_mechanic.mdl"
|
||||
#define MODEL_ROCHELLE "models/survivors/survivor_producer.mdl"
|
||||
#define MODEL_MINIGUN "models/w_models/weapons/w_minigun.mdl"
|
||||
|
||||
stock void GetHorizontalPositionFromOrigin(const float pos[3], const float ang[3], float units, float finalPosition[3]) {
|
||||
float theta = DegToRad(ang[1]);
|
||||
finalPosition[0] = units * Cosine(theta) + pos[0];
|
||||
finalPosition[1] = units * Sine(theta) + pos[1];
|
||||
finalPosition[2] = pos[2];
|
||||
}
|
||||
stock void GetHorizontalPositionFromClient(int client, float units, float finalPosition[3]) {
|
||||
float pos[3], ang[3];
|
||||
GetClientEyeAngles(client, ang);
|
||||
GetClientAbsOrigin(client, pos);
|
||||
|
||||
float theta = DegToRad(ang[1]);
|
||||
pos[0] += -150 * Cosine(theta);
|
||||
pos[1] += -150 * Sine(theta);
|
||||
finalPosition = pos;
|
||||
}
|
||||
|
||||
stock void L4D2_RunScript(const char[] sCode, any ...) {
|
||||
static int iScriptLogic = INVALID_ENT_REFERENCE;
|
||||
if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic)) {
|
||||
iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
|
||||
if(iScriptLogic == INVALID_ENT_REFERENCE|| !IsValidEntity(iScriptLogic))
|
||||
SetFailState("Could not create 'logic_script'");
|
||||
|
||||
DispatchSpawn(iScriptLogic);
|
||||
}
|
||||
|
||||
static char sBuffer[512];
|
||||
VFormat(sBuffer, sizeof(sBuffer), sCode, 2);
|
||||
|
||||
SetVariantString(sBuffer);
|
||||
AcceptEntityInput(iScriptLogic, "RunScriptCode");
|
||||
}
|
||||
stock void ShowDelayedHintToAll(const char[] format, any ...) {
|
||||
char buffer[254];
|
||||
VFormat(buffer, sizeof(buffer), format, 2);
|
||||
static int hintInt = 0;
|
||||
if(hintInt >= 7) {
|
||||
PrintHintTextToAll("%s",buffer);
|
||||
hintInt = 0;
|
||||
}
|
||||
hintInt++;
|
||||
}
|
||||
stock bool FindSurvivorModel(const char str[16], char[] model, int modelStrSize) {
|
||||
int possibleNumber = StringToInt(str, 10);
|
||||
if(modelStrSize == 1 && possibleNumber <= 7 && possibleNumber >= 0) {
|
||||
switch(possibleNumber) {
|
||||
case 0: {
|
||||
strcopy(model, modelStrSize, MODEL_NICK);
|
||||
} case 1: {
|
||||
strcopy(model, modelStrSize, MODEL_ELLIS);
|
||||
} case 2: {
|
||||
strcopy(model, modelStrSize, MODEL_COACH);
|
||||
} case 3: {
|
||||
strcopy(model, modelStrSize, MODEL_ROCHELLE);
|
||||
} case 4: {
|
||||
strcopy(model, modelStrSize, MODEL_BILL);
|
||||
} case 5: {
|
||||
strcopy(model, modelStrSize, MODEL_ZOEY);
|
||||
} case 6: {
|
||||
strcopy(model, modelStrSize, MODEL_FRANCIS);
|
||||
} case 7: {
|
||||
strcopy(model, modelStrSize, MODEL_LOUIS);
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
if(possibleNumber == 0) {
|
||||
//try to parse str
|
||||
if(StrEqual(str, "bill", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_BILL);
|
||||
}else if(StrEqual(str, "zoey", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_ZOEY);
|
||||
}else if(StrEqual(str, "francis", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_FRANCIS);
|
||||
}else if(StrEqual(str, "louis", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_LOUIS);
|
||||
}else if(StrEqual(str, "nick", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_NICK);
|
||||
}else if(StrEqual(str, "ellis", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_ELLIS);
|
||||
}else if(StrEqual(str, "rochelle", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_ROCHELLE);
|
||||
}else if(StrEqual(str, "coach", false)) {
|
||||
strcopy(model, modelStrSize, MODEL_COACH);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
stock bool GetGround(int client, float[3] vPos, float[3] vAng) {
|
||||
GetClientAbsOrigin(client, vPos);
|
||||
vAng = vPos;
|
||||
vAng[2] += 5.0;
|
||||
vPos[2] -= 500.0;
|
||||
|
||||
Handle trace = TR_TraceRayFilterEx(vAng, vPos, MASK_SHOT, RayType_EndPoint, TraceFilter);
|
||||
if(!TR_DidHit(trace))
|
||||
{
|
||||
delete trace;
|
||||
return false;
|
||||
}
|
||||
TR_GetEndPosition(vPos, trace);
|
||||
delete trace;
|
||||
|
||||
GetClientAbsAngles(client, vAng);
|
||||
return true;
|
||||
}
|
||||
stock bool SpawnMinigun(const float vPos[3], const float vAng[3]) {
|
||||
float vDir[3], newPos[3];
|
||||
GetAngleVectors(vAng, vDir, NULL_VECTOR, NULL_VECTOR);
|
||||
vDir[0] = vPos[0] + (vDir[0] * 50);
|
||||
vDir[1] = vPos[1] + (vDir[1] * 50);
|
||||
vDir[2] = vPos[2] + 20.0;
|
||||
newPos = vDir;
|
||||
newPos[2] -= 40.0;
|
||||
|
||||
Handle trace = TR_TraceRayFilterEx(vDir, newPos, MASK_SHOT, RayType_EndPoint, TraceFilter);
|
||||
if(TR_DidHit(trace)) {
|
||||
TR_GetEndPosition(vDir, trace);
|
||||
|
||||
int minigun = CreateEntityByName("prop_mounted_machine_gun");
|
||||
minigun = EntIndexToEntRef(minigun);
|
||||
SetEntityModel(minigun, MODEL_MINIGUN);
|
||||
DispatchKeyValue(minigun, "targetname", "louis_holdout");
|
||||
DispatchKeyValueFloat(minigun, "MaxPitch", 360.00);
|
||||
DispatchKeyValueFloat(minigun, "MinPitch", -360.00);
|
||||
DispatchKeyValueFloat(minigun, "MaxYaw", 90.00);
|
||||
newPos[2] += 0.1;
|
||||
TeleportEntity(minigun, vDir, vAng, NULL_VECTOR);
|
||||
DispatchSpawn(minigun);
|
||||
delete trace;
|
||||
return true;
|
||||
}else{
|
||||
LogError("Spawn minigun trace failure");
|
||||
delete trace;
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue