Anyone know how to go about making server side barricades?

Users who are viewing this thread

I have seen it done, placing barricades in a server side invasion mod such as 27 days.

Anyone can hint me on how it might of been done?


You purchased a hammer off the table and when using it a wood panel would appear in front of you, and you clicked to place. 

Is it hard?  :sad:

Essentially I was going to leave that sort of feature out, because it causes server crashes, but since I am going to use brainy bots, there will not be 100 bots freaking out over a barricade, as for the bots go, it will be quality over quantity. 
 
Code:
(ti_on_weapon_attack, [
	(set_fixed_point_multiplier, 1000),
	(position_move_x, pos1, 99), ## tweak these 3 values to spawn the prop in front of you
	(position_move_y, pos1, 99),
	(position_move_z, pos1, 99),
	(set_spawn_position, pos1),
	(spawn_scene_prop, <scene_prop_id>), ## put the id of the large siege shield or whatever prop you want to use as barricade
	## don't forget to go to module_scene_props and edit the prop so when it is destroyed, it will be moved underground
	## also you need to make a script that will make the bots attack the barricades
])
 
okay so i tried porting an old barricade code from 2010, lots of errors.

this seems simpler, though on attack?  Did not know shields could attack though your code makes sense. 

How would i get the bots to attack the prop?  Is there a way to give a prop an agent id and team number? lol

Edit:  I think i am going to do it more like 27 days did it, where it costs money to place a barricade, so instead of spawning a shield, i will find some sort of plank and when someone uses their engineer hammer it will cost like 1-5k to place some kind of board in native if i can find one. 


 
If making them attack it is too difficult, then you could always set the prop to disapear after awhile, sort of like the ladders in PW.  Maybe set a time limit on how often it can be built if you're going this path too.
 
yeah this is what i have so far.  Still need to choose the items and props to use. 

Code:
(ti_on_weapon_attack, [
    (store_trigger_param_1, ":player_id"), 
	(player_get_agent_id, ":agent_id", ":player_id"),
	(player_get_gold, ":gold", ":player_id"),
	(try_begin),
	(lt, ":gold", 5000),
	(str_store_string, s41, "@Not enough gold to place barricade, you need 5000! "),	
    (multiplayer_send_string_to_player, ":player_id", multiplayer_event_show_server_message, s41),
	(else_try),
    (ge, ":gold", 5000),	
	(agent_get_wielded_item, ":wielded_item", ":agent_id", 0),
	(eq, ":wielded_item", 367),
	(agent_get_position, pos1, ":agent_id"),
	(set_fixed_point_multiplier, 1000),
	(position_move_x, pos1, 0), ## tweak these 3 values to spawn the prop in front of you
	(position_move_y, pos1, 99),
	(position_move_z, pos1, 0),
	(set_spawn_position, pos1),
	(spawn_scene_prop, "spr_wood_heap_b"),
	(call_script, "script_player_adjust_gold", ":player_id", 5000, -1),
    (str_store_string, s42, "@Barricade Placed for 5000 gold! "),	
    (multiplayer_send_string_to_player, ":player_id", multiplayer_event_show_server_message, s42),	
	(try_end),
]),

I am not sure on weapon attack has triggers yet, we will see. 
 
this is what i am using for the prop i chose, but i am unsure how to get the bots to attack it.

Code:
("wood_heap_b",sokf_show_hit_point_bar|sokf_destructible,0,"wood_heap_b","bo_wood_heap_b", [
  
  (ti_on_init_scene_prop,
    [
      (store_trigger_param_1, ":instance_no"),
      (scene_prop_set_hit_points, ":instance_no", 2000),
    ]),
     


   (ti_on_scene_prop_destroy,
    [
      (play_sound, "snd_dummy_destroyed"),
      
      (assign, ":rotate_side", 86),
      
      (try_begin),
        (this_or_next|multiplayer_is_server),
		
        (store_trigger_param_1, ":instance_no"),      

        (set_fixed_point_multiplier, 100),
        (prop_instance_get_position, pos1, ":instance_no"),


          (try_begin),
            (position_move_z, pos1, -100),
			(prop_instance_set_position, ":instance_no", pos1),
          (try_end),
        (try_end),

    ]),       

    (ti_on_scene_prop_hit,
    [
      (store_trigger_param_1, ":instance_no"),       
      (store_trigger_param_2, ":damage"),
      
      (try_begin),
        (scene_prop_get_hit_points, ":hit_points", ":instance_no"),
        (val_sub, ":hit_points", ":damage"),
        (gt, ":hit_points", 0),
        (play_sound, "snd_dummy_hit"),
      (else_try),
        (neg|multiplayer_is_server),
        (play_sound, "snd_dummy_destroyed"),
      (try_end),

      (try_begin),


        (particle_system_burst, "psys_dummy_smoke", pos1, 3),
        (particle_system_burst, "psys_dummy_straw", pos1, 10),
      (try_end),      
    ]),
  ]),
 
There's this code I wrote for NI ages ago, not sure if it's compatible. Basically it finds the wielded weapon and forces the appropriate attack to play, aiming at the barricade. If it hits great, but the majority of damage will probably done through calculating the agent's strength. You can probably get rid of the force attack if it screws with the bots too much.
Code:
#module_mission_templates
(1, 0, 0, [(multiplayer_is_server),], [
(try_for_range, ":prop", "spr_barricade", "spr_explosive_barrel"), (call_script, "script_cf_destroy_barricade_new", ":prop",0), (try_end),]),

##New script Full Invasion FI FuIn
  # script_cf_destroy_barricade
  # Input: arg1 = instance_no (none = 0)
  # Input: arg1 = prop_no (spr_pavise, etc)
  # Output: none
  ("cf_destroy_barricade_new",
    [ (store_script_param_1, ":instance_no"),
      (store_script_param_1, ":prop_no"),


	  (scene_prop_get_instance, ":barricade_object", ":prop_no", ":instance_no"),
      (ge, ":barricade_object", 0),
      (prop_instance_get_position, pos1, ":barricade_object"),
      # (try_begin),
        # (eq, ":prop_no", "spr_pavise"),
        # (assign, ":attack_distance", 120),
      # (else_try),
        # (assign, ":attack_distance", 320),
      # (try_end),
      (scene_prop_get_hit_points, ":hitpoints", ":instance_no"),
      (try_for_agents, ":agent_no"),
        (gt, ":hitpoints", 0),
        (agent_is_alive, ":agent_no"),
        (agent_is_human, ":agent_no"), #only horse should be sleipnir
        (agent_get_team, ":team_no", ":agent_no"),
        (eq, ":team_no", 1),
        # (agent_get_combat_state, ":aics", ":agent_no"),
        # (neq, ":aics", 1), #not firing ranged
        # (neq, ":aics", 1), #not firing ranged
        (agent_get_position,pos2, ":agent_no"),
        (get_distance_between_positions, ":dist", pos1, pos2),

        (le, ":dist", 320),
        
        (agent_get_wielded_item, ":weapon", ":agent_no", 0),
        (item_get_type, ":type", ":weapon"),
        (assign, ":attack_dir", -1),
        (try_begin), #random slashers (axes can't stab)
          (this_or_next|eq, ":type", itp_type_one_handed_wpn),
          (eq, ":type", itp_type_two_handed_wpn),
          (store_random_in_range, ":attack_dir", 1, 4),
        (else_try),
          (eq, ":type", itp_type_polearm),
          (assign, ":attack_dir", 3), #overhead (for pikes and such)
          (try_begin),
            (agent_get_wielded_item, ":shield", ":agent_no", 1),
            (this_or_next|gt, ":shield", 0), #shielding means no slashing
            (eq, ":weapon", "itm_tutorial_spear"), #stupid-ass town guard weapon
            #this might not even work if the MS reads the first tutorial spear (item #1 instead of #130)
            (assign, ":attack_dir", 0), #stabbity stab
          (try_end),          
        (try_end),
        (ge, ":attack_dir", 0),
        (agent_set_look_target_position, ":agent_no", pos1),
        # (store_random_in_range, ":attack_dir", 0, 4),
        (agent_set_attack_action, ":agent_no", ":attack_dir", 0), #swings at door
        (agent_get_troop_id, ":troop_id", ":agent_no"),
        (assign, ":str", 1),
        (try_begin),
          (gt, ":troop_id", 0),
          (store_attribute_level, ":str", ":troop_id", ca_strength),
        (try_end),
        (val_mul, ":str", 10),
        (val_add, ":str", 1),

        (val_sub, ":hitpoints", ":str"),
        (scene_prop_set_hit_points, ":instance_no", ":hitpoints"),
        (try_begin), #do destructible stuff
          (le, ":hitpoints", 0),
          (play_sound_at_position, "snd_dummy_destroyed", pos1),
          # (store_trigger_param_1, ":instance_no"),
          # (prop_instance_get_position, pos1, ":instance_no"),
          (position_move_z, pos1, -100),
          (prop_instance_set_position, ":instance_no", pos1),
          (scene_prop_set_visibility, ":instance_no", 0),
          (prop_instance_enable_physics,":instance_no", 0),
          (scene_prop_set_hit_points, ":instance_no", 0),
        (try_end),
      (try_end),
      
      (val_add, ":instance_no", 1),
      (call_script, "script_cf_destroy_barricade", ":instance_no"),
  ]),
 
Back
Top Bottom