Author Topic: *Scripting Thread*  (Read 89069 times)

0 Members and 1 Guest are viewing this topic.

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #90 on: January 18, 2016, 01:46:34 am »
Hi!

My regiment has recently got it's own server and I was thinking about ways to help with training. I was hoping someone could help me with how to create a script to force one team to be only one regiment selection.

I basically want it so that I can have players on Team 1 and bots on Team 2 which can be forced to all be Partisans for general practice or cavalry for anti-cavalry practice.

Any help would be great, I have no experience with scripting!

Cheers

Clash

Both things can be done and are light/medium weight in difficulty, but if you want to script them yourself, since you mention you have no experience in scripting, you have to start with basic M&B modding tutorials, as in how to setup module system and compile it into game files, so you have something to work on.
https://www.fsegames.eu/forum/index.php?topic=3481.0
https://www.fsegames.eu/forum/index.php?topic=11836.0
Since you want to make server-side modification it gets a bit complicated, for testing purposes it is best to have local test server, ie a dedicated server running on your PC in which you will overwrite Modules/Napoleonic Wars/ .txt files with the ones you compiled, while using unmodified game version as client (client=your game that logs on to server) so you can test if server is compatible with standard NW client and acting as it should.

Offline Clashinnit

  • Volunteer
  • *
  • Posts: 11
    • View Profile
Re: *Scripting Thread*
« Reply #91 on: January 18, 2016, 09:20:58 pm »
Thanks for the reply!

Is there any way to simply install these scripts without going through the process of writing the scripts yourself? I've never really modded any games before.

Offline tired

  • First Lieutenant
  • *
  • Posts: 1082
    • View Profile
  • Nick: [BBG] tired
  • Side: Neutral
Re: *Scripting Thread*
« Reply #92 on: April 09, 2016, 04:32:42 am »
Is there a way when you spawn bots, that you limit their classes? I want to limit spawned bits on a couple of maps to just infantry only. I think a couple of bot servers can already limit bots to infantry only.  I would be grateful for any help

Sent from my SM-G900V using Tapatalk


Offline Pio

  • Sergeant
  • *
  • Posts: 47
    • View Profile
    • my steam profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #93 on: April 09, 2016, 10:09:38 pm »
One way would be to edit module_items.py and remove horses from cav troops equipment. It wouldn't really disable cav, but bots would spawn without horses.

Offline tired

  • First Lieutenant
  • *
  • Posts: 1082
    • View Profile
  • Nick: [BBG] tired
  • Side: Neutral
Re: *Scripting Thread*
« Reply #94 on: April 10, 2016, 04:01:00 pm »
Is there a way to associate a specific py file with a specific map? Or what about having only infantry bots spawn and only melee charge instead of use weapons at will

Sent from my SM-G900V using Tapatalk


Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #95 on: April 10, 2016, 04:34:56 pm »
Is there a way to associate a specific py file with a specific map?

This would work in module_scripts and module_mission_templates
Code
(store_current_scene, ":cur_scene"),
        (try_begin),
        (eq, ":cur_scene", "scn_mp_custom_map_1"), #is it custom map 1
            #your lines of code here:
            #-do something-
        (try_end), #map 1 block end


Or what about having only infantry bots spawn and only melee charge instead of use weapons at will

Possible but not as simple as commenting out some bots from module_troops, as there are many checks throughout the rest of the code which depend on these troops being defined, you must either alter these checks (I'd expect a lot of work if you're commenting out all cav bots) or think of something else. I don't think a novice can implement previous solution without causing some horrible and impossible to track bugs. Agent_spawned_common script in scripts.py is a good place to manipulate the equipment of each agent just before it gets spawned, just make sure you are adding code to the block which applies to server side of things. You would have to add checks if agents is a bot, not a horse, and is a cav class, and then do stuff with it's equipment like remove mount and change clothes and weapons. For an example of equipment altering code you can look for treasure chest code, the one which swaps your hat with pirate hat.

As for melee charge there is a simple hack, just remove their ammo from their equipment in module_troops and they will never use ranged mode as bots never fire the one bullet they have. Or remove the ammo in that common spawn script, that solution would require less work and would give you control to decide under which conditions the script will activate, as maybe you want to have normal shooting bots for some other uses on the same server.
« Last Edit: April 10, 2016, 04:36:52 pm by Grozni »

Offline tired

  • First Lieutenant
  • *
  • Posts: 1082
    • View Profile
  • Nick: [BBG] tired
  • Side: Neutral
Re: *Scripting Thread*
« Reply #96 on: April 10, 2016, 05:07:40 pm »
Is there a way to associate a specific py file with a specific map?

This would work in module_scripts and module_mission_templates
Code
(store_current_scene, ":cur_scene"),
        (try_begin),
        (eq, ":cur_scene", "scn_mp_custom_map_1"), #is it custom map 1
            #your lines of code here:
            #-do something-
        (try_end), #map 1 block end


Or what about having only infantry bots spawn and only melee charge instead of use weapons at will

Possible but not as simple as commenting out some bots from module_troops, as there are many checks throughout the rest of the code which depend on these troops being defined, you must either alter these checks (I'd expect a lot of work if you're commenting out all cav bots) or think of something else. I don't think a novice can implement previous solution without causing some horrible and impossible to track bugs. Agent_spawned_common script in scripts.py is a good place to manipulate the equipment of each agent just before it gets spawned, just make sure you are adding code to the block which applies to server side of things. You would have to add checks if agents is a bot, not a horse, and is a cav class, and then do stuff with it's equipment like remove mount and change clothes and weapons. For an example of equipment altering code you can look for treasure chest code, the one which swaps your hat with pirate hat.

As for melee charge there is a simple hack, just remove their ammo from their equipment in module_troops and they will never use ranged mode as bots never fire the one bullet they have. Or remove the ammo in that common spawn script, that solution would require less work and would give you control to decide under which conditions the script will activate, as maybe you want to have normal shooting bots for some other uses on the same server.
Omg wow thanks, I'll play around with these

Sent from my SM-G900V using Tapatalk


Offline tired

  • First Lieutenant
  • *
  • Posts: 1082
    • View Profile
  • Nick: [BBG] tired
  • Side: Neutral
Re: *Scripting Thread*
« Reply #97 on: April 29, 2016, 10:35:48 pm »
I've seen a server that sends a message on a server when an admin joins, like "Behave, an admin is here". Would there be a way to do the same thing but play a small sound file instead?

Sent from my SM-G900V using Tapatalk


Offline Pio

  • Sergeant
  • *
  • Posts: 47
    • View Profile
    • my steam profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #98 on: April 30, 2016, 02:08:56 am »
Yes, to do that use:
Code
(call_script,"script_multiplayer_server_play_sound_at_position",":sound_id"),
where sound_id is an id of one of the sounds that exists in the game. The script uses pos56 as a position where the sound will be played. You can only use sounds that already exist in the game.

Offline TheDoctor

  • Sergeant Major
  • *
  • Posts: 497
  • UB_1stDE_LtCol_TheDoctor Former Col of 11thMS
    • View Profile
  • Nick: CaptainArtard or AndyTheIrishmen
  • Side: Union
Re: *Scripting Thread*
« Reply #99 on: May 04, 2016, 04:48:35 am »
Anyone got a script that would add Musicians / other things to commander battle in NaS.
So what you are saying is, you have a tactile mind of a potato...
--Burnout

Offline Lilja Mariasdóttir

  • Colonel
  • *
  • Posts: 2015
  • Ist ein Schaf in einer Tasse
    • View Profile
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #100 on: May 11, 2016, 03:55:15 pm »
Anyone got a script that would add Musicians / other things to commander battle in NaS.
Is that even possible?
Seehofer schafft das Heer ab.

Offline NickyJ

  • Major General
  • **
  • Posts: 3560
  • The Twilight Zone
    • View Profile
  • Nick: LIR_Lieut_NickyJ
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #101 on: May 11, 2016, 05:27:46 pm »
The EU_Commander_Battle server for NW does that, so it is possible. Not sure how, though.

Offline Lilja Mariasdóttir

  • Colonel
  • *
  • Posts: 2015
  • Ist ein Schaf in einer Tasse
    • View Profile
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #102 on: May 11, 2016, 05:34:14 pm »
Wow, this must be a really unique server. Are those musicians even playing music, or just decoration?
Seehofer schafft das Heer ab.

Offline NickyJ

  • Major General
  • **
  • Posts: 3560
  • The Twilight Zone
    • View Profile
  • Nick: LIR_Lieut_NickyJ
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #103 on: May 11, 2016, 07:21:25 pm »
They do play music, usually one or two per regiment. Color bearers are also spawned in. Whoever made it did a very good job.

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #104 on: May 17, 2016, 01:47:17 am »
Adding working musicians and flag bearer bots to NW commander battle server is not that hard, it is actually easy for a good modder, I did it for fun and it took me about four hours. The script uses proper musician and flag-bearer type for all units. Even for cavalry, though you may want to turn that off due to practical reasons. Also it does not interfere with other game types in any way, for example it does not alter typical equipment for bots, though if you host a serious CB server you shouldn't be concerned about that.

Anyone who wants this script, and can prove that he hosts a serious CB server, can send me a PM and we'll work something out. Unlike a certain modder, I will not insist on having my name written all over the server and spammed within announcements each couple minutes.

As for NaS, it is not possible unless developers implement it or make their module system public.
« Last Edit: May 17, 2016, 01:53:16 am by Grozni »