Results 1 to 10 of 10

Thread: NPCS default weapons management

  1. #1

    Default NPCS default weapons management

    Dear all, i'm new in this forum, if a question like mine has already been asked or is in the wrong section please let me know.

    I started an editing project on MOHAA, specifically on Breakthrough. Does anyone in the forum know where and how to manage the default weapons for NCPs in single player maps? I tried to search in the .scr files and .bsp files but I could not find anything that could help me, thanks.

  2. #2

    Default

    I don't know scripting or mapping, but I think one way is to edit the map and replace the original NPCs with the NPCs that are using your guns and settings.
    To edit the maps (.bsp files) you need MoHRadiant tool.

    Another way I saw in youtube is by manualy spawning NPC's through the console and set their settings there: https://www.youtube.com/watch?v=TAokNBps7TA
    https://www.youtube.com/watch?v=kL3LRDzvnwo

    You could possibly use the same commands to spawn NPCs with your settings on the map's .scr file. by writting something like '$player stufftext spawn model/human/adolf_hatler.tik weapon "jonson launcher" health 999 accuracy 1000 coords x y z' or allong those lines.

    I hope this provides you some usefull information and good luck.
    Last edited by Soares93; September 4th, 2021 at 07:14 PM.

  3. #3

    Default

    Quote Originally Posted by ohifra1987 View Post
    Dear all, i'm new in this forum, if a question like mine has already been asked or is in the wrong section please let me know.

    I started an editing project on MOHAA, specifically on Breakthrough. Does anyone in the forum know where and how to manage the default weapons for NCPs in single player maps? I tried to search in the .scr files and .bsp files but I could not find anything that could help me, thanks.
    On the Pak1 on the global folder theres one script called weapon where you have all the weapons on the game but im not sure if his used on SP or not to set a weapon on the AI.

    If you are in a project to edit alot of things on the game i suggest you to download this file because have alot of commands of the game where you can use on the SP:
    Attached Files Attached Files

  4. #4

    Default

    Quote Originally Posted by ohifra1987 View Post
    Does anyone in the forum know where and how to manage the default weapons for NCPs in single player maps? I tried to search in the .scr files and .bsp files but I could not find anything that could help me, thanks.
    I suppose it depends what you mean by default weapons. MOHAA actually does have a concept of default weapons for AI, but it depends on how they are spawned in script or placed in Radiant. When placing them in Radiant, you have an option of selecting 'default', and the game reads the AI .tik files to determine what the weapon should be. For example, NCO models tend to have MP40s as their default weapon.

    For example, in maintt/pak1.pk3/models/human/german_afrika_NCO.tik


    server
    {
    classname Actor
    setsize "-16 -16 0" "16 16 92"
    german
    health 100
    weapon "MP40" //<----- default weapon

    // Make him mumble but not breathe steam
    exec global/breathe.scr 0 1

    // Set up the helmet for popping off
    // <model to spawn> <speed to throw it at> <damage multiplier for helmet shots> <surface to turn off>
    sethelmet "models/gear/german_dakcap.tik" 200 4 "hat"
    }


    That file is in maintt, but because BT is an expansion, only some of the AI tiks are in there. You'd need to edit the rest of them in main if you wanted the Wehrmacht NCO for example.

    So you could change the weapon property to be another weapon, but this will only change weapons of the AI that were placed via Radiant with 'default' selected or spawned in the map without a weapon specified in the script. It won't change the guns for the individual AI given a specific weapon, such as the snipers in Sniper Town as an example.

    So you could try modifying the above tik files and see if that is good enough. I can't be certain that you won't run into any issues doing this, but it's one of the safest ways to do it, as you won't override special AI that are meant to have a specific weapon for a level to function.

    There are other ways to force AI to have weapons (other than messing with map scripts), such as executing a script when an actor spawns. You could do this by modifying every human tik like above, or you could find the file models/human/new_generic_human.tik and add an init block (underneath setup) like so:


    setup
    {
    ischaracter
    }

    init
    {
    server
    {
    exec somefolder/somescript.scr
    }
    }


    And in that file have a script like so:


    main:
    switch (self.model)
    {
    case "models/human/german_afrika_NCO.tik":
    case "models/human/german_wehrmact_NCO.tik":
    self weapon "stg44"
    break
    case "models/human/german_wehrmact_soldier.tik":
    self weapon "mp40"
    break
    }
    end


    And just add the models you wish to change. This works because every AI tik includes new_generic_human.tik. Just means you can handle it in a single file rather than messing with them all. This example will also override those given a specific weapon in Radiant, and also those spawned in the scripts with a weapon command supplied as part of the spawn command. It won't stop changes made later on however.

    Also bear in mind that AI have different equipment loadouts for each gun, and stupidly the developers left out the loadouts for MP40s on german_wehrmact_soldier.tik so they run around without a helmet or any equipment like idiots. I guess one developer/animator/modeller thought normal soldiers shouldn't have MP40s, but then the scripters put them in the maps anyway. You can add those in yourself if needs be.

    I wouldn't recommend changing global/weapon.scr as the engine calls this script every time a gun is given to an AI, so it'll just call it again when changing their weapon and you can run into all sorts of issues.
    Last edited by 1337Smithy; September 5th, 2021 at 04:18 AM.

  5. #5

    Default

    Hi Guys,
    thank you all for the answers and sorry for the delay with my answer.
    Unfortunately, none of the methods highlighted worked. I'll try with radiant, in this regard can you tell me some topic in the forum that can help me with the use of the tool?

  6. #6

    Default

    When I mentioned Radiant (level editor for mohaa), I was referring to how the developers originally placed the AI when they made the maps. It isn't feasible to use Radiant to change them all as you'd have to decompile, fix the maps, and also change the AI weapons.

    The methods I mentioned do work, as I've done similar stuff before. But it won't work for all, as AI are given weapons by various means at various times, and depends on the level and the individual designer's technique.

    Which options did you try and what maps did you test them on?

  7. #7

    Default

    My modification target is this model found in medal of honor Breakthrough: Sc_Al_Brit_Cmd.tik, this character is found in maps e2l1 and e2l2.

    As you can see from the images it was very easy to modify the .tik file in order to change the characteristics of the model. The problem is the default weapon, the character in fact uses the vickers machine gun, I would like to modify it with the Thompson.

    Al brit.jpg

    Below you will find the inside of the .tik file, even in this document it is said that the model is equipped with the M1 garand.

    Al brit doc.jpg

  8. #8

    Default

    Ah, yep, so you're trying to change the gun of a 'main' character, rather than your average AI, so they are more likely to have their weapons defined in the level scripts, usually some point after they have spawned in the game (so changing their .tik file is useless).

    in maps/e2l2.scr, for example, there is an initPlayer function called on map start which changes the AI's gun (first line). In this case the AI has the (target)name of lyndon. The dollar before the name represents a targetname operator. The string that follows it is their targetname. In this case, the name that was given to them in Radiant.

    You can change the weapon in the quote to thompson to change his gun at start. However, as mohaa SP is heavily scripted, especially friendly AI, it is often the case that the weapon is given to AI multiple times in a mission. In fact, quite often the character you see in one scene is actually a new AI in another, as the originals can be despawned when not in use. I did a 'find in files' for the e2l2 scripts and couldn't find any more references to 'vickers' so you might be safe changing that one line.



    //------------------------------------------------------------------------------
    initPlayer:
    //------------------------------------------------------------------------------

    $lyndon gun "vickers" <-------- change this

    exec global/loadout.scr

    thread global/items.scr::add_item "explosives" noprint

    $allhell_vehicles nottriggerable
    $spawnlyndon nottriggerable

    //init the warehouse door
    $warehousedoor sound_open_start gate_iron_open1
    $warehousedoor sound_open_end door_metal_open_stop1
    $warehousedoor sound_close_start gate_iron_open1
    $warehousedoor sound_close_end door_metal_open_stop1


    end


    For BT, you will find the main script in maintt/maps folder (pak1.pk3), and there are subsequent 'gag' scripts residing in maps/<mapname> folder that typically control each scene in a given level. As you can see, you will find the scripters/designers rarely put code in the right place. initPlayer is a terrible name for a function that changes more than the player.
    Last edited by 1337Smithy; November 11th, 2021 at 01:32 PM.

  9. #9

    Cool

    Quote Originally Posted by 1337Smithy View Post
    Ah, yep, so you're trying to change the gun of a 'main' character, rather than your average AI, so they are more likely to have their weapons defined in the level scripts, usually some point after they have spawned in the game (so changing their .tik file is useless).

    in maps/e2l2.scr, for example, there is an initPlayer function called on map start which changes the AI's gun (first line). In this case the AI has the (target)name of lyndon. The dollar before the name represents a targetname operator. The string that follows it is their targetname. In this case, the name that was given to them in Radiant.

    You can change the weapon in the quote to thompson to change his gun at start. However, as mohaa SP is heavily scripted, especially friendly AI, it is often the case that the weapon is given to AI multiple times in a mission. In fact, quite often the character you see in one scene is actually a new AI in another, as the originals can be despawned when not in use. I did a 'find in files' for the e2l2 scripts and couldn't find any more references to 'vickers' so you might be safe changing that one line.



    //------------------------------------------------------------------------------
    initPlayer:
    //------------------------------------------------------------------------------

    $lyndon gun "vickers" <-------- change this

    exec global/loadout.scr

    thread global/items.scr::add_item "explosives" noprint

    $allhell_vehicles nottriggerable
    $spawnlyndon nottriggerable

    //init the warehouse door
    $warehousedoor sound_open_start gate_iron_open1
    $warehousedoor sound_open_end door_metal_open_stop1
    $warehousedoor sound_close_start gate_iron_open1
    $warehousedoor sound_close_end door_metal_open_stop1


    end


    For BT, you will find the main script in maintt/maps folder (pak1.pk3), and there are subsequent 'gag' scripts residing in maps/<mapname> folder that typically control each scene in a given level. As you can see, you will find the scripters/designers rarely put code in the right place. initPlayer is a terrible name for a function that changes more than the player.

    Hi, it works ! please see attachment, many thx
    Attached Images Attached Images

  10. #10

    Default

    Good to hear!

Posting Permissions

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