DOD Throw Knife to Weaponbox
VERSION "16 MARCH 2023"
AUTHOR "[America][TheVaskov]"
Description
Press the +attack2 (right mouse button) to throw a knife or a spade and kill the enemy
ChatGPT:
This code is a plugin for the Day of Defeat game in amxx 1.8.2 Goldsrc. It is designed to create effects and sounds when using the knife in the game. It also changes the weapon box model to match the knife being used. The code also handles collisions of the knife with players and other objects in the game, including breakable objects.
- Weaponbox retuned to flying knife
- Spakles when spade\kinife hit the wall in hands or in air
- Bloodpuff when kill player
- Hud kill info works good and correctly
- Update frags and kills is scoreboard (TAB)
- Correctly orientation of rotating , blade to front
- You can set private models for throw knife.
- When knife flyis, we hear roation sound.
CVAR:
- Stack in wall for 2 seconds yes = 1; no = 0
- additional blood splashes yes = 1; no = 0
- Pitch vector corrector Z-axis ~200 is good. 0 = parallel to ground
- Velocity of throw 500 = 3 metres ; 1800 = 30 metres
- Rotation speed of spade/knife ~800 is good
To Do- Need to Make hands empty after throw, cause now it autochanges to primary weapon
- REgister sever config Friendly fire .. and mke FF knife attack
- DONE 1.7: Turn off drop weaponbox when press G
- DONE 1.7: Need to register touch breakable objects to destroy or make sparkle like from wall-toching
New is version 1.5: - Spakles works better in spawn and some maps ( MSG_PVS replaced to MSG_ALL )
- Cleared some functions Deleted: pev(flyknifeid, pev_globalname, status,31
- Added new cvars
New is version 1.6: july 2022
- When knife flyis, we hear roation sound.
New is version 1.7: november 2022
- Turn off drop weaponbox when press G
- Knife destroys windows, woods, but not destroy walls in dod_chrlie.bsp and another maps.
- Better perfomance, I did blocked some func calls, for clear "client_prethink"
New is version 1.8: March-April 2022
- Better perfomance: Full turn-off ClientPrethink. Now: Ham_Item_PreFrame. it run only when knife in arms , and we don't need asking system do we have knife now , how it was in previus versions in CurWeapon_P.
- Add trail for flying knife
Need fix: It is necessary to continue the definition of breaking objects, now the knife can break the wood of the door, only if they do not have the TARGET parameter. the map is so old that there is no target parameter in the very essence of the glass, so there is nothing to turn to for verification. (Spawn Allies window)
amxx profiler info vers 1.7 (OLD) well I will update later this info
Code:
date: Sat Nov 19 13:21:08 2022 map: 1boom5
type | name | calls | time / min / max
-------------------------------------------------------------------
n | get_user_msgid | 2 | 0.000001 / 0.000000 / 0.000000
n | precache_model | 5 | 0.001688 / 0.000256 / 0.000465
n | precache_sound | 4 | 0.000007 / 0.000001 / 0.000004
n | register_plugin | 1 | 0.000002 / 0.000002 / 0.000002
n | register_cvar | 5 | 0.000033 / 0.000001 / 0.000008
n | RegisterHam | 4 | 0.000100 / 0.000008 / 0.000041
n | register_forward | 3 | 0.000006 / 0.000002 / 0.000003
n | register_event | 1 | 0.000005 / 0.000005 / 0.000005
n | pev | 4708 | 0.002845 / 0.000000 / 0.000023
n | get_user_weapon | 2 | 0.000002 / 0.000001 / 0.000001
n | client_cmd | 2 | 0.000017 / 0.000008 / 0.000009
n | is_valid_ent | 2 | 0.000016 / 0.000001 / 0.000015
n | SetHamReturnInteger | 2 | 0.000001 / 0.000000 / 0.000001
n | is_user_alive | 42 | 0.000010 / 0.000000 / 0.000001
n | set_pev | 26 | 0.000012 / 0.000000 / 0.000002
n | emit_sound | 7 | 0.000061 / 0.000002 / 0.000015
n | get_pcvar_num | 8 | 0.000002 / 0.000000 / 0.000000
n | velocity_by_aim | 2 | 0.000002 / 0.000001 / 0.000001
n | vector_to_angle | 2 | 0.000004 / 0.000002 / 0.000002
n | engfunc | 5 | 0.000029 / 0.000002 / 0.000012
n | random_float | 2 | 0.000001 / 0.000000 / 0.000001
n | set_task | 6 | 0.000025 / 0.000003 / 0.000005
n | unregister_forward | 2 | 0.000004 / 0.000000 / 0.000004
n | equal | 56 | 0.000016 / 0.000000 / 0.000001
n | entity_get_vector | 42 | 0.000030 / 0.000000 / 0.000001
n | message_begin | 2 | 0.000002 / 0.000001 / 0.000001
n | write_byte | 2 | 0.000001 / 0.000001 / 0.000001
n | write_coord | 6 | 0.000001 / 0.000000 / 0.000000
n | message_end | 2 | 0.000001 / 0.000001 / 0.000001
n | entity_get_string | 1 | 0.000000 / 0.000000 / 0.000000
n | ExecuteHam | 1 | 0.000107 / 0.000107 / 0.000107
n | client_print | 1 | 0.000005 / 0.000005 / 0.000005
n | is_user_connected | 41 | 0.000011 / 0.000000 / 0.000001
n | pev_valid | 7 | 0.000003 / 0.000000 / 0.000001
p | ReTuneMovetype | 2 | 0.000002 / 0.000001 / 0.000001
p | ThrowSoundRepeat | 4 | 0.000006 / 0.000001 / 0.000002
p | WeaponBox_Spawn | 5 | 0.000004 / 0.000001 / 0.000001
p | Weaponbox_Retune | 2 | 0.000008 / 0.000003 / 0.000005
p | client_PreThink | 4526 | 0.003369 / 0.000000 / 0.000004
p | client_connect | 2 | 0.000001 / 0.000000 / 0.000001
p | flyknife_touch | 64 | 0.000145 / 0.000000 / 0.000006
p | func_WeaponDrop | 2 | 0.000002 / 0.000001 / 0.000001
p | plugin_init | 1 | 0.000003 / 0.000003 / 0.000003
p | plugin_precache | 1 | 0.000003 / 0.000003 / 0.000003
f | FVecIVec | 42 | 0.000030 / 0.000000 / 0.000004
f | ReTuneMovetype | 1 | 0.000001 / 0.000001 / 0.000001
17 natives, 2 public callbacks, 12 function calls were not executed.
//// Function list
/*
plugin_precache
plugin_init
player_Spawn_P // block drop knife by G button (drop command)
DeathMsg_P // block drop knife by G button (drop command)
CurWeapon_P // parse knife name for drop this is fix for drop only knife without pistol or else.
client_connect // block drop knife by G button (drop command)
client_PreThink // oldway +attack2 to throwknife
Ham_Weapon_P // +attack to throwknife
WeaponBox_Drop_P // accepting for drop knife
WeaponBox_Spawn // register weaponbox with knife to make it throw
Weaponbox_Retune // set movetype, new classname, set rotation, set velocity
WeaponBox_Touch // register touch
Particle_Fx // fx when you stab the wall hands with knife to make sparkle :D
WeaponBox_Unstuck // Back movetype after stack in wall
WeaponBox_Sound // Repeats rotation sound whe knife flyes
*/
-----------
I've not intrested in anoter HL mods (CS , TF ..... ) only DOD