Results 1 to 3 of 3

Thread: Throwing Knife MOHAA Mod v2 (spawn with knives)

  1. #1

    Default Throwing Knife MOHAA Mod v2 (spawn with knives)

    I fixed some bugs in my Throwing Knife mod and added a new script "give_players_knives.scr" to give all players 1, 2, or 3 knives after spawning, and after dying and respawning.
    Killing people with knives now counts as kills/scorepoints.
    For all multiplayer maps, players spawn with 1 knife by default. There's also 4 hidden knives laying around in each map.
    .pk3 is below (make sure no other "maps/dm" maps/obj" folders are interfering with this mod). Enjoy.

    Code:
    <><><> Throwing Knife MOHAA Mod <><><>
    
    Throwing knives from Call of Duty have now been ported into MOHAA, using the static/screwdriver.tik model as the throwing knife. These knives' origins are placed ideally on top of tables when the map loads initially. 
    Since replacing one of the game's inventory weapons (papers or binoculars) proved harder than expected, these throwing knives are spawned in as trigger_use triggers. Lots of math also went into the thrown knives' angles when they impact a wall or the ground. 
    Once impacted, these knives (screwdrivers) will almost be pointing sharp-end-first into the ground/wall even if thrown from very far away. Any knives that are laying around on the map will be moved back to their map-initial origins after 45 seconds. 
    If the player dies, all held knives are dropped to the ground. If the player switches teams, goes to spectator or leaves, all held knives are moved back to their last known location, before also moving back to their map-initial origins after 45 seconds. 
    
    All players can also spawn with 1, 2, or 3 knives after each respawn if the map script has "exec global/give_players_knives.scr 1". 
    These given knives are removed instead of dropping to the ground if the player carrying them dies (prevents too many knives spawning), but players can still pick them up if they were already thrown. 
     
    Hold USE + Right-click to throw a knife. Players can pick up and hold up to 3 throwing knives. Knives cannot kill teammates. Any knife that hits an enemy player is an instant-kill.
    
    <><><> <><><>
    
    <><><> Parameters & Examples <><><>
    
    - Parameters: name, origin, angles, light.
    - Example: exec global/throwingknife.scr k1 ( 65 125 100 ) ( 0 180 0 ) 0
    
    - Each throwing knife must have its own name ("name" cannot be NIL).
    - The "light" parameter specifies whether to initially illuminate the throwing knives with a green light (0 by default). 
    All knives currently flying in the air have a large red light. All knives that were thrown and now sticking to a wall or the ground have a smaller radius green light.
    
    - "level.knife_resettime = 45" seconds by default. This determines how many seconds until a thrown knife resets back to their map-initial origins/angles.
    
    - "level.knife_velocity = 1400" units per second by default. This determines how fast and how far all knives can be thrown (velocity is not randomized).
    
    - "level.knife_killself = 0" by default. If set to 1, players can kill themselves by throwing their own knife into the air and trying to catch it.
    
    - An example mohdm1.scr map is given in the .pk3 for testing this mod. Two bunkertables, each with two throwing knives, are found next to the bridge and the monument. The two level variables above can be added to further modify this mod. 
    
    <><><> <><><>
    
    <><><> Known Bugs & FAQ <><><>
    
    A thrown knife sometimes sticks inside of a wall. This cannot be fixed. The setsize in models/static/screwdriver.tik already ensures that only the tip of the screwdriver is sticking inside. 
    However, some walls' actual .bsp solid brushes are slightly deeper within the wall, than the wall's visible textures. The throwing knives' green lights ensure that players can still see them even if they're inside walls.
    
    Very rare hitbox-related issue: a player's size is 30 x 30 x 95 (standing) or 30 x 30 x 55 (crounching). A thrown knife measures 42.5 maximum vector_length units from enemy players before killing them since (30)^2 + (30)^2 = (42.5)^2, 
    but very rarely the knife could stick in mid-air to the edge of a player without killing them. If that's the case: CTRL+F in throwingknife.scr, search for the last "42.5", increase that number a few more units. 
    
    If a knife was thrown but nothing appeared, make sure you have the global/math.scr file.
    
    If a knife was thrown but it went straight through players and walls (didn't touch anything), you have another mod whose models/static/screwdriver.tik is loading after this one. Add a few more Z's to this .pk3's filename, so this mod loads last.
    
    <><><> <><><>
    
    <><><> How To Install / Uninstall <><><>
    
    If packed in a .zip, unpack the .pk3 file. Copy the .pk3 file and paste it in the "Medal of Honor/main" folder (same folder as Pak0.pk3, Pak1.pk3, Pak2.pk3).
    
    Uninstall by deleting the .pk3 mod file from the "main" folder.
    
    <><><> Searingwolfe <><><>
    Code:
    <><><> Updates & Bug Fixes <><><>
    
    v1.0 (3-3-2023): - Released.
    
    ---------------
    
    v2.0 (4-2-2023): - Added global/give_players_knives.scr script, allowing all players to spawn with 1, 2, or 3 knives after each time they die or leave spectator. Any script-given knives that a dead player was holding are removed instead of dropped to the ground, 
    instead of spawning more and more knives each time a player dies.
    
    - Killing players with throwing knives now counts as kills/scorepoints and shows who players were killed by.
    
    - If a player throws a knife in the air and it hits himself, the knife's origin is moved to the player's feet instead of floating in the air. Optionally, if "level.knife_killself = 1" in the map's script, then players can kill themselves with their own knives.
    
    - Added 4 throwing knives laying on tables and crates for all MOHAA multiplayer maps (OBJ maps are TDM). Players for all maps will spawn with 1 throwing knife.
    
    - Fixed a spamming "cannot apply self.knivesheld > to a NIL listener" console error whenever a player holding knives leaves the game by first checking if self.knivesheld != NIL.
    
    - Fixed a rare case causing a thrown screwdriver's angles to land pointing backwards (looking horizontally, throwing a knife so it flies long enough to make local.knife.flewlong = 1).
    
    - "Hold USE + Right-click" instructions are printed only one time for each player per map.
    
    <><><> <><><>
    Attached Files Attached Files
    Last edited by Searingwolfe; April 9th, 2023 at 10:30 PM. Reason: Fixed throwingknife.scr, so it stops giving false positives

  2. #2

    Default

    Not really a bump, but I know why Microsoft Defender was flagging throwingknife.scr as a Trojan:Script.

    In the script, lots of comments end with periods, including "30." "130." and "0.1.". I think these were flagged as possible IP addresses since code lines ended with them.

    The periods were removed, and just like that no more false-positive flagging. The script is readable without any issues now.

    I'll make sure to double-check all my scripts before uploading them, but for future reference, avoid ending lines with numbers and periods.

  3. #3

    Default

    Quote Originally Posted by Searingwolfe View Post
    Not really a bump, but I know why Microsoft Defender was flagging throwingknife.scr as a Trojan:Script.

    In the script, lots of comments end with periods, including "30." "130." and "0.1.". I think these were flagged as possible IP addresses since code lines ended with them.

    The periods were removed, and just like that no more false-positive flagging. The script is readable without any issues now.

    I'll make sure to double-check all my scripts before uploading them, but for future reference, avoid ending lines with numbers and periods.
    They must have changed something recently on Microsoft Defender.
    I got another false positive from an old script the other day. I don't remeber which one was or if it contains numbers looking like ip addresses tho

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •