Author Topic: *Scripting Thread*  (Read 87718 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 #180 on: February 20, 2017, 11:27:22 am »
Scripters of NW, how scriptable are conquest flags.

Very scriptable, down to smallest details.

Can you point me to the right direction on where to start? :D

Main part of it is in module_mission_templates.py among multiplayer_hq mission template triggers, if you scroll down along that mission template you will find several triggers which obviously relate to flag situation. Constants used such as the minimum distance to a flag needed for capture are set in header_common.py . If you find any scripts are used, they are defined in module_scripts.py and presentations are in module_presentations.py  If you are making server-side only mod you will probably stay away from presentations and only write code inside blocks of code meant for server (multiplayer_is_dedicated_server, multiplayer_is_server and such)


Offline Hockey

  • Private
  • *
  • Posts: 2
  • Bae
    • View Profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #181 on: April 16, 2017, 01:16:19 am »
Hello. Im looking for a script that only allows sailors and partizani to spawn with certain types of weapons. If nobody can do it for free I am willing to pay.

Offline Flappywm

  • Volunteer
  • *
  • Posts: 2
    • View Profile
Re: *Scripting Thread*
« Reply #182 on: May 01, 2017, 10:27:04 am »
How do i script "ze tresure chest." So when you hold F on it it gives you certain items/armour.?

Offline DarthKiller

  • Sergeant Major
  • *
  • Posts: 83
    • View Profile
    • Eliteteam alias. The Imperial Army
  • Nick: kk_IR_Nr59_Obst_DarthKiller
  • Side: Union
Re: *Scripting Thread*
« Reply #183 on: May 04, 2017, 02:43:28 am »
SOLVED
Hello lads,
Today I developed a little script piece for my own automatic guns based off the "Star Wars - Bear Force II" modification. (This part does not really relate to my problem)
As you scripters can probably figure out, my script issues a reloading player (this is done along the code when the reloading animation equals the current player's animation) to walk when he does. But, infact it does not.

Foreword:
Yes, it is implemented in module_mission_templates.py,
Yes, I have added it to the common stuff place with a wonderful "," (it isn't the last one there),
Yes, I have initialized the slot_agent_is_reloading at the on_agent_spawn_common stuff with "0".


So, I'd like to know if any of you more experienced guys got a proper solution on my problem.

Another Note:
The loop itself works fine to determine whether it reloads or not, I found out by having errors beforehand with the agent ID being the Slot value so it printed me 0 when I wasn't reloading and 1 when I was. // Edit: This was random crap being produced, I realized the errors I did here..

Here is the mentioned script:
Spoiler
sw_check_animation_reload = (0.05, 0, 0, [],
[
   (multiplayer_get_my_player, ":my_player"),
    (player_is_active,":my_player"),
    (player_is_active,":my_player"),
    (neg|player_is_busy_with_menus, ":my_player"),
   (player_get_agent_id, ":my_agent", ":my_player"),
   (agent_is_active,":my_agent"),
   (agent_is_alive, ":my_agent"),
   (agent_get_slot, ":old_speed", ":my_agent", slot_agent_base_speed_mod),
   (try_begin),
      (agent_slot_eq, ":my_agent", slot_agent_is_reloading, 0),
      (agent_get_wielded_item, ":item", ":my_agent", 0),
      (ge, ":item", 0),
      (item_slot_ge, ":item", slot_item_ranged_type, 1),
      (item_get_slot, ":reload_animation", ":item", slot_item_reload_animation),
      (agent_get_animation, ":animation", ":my_agent", 1),
      (eq, ":animation", ":reload_animation"),
      (agent_set_speed_modifier, ":my_agent", 55),
      (agent_set_slot, ":my_agent", slot_agent_base_speed_mod, 55),
      (agent_set_slot, ":my_agent", slot_agent_is_reloading, 1),
   (else_try),
      (agent_slot_eq, ":my_agent", slot_agent_is_reloading, 1),
      (agent_get_wielded_item, ":item", ":my_agent", 0),
      (ge, ":item", 0),
      (item_slot_ge, ":item", slot_item_ranged_type, 1),
      (item_get_slot, ":reload_animation", ":item", slot_item_reload_animation),
      (agent_get_animation, ":animation", ":my_agent", 1),
      (neq, ":animation", ":reload_animation"),
      (agent_set_speed_modifier, ":my_agent", ":old_speed"),
      (agent_set_slot, ":my_agent", slot_agent_base_speed_mod, ":old_speed"),
      (agent_set_slot, ":my_agent", slot_agent_is_reloading, 0),
   (try_end),
])
[close]

I changed the script to the working version. Enjoy using or improving it for your own lusts
« Last Edit: May 04, 2017, 03:13:27 am by DarthKiller »
Join the Nr59 join the Infantry.
kk_IR_Nr59_Obst_DarthKiller

Offline Aternox

  • Second Lieutenant
  • *
  • Posts: 45
  • A prayer's as good as a bayonet on a day like this
    • View Profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #184 on: October 14, 2017, 09:03:58 pm »
Gentlemen,

I'm an amateur scripter and would like some help with my automated anti-delaying script as shown below

As you will work out, the requirements needed (should be) for the script to go ahead to the end:
  • Must be 3 mins since start of round time
  • Only 1 player left on team 1
  • There being a dead player on team 1 (so a lone player doesn't get autoslayed)
  • 'delaying' player must still be alive until 120 sec after first successful counter addition
The mission template is timed @ 15 seconds because it doesn't seem to need to be triggered very often

Spoiler
multiplayer_server_antidelay = (   
   15, 0, 0, [(this_or_next|multiplayer_is_server),
              (neg|game_in_multiplayer_mode),
              (eq, "$g_round_ended", 0),
           (store_mission_timer_a, reg0),
           (gt, reg0, 180),
              ],
       [                         
         (assign,":last_player_alive_team_1",-1),
         #(assign,":last_player_alive_team_2",-1),
         (assign,":num_players_team_1",0),
         #(assign,":num_players_team_2",0),
         (try_for_range, ":player_no", "$g_player_loops_begin", multiplayer_player_loops_end),
           (player_is_active, ":player_no"),
           (player_get_agent_id,":agent_id",":player_no"),
           (agent_is_active,":agent_id"),   
           (agent_is_alive,":agent_id"),                           
           (agent_get_team,":team",":agent_id"),
             (eq,":team",0),
             (assign,":last_player_alive_team_1",":player_no"),
             (val_add,":num_players_team_1",1),
         (try_end),
      
        (try_begin),      
       (neq,":num_players_team_1",1),
                 (assign,"$counter", 0),      
        (else_try),
       (eq,":num_players_team_1",1),      
       (assign, ":agent_is_ok",1),
       
      #(try_begin),
      (try_for_range, ":player_no", "$g_player_loops_begin", multiplayer_player_loops_end), #deadbegin
                 (player_is_active, ":player_no"),
                 (player_get_agent_id,":agent_id",":player_no"),
       (agent_is_active, ":agent_id"),   
                 (neg|agent_is_alive, ":agent_id"),           
                 (agent_get_team,":team",":agent_id"),
       (eq, ":team",0), #deadend there is a dead player on the team
       (assign,":agent_is_ok", 0),
      (try_end),
         (eq, ":agent_is_ok", 0),
         (val_add,"$counter",15),      
      
      (try_begin),
       (eq, "$counter", 30),
       (str_store_string, s2, "str_slay_message_1"), #personal warning msg for slay in 90 sec to prevent delay
            (multiplayer_send_string_to_player, ":last_player_alive_team_1",multiplayer_event_show_server_message, s2),
                (else_try),
       (ge, "$counter", 120),
                 (call_script, "script_multiplayer_server_slay_player", ":last_player_alive_team_1"),
       (str_store_player_username, s3,":last_player_alive_team_1"),
       (str_store_string, s4, "str_slay_message_2"), #server msg user has been slayed
       (call_script, "script_multiplayer_broadcast_message"),
           (try_end),
        #(try_end),   
       (try_end),      
        ])
[close]
Problem is: trigger at $counter = 30 happens (possibly before 3 mins into the round, can't remember from test) and $counter >= 120 (aka slay player) never happens. The strings I know will work fine and I'm guessing it needs a store_trigger_param for the slay or something. Would be much appreciated if someone could help fix it here!
« Last Edit: October 14, 2017, 09:17:22 pm by Aternox »

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #185 on: October 14, 2017, 10:07:01 pm »
"The strings I know will work fine " did you mean to say the message string gets sent in >= 120 block? Or it doesn't work at all?

In case the problem is only in calling slay script, you can try it raw:

(first, declare the (assign, "agent_id", -1), before the player loop so you don't have a scope problem.)

(agent_set_hit_points, ":agent_id", 0, 1),
(agent_deliver_damage_to_agent, ":agent_id", ":agent_id","itm_admin_kill_dummy"), #kill him

(player_get_kill_count, ":player_kill_count", ":player_no"), #adding 1 to his kill count, because he will lose 1 undeserved kill count for TKing himself
(val_add, ":player_kill_count", 1),
(player_set_kill_count, ":player_no", ":player_kill_count"),


Offline Aternox

  • Second Lieutenant
  • *
  • Posts: 45
  • A prayer's as good as a bayonet on a day like this
    • View Profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #186 on: October 15, 2017, 12:36:08 am »
With the strings I mean I know they compiled properly (the game doesn't have a problem being not able to find the string)

I have tried this now but it's the same with the $counter 30 works with the string being sent but the >=120 does nothing

Spoiler
multiplayer_server_antidelay = (   
   15, 0, 0, [(this_or_next|multiplayer_is_server),
              (neg|game_in_multiplayer_mode),
              (eq, "$g_round_ended", 0),
           (store_mission_timer_a, reg0),
           (gt, reg0, 180),
              ],
       [                         
         (assign,":last_player_alive_team_1",-1),
         #(assign,":last_player_alive_team_2",-1),
         (assign,":num_players_team_1",0),
         #(assign,":num_players_team_2",0),
     (assign, ":agent_id", -1),
         (try_for_range, ":player_no", "$g_player_loops_begin", multiplayer_player_loops_end),
           (player_is_active, ":player_no"),
           (player_get_agent_id,":agent_id",":player_no"),
           (agent_is_active,":agent_id"),   
           (agent_is_alive,":agent_id"),                           
           (agent_get_team,":team",":agent_id"),
             (eq,":team",0),
             (assign,":last_player_alive_team_1",":player_no"),
             (val_add,":num_players_team_1",1),
         (try_end),
       
        (try_begin),       
       (neq,":num_players_team_1",1),
                 (assign,"$counter", 0),       
        (else_try),
       (eq,":num_players_team_1",1),       
       (assign, ":agent_is_ok",1),
       
               (try_for_range, ":player_no", "$g_player_loops_begin", multiplayer_player_loops_end), #deadbegin
                 (player_is_active, ":player_no"),
                 (player_get_agent_id,":agent_id",":player_no"),
                 (agent_is_active, ":agent_id"),   
                 (neg|agent_is_alive, ":agent_id"),           
                 (agent_get_team,":team",":agent_id"),
                 (eq, ":team",0), #deadend there is a dead player on the team
                 (assign,":agent_is_ok", 0),
              (try_end),
         (eq, ":agent_is_ok", 0),
         (val_add,"$counter",15),     
     
        (try_begin),
          (eq, "$counter", 30),
          (str_store_string, s2, "str_slay_message_1"), #personal warning msg for slay in 90 sec to prevent delay
          (multiplayer_send_string_to_player, ":last_player_alive_team_1",multiplayer_event_show_server_message, s2),
        (else_try),
         (ge, "$counter", 120),
         (player_get_agent_id,":agent_id",":last_player_alive_team_1"),
    (agent_set_hit_points, ":agent_id", 0, 1),
    (agent_deliver_damage_to_agent, ":agent_id", ":agent_id","itm_admin_kill_dummy"), #kill him
        #(call_script, "script_multiplayer_server_slay_player", ":last_player_alive_team_1"),
         (str_store_player_username, s3,":last_player_alive_team_1"),
         (str_store_string, s4, "str_slay_message_2"), #server msg user has been slayed
         (call_script, "script_multiplayer_broadcast_message"),
         (player_get_kill_count, ":player_kill_count", ":last_player_alive_team_1"), #adding 1 to his kill count, because he will lose 1 undeserved kill count for TKing himself
    (val_add, ":player_kill_count", 1),
    (player_set_kill_count, ":last_player_alive_team_1", ":player_kill_count"),
        (try_end),   
    (try_end),     
        ])
[close]
« Last Edit: October 15, 2017, 12:39:22 am by Aternox »

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #187 on: October 15, 2017, 01:18:57 am »
I don't think this will solve your problem but just so you know this is the proper way to get the round time passed, as store_mission_timer_a gets the time from the moment the map loads and doesn't reset when rounds end, and $g_round_start_time holds mission timer value it had when the current round started.

[(this_or_next|multiplayer_is_server),
           (neg|game_in_multiplayer_mode),
           (eq, "$g_round_ended", 0),
           (store_mission_timer_a, ":current_time"),
           (store_sub, ":round_seconds_passed", ":current_time", "$g_round_start_time"),
           (gt, ":round_seconds_passed", 180),
              ],

Your code looks like it should be working, try sprinkling it with debug message broadcasts to get a better idea of what is going on, what gets triggered and what not, what is the current value of $counter etc..


Offline Aternox

  • Second Lieutenant
  • *
  • Posts: 45
  • A prayer's as good as a bayonet on a day like this
    • View Profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #188 on: October 15, 2017, 01:28:37 am »
Thanks for the help,

the timer correction is great as well thanks, I have another script with a similar incorrect timer that I can fix too now

and yeah I'll make the script to broadcast the $counter value regularly, see if it's not reaching 120
« Last Edit: October 15, 2017, 03:19:30 am by Aternox »

Offline 1steivn_cas

  • Volunteer
  • *
  • Posts: 5
    • View Profile
Re: *Scripting Thread*
« Reply #189 on: January 27, 2018, 04:50:58 pm »
Hello, I need a server side script or something that changes the item the 'ze treasure' chest gives you

I have no idea how python stuff works so i'll just ask here if anyone can help.

Offline Thunderstormer

  • FSE Developer
  • ****
  • Posts: 6309
  • Worse than Hotler
    • View Profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #190 on: January 28, 2018, 01:57:31 am »
Nothing really too complicated about it.   just need to change 2 lines of code if you are changing what hat they give.

Spoiler
("ze_treasure",spr_use_time(4),"chest_b","bo_ze_treasure", [
    (ti_on_scene_prop_use,
    [
      (store_trigger_param_1, ":agent_id"),
      #(store_trigger_param_2, ":instance_id"),

      #(neg|scene_prop_slot_eq, ":instance_id", scene_prop_slot_just_fired, 1), # abuse just_fired for already used.
     
      (agent_is_active,":agent_id"),
      (agent_is_alive,":agent_id"),
     
      # remove his shit.
      #(try_for_range_backwards,":equipment_slot",0,4), # ,ek_item_0,ek_head),
      #  (agent_get_item_slot, ":item_id", ":agent_id", ":equipment_slot"),
       
      #  (gt,":item_id",-1), # even have a item there?
       
      #  (agent_unequip_item, ":agent_id", ":item_id", ":equipment_slot"),
      #(try_end),
      (try_begin),
        (agent_get_item_slot, ":item_id", ":agent_id", 4), #ek_head
        (gt,":item_id",-1), # even have a item there?
        (agent_unequip_item, ":agent_id", ":item_id", 4), #ek_head
      (try_end),
     
      # add ze goodies.
      (agent_equip_item,":agent_id","itm_pirate_hat"),
      #(agent_equip_item,":agent_id","itm_french_officer_pistol"),
      #(agent_equip_item,":agent_id","itm_pistol_ammo"),
      #(agent_equip_item,":agent_id","itm_spyglass"),
      #(agent_equip_item,":agent_id","itm_french_light_cav_off_sabre"),
     
      #(agent_set_wielded_item,":agent_id","itm_french_officer_pistol"),
     
      #(scene_prop_set_slot,":instance_id",scene_prop_slot_just_fired,1),
     
      (try_for_players, ":player_no", 1),
        (player_is_active, ":player_no"),
        (multiplayer_send_3_int_to_player, ":player_no", multiplayer_event_return_agent_set_item, ":agent_id", "itm_pirate_hat", 4),
      (try_end),
    ]),
  ]),
[close]
Should you need to talk to me regarding NA1 or or something regarding admining or the admins, PM me here on the forums and not on steam.  *

*This does not include Official Server Admins.

Offline Soda_Lover

  • Private
  • *
  • Posts: 51
  • Landwehr = bestwehr
    • View Profile
    • Steam Profile
  • Nick: PotatoInMyAnus
  • Side: Union
Re: *Scripting Thread*
« Reply #191 on: February 07, 2018, 08:55:42 pm »
How does one make teleporting doors/hatches? I have never scripted before, only made maps, but never scripted so I need a thorough answer with how to do it.
Thanks!

Offline Thunderstormer

  • FSE Developer
  • ****
  • Posts: 6309
  • Worse than Hotler
    • View Profile
  • Side: Neutral
Re: *Scripting Thread*
« Reply #192 on: February 07, 2018, 09:49:55 pm »
How does one make teleporting doors/hatches? I have never scripted before, only made maps, but never scripted so I need a thorough answer with how to do it.
Thanks!
on my phone.  There are already teleporting doors in the game.  Go to the scene props py file and look at how's it's done.  Should be pretty straightforward.

In the hotfix I did make one change to them, and that is on the vertical doors.  You can see the change via a video in the blog thread.
Should you need to talk to me regarding NA1 or or something regarding admining or the admins, PM me here on the forums and not on steam.  *

*This does not include Official Server Admins.

Offline Spoons

  • Donator
  • *
  • Posts: 627
    • View Profile
  • Nick: 33rd_Col_Spoons
  • Side: Neutral
Re: *Scripting Thread*
« Reply #193 on: February 17, 2018, 12:46:13 pm »
I need a little help with using game chat as a trigger to set a numeric variable, basically I would like to be able to type: /left 5  and /right 6   and have it set a global that I can then use later:

(try_begin),
(eq, "$g_left", 5),


(try_begin),
(eq, "$g_right", 6),

But only so admins can use it, so maybe just checking admin chat would be the easiest (would probably help if all players could see the change).


Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: *Scripting Thread*
« Reply #194 on: February 17, 2018, 07:40:50 pm »
What you want requires string parsing, and module system doesn't have such capabilities so you would have to send the string to a PHP page or similar web server side script and return the reponse with info on which variable is changing and what the new value is.

If you don't want to write web scripts you can use new custom keys ability. V, B and four directional keys can be sent from client to activate server script, where you can implement some sort of menu system and have, for example, set Left variable to 5 by tapping left key five times, or have a system which increases previously selected variable by pressing right and decreases by pressing left key.

You can search through new module system files for "custom_keys:" to gather pieces of how it all works, or wait until I write a tutorial about using those and other new stuff useful for server modders.

I need a little help with using game chat as a trigger to set a numeric variable, basically I would like to be able to type: /left 5  and /right 6   and have it set a global that I can then use later:

(try_begin),
(eq, "$g_left", 5),


(try_begin),
(eq, "$g_right", 6),

But only so admins can use it, so maybe just checking admin chat would be the easiest (would probably help if all players could see the change).