OSP Kit Combat Fancy Damage Systems

Users who are viewing this thread

Einskaldir said:
SonKidd said:
you need 'neck shots'.

you can try to increase the range and test it again.
(is_between, ":distance", 140, 185),
If it works, it means your coding is OK, then you can reduce the values again. If it still doesn't work then it's something else.

Thanks for the tip SonKidd. I modified those values to (is_between, ":distance", 90, 185),  but nothing happens. Maybe I'm very bad aiming at the neck. By the way, trying to understand what I'm doing, I'd like to know what the numbers in the code are, specially that ones:

->(ge, ":damage", 30), # i'm guess that is the minimum amount of damage.
->(val_sub, ":hp", 5), # That one I really don't have a clue. Is the minimum HP what the victim must have? Or what?

Also, here is the code as is in the file:
Code:
common_battle_mission_start = (
  ti_before_mission_start, 0, 0, [],
  [
    (team_set_relation, 0, 2, 1),
    (team_set_relation, 1, 3, 1),
    (call_script, "script_change_banners_and_chest"),
    ])

theoris_decapitation = (
    ti_on_agent_hit, 0, 0, [],
    [
       (store_trigger_param_1, ":agent"),
      (agent_is_human, ":agent"),
       (store_trigger_param_3, ":damage"),
      (ge, ":damage", 30), #strong blow
      (store_agent_hit_points, ":hp", ":agent", 1),
      (val_sub, ":hp", 5),
      (ge, ":damage", ":hp"),
      (agent_get_position, pos1, ":agent"),
      (get_distance_between_positions, ":distance", pos1, pos0),
      (is_between, ":distance", 90, 185), # *zing*
      (agent_get_item_slot, ":item", ":agent", 4), #head slot
      (try_begin),
          (ge, ":item", 1),
         (agent_unequip_item, ":agent", ":item"),
      (try_end),
      (agent_equip_item, ":agent", "itm_invisible_head"),
      (particle_system_burst, "psys_game_blood_2", pos0, 125), #Yeah..
      #(set_spawn_position, pos1),
      #(spawn_scene_prop, "spr_physics_head"),
   ]),
   
common_battle_tab_press = (
  ti_tab_pressed, 0, 0, [],
  [
    (try_begin),
      (eq, "$g_battle_won", 1),
      (call_script, "script_count_mission_casualties_from_agents"),
      (finish_mission,0),
    (else_try),
      (call_script, "script_cf_check_enemies_nearby"),
      (question_box,"str_do_you_want_to_retreat"),
    (else_try),
      (display_message,"str_can_not_retreat"),
    (try_end),
    ])

Cheers.

Did you add a reference to "theoris_decapitation" for each needed mission_template, i.e., "lead_charge"?

(ge, ":damage", 30),  -  If the damage is greater than or equal to 30.
(val_sub, ":hp", 5),  - 
      (store_agent_hit_points, ":hp", ":agent", 1),  => Stores agent hp to :hp
      (val_sub, ":hp", 5),  => Subtracts 5 from :hp (hp = hp -5)
      (ge, ":damage", ":hp"),  => If ( damage >= hp) (after hp - 5) (ie if damage >= hp-5)
Not sure what it's used for though... maybe it should be val_add??
 
Maybe that:


      (ge, ":damage", ":hp"),  => If ( damage >= hp) (after hp - 5) (ie if damage >= hp-5)

Would means "if damage > :hp then chop the head' off" (so if damage = 30 but :hp 40 (hp 45- 5) the head remains) but I really don't know.

Anyways, I don't add any reference because I didn't know that step was needed and -most important- because I don't know how. I've read the MS sticky thread but many this are not explained.

Thanks again for clarify and help such newbie.
 
Einskaldir said:
Maybe that:


      (ge, ":damage", ":hp"),  => If ( damage >= hp) (after hp - 5) (ie if damage >= hp-5)

Would means "if damage > :hp then chop the head' off" (so if damage = 30 but :hp 40 (hp 45- 5) the head remains) but I really don't know.

Anyways, I don't add any reference because I didn't know that step was needed and -most important- because I don't know how. I've read the MS sticky thread but many this are not explained.

Thanks again for clarify and help such newbie.

See part "incursion in mission_template":
http://forums.taleworlds.com/index.php/topic,134031.0.html
 
Thanks SonKidd, that link was very enlightning, and the references are currently added as follows:
Code:
(
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [//
      common_battle_order_panel_tick,

    ], theoris_decapitation,
  ),

Already compiled without errors, however still not working.

There are any other MS file that needs to be tweaked besides mission templates?
 
Code:
(
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [//
      common_battle_order_panel_tick,
    theoris_decapitation,

    ],
  ),
Code:
theoris_decapitation = (
    ti_on_agent_hit, 0, 0, [],
    [
       (store_trigger_param_1, ":agent"),
      (agent_is_human, ":agent"),
       (store_trigger_param_3, ":damage"),
      (ge, ":damage", 30), #strong blow
      (store_agent_hit_points, ":hp", ":agent", 1),
      (val_sub, ":hp", 5),
      (ge, ":damage", ":hp"),
      (agent_get_position, pos1, ":agent"),
      (get_distance_between_positions, ":distance", pos1, pos0),
      (is_between, ":distance", 90, 185), # *zing*
      (agent_get_item_slot, ":item", ":agent", 4), #head slot
      (try_begin),
          (ge, ":item", 1),
         (agent_unequip_item, ":agent", ":item"),
      (try_end),
      (agent_equip_item, ":agent", "itm_invisible_head"),
      (particle_system_burst, "psys_game_blood_2", pos0, 125), #Yeah..
      #(set_spawn_position, pos1),
      #(spawn_scene_prop, "spr_physics_head"),
   ])
 
Thanks Theoris, tried it right now as you said. Compiled ok, but recieved this error ingame:

errormzc.jpg
 
*facepalm*

Edit 1: That's fixed now and works! (tried replacing the head with a helmet and is ok. Now just need to make some chopped and bloody neck instead of a helmet and done!

Thank you all very, very much!

Edit 2:
mb6s.jpg

Just need to tweak the textures a bit.

P.S: At the moment of cut some heads no extra blood was flowing, but anyways is really nice!
 
Apart from a temporary particle blood effect, maybe it's possible to spawn a puddle of blood at the ground beneath the one that just lost his head. With several different shaped puddles and a randomised selection so it's not getting boring that quickly.

Another thing, with invisible gloves, cutting off hands should be possible too. But I think getting a proper hit location detection is difficult here.
 
Good idea about the hands. I was thinking on cutting legs too. I guess that this can be done in the same way, the problem as you say, is how to get the hit location.
 
I guess that modifying your initial decapitation code would be good for legs (random leg or specific) changing the distance in pos0 to 50, 55 or something like that.

Note: If the above is a ridiculous statement is just because I only guess, without having any real coding knowledge.
 
Legs are usually below a certain height (unless they're jumping or kicking, which bots will never do). The problem is that if you reequip another item, both legs will be affected (unless you separate the rigged meshes and make new items). The amount of boots would then triple. The same problem would occur with gloves, which is also difficult to track (you could assign general areas for specific agent actions/animations, but it's probably not worth the effort).

Also, bleeding stumps should be easy enough.
Code:
(ti_on_item_init, 
[
(set_position_delta, 0, 0, -10), #center of head is somewhere above stump?
(particle_system_add_new, "psys_game_blood"),
(particle_system_emit, "psys_game_blood" , 100000, 100),
]
),
Not too sure about the last parameter - if you leave it out the particles should run out by themselves.
 
So can this work or have I to set in another way?

theoris_decapitation = (
    ti_on_agent_hit, 0, 0, [],
    [
      (store_trigger_param_1, ":agent"),
      (agent_is_human, ":agent"),
      (store_trigger_param_3, ":damage"),
      (ge, ":damage", 50), #strong blow
      (store_agent_hit_points, ":hp", ":agent", 1),
      (val_sub, ":hp", 5),
      (ge, ":damage", ":hp"),
      (agent_get_position, pos1, ":agent"),
      (get_distance_between_positions, ":distance", pos1, pos0),
      (is_between, ":distance", 160, 176), # *zing*
      (agent_get_item_slot, ":item", ":agent", 4), #head slot
      (try_begin),     
          (ge, ":item", 1),
        (agent_unequip_item, ":agent", ":item"),
        (le, ":hp", 0),
        (set_position_delta, 0, 0, -10), #center of head is somewhere above stump?
        (particle_system_add_new, "psys_game_blood"),
        (particle_system_emit, "psys_game_blood" , 100000, 100),

      (try_end),
      (agent_equip_item, ":agent", "itm_invisible_head"),
      (particle_system_burst, "psys_game_blood_2", pos0, 125), #Yeah..
      #(set_spawn_position, pos1),
      #(spawn_scene_prop, "spr_physics_head"),
    ])
 
Note the trigger ti_on_item_init. It goes with itm_invisible_head. If you start bursting from the ti_on_agent_hit trigger it will only emit where the stump was, and won't fall with the corpse.
 
This is my code to detect the body part that hit :
Code:
check_wounded_troop = (ti_on_agent_hit, 0, 0, [], 
 [(store_trigger_param_1, ":agent_id"),
  (store_trigger_param_2, ":attacker"),	
  (store_trigger_param_3, ":damage"),  
  (agent_get_troop_id, ":troop_id", ":agent_id"),
  (agent_get_troop_id, ":troop_attacker", ":attacker"),
  ### DISPLAY ONLY ########################################
  (assign, reg1,  ":damage"),
  (str_store_troop_name, s1,":troop_id"),
  (str_store_troop_name, s2,":troop_attacker"),
  (try_begin),
	 (ge, reg0, 0),
	 (str_store_item_name, s3, reg0),
  (else_try),
       (str_store_string, s3, '@NO ITEM'),	
  (try_end),  
  ### DISPLAY ONLY ########################################
  (assign, reg1,  ":damage"),
  (set_fixed_point_multiplier, 100),  
  (agent_get_position,pos1,":agent_id"),
  (position_transform_position_to_local, pos3, pos1, pos0),	        # pos 3 is relative location of hit
  (position_get_x, ":x_off", pos3), (position_get_y, ":y_off", pos3), (position_get_z, ":z_off", pos3),  
  (agent_get_horse, ":horse", ":agent_id"),
  (try_begin),
     (ge, ":horse", 0), (val_sub, ":z_off", 90),                    # offset for riding     
  (try_end),                                                        # hit part : 0 : head; 1 : body; 2 : left arm; 3 : right arm; 4 : left leg; 5 : right leg             
  (try_begin),
     (is_between, ":z_off", 150, 180),
     (try_begin),
       (is_between, ":y_off", -30, 30), 
       (display_message, "@{s2} hit {s1}'s head by {s3} with {reg1} damage."),
     (else_try),
       (ge, ":x_off", 0),
       (display_message, "@{s2} hit {s1}'s right arm by {s3} with {reg1} damage."),
     (else_try),
       (display_message, "@{s2} hit {s1}'s left arm by {s3} with {reg1} damage."),
     (try_end),  
  (else_try),
     (le, ":z_off", 90),
     (try_begin),
       (ge, ":x_off", 0),
       (display_message, "@{s2} hit {s1}'s right leg by {s3} with {reg1} damage."),
     (else_try),
       (display_message, "@{s2} hit {s1}'s left leg by {s3} with {reg1} damage."),
     (try_end),
  (else_try),
     (is_between, ":z_off", 90, 150),
     (try_begin),
       (is_between, ":y_off", -30, 30),
       (is_between, ":x_off", -30, 30),
       (display_message, "@{s2} hit {s1}'s body by {s3} with {reg1} damage."),
     (else_try),
       (ge, ":x_off", 0),
       (display_message, "@{s2} hit {s1}'s right arm by {s3} with {reg1} damage."),
     (else_try),
       (display_message, "@{s2} hit {s1}'s left arm by {s3} with {reg1} damage."),
     (try_end),     
  (try_end),   
])

Head is 150 to 180 cm from ground, with 30 cm radius from center. Legs are below 90 cm, body is 90-150 cm from ground, with 30 cm radius from center. Outside of the radius could be arms. It's not too precision, but better then only check distance_from_ground.
 
Back
Top Bottom