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

0 Members and 1 Guest are viewing this topic.

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 223
    • View Profile
  • Nick: Grozni_BloodAndHonor
  • 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)

Ride with us into gore and glory, join the 73rd cavalry! http://73rdeu.enjin.com/recruitment We also have line and light companies if you're not a cav person 

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
  • *
  • Posts: 29
    • View Profile
    • Eliteteam alias. The Imperial Army
  • Nick: kk_IR_Nr59_Hptm_DarthKiller454
  • 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),
])

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_Hptm_DarthKiller454

Offline Aternox

  • Sergeant Major
  • *
  • Posts: 27
  • 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),      
        ])
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: 223
    • View Profile
  • Nick: Grozni_BloodAndHonor
  • 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"),

Ride with us into gore and glory, join the 73rd cavalry! http://73rdeu.enjin.com/recruitment We also have line and light companies if you're not a cav person 

Offline Aternox

  • Sergeant Major
  • *
  • Posts: 27
  • 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),     
        ])
« Last Edit: October 15, 2017, 12:39:22 am by Aternox »

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 223
    • View Profile
  • Nick: Grozni_BloodAndHonor
  • 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..

Ride with us into gore and glory, join the 73rd cavalry! http://73rdeu.enjin.com/recruitment We also have line and light companies if you're not a cav person 

Offline Aternox

  • Sergeant Major
  • *
  • Posts: 27
  • 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 »