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

0 Members and 1 Guest are viewing this topic.

Offline King_George

  • Second Lieutenant
  • *
  • Posts: 519
    • 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

  • First Sergeant
  • *
  • Posts: 71
  • 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

  • Second Lieutenant
  • *
  • Posts: 519
    • 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

  • First Sergeant
  • *
  • Posts: 71
  • 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

  • Second Lieutenant
  • *
  • Posts: 519
    • 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 Mariasdóttir

  • Colonel
  • *
  • Posts: 2013
  • Ist ein Schaf in einer Tasse
    • 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),
Seehofer schafft das Heer ab.

Offline King_George

  • Second Lieutenant
  • *
  • Posts: 519
    • 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

  • Second Lieutenant
  • *
  • Posts: 519
    • 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: 2486
    • View Profile
  • Nick: Freestyler
  • Side: Union
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

  • First Sergeant
  • *
  • Posts: 71
  • 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: 2486
    • View Profile
  • Nick: Freestyler
  • Side: Union
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

  • First Sergeant
  • *
  • Posts: 71
  • 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: 2486
    • View Profile
  • Nick: Freestyler
  • Side: Union
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

  • First Sergeant
  • *
  • Posts: 71
  • 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]

Offline tired

  • First Lieutenant
  • *
  • Posts: 1082
    • View Profile
  • Nick: [BBG] tired
  • Side: Neutral
Re: *Scripting Thread*
« Reply #224 on: December 11, 2018, 03:55:17 pm »
Hey I wanted to let a head admin be able to also kick other admins. Here's what I found with the ban admin code



(else_try),
            (eq, ":event_type", multiplayer_event_admin_kick_player),
            (try_begin),
              (store_script_param, ":value", 3),
              (player_is_active, ":value"),
              #condition checks are done
             
              # Vincenzo begin
              (neg|player_is_admin, ":value"),
             
              (str_store_player_username, s2, ":player_no"), # adminname
              (str_store_player_username, s3, ":value"),
              (str_store_string, s4, "str_kick_player_s2_s3"),
              (call_script, "script_multiplayer_broadcast_message"),
              # Vincenzo end
             
              (kick_player, ":value"),
            (try_end),
          (else_try),
            (eq, ":event_type", multiplayer_event_admin_ban_player),
            (try_begin),
              (store_script_param, ":value", 3),
              #validity check
              (player_is_active, ":value"),
                     (try_begin),
                (player_get_unique_id, ":value_id", ":value"),
                (gt,":value_id", 1), # Key auth server problem protection (id 1 if wrong)
              #condition checks are done
              (try_begin),  # unmark the lines from here down to try end.   you dont need all of the lines.  feel free to only unmark as many lines as you need for admin ids.   you can add more IDs. 
                      (player_is_admin, ":value"), #lets not run the code below if player being banned is not an admin, as it would be pointless
                (player_get_unique_id, ":player_id", ":player_no"),#get their ID
                (this_or_next|eq, ":player_id", 1111111), # only these admins can ban other admins.  # 1
                (this_or_next|eq, ":player_id", 1111111),  # 2
                (eq, ":player_id", 1111111),#always make sure the last/only id you want to be able to ban admins is just eq, not this or next eq. # 3
               
                (neq, ":value_id", 1111111), # you will want to put the IDs of admins here that you dont want banned when their name is clicked.  hint, you can ban youself if you dont add your ID here
                (neq, ":value_id", 1111111), #  if an admin not approved above will not be able to ban admins.   there should be no message saying someone was banned when no one was. 
                (neq, ":value_id", 111111),
                (player_set_is_admin, ":value", 0),
             (try_end),
              (neg|player_is_admin, ":value"),
              (str_store_player_username, s2, ":player_no"), # adminname
              (str_store_player_username, s3, ":value"),
              (str_store_string, s4, "str_ban_player_s2_s3"),
              (call_script, "script_multiplayer_broadcast_message"),
             
              (ban_player, ":value", 0, ":player_no"),
              (else_try),
                (kick_player, ":value"),
              (try_end),
            (try_end),




I'm not sure exactly what to add or change to let admins kick another admin. I tried adding some code but it didn't work.