Author Topic: *Scripting Thread*  (Read 72105 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 #225 on: December 11, 2018, 04:18:01 pm »
That part of code is thoroughly commented and you just have to read what the comments say.

player_id is ID of player who is attempting to ban, value_id is ID of player who player_id is trying to ban.

Replace 1111111s with game IDs (the IDs shown when someone joins the server):

 - Where it says # only these admins can ban other admins.  you replace 1111111s with IDs of admin who can ban other admins.
 - Few lines below (where value_id is compared) you do the same for admins who can't be banned

You just add or remove lines depending on how many main or unbanable admins you have, while keeping in mind this_or_next, if you are not sure how this_or_next work look it up.

You can try to copy those tests into kick event as well, but that makes no sense, if it comes to that (main admin kicking lesser admin) you will want to use ban instead.

Offline Ivkolya

  • Sergeant Major
  • *
  • Posts: 333
    • View Profile
  • Nick: Ivkolya
  • Side: Neutral
Re: *Scripting Thread*
« Reply #226 on: December 11, 2018, 09:09:49 pm »
Hello all, I'm trying to disable bots spawning as cavalry units on certain maps of team deathmatch mode. In siege mode in NW there is working restriction for bots spawning as cavalry, at least in defending team, but I didn't find script for that. Maybe someone can point me where it is? I think it can be a start for disabling AI cavalry in other modes

Also I've noticed that on my new scene attacking team has no horses (but all bots are of the same unit), and defending team has cavalry, which is strange

I created new topic, but maybe here someone will see and help me (and, I guess, help many other modders), so sorry for double-posting.

I made many attempts to find a solution. I was advised to look into this module_mission_templates code,

Spoiler
Code
      (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":selected_team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),

      (team_get_faction, ":team_faction", ":selected_team"),
      (assign, ":num_ai_troops", 0),
      (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
        (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
        (eq, ":ai_troop_faction", ":team_faction"),
        (val_add, ":num_ai_troops", 1),
      (try_end),
[close]

As I think, disable cavalry for certain scenes could be made by adding list of scenes as condition and excluding cavalry units from available for spawning after oriiginal line

Code
	   (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),

First of all I tried to add lines like (neg|troop_is_guarantee_horse, ":cur_ai_troop") or (neg|troop_select_type_cavalry, ":cur_ai_troop") and couple of other variants, but they didn't work, bots were dead in list of players.

In the end I changed module_constants (added infantry of all factions) after multiplayer_ai_troops_end (as this variable is referenced in original script)

Spoiler
Code
multiplayer_ai_troops_begin = "trp_british_infantry_ai"
multiplayer_ai_troops_end = multiplayer_troops_begin

multiplayer_ai_british_infantry_begin = "trp_british_infantry_ai"
multiplayer_ai_british_infantry_end = "trp_british_hussar_ai"

multiplayer_ai_french_infantry_begin = "trp_french_infantry_ai"
multiplayer_ai_french_infantry_end = "trp_french_hussar_ai"

multiplayer_ai_prussian_infantry_begin = "trp_prussian_infantry_ai"
multiplayer_ai_prussian_infantry_end = "trp_prussian_dragoon_ai"

multiplayer_ai_russian_infantry_begin = "trp_russian_foot_guard_ai"
multiplayer_ai_russian_infantry_end = "trp_russian_hussar_ai"

multiplayer_ai_austrian_infantry_begin = "trp_austrian_infantry_ai"
multiplayer_ai_austrian_infantry_end = "trp_austrian_hussar_ai"

multiplayer_ai_rhine_infantry_begin = "trp_rhine_infantry_bavaria_ai"
multiplayer_ai_rhine_infantry_end = "trp_rhine_mounted_jaeger_ai"
[close]

So my code looks like this now

Code
      (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":selected_team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),

      (team_get_faction, ":team_faction", ":selected_team"),
      (assign, ":num_ai_troops", 0),
  (store_current_scene, ":cur_scene"),
      (try_begin),
   (eq, ":cur_scene", "scn_assault_on_malakoff_test"),
   (eq, "$g_multiplayer_game_type", multiplayer_game_type_team_deathmatch),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_british_infantry_begin, multiplayer_ai_british_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_french_infantry_begin, multiplayer_ai_french_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_russian_infantry_begin, multiplayer_ai_russian_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_prussian_infantry_begin, multiplayer_ai_prussian_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_austrian_infantry_begin, multiplayer_ai_austrian_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_rhine_infantry_begin, multiplayer_ai_rhine_infantry_end),
     (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
             (eq, ":ai_troop_faction", ":team_faction"),
             (val_add, ":num_ai_troops", 1),
  (try_end),
 
      (else_try),
   (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
             (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
             (eq, ":ai_troop_faction", ":team_faction"),
             (val_add, ":num_ai_troops", 1),
      (try_end),

But bots are dead when I start team deathmach with bots.
And maybe I wrote something wrong? Maybe overall it's the right way, but I just wrote something wrong?
I really hope someone will help me.

Offline Bloody Bayonet Gaming

  • Sergeant
  • *
  • Posts: 68
    • View Profile
Re: *Scripting Thread*
« Reply #227 on: December 11, 2018, 11:25:42 pm »
That part of code is thoroughly commented and you just have to read what the comments say.

player_id is ID of player who is attempting to ban, value_id is ID of player who player_id is trying to ban.

Replace 1111111s with game IDs (the IDs shown when someone joins the server):

 - Where it says # only these admins can ban other admins.  you replace 1111111s with IDs of admin who can ban other admins.
 - Few lines below (where value_id is compared) you do the same for admins who can't be banned

You just add or remove lines depending on how many main or unbanable admins you have, while keeping in mind this_or_next, if you are not sure how this_or_next work look it up.

You can try to copy those tests into kick event as well, but that makes no sense, if it comes to that (main admin kicking lesser admin) you will want to use ban instead.
No I got the ban part working, I just wanted kicks to work too, because in reality I can just ban an admin from the control panel and restart server pretty quickly if something really warranted it. Just want help with kicking. I tried copying the code into the kick section but had errors with admin working properly

Sent from my SM-G930VC using Tapatalk

Offline Swordsman

  • Second Lieutenant
  • *
  • Posts: 161
  • General de la Junta Suprema Central
    • View Profile
    • Nova Simulatio
  • Nick: JSC_Swordsman
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #228 on: December 17, 2018, 01:31:02 am »
Hello, i have a question, if someone can help me. I wan to give the player via ze_treasure vodka bottle only in server side, i know how to do that and its working, but i want to give the player like 30 bottles like the holy hand grenade.

I try to replace in modules items the config of bottle but doesnt work, any idea?

Offline pete99

  • First Sergeant
  • *
  • Posts: 71
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #229 on: December 17, 2018, 04:11:49 am »
Sadly I don't think you can change things like that in the items file server side, unless the client player has the same mod installed. If i'm wrong someone can correct me, but I don't think it syncs properly with the player. When they have used up their four bottles the server will be telling them they have more, while their own game tells them they have no more, resulting in it glitching out and not working.

Offline Swordsman

  • Second Lieutenant
  • *
  • Posts: 161
  • General de la Junta Suprema Central
    • View Profile
    • Nova Simulatio
  • Nick: JSC_Swordsman
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #230 on: December 17, 2018, 11:56:21 am »
Sadly I don't think you can change things like that in the items file server side, unless the client player has the same mod installed. If i'm wrong someone can correct me, but I don't think it syncs properly with the player. When they have used up their four bottles the server will be telling them they have more, while their own game tells them they have no more, resulting in it glitching out and not working.

Thanks for the reply, as you said it doesnt work. I was testing and if i change my own itemkinds1.txt it works correctly. I have another question, i see that it is possible to change for expample a hat when you enter a server, how does it work?

Offline pete99

  • First Sergeant
  • *
  • Posts: 71
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #231 on: December 17, 2018, 12:17:44 pm »
If you mean, changing parts of your uniform and so on, there’s a lot of different ways you can go about this. You could just change the type of clothes a troop type is equipped with, in module_troops, which is an easy way. Otherwise you could look into equipping items and clothes types.

You could just create a trigger, say whenever a player spawns which could equip them with a different uniform.

Otherwise, a little more complex, in NW now they have the option to do something like this at the push  of a button. If you look up a few posts in this thread you can see a couple of screenshots of the sort of thing I did. ^


Offline Swordsman

  • Second Lieutenant
  • *
  • Posts: 161
  • General de la Junta Suprema Central
    • View Profile
    • Nova Simulatio
  • Nick: JSC_Swordsman
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #232 on: December 17, 2018, 12:20:23 pm »
Well lets say that i want to change the hat when a player enter the server. Player choose a troop and it change the hat to a santa hat for example. I see your screens, look so cool.

Offline pete99

  • First Sergeant
  • *
  • Posts: 71
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #233 on: December 17, 2018, 12:44:56 pm »
In that case, yes you would probably want to set a trigger in mission templates for every time a player spawns, which uneuips their hat and equips another one. If you want a really good example of how to do this take a look at Ze_treasure scene prop in module scene props, which equips a pirate hat.

Keep in mind though, it would have to be an item already in the game. If you actually wanted to see say a Santa hat (not one of the standard items)  you would need it on server and client side XD.

Offline Swordsman

  • Second Lieutenant
  • *
  • Posts: 161
  • General de la Junta Suprema Central
    • View Profile
    • Nova Simulatio
  • Nick: JSC_Swordsman
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #234 on: December 17, 2018, 03:02:12 pm »
Hello again, thanks for the info. I change the spawn in mission templates for team deathmatch with this, i see that the troop_clear_inventory dont work, dont know if there is another way to unequip all items when spawn.

Code
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),

         (troop_clear_inventory, "$g_player_troop"),
   
         (try_begin),
             (agent_get_item_slot, ":item_id", ":agent_no", 4), #ek_head
             (gt,":item_id",-1), # even have a item there?
             (agent_unequip_item, ":agent_no", ":item_id", 4), #ek_head
         (try_end),
     
         (agent_equip_item,":agent_no","itm_grenade"),
       
         (agent_equip_item,":agent_no","itm_pirate_hat"),
         
         (agent_set_wielded_item,":agent_no","itm_grenade",0),

         ]),

But now im getting some kind of error in my server. "Incorrect skeleton type for anim 143 Error: Incorrect skeleton type for anim 143" and the server crash.

EDIT: I was looking and the animation 143 is this. anim_equip_default = 143

« Last Edit: December 17, 2018, 03:06:32 pm by Swordsman »

Offline Lilja Mariasdóttir

  • Colonel
  • *
  • Posts: 1939
  • Ist ein Schaf in einer Tasse
    • View Profile
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #235 on: December 17, 2018, 03:16:33 pm »

But now im getting some kind of error in my server. "Incorrect skeleton type for anim 143 Error: Incorrect skeleton type for anim 143" and the server crash.

EDIT: I was looking and the animation 143 is this. anim_equip_default = 143
That is a common mistake. You try to equip an item to a horse, and that will lead to a crash. You need to exclude horses from equipping stuff.
(agent_is_human, ":agent_no"),
In support of https://gamersagainstbigotry.org/

Seehofer schafft das Heer ab.

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #236 on: December 17, 2018, 04:25:39 pm »
Code
 
 (troop_clear_inventory, "$g_player_troop"),

This is another mistake, tho more of an unneeded line than an error, $g_player_troop is a local variable used only by client. Also you are working with agents, not troops. Troops are templates on which agents are based.

You just have to remove agent's hat and replace it, look at treasure chest code in module_scene_props

Offline Swordsman

  • Second Lieutenant
  • *
  • Posts: 161
  • General de la Junta Suprema Central
    • View Profile
    • Nova Simulatio
  • Nick: JSC_Swordsman
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #237 on: December 17, 2018, 10:44:29 pm »
Hello again, thanks for the replys, i've made some change, but im not sure where to set the (agent_is_human, ":agent_no"),. The question is that i want when players enter my server they have a santa hat in all troops they choose(this is working now), and they have grenades equiped as only object, so i wanna unequip default items of agents. May i have 4 unequip "try" like the code or can i have it in one only?

Code
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (agent_is_human, ":agent_no"),
         (call_script, "script_multiplayer_server_on_agent_spawn_common", ":agent_no"),
   
         (try_begin),
             (agent_get_item_slot, ":item_id", ":agent_no", 4), #ek_head
             (gt,":item_id",-1), # even have a item there?
             (agent_unequip_item, ":agent_no", ":item_id", 4),#ek_head
         (try_end),

         (try_begin),
             (agent_get_item_slot, ":item_id", ":agent_no", 0),
             (gt,":item_id",-1), # even have a item there?
             (agent_unequip_item, ":agent_no", ":item_id", 0),
         (try_end),

         
         
         (agent_equip_item,":agent_no","itm_grenade", 0),
         
         (agent_equip_item,":agent_no","itm_pirate_hat"),
         
         (agent_set_wielded_item,":agent_no","itm_grenade",0),

         ]),

Offline pete99

  • First Sergeant
  • *
  • Posts: 71
  • Gang Warily
    • View Profile
  • Nick: Drummond
  • Side: Confederacy
Re: *Scripting Thread*
« Reply #238 on: December 17, 2018, 11:12:38 pm »
First up, I think for equiping the hat (that is server side) in order for all the players to see the change you will also have to do a "try_for_players" operation and add this:

(multiplayer_send_3_int_to_player, ":player_no", multiplayer_event_return_agent_set_item, ":player_agent", "itm_pirate_hat", 4),


As for unequiping all items, I think you can pretty much just keep doing what you have there, just with a different slot each time:

(try_begin),
             (agent_get_item_slot, ":item_id", ":agent_no", 0),
             (gt,":item_id",-1), # even have a item there?
             (agent_unequip_item, ":agent_no", ":item_id", 0),
         (try_end),

Otherwise you could also do a loop through all player's items:

(try_for_range,":item",0,234),
(is_between, ":item", "itm_no_item", "itm_french_voltigeur_body_officer"),

(agent_unequip_item, ":agent_no", ":item"),

And that should unequip all items (except clothing).
Hope this helps



Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #239 on: December 18, 2018, 12:52:56 am »
If you're not sure what you are doing, the best way to not mess up in regard to whether the code will run on the server and update all clients or not is by editing the multiplayer_server_on_agent_spawn_common script itself. You don't need to do sending of ints as pete99 suggested, simply doing the agent_equip_item will update all clients (assuming you removed old item with agent_unequip_item).

Take a good look at the multiplayer_server_on_agent_spawn_common  script, it has all the clues you need to come up with all sorts of agent modification upon spawning.

As for where to put your stuff, just add your own try block somewhere under these lines:
     (try_begin),
       (this_or_next|multiplayer_is_server), # only on servers.
       (neg|game_in_multiplayer_mode),
       #new code you will add:
        (try_begin),
             #your new stuff
        (try_end),
        #you have made separate try block so the rest of the code below will continue to run as normal

In your try block check for if agent_is_human as in is it not a horse, and perhaps neg|agent_is_non_player if you don't want that to happen for bots as well, then call other scripts to check for troop and rank if that matters, you will find an example few lines below.

As for what to put there, really just look at the treasure chest code, it does exactly what you want (replaces head gear).