ti_on_agent_hit not working on public servers

Users who are viewing this thread

new_playerr

Recruit
Hello,
Does anyone know if it is possible to make ti_on_agent_hit possible to work client side?
Ive been trying to use ti_on_missile_hit too, but it only works when missle hits world, but when agent gets hit there doesnt happen anything.
On the other hand when i create my own server everything works perfectly, when i hit agents i see displayed message in chat.
I would be thankfull for any help and explaination what happens!!
PS I also noticed that particle bursts (bullets smoke or something) triggered by on_missile_hit are much more imprecise client side than server side. Is it some kind of half assed cheating prevention?

Sorry for my code

item data with trigger + script on_bullet_hit
Code:
["bad_bullets", "Cheap Bullets", [("bullet_patron",0),("bullet_normal",ixmesh_flying_ammo),("porohovnitsa_4", ixmesh_inventory)], itp_type_bolts|itp_can_penetrate_shield, 0,
  50,weight(2)|abundance(100)|weapon_length(5)|thrust_damage(0,pierce)|max_ammo(16),imodbits_missile,
    [ (ti_on_missile_hit, [ (call_script, "script_oim_on_bullet_hit"), ])]],

  # script_oim_on_bullet_hit
  # input:       
  ("oim_on_bullet_hit",
  [
  (store_trigger_param_1, ":shooter_agent"),
  (store_trigger_param_2, ":collision_type"),
  (try_begin),
    (get_player_agent_no, ":player_agent_no"),
    (eq, ":player_agent_no", ":shooter_agent"),
    (particle_system_burst_no_sync, "psys_oim_musket_svet", pos1, 50),
  #(else_try),
  #  (try_begin),
  #   # 0 = world
  #   # 1 = agent
  #   # 2 = dynamic prop
  #   # 3 = world
  #   # 4 = mission object
  #   # 8 = friend
  #   # 9 = neutral agent
  #   # 10 = under water
  #   (this_or_next|eq, ":collision_type", 0), # world collisions
  #   (eq, ":collision_type", 3), # world collisions
  #   (particle_system_burst_no_sync, "psys_musket_hit", pos1, 8),
  #   (particle_system_burst_no_sync, "psys_musket_hit_particle", pos1, 8),
  #  (else_try),
  #   (this_or_next|eq, ":collision_type", 2),
  #   (eq, ":collision_type", 4), # mission objects
  #   (particle_system_burst_no_sync, "psys_musket_hit_objects", pos1, 8),
  #  (try_end),
  (try_end),
  ]),
Tuple from mission templates:
Code:
# ti_on_agent_hit
# Trigger Param 1: damage inflicted agent_id
# Trigger Param 2: damage dealer agent_id
# Trigger Param 3: inflicted damage
# Register 0: damage dealer item_id
# Position Register 0: position of the blow
#                      rotation gives the direction of the blow
on_every_hit_message = (ti_on_agent_hit, 0, 0,
[
  (multiplayer_get_my_player, ":my_player_no"),
  (player_get_team_no, ":my_player_team", ":my_player_no"),
  (lt, ":my_player_team", multi_team_spectator),
  (neg|player_is_busy_with_menus, ":my_player_no"),
  (get_player_agent_no, ":player_agent_no"),
  (neq, ":player_agent_no", -1),
  (agent_is_alive, ":player_agent_no"),
],
       [
         (store_trigger_param_1, ":damaged_agent_no"),
         (store_trigger_param_2, ":atacker_no"),
         (store_trigger_param_3, reg1),
       
         (get_player_agent_no, ":player_agent_no"),
       
         (try_begin),
           (eq, ":atacker_no", ":player_agent_no"),
           (try_begin),
               (agent_is_non_player, ":damaged_agent_no"),
               (str_store_agent_name, s2, ":damaged_agent_no"),
           (else_try),
               (agent_get_player_id, ":player_no", ":damaged_agent_no"),
               (str_store_player_username, s2, ":player_no"),
           (try_end),
           (str_store_item_name, s3, reg0),
            (agent_get_position, pos1,":player_agent_no"),
            (get_distance_between_positions_in_meters, reg2, pos1, pos0),
            (gt,reg2,4), #longest weapon has 325 reach
           (display_message, "@{s2} - {reg1} damage - {reg2} meters", 0x136568),
        (try_end),
      
       ]
  )

If i would like to make some kind of shooting range server for me and my friends, than i would have to make triggers like this only server side right? Then i would have to send all positions, agents no, damage etc through server events and then stuff like this would work client side on public servers am i correct?
 
Last edited by a moderator:
@new_playerr sadly it's a hardcoded behavior, read more about it here:
The reason behind it is probably to make it harder to write client-side multiplayer cheats.

You could probably go around this limitation, but it will be very inefficient, and processor heavy.
You could for example detect the trigger on server side, copy its trigger parameters into some globals, then write a trigger on client side that runs every frame, detects changes to those globals and reads them. Then you can execute client-side code using those values.
Keep in mind that my idea above is untested, so proceed with caution.
 
Upvote 0
The code works when i am a game multiplayer server using "create game" option (or something like that), but it doesnt work when i use the same code in public servers (im not sure if being an admin changes anything, it was a long time ago).
Because of this i made code that sends server-client event, with all needed data (but without making operations with that data server side like distance in meters) to that one particular player who attacked. That allows me to do the same thing as code i send before, but only when client is on servers with my module. I dont know if that is optimal solution xD
thanks for help and links!!
 
Upvote 0
Back
Top Bottom