sm-plugins/ItemSpawn/scripting/items/whiteknight.inc

286 lines
14 KiB
PHP
Raw Normal View History

2018-08-07 21:54:11 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_WhiteKnight(int client, int argc)
{
float fOrigin[3];
if (argc < 1)
{
GetClientEyePosition(client, fOrigin);
SpawnWhiteKnight(fOrigin);
LogAction(client, -1, "\"%L\" spawned WhiteKnight at <%f><%f><%f>.", client, fOrigin[0], fOrigin[1], fOrigin[2]);
return Plugin_Handled;
}
char sArgs[64];
char sTargetName[MAX_TARGET_LENGTH];
int iTargets[MAXPLAYERS];
int iTargetCount;
bool bIsML;
GetCmdArg(1, sArgs, sizeof(sArgs));
if ((iTargetCount = ProcessTargetString(sArgs, client, iTargets, MAXPLAYERS, COMMAND_FILTER_CONNECTED, sTargetName, sizeof(sTargetName), bIsML)) <= 0)
{
ReplyToTargetError(client, iTargetCount);
return Plugin_Handled;
}
for (int i = 0; i < iTargetCount; i++)
{
if(IsClientInGame(iTargets[i]) && IsPlayerAlive(iTargets[i]) && (ZR_IsClientZombie(iTargets[i])))
{
GetClientEyePosition(iTargets[i], fOrigin);
SpawnWhiteKnight(fOrigin);
LogAction(client, -1, "\"%L\" gave WhiteKnight to \"%L\".", client, iTargets[i]);
}
}
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void SpawnWhiteKnight(float fOrigin[3])
{
float fOriginTemp[3];
// weapon_knife.
int iKnife = CreateEntityAtOrigin("weapon_knife", fOrigin);
DispatchKeyFormat(iKnife, "targetname", "item_knight_knife_%d", g_iCounter);
DispatchKeyFormat(iKnife, "hammerid", "11051995%d", g_iCounter);
DispatchKeyFormat(iKnife, "spawnflags", "1");
DispatchKeyFormat(iKnife, "angles", "0 0 0");
DispatchKeyFormat(iKnife, "OnPlayerPickup", "item_knight_knife_%d,AddOutput,renderfx 6,0.02,1", g_iCounter);
DispatchKeyFormat(iKnife, "OnPlayerPickup", "item_knight_model_%d,SetAnimation,dog_run,0,1", g_iCounter);
DispatchKeyFormat(iKnife, "OnPlayerPickup", "item_knight_model_%d,SetDefaultAnimation,dog_run,0,1", g_iCounter);
DispatchKeyFormat(iKnife, "OnPlayerPickup", "item_knight_health_%d,FireUser1,,0,1", g_iCounter);
DispatchKeyFormat(iKnife, "OnPlayerPickup", "item_knight_health_%d,FireUser2,,0,1", g_iCounter);
DispatchKeyFormat(iKnife, "OnPlayerPickup", "item_knight_controls_%d,Activate,,0,1", g_iCounter);
DispatchKeyFormat(iKnife, "OnPlayerPickup", "!activator,AddOutput,health 50000,0,1");
2018-08-07 21:54:11 +02:00
SpawnAndActivate(iKnife);
HookSingleEntityOutput(iKnife, "OnPlayerPickup", WhiteKnightPickup, true);
// model origin.
fOriginTemp[0] = fOrigin[0] + 6.0;
fOriginTemp[1] = fOrigin[1];
fOriginTemp[2] = fOrigin[2] - 32.0;
2018-08-07 21:54:11 +02:00
// prop_dynamic model.
int iModel = CreateEntityAtOrigin("prop_dynamic", fOriginTemp);
DispatchKeyFormat(iModel, "targetname", "item_knight_model_%d", g_iCounter);
DispatchKeyFormat(iModel, "model", "models/dog_jugger.mdl");
DispatchKeyFormat(iModel, "disablebonefollowers", "1");
DispatchKeyFormat(iModel, "defaultanim", "dog_defense");
2018-08-07 21:54:11 +02:00
DispatchKeyFormat(iModel, "angles", "0 0 0");
DispatchKeyFormat(iModel, "solid", "0");
SpawnAndActivate(iModel);
ParentToEntity(iModel, iKnife);
// trigger_once strip.
int iTriggerStrip = CreateEntityAtOrigin("trigger_once", fOrigin);
DispatchKeyFormat(iTriggerStrip, "targetname", "item_knight_strip_%d", g_iCounter);
DispatchKeyFormat(iTriggerStrip, "filtername", "item_spawn_human_filter");
DispatchKeyFormat(iTriggerStrip, "spawnflags", "1");
DispatchKeyFormat(iTriggerStrip, "startdisabled", "1");
DispatchKeyFormat(iTriggerStrip, "OnStartTouch", "item_spawn_weaponstrip,StripWeaponsAndSuit,,0,1");
SpawnAndActivate(iTriggerStrip);
ParentToEntity(iTriggerStrip, iKnife);
// make the trigger work.
SetEntityBBox(iTriggerStrip, view_as<float>({-8.0, -8.0, -8.0}), view_as<float>({8.0, 8.0, 8.0}));
SetEntityProps(iTriggerStrip);
// attack push origin.
fOriginTemp[0] = fOrigin[0] + 112.0;
fOriginTemp[1] = fOrigin[1];
fOriginTemp[2] = fOrigin[2] + 4.0;
// trigger_push attack push.
int iTriggerPushOne = CreateEntityAtOrigin("trigger_push", fOriginTemp);
DispatchKeyFormat(iTriggerPushOne, "targetname", "item_knight_push_1_%d", g_iCounter);
DispatchKeyFormat(iTriggerPushOne, "filtername", "item_spawn_zombie_filter");
DispatchKeyFormat(iTriggerPushOne, "spawnflags", "1");
DispatchKeyFormat(iTriggerPushOne, "startdisabled", "1");
DispatchKeyFormat(iTriggerPushOne, "pushdir", "-45 0 0");
DispatchKeyFormat(iTriggerPushOne, "speed", "600");
SpawnAndActivate(iTriggerPushOne);
ParentToEntity(iTriggerPushOne, iKnife);
// make the trigger work.
SetEntityBBox(iTriggerPushOne, view_as<float>({-70.0, -52.0, -36.0}), view_as<float>({70.0, 52.0, 36.0}));
SetEntityProps(iTriggerPushOne);
// trigger_push attack push.
int iTriggerPushTwo = CreateEntityAtOrigin("trigger_push", fOriginTemp);
DispatchKeyFormat(iTriggerPushTwo, "targetname", "item_knight_push_2_%d", g_iCounter);
DispatchKeyFormat(iTriggerPushTwo, "filtername", "item_spawn_zombie_filter");
DispatchKeyFormat(iTriggerPushTwo, "spawnflags", "1");
DispatchKeyFormat(iTriggerPushTwo, "startdisabled", "1");
DispatchKeyFormat(iTriggerPushTwo, "pushdir", "-45 0 0");
DispatchKeyFormat(iTriggerPushTwo, "speed", "1500");
SpawnAndActivate(iTriggerPushTwo);
ParentToEntity(iTriggerPushTwo, iKnife);
// make the trigger work.
SetEntityBBox(iTriggerPushTwo, view_as<float>({-70.0, -52.0, -36.0}), view_as<float>({70.0, 52.0, 36.0}));
SetEntityProps(iTriggerPushTwo);
// attack hurt origin.
fOriginTemp[0] = fOrigin[0] + 130.0;
fOriginTemp[1] = fOrigin[1];
fOriginTemp[2] = fOrigin[2] + 4.0;
// trigger_hurt attack hurt.
int iTriggerHurtOne = CreateEntityAtOrigin("trigger_hurt", fOriginTemp);
DispatchKeyFormat(iTriggerHurtOne, "targetname", "item_knight_hurt_1_%d", g_iCounter);
DispatchKeyFormat(iTriggerHurtOne, "filtername", "item_spawn_zombie_filter");
DispatchKeyFormat(iTriggerHurtOne, "spawnflags", "9");
DispatchKeyFormat(iTriggerHurtOne, "startdisabled", "1");
DispatchKeyFormat(iTriggerHurtOne, "damagetype", "512");
DispatchKeyFormat(iTriggerHurtOne, "damagemodel", "0");
DispatchKeyFormat(iTriggerHurtOne, "damagecap", "20");
DispatchKeyFormat(iTriggerHurtOne, "damage", "800");
SpawnAndActivate(iTriggerHurtOne);
ParentToEntity(iTriggerHurtOne, iKnife);
// make the trigger work.
SetEntityBBox(iTriggerHurtOne, view_as<float>({-52.0, -52.0, -36.0}), view_as<float>({52.0, 52.0, 36.0}));
SetEntityProps(iTriggerHurtOne);
// nuke hurt origin.
fOriginTemp[0] = fOrigin[0] + 6.0;
fOriginTemp[1] = fOrigin[1];
fOriginTemp[2] = fOrigin[2] + 32.0;
int iTriggerHurtTwo = CreateEntityAtOrigin("trigger_hurt", fOriginTemp);
DispatchKeyFormat(iTriggerHurtTwo, "targetname", "item_knight_hurt_2_%d", g_iCounter);
DispatchKeyFormat(iTriggerHurtTwo, "filtername", "item_spawn_zombie_filter");
DispatchKeyFormat(iTriggerHurtTwo, "spawnflags", "9");
DispatchKeyFormat(iTriggerHurtTwo, "startdisabled", "1");
DispatchKeyFormat(iTriggerHurtTwo, "damagetype", "512");
DispatchKeyFormat(iTriggerHurtTwo, "damagemodel", "0");
DispatchKeyFormat(iTriggerHurtTwo, "damagecap", "20");
DispatchKeyFormat(iTriggerHurtTwo, "damage", "20000");
SpawnAndActivate(iTriggerHurtTwo);
ParentToEntity(iTriggerHurtTwo, iKnife);
// make the trigger work.
SetEntityBBox(iTriggerHurtTwo, view_as<float>({-1024.0, -1024.0, -800.0}), view_as<float>({1024.0, 1024.0, 800.0}));
SetEntityProps(iTriggerHurtTwo);
// logic_relay death.
int iRelayDeath = CreateEntityAtOrigin("logic_relay", fOrigin);
DispatchKeyFormat(iRelayDeath, "targetname", "item_knight_death_%d", g_iCounter);
DispatchKeyFormat(iRelayDeath, "spawnflags", "0");
DispatchKeyFormat(iRelayDeath, "OnTrigger", "!self,FireUser1,,0.1,-1");
DispatchKeyFormat(iRelayDeath, "OnUser1", "item_knight_knife_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iRelayDeath, "OnUser1", "item_knight_strip_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iRelayDeath, "OnUser1", "item_knight_push_1_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iRelayDeath, "OnUser1", "item_knight_push_2_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iRelayDeath, "OnUser1", "item_knight_hurt_1_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iRelayDeath, "OnUser1", "item_knight_hurt_2_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iRelayDeath, "OnUser1", "!activator,AddOutput,rendermode 0,0,1");
DispatchKeyFormat(iRelayDeath, "OnUser1", "!activator,AddOutput,renderfx 0,0,1");
DispatchKeyFormat(iRelayDeath, "OnUser1", "!activator,SetDamageFilter,,0,1");
DispatchKeyFormat(iRelayDeath, "OnUser1", "!activator,SetHealth,0,0.02,-1");
SpawnAndActivate(iRelayDeath);
ParentToEntity(iRelayDeath, iKnife);
// health origin.
fOriginTemp[0] = fOrigin[0] + 6.0;
fOriginTemp[1] = fOrigin[1];
fOriginTemp[2] = fOrigin[2] + 56.0;
// func_physbox_multiplayer health.
int iHealth = CreateEntityAtOrigin("func_physbox_multiplayer", fOriginTemp);
DispatchKeyFormat(iHealth, "targetname", "item_knight_health_%d", g_iCounter);
DispatchKeyFormat(iHealth, "model", "models/props/cs_militia/crate_extrasmallmill.mdl");
DispatchKeyFormat(iHealth, "spawnflags", "9237504");
DispatchKeyFormat(iHealth, "rendermode", "0");
DispatchKeyFormat(iHealth, "renderfx", "0");
DispatchKeyFormat(iHealth, "rendercolor", "255 255 255");
DispatchKeyFormat(iHealth, "renderamt", "255 255 255");
DispatchKeyFormat(iHealth, "propdata", "0");
DispatchKeyFormat(iHealth, "pressuredelay", "0");
DispatchKeyFormat(iHealth, "preferredcarryangles", "0 0 0");
DispatchKeyFormat(iHealth, "performancemode", "1");
DispatchKeyFormat(iHealth, "notsolid", "0");
DispatchKeyFormat(iHealth, "nodamageforces", "0");
DispatchKeyFormat(iHealth, "material", "2");
DispatchKeyFormat(iHealth, "massScale", "0");
DispatchKeyFormat(iHealth, "health", "750");
DispatchKeyFormat(iHealth, "gibdir", "0 0 0");
DispatchKeyFormat(iHealth, "forcetoenablemotion", "0");
DispatchKeyFormat(iHealth, "explosion", "0");
DispatchKeyFormat(iHealth, "exploderadius", "0");
DispatchKeyFormat(iHealth, "explodemagnitude", "0");
DispatchKeyFormat(iHealth, "explodedamage", "0");
DispatchKeyFormat(iHealth, "disableshadows", "1");
DispatchKeyFormat(iHealth, "disablereceiveshadows", "1");
DispatchKeyFormat(iHealth, "damagetype", "0");
DispatchKeyFormat(iHealth, "damagetoenablemotion", "0");
DispatchKeyFormat(iHealth, "damagefilter", "item_spawn_zombie_filter");
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_knife_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_strip_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_push_1_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_push_2_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_hurt_1_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_hurt_2_%d,Kill,,0,-1", g_iCounter);
2018-08-07 21:54:11 +02:00
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_controls_%d,Kill,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_model_%d,ClearParent,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_model_%d,SetAnimation,dog_die,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnBreak", "item_knight_model_%d,SetDefaultAnimation,dog_die_loop,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnUser1", "!activator,SetDamageFilter,item_spawn_human_filter,0,-1");
DispatchKeyFormat(iHealth, "OnUser1", "!activator,AddOutput,rendermode 10,0,-1");
DispatchKeyFormat(iHealth, "OnUser1", "!activator,AddOutput,renderfx 6,0,-1");
DispatchKeyFormat(iHealth, "OnUser1", "!self,FireUser1,,1,-1");
DispatchKeyFormat(iHealth, "OnUser2", "item_knight_death_%d,CancelPending,,0,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnUser2", "item_knight_death_%d,Trigger,,0.05,-1", g_iCounter);
DispatchKeyFormat(iHealth, "OnUser2", "!self,FireUser2,,0.1,-1");
SpawnAndActivate(iHealth);
ParentToEntity(iHealth, iKnife);
2018-08-07 21:54:11 +02:00
// make the physbox work.
SetEntityBBox(iHealth, view_as<float>({-36.0, -52.0, -56.0}), view_as<float>({36.0, 52.0, 56.0}));
SetEntityProps(iHealth);
2018-08-07 21:54:11 +02:00
HookSingleEntityOutput(iHealth, "OnBreak", WhiteKnightKill, true);
// game_ui.
int iControls = CreateEntityAtOrigin("game_ui", fOrigin);
DispatchKeyFormat(iControls, "targetname", "item_knight_controls_%d", g_iCounter);
DispatchKeyFormat(iControls, "spawnflags", "0");
DispatchKeyFormat(iControls, "fieldofview", "-1.0");
DispatchKeyFormat(iControls, "PressedAttack", "item_knight_attack_compare_%d,Compare,,0,-1", g_iCounter);
DispatchKeyFormat(iControls, "PressedAttack2", "item_knight_shield_compare_%d,Compare,,0,-1", g_iCounter);
SpawnAndActivate(iControls);
ParentToEntity(iControls, iKnife);
2018-08-07 21:54:11 +02:00
AcceptEntityInput(iTriggerStrip, "Enable");
g_iCounter++;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void WhiteKnightPickup(const char[] output, int caller, int activator, float delay)
{
ServerCommand("say ** %N has picked up the White Knight **", activator);
PrintToChat(activator, " LEFT CLICK = ATTACK and RIGHT CLICK = SHIELD.");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void WhiteKnightKill(const char[] output, int caller, int activator, float delay)
{
ServerCommand("say ** %N has killed the White Knight **", activator);
2018-08-07 21:54:11 +02:00
}