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

0 Members and 3 Guests are viewing this topic.

Offline King_George

  • Sergeant Major
  • *
  • Posts: 233
    • View Profile
  • Nick: King_George
  • Side: Union
Re: *Scripting Thread*
« Reply #210 on: October 21, 2018, 09:21:08 am »

A script which makes it so you either shoot 5 rounds with a musket without having to reload it and then have to reload and it takes a while.

If you wanted it to be a client and server side mod this could be pretty easy, though i'm assuming you would probably just want it server side?

OR you can reload fast. As I said I'm new to the modding scene I did ask for advice; Kanade Tachibana suggested to just boost up the reload speed from the officer, but again, still don't know how to do that either...

You can pretty easily speed up the reload speed with the module system (even to the point of making it almost semi-automatic). So if you are willing to get into that, i'd recommend getting the module system. Other than that, maybe someone else can come up with a better answer than me...

Yeah, if possible server side.

For the module system, I'm sort of into it but not sure what to look for as I have no clue in programming... x)

Offline pete99

  • Sergeant
  • *
  • Posts: 56
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #211 on: October 21, 2018, 12:28:54 pm »
First up, look for header_operations.py, as this is literally like the dictionary for modding M&B. It has all the most important commands in it.

To do what you want to do, you want to go to module_mission_templates.py. The "module" files are the main ones you normally edit. So mission_teamplates is basically covering everything to do with missions, gamemodes, and most importantly triggers. You can check out header_triggers for some triggers you can use, but normally in mission templates you will see something like this:

(1, 0, 0, [],
       [

That is the beginning part of a trigger which fires every 1 second. I put together a quick version of what you probably want, though other people can correct it if i messed something up:

Spoiler
(ti_on_agent_spawn, 0, 0, [],              #Trigger fires every time an agent spawns. (Found in header_triggers).
       [
(multiplayer_is_server),                      #Is server
(try_for_players, ":player_no", 1),       #Loop through all players on the server
(player_get_agent_id, ":player_agent_id", ":player_no"), #Get player's agent id
(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_reload_speed_modifier, ":player_agent_id", 999), #Set reload speed (between 0-1000)
(try_end),
]),
[close]

All these commands are found in the header operations file. Anyway, all you have to do then is find the right place to put this piece of code. Look through the mission templates file using the find tool and you should find different gamemodes looking like this:
Spoiler
(
    "multiplayer_bt",mtf_battle_mode,-1, #battle mode
    "You lead your men to battle.",
    [
[close]
Thats the battle mode section.  Somewhere after this bit:
Spoiler
[
      common_battle_init_banner,

      multiplayer_server_check_polls,
      multiplayer_server_bonuses,
         multiplayer_server_auto_ff,
[close]
You'll see some triggers. Just splice your code in between one of those, compile the module, and you should be done. Then you just upload you mission_templates.txt file onto your server and it will work in battle mode.

....long reply i know...but hopefully it helps get you started. Check out some of the modding tutorials in these and the taleworlds forums on modding for other stuff. The are really helpful.
« Last Edit: October 22, 2018, 03:51:13 am by pete99 »

Offline King_George

  • Sergeant Major
  • *
  • Posts: 233
    • View Profile
  • Nick: King_George
  • Side: Union
Re: *Scripting Thread*
« Reply #212 on: October 22, 2018, 09:54:58 pm »
First up, look for header_operations.py, as this is literally like the dictionary for modding M&B. It has all the most important commands in it.

To do what you want to do, you want to go to module_mission_templates.py. The "module" files are the main ones you normally edit. So mission_teamplates is basically covering everything to do with missions, gamemodes, and most importantly triggers. You can check out header_triggers for some triggers you can use, but normally in mission templates you will see something like this:

(1, 0, 0, [],
       [

That is the beginning part of a trigger which fires every 1 second. I put together a quick version of what you probably want, though other people can correct it if i messed something up:

Spoiler
(ti_on_agent_spawn, 0, 0, [],              #Trigger fires every time an agent spawns. (Found in header_triggers).
       [
(multiplayer_is_server),                      #Is server
(try_for_players, ":player_no", 1),       #Loop through all players on the server
(player_get_agent_id, ":player_agent_id", ":player_no"), #Get player's agent id
(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_reload_speed_modifier, ":player_agent_id", 999), #Set reload speed (between 0-1000)
(try_end),
]),
[close]

All these commands are found in the header operations file. Anyway, all you have to do then is find the right place to put this piece of code. Look through the mission templates file using the find tool and you should find different gamemodes looking like this:
Spoiler
(
    "multiplayer_bt",mtf_battle_mode,-1, #battle mode
    "You lead your men to battle.",
    [
[close]
Thats the battle mode section.  Somewhere after this bit:
Spoiler
[
      common_battle_init_banner,

      multiplayer_server_check_polls,
      multiplayer_server_bonuses,
         multiplayer_server_auto_ff,
[close]
You'll see some triggers. Just splice your code in between one of those, compile the module, and you should be done. Then you just upload you mission_templates.txt file onto your server and it will work in battle mode.

....long reply i know...but hopefully it helps get you started. Check out some of the modding tutorials in these and the taleworlds forums on modding for other stuff. The are really helpful.
Thanks a lot, just now managed to test it and to see it actually works! YEY :D

I am, however, curious about more things if you'd be up for further discussions about following things

1) I'd like to set starting ammo; I've looked up the header_operations.py as you suggested and found the command agent_set_ammo so I'm guessing the command would go something among the lines of:

Spoiler
(try_begin),
(try_for_players, ":player_no", 1),       #Loop through all players on the server
(player_get_agent_id, ":player_agent_id", ":player_no"), #Get player's agent id
(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_ammo, ":player_agent_id", "10"),
(try_end),
[close]

Could you check if that is actually script like ok looking?

Now even if it is correct, I have no clue where to put it... Perhaps in Scripts but still don't know where in Scripts... :S  Oh the struggles...

2) The reload speed actually works in battle mode, but I need it for conquest mode and I tried a bit with using the same script but putting in somewhere after the #headquarters mode but there's a bit more triggers there so I'm a bit stuck :S

Offline pete99

  • Sergeant
  • *
  • Posts: 56
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #213 on: October 23, 2018, 12:30:30 am »
For headquarters mode it should be similar. Look for the section where you see triggers written such as this for an example:

(ti_on_agent_spawn, 0, 0, [],
       [
and splice your code somewhere in that section, though check not to put it before a ]),  as that would be interrupting another trigger script. I think the agent set ammo should work, though check that the "10" doesn't have "" around it, just have a plain 10. Other than that, place it in the mission templates file same way you did for the other one.

For this code though, you may want to change a few things, as i think every time an agent spawns it will give all the players 10 ammo...which you probably don't want. Again, if i'm wrong someone can correct me, but I think it should be something like this:

Spoiler
(ti_on_agent_spawn, 0, 0, [],              #Trigger fires every time an agent spawns. (Found in header_triggers).
       [
(multiplayer_is_server),                      #Is server
(store_trigger_param_1, ":player_agent_id"),  #This stores the specific spawned agent id.

(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_ammo, ":player_agent_id", 10),
(try_end),
]),
[close]

I think this should work, as it will only take effect on the recently spawned players...though probably best to test it on the server and see how it goes since i'm not 100%. Hope this helps.

Offline King_George

  • Sergeant Major
  • *
  • Posts: 233
    • View Profile
  • Nick: King_George
  • Side: Union
Re: *Scripting Thread*
« Reply #214 on: October 23, 2018, 01:09:44 pm »
For headquarters mode it should be similar. Look for the section where you see triggers written such as this for an example:

(ti_on_agent_spawn, 0, 0, [],
       [
and splice your code somewhere in that section, though check not to put it before a ]),  as that would be interrupting another trigger script. I think the agent set ammo should work, though check that the "10" doesn't have "" around it, just have a plain 10. Other than that, place it in the mission templates file same way you did for the other one.

For this code though, you may want to change a few things, as i think every time an agent spawns it will give all the players 10 ammo...which you probably don't want. Again, if i'm wrong someone can correct me, but I think it should be something like this:

Spoiler
(ti_on_agent_spawn, 0, 0, [],              #Trigger fires every time an agent spawns. (Found in header_triggers).
       [
(multiplayer_is_server),                      #Is server
(store_trigger_param_1, ":player_agent_id"),  #This stores the specific spawned agent id.

(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_ammo, ":player_agent_id", 10),
(try_end),
]),
[close]

I think this should work, as it will only take effect on the recently spawned players...though probably best to test it on the server and see how it goes since i'm not 100%. Hope this helps.

Everything went according to the grand plan except that I don't get 10 but still get 30 bullets... :S   

Maybe put -20 as value so I effectively get 10?... xD

EDIT: Putting -20 doesn't work :(
« Last Edit: October 23, 2018, 02:03:57 pm by King_George »

Offline Lilja Adolfsdóttir

  • Colonel
  • *
  • Posts: 1491
  • Great Sister of Minisiege EU_Commander & Mininaval
    • View Profile
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #215 on: October 23, 2018, 04:46:37 pm »
header:
(agent_set_ammo,<agent_id>,<item_id>,<value>),

so instead of
(agent_set_ammo, ":player_agent_id", 10),

you write (only working for musket ammunition, for other ammunition add the wanted ammo (rockets, grenades, pistolammo ...):
(agent_set_ammo, ":player_agent_id", "itm_bullets", 10),
„Im Verein mit den Mir verbündeten Herrschern hatte ich unseren Feinden vorgeschlagen, alsbald in Friedensverhandlungen einzutreten. Die Feinde haben Meinen Vorschlag abgelehnt. Ihr Machthunger will Deutschlands Vernichtung. Der Krieg nimmt seinen Fortgang! Vor Gott und der Menschheit fällt den feindlichen Regierungen allein die schwere Verantwortung für alle weiteren furchtbaren Opfer zu, die Mein Wille euch hat ersparen wollen. In der gerechten Empörung über der Feinde anmaßenden Frevel, in dem Willen, unsere heiligsten Güter zu verteidigen und dem Vaterlande eine glückliche Zukunft zu sichern, werdet ihr zu Stahl werden. Unsere Feinde haben die von Mir angebotene Verständigung nicht gewollt. Mit Gottes Hilfe werden unsere Waffen sie dazu zwingen!“ gez. Wilhelm, I. R.

Offline King_George

  • Sergeant Major
  • *
  • Posts: 233
    • View Profile
  • Nick: King_George
  • Side: Union
Re: *Scripting Thread*
« Reply #216 on: October 24, 2018, 10:51:07 pm »
Spoiler
For headquarters mode it should be similar. Look for the section where you see triggers written such as this for an example:

(ti_on_agent_spawn, 0, 0, [],
       [
and splice your code somewhere in that section, though check not to put it before a ]),  as that would be interrupting another trigger script. I think the agent set ammo should work, though check that the "10" doesn't have "" around it, just have a plain 10. Other than that, place it in the mission templates file same way you did for the other one.

For this code though, you may want to change a few things, as i think every time an agent spawns it will give all the players 10 ammo...which you probably don't want. Again, if i'm wrong someone can correct me, but I think it should be something like this:

Spoiler
(ti_on_agent_spawn, 0, 0, [],              #Trigger fires every time an agent spawns. (Found in header_triggers).
       [
(multiplayer_is_server),                      #Is server
(store_trigger_param_1, ":player_agent_id"),  #This stores the specific spawned agent id.

(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_ammo, ":player_agent_id", 10),
(try_end),
]),
[close]

I think this should work, as it will only take effect on the recently spawned players...though probably best to test it on the server and see how it goes since i'm not 100%. Hope this helps.

header:
(agent_set_ammo,<agent_id>,<item_id>,<value>),

so instead of
(agent_set_ammo, ":player_agent_id", 10),

you write (only working for musket ammunition, for other ammunition add the wanted ammo (rockets, grenades, pistolammo ...):
(agent_set_ammo, ":player_agent_id", "itm_bullets", 10),
[close]

Well thanks to both, managed to fix it with the "itm_bullets" and now it works! :D

Offline King_George

  • Sergeant Major
  • *
  • Posts: 233
    • View Profile
  • Nick: King_George
  • Side: Union
Re: *Scripting Thread*
« Reply #217 on: October 31, 2018, 03:44:28 pm »
For headquarters mode it should be similar. Look for the section where you see triggers written such as this for an example:

(ti_on_agent_spawn, 0, 0, [],
       [
and splice your code somewhere in that section, though check not to put it before a ]),  as that would be interrupting another trigger script. I think the agent set ammo should work, though check that the "10" doesn't have "" around it, just have a plain 10. Other than that, place it in the mission templates file same way you did for the other one.

For this code though, you may want to change a few things, as i think every time an agent spawns it will give all the players 10 ammo...which you probably don't want. Again, if i'm wrong someone can correct me, but I think it should be something like this:

Spoiler
(ti_on_agent_spawn, 0, 0, [],              #Trigger fires every time an agent spawns. (Found in header_triggers).
       [
(multiplayer_is_server),                      #Is server
(store_trigger_param_1, ":player_agent_id"),  #This stores the specific spawned agent id.

(agent_is_active, ":player_agent_id"),
(agent_is_alive, ":player_agent_id"),    #Check the agent is alive
(agent_set_ammo, ":player_agent_id", 10),
(try_end),
]),
[close]

I think this should work, as it will only take effect on the recently spawned players...though probably best to test it on the server and see how it goes since i'm not 100%. Hope this helps.

Btw, if you want to invite for 33rd conquest event today with the scripts, feel free to add me on steam and we can figure something out ;)

Offline Freestyler

  • Donator
  • *
  • Posts: 1795
  • Nr.13❤️
    • View Profile
  • Nick: IceAngel
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #218 on: November 07, 2018, 01:16:25 pm »
Guys i am Interessted at Server Side skins (Script) can any Help me?

Offline pete99

  • Sergeant
  • *
  • Posts: 56
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #219 on: November 11, 2018, 01:50:42 am »
What exactly are you looking for? Actual new skins, or a way to give/equip current uniforms for players?

Offline Freestyler

  • Donator
  • *
  • Posts: 1795
  • Nr.13❤️
    • View Profile
  • Nick: IceAngel
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #220 on: November 11, 2018, 11:02:46 pm »
What exactly are you looking for? Actual new skins, or a way to give/equip current uniforms for players?
a method/Script for Server Side skins (no skins)

Offline pete99

  • Sergeant
  • *
  • Posts: 56
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #221 on: November 12, 2018, 12:21:40 am »
I have a method using the new custom menu option if you are interested? Basically just press a key and it brings up a menu of uniforms/items you can equip.

Offline Freestyler

  • Donator
  • *
  • Posts: 1795
  • Nr.13❤️
    • View Profile
  • Nick: IceAngel
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #222 on: November 12, 2018, 06:18:27 am »
I have a method using the new custom menu option if you are interested? Basically just press a key and it brings up a menu of uniforms/items you can equip.
yes Interessted but it is possible to Change Uniforms  in the Script?

Offline pete99

  • Sergeant
  • *
  • Posts: 56
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #223 on: November 12, 2018, 11:00:43 am »
Yes you can change to whatever uniforms I have listed there. I have quite a few added (not all the uniforms as that would be a lot) but quite a lot of them. Here's a couple of screenshots to give you an idea of what I've done:

Press a button and menu comes up.
Spoiler
[close]
Press number for clothes tab.
Spoiler
[close]
Can click into hats, torso or legs sections.
Spoiler
[close]
Select the item you want to equip yourself with and you're done.
Spoiler
[close]