hl2:dm weapon shovel

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

hl2:dm weapon shovel

Postby daren adler » Thu Jan 19, 2023 10:07 pm

Hello all. i have a weapon i use but only kills npc. I would love to have it be able to kill all. Here is the weapon_shovel txt script.

Code: Select all

WeaponData
{
   // Weapon data is loaded by both the Game and Client DLLs.
   "viewmodel"         "models/weapons/exiles/v_crowbar.mdl"
   "playermodel"      "models/weapons/exile2/w_crowbar.mdl"
   
   // this prefix will be used and fixed by customguns if this gun is custom
   // more prefixes can be found in weapon scripts files
   "anim_prefix"      "crowbar"
   
   "clip_size"         "-1"
   "primary_ammo"      "None"
   "secondary_ammo"   "None"
   
   "autoswitchto"      "0"
   "autoswitchfrom"   "0"

   SoundData
   {
      "single_shot"      "Weapon_Crowbar.Single"
      "melee_hit"         "Weapon_Crowbar.Melee_Hit"
      "melee_hit_world"   "Weapon_Crowbar.Melee_HitWorld"
   }

   "CustomGunsPluginData"
   {
      "name"                  "Shovel"
      
      // mdl or vmt for selection menu
      "model"                  "models/weapons/exiles/w_crowbar.mdl"
      
      // make the gun usable only by admins who have this flag(s), or -1 to alow everyone to use the gun
      "admin_level"            "-1"
      
      // add this gun to player's inventory on spawn?
      "give_on_spawn"            "1"
      
      // add this gun to player's inventory when he equips this weapon
      "give_with_weapon"         ""
      
      // binds to this weapon, auto switching when player selects it; if set, both weapons should use the same ammo type and give_with_weapon should be set the same as this!
      "bind_to_weapon"         ""
      
      // if 1, does not disappear from inventory when player drops the physical weapon or is stripped from weapons; recommended for admin weapons or weapons given on spawn
      "persistent"            "1"
      
      // weapon_type - possible values:
      //      bullet - (default) Standard bullet weapon, uses clip sizes and ammo type defined above
      //      throwable - Throws something away from the player - grenades, molotovs, ..
      //      custom - Custom coded weapon
      "weapon_type"      "custom"
      
      "custom_settings"
      {
         // * If set to 1, this custom gun will use game-defined ammo type (set above) and behavior instead of plugin managed ammo.
         // * Fire functions will be managed by game, so they won't be called when the weapon runs out of ammo.
         // * Use with CG_RemovePlayerAmmo() native
         //
         // ** Setting this to 0 will allow you to manage ammo ("m_iClip1" value) yourself via plugin. This overrides ammotype to an unknown value.
         // ** Fire functions will always be called when the weapon is ready to fire, without any ammo checks. Also set this to 0 if your weapon doesn't use ammo.
         // ** Set "primary_ammo" other than "None" to enable HUD ammo display.
         "uses_game_ammo"      "0"
      }
      
      "download"
      {

      }
   }
}

Any help or a sourcepython scripts would be great. (the kill power i would like to be same as the crowbar please). thank you and have a great day.
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: hl2:dm weapon shovel

Postby cssbestrpg » Fri Jan 20, 2023 9:41 am

Does the crowbar kill one hit or how much damage it makes?
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: hl2:dm weapon shovel

Postby Kami » Fri Jan 20, 2023 11:35 am

Assuming you are using customguns sourcemod plugin?

Is it working on enemies in Team Deathmatch?
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: hl2:dm weapon shovel

Postby daren adler » Fri Jan 20, 2023 5:26 pm

Kami wrote:Assuming you are using customguns sourcemod plugin?

Is it working on enemies in Team Deathmatch?


No, it only kills npc's. i am using the customguns plugin yes. I also use it in my coop server, in the coop/campaign server it kills the npc with 2 hits. Here are the smx and sp for it also if u need it. https://www.dropbox.com/s/ai8w61zni8gjvl3/weapon_shovel.zip?dl=0
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: hl2:dm weapon shovel

Postby cssbestrpg » Fri Jan 20, 2023 7:38 pm

You want it work also on players?

Edit:

I edited sourcemod code that it should work on players, but i can't compile since i don't use sourcemod.
Here is download for modifed sp.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: hl2:dm weapon shovel

Postby daren adler » Fri Jan 20, 2023 10:49 pm

cssbestrpg wrote:You want it work also on players?

Edit:

I edited sourcemod code that it should work on players, but i can't compile since i don't use sourcemod.
Here is download for modifed sp.


ya thanks, but that sp cannot be recompiled,,i tryed, thats y i asked to be made into a py. Used them files to show what it is.

Here is what it says when i try to compile it

Code: Select all

Your plugin failed to compile! Read the errors below:
SourcePawn Compiler 1.11
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

/home/groups/sourcemod/upload_tmp/php7PbCna.sp(4) : error 417: cannot read from file: "customguns"

1 Error.

882242 successful compiles to date.
733351 failed compiles to date.
cssbestrpg
Senior Member
Posts: 287
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: hl2:dm weapon shovel

Postby cssbestrpg » Fri Jan 20, 2023 10:58 pm

That error means you need at server compile it with the txt file, i don't know which location it needs to be.
I have started coding it to Source.Python, but its not yet ready.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: hl2:dm weapon shovel

Postby daren adler » Sat Jan 21, 2023 4:09 am

cssbestrpg wrote:That error means you need at server compile it with the txt file, i don't know which location it needs to be.
I have started coding it to Source.Python, but its not yet ready.

ok, thank you. :smile:
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: hl2:dm weapon shovel

Postby Kami » Sat Jan 21, 2023 3:30 pm

You can download an older sourcemod version here https://www.sourcemod.net/downloads.php ... dev&all=1#

Then you download the custom guns plugin https://github.com/Alienmario/customguns-hl2dm

and copy everything from there to the addons/sourcemod folder you downloaded first.

Then you should be able to compile the weapon_shovel.sp.

I tried this version and it seems to work (at least with bots):

Code: Select all

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <customguns>

#define WEAPON "weapon_shovel"
#define REFIRE 0.5
#define RANGE 90.0
#define DAMAGE 55.0
#define PUSH_SCALE 250.0

float additionalTime[MAXPLAYERS+1];
float nextEnergy[MAXPLAYERS+1];

public void CG_OnHolster(int client, int weapon, int switchingTo){
   char sWeapon[32];
   GetEntityClassname(weapon, sWeapon, sizeof(sWeapon));
   
   if(StrEqual(sWeapon, WEAPON)){
      additionalTime[client] = 0.0;
      nextEnergy[client] = 0.0;
   }
}

public void CG_OnPrimaryAttack(int client, int weapon){
   char sWeapon[32];
   GetEntityClassname(weapon, sWeapon, sizeof(sWeapon));
   
   if(StrEqual(sWeapon, WEAPON)){
      CG_SetPlayerAnimation(client, PLAYER_ATTACK1);
      CG_PlayActivity(weapon, ACT_VM_MISSCENTER); // ACT_VM_HITCENTER

      if(additionalTime[client] <= 0.025)
      {
         additionalTime[client] = 0.025;
      }
      additionalTime[client] += additionalTime[client]*1.2;
      if(additionalTime[client] >= 0.5)
      {
         additionalTime[client] = 0.5;
      }
      
      CG_Cooldown(weapon, REFIRE + additionalTime[client]);
      
      float pos[3], angles[3], endPos[3];
      CG_GetShootPosition(client, pos);
      GetClientEyeAngles(client, angles);
      
      GetAngleVectors(angles, endPos, NULL_VECTOR, NULL_VECTOR);
      ScaleVector(endPos, RANGE);
      AddVectors(pos, endPos, endPos);
      
      TR_TraceHullFilter(pos, endPos, view_as<float>({-10.0, -10.0, -10.0}), view_as<float>({10.0, 10.0, 10.0}), MASK_SHOT_HULL, TraceEntityFilter, client);
      
      float punchAngle[3];
      punchAngle[0] = GetRandomFloat( 1.0, 2.0 );
      punchAngle[1] = GetRandomFloat( -2.0, -1.0 );
      Tools_ViewPunch(client, punchAngle);
      
      if(TR_DidHit())
      {
         EmitGameSoundToAll("Weapon_Crowbar.Melee_Hit", weapon);
         
         int entityHit = TR_GetEntityIndex();
         if(entityHit > 0 && (!IsPlayer(entityHit) || GetClientTeam(entityHit) != GetClientTeam(client) || IsPlayer(entityHit)))
         {
            char classname[32];
            GetEntityClassname(entityHit, classname, sizeof(classname));
            if(GetEntityMoveType(entityHit) == MOVETYPE_VPHYSICS || StrContains(classname, "npc_") == 0)
            {
               float force[3];
               GetAngleVectors(angles, force, NULL_VECTOR, NULL_VECTOR);
               ScaleVector(force, PUSH_SCALE);
               TeleportEntity(entityHit, NULL_VECTOR, NULL_VECTOR, force);
               
               if(GetEntityMoveType(entityHit) == MOVETYPE_VPHYSICS)
               {
                  SetEntPropVector(entityHit, Prop_Data, "m_vecAbsVelocity", NULL_VECTOR); //trampoline fix
               }
            }
            SDKHooks_TakeDamage(entityHit, client, client, DAMAGE, DMG_CLUB);
         }
         
         // Do additional trace for impact effects
         // if ( ImpactWater( pos, endPos ) ) return;
         float impactEndPos[3];
         GetAngleVectors(angles, impactEndPos, NULL_VECTOR, NULL_VECTOR);
         ScaleVector(impactEndPos, 50.0);
         TR_GetEndPosition(endPos);
         AddVectors(impactEndPos, endPos, impactEndPos);

         TR_TraceRayFilter(endPos, impactEndPos, MASK_SHOT_HULL, RayType_EndPoint, TraceEntityFilter, client);
         if(TR_DidHit())
         {
            UTIL_ImpactTrace(pos, DMG_CLUB);
         }
      }
      else
      {
         EmitGameSoundToAll("Weapon_Crowbar.Single", weapon);
      }
   }
}

public void CG_ItemPostFrame(int client, int weapon){
   char sWeapon[32];
   GetEntityClassname(weapon, sWeapon, sizeof(sWeapon));
   
   if(StrEqual(sWeapon, WEAPON)){
      if(!(GetClientButtons(client) & IN_ATTACK) && GetGameTime() >= nextEnergy[client])
      {
         additionalTime[client] *= 0.5;
         nextEnergy[client] = GetGameTime() + 0.25;
      }
   }
}

public bool TraceEntityFilter(int entity, int mask, any data){
   if (entity == data)
      return false;
   return true;
}


I also attached a compiled version.
Attachments
weapon_shovel.zip
(10.42 KiB) Downloaded 280 times
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: hl2:dm weapon shovel

Postby daren adler » Sun Jan 22, 2023 2:29 am

Works great Kami.... Thank you so much. :) ...I know this might sound crazy, but can that be re-done the same way but called weapon_knife ?. I am asking that becouse the reason it called shovel is becouse of the smx is called shovel,,would like it to be knife, but if cant be done that would be ok, becouse it does work,, just thought that naming it what it really is would be nice.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: hl2:dm weapon shovel

Postby Kami » Sun Jan 22, 2023 10:25 am

I'm a bit confused as the weapon_shovel is clearly a shovel and not a knife.

Image

Edit:
If you just changed the model to a knife and want to show a different name ingame you can change

"name" "Shovel"

to

"name" "Knife"

in the weapon script file.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: hl2:dm weapon shovel

Postby daren adler » Sun Jan 22, 2023 8:40 pm

Kami wrote:I'm a bit confused as the weapon_shovel is clearly a shovel and not a knife.

Image

Edit:
If you just changed the model to a knife and want to show a different name ingame you can change

"name" "Shovel"

to

"name" "Knife"

in the weapon script file.


The smx is for the weapon_shovel, but thats not what the skin is i used, (the shovel has the smx and that was the only way i could get the weapon to hurt npcs). https://steamuserimages-a.akamaihd.net/ugc/2001321225497723904/E7FFC3F41FCFFB8CA6ABC781A98E706526232B46/?imw=5000&imh=5000&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false If i change the name for the weapon on the txt of it, it will not work.
User avatar
Kami
Global Moderator
Posts: 263
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: hl2:dm weapon shovel

Postby Kami » Sun Jan 22, 2023 9:29 pm

The name shown in the weapon wheel is defined in the script file, so changing the smx file will not change the weapon name.

In your first post you showed your script file and it says

"name" "Shovel"

You need to change this to whatever you want the weapon wheel to show.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: hl2:dm weapon shovel

Postby daren adler » Mon Jan 23, 2023 12:19 am

Kami wrote:The name shown in the weapon wheel is defined in the script file, so changing the smx file will not change the weapon name.

In your first post you showed your script file and it says

"name" "Shovel"

You need to change this to whatever you want the weapon wheel to show.


ok will do. ty :smile:

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 20 guests