Skip to content

Instantly share code, notes, and snippets.

@nosoop
Created April 29, 2021 23:19
Show Gist options
  • Save nosoop/f7b72b1cb638a4570fa46a63c0594501 to your computer and use it in GitHub Desktop.
Save nosoop/f7b72b1cb638a4570fa46a63c0594501 to your computer and use it in GitHub Desktop.
/**
* if you're bored you can simply close your eyes and rotate a cow in your mind.
* it's free and the cops can't stop you
*/
#pragma semicolon 1
#include <sourcemod>
#pragma newdecls required
#include <stocksoup/traceutils>
#define MODEL_PATH_COW "models/props_2fort/cow001_reference.mdl"
// find as close a match to the collision box to the cow as we can
// #define MODEL_PATH_PHYSBLOCK "models/props_gameplay/sign_wood_cap002.mdl"
// #define MODEL_PATH_PHYSBLOCK "models/props_well/computer_cart01.mdl"
#define MODEL_PATH_PHYSBLOCK "models/props_2fort/chalkboard01.mdl"
#define SOUND_PATH_COW_SPAWN "ui/item_metal_weapon_drop.wav"
#define SOUND_PATH_COW_LOOP "karmacharger/cow_loop.wav"
ArrayList g_Cows;
public void OnPluginStart() {
RegAdminCmd("karma_cow_drop", CommandSetPositionAim, ADMFLAG_ROOT);
g_Cows = new ArrayList();
}
public void OnMapStart() {
PrecacheModel(MODEL_PATH_COW);
PrecacheModel(MODEL_PATH_PHYSBLOCK);
PrecacheSound(SOUND_PATH_COW_SPAWN);
AddFileToDownloadsTable("sound/" ... SOUND_PATH_COW_LOOP);
PrecacheSound(SOUND_PATH_COW_LOOP);
}
public void OnPluginEnd() {
// let the cows go home
// their moos will eternally ring in your ears though
for (int i, n = g_Cows.Length; i < n; i++) {
int e = g_Cows.Get(i);
if (IsValidEntity(e)) {
RemoveEntity(e);
}
}
}
Action CommandSetPositionAim(int client, int argc) {
float position[3], origin[3];
GetClientAbsOrigin(client, origin);
GetClientAimEndPosition(client, position);
float direction[3], angles[3];
MakeVectorFromPoints(position, origin, direction);
GetVectorAngles(direction, angles);
angles[0] = 0.0;
// moo
int cow = CreateEntityByName("prop_dynamic");
SetEntityModel(cow, MODEL_PATH_COW);
DispatchSpawn(cow);
TeleportEntity(cow, position, angles, NULL_VECTOR);
g_Cows.Push(EntIndexToEntRef(cow));
// entity used as a physics model reference for the cow,
// because the cow doesn't have collision
int block = CreateEntityByName("func_respawnroomvisualizer");
SetEntityModel(block, MODEL_PATH_PHYSBLOCK);
SetEntProp(block, Prop_Data, "m_iTeamNum", GetClientTeam(client));
// DispatchKeyValue(block, "solid", "6");
DispatchSpawn(block);
/// chalkboard
angles[1] += 90.0;
position[2] += 32.0;
TeleportEntity(block, position, angles, NULL_VECTOR);
SetEntityRenderMode(block, RENDER_TRANSALPHA);
SetEntityRenderColor(block, .a = 0);
AcceptEntityInput(block, "DisableShadow");
g_Cows.Push(EntIndexToEntRef(block));
EmitSoundToAll(SOUND_PATH_COW_SPAWN, cow);
EmitSoundToAll(SOUND_PATH_COW_LOOP, cow);
return Plugin_Handled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment