Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
WEll, I tried my luck on creating an a script which creates a scene prop when the object is thrown. It didn't work out well. It after throwing, you got a huge lagg for 5-10 seconds and after that, it didn't even spawn. With few changes, it did but still the huge lag + crashed when looked at prop. Could some help on this? I'm new to coding so don't be too harsh:razz:
Code:
["sandbags","Sandbags", [("sand_b_barricade",0)], itp_type_thrown |itp_merchandise|itp_primary ,itcf_throw_stone, 1000 , weight(4)|difficulty(0)|spd_rtng(97) | shoot_speed(30) | thrust_damage(0 ,  blunt)|max_ammo(2)|weapon_length(8),imodbits_none,
   [(ti_on_missile_hit, [
							 
							  (multiplayer_is_server),
							  (store_trigger_param_1, ":meplayer"),
							  (multiplayer_get_my_player, ":meplayer"),
							  (player_get_agent_id, ":meagent", ":meplayer"),
							  (agent_get_position, pos2, ":meplayer"),
							  (position_set_z_to_ground_level, pos2),
							  (set_spawn_position, pos2),
							  
                              (spawn_scene_prop,"spr_barricade_b"),
							  (particle_system_burst, "psys_dummy_smoke", pos2, 50),
							  (scene_prop_set_slot, reg0, scene_prop_C4_placer, ":meplayer"),
						])]],
 
Why do you store the trigger parameter in ":meplayer" only to overwrite it? Also, shouldn't you make it a ti_on_weapon_attack. The ti_on_missle_hit is probably causing the lag. Since you can't throw a sandbag far you might as well measure out a little bit from the player and set z level to ground.

EDIT: Sorry wrong trigger, I fixed it.
 
ithilienranger said:
Why do you store the trigger parameter in ":meplayer" only to overwrite it? Also, shouldn't you make it a ti_on_weapon_attack. The ti_on_missle_hit is probably causing the lag. Since you can't throw a sandbag far you might as well measure out a little bit from the player and set z level to ground.

EDIT: Sorry wrong trigger, I fixed it.
So, your saying that I should remove or change it to :meagent instead?
Theoris said:
Might be either the model or the dummy smoke.
Ill try removing the dummy smoke. Thanks.
 
I am saying to use  (store_trigger_param_1, ":meplayer"), and the ti_on_weapon_attack because then you automatically get the agent with the weapon. I believe part of the lag is from ti_on_missile_hit because it has to check for collisions.
 
ti_on_missile_hit isnt checking for any collisions

it is called once all the actual code is done and the position is given as a parameter
 
Your code has several problems.

  (multiplayer_is_server),
  (store_trigger_param_1, ":meplayer"),
  (multiplayer_get_my_player, ":meplayer"),
  (player_get_agent_id, ":meagent", ":meplayer"),

  (agent_get_position, pos2, ":meplayer"),
  (position_set_z_to_ground_level, pos2),
  (set_spawn_position, pos2),
 
                              (spawn_scene_prop,"spr_barricade_b"),
  (particle_system_burst, "psys_dummy_smoke", pos2, 50),
  (scene_prop_set_slot, reg0, scene_prop_C4_placer, ":meplayer"),

":meplayer" is a player, not an agent, you can't call agent_get_position with it.
Doesn't make much sense. This would result in the sandbag being placed at the position of the host player everytime anyone throws that item, as this trigger is only called by the server. If you used a dedicated server, it would cause even more issues, as there would be no host player.
This is being overwritten in the next line, so it doesn't have any effect.
 
Highlander said:
Your code has several problems.

  (multiplayer_is_server),
  (store_trigger_param_1, ":meplayer"),
  (multiplayer_get_my_player, ":meplayer"),
  (player_get_agent_id, ":meagent", ":meplayer"),

  (agent_get_position, pos2, ":meplayer"),
  (position_set_z_to_ground_level, pos2),
  (set_spawn_position, pos2),
 
                              (spawn_scene_prop,"spr_barricade_b"),
  (particle_system_burst, "psys_dummy_smoke", pos2, 50),
  (scene_prop_set_slot, reg0, scene_prop_C4_placer, ":meplayer"),

":meplayer" is a player, not an agent, you can't call agent_get_position with it.
Doesn't make much sense. This would result in the sandbag being placed at the position of the host player everytime anyone throws that item, as this trigger is only called by the server. If you used a dedicated server, it would cause even more issues, as there would be no host player.
This is being overwritten in the next line, so it doesn't have any effect.
: D That explains. I changed the code quite a bit. Ill post it soon after testing it.
 
Theoris said:
ti_on_missile_hit isnt checking for any collisions

it is called once all the actual code is done and the position is given as a parameter
What? It has to check when the missile hits an object and thus the code is finished. It is overkill for dropping a sandbag though.
 
Alrighty, made changes. Now, the scene prop does spawn. However, after you have released the attack button, there is a 4 second delay, then, the prop spawns, works fine for a short while. After few seconds, it starts lagging and game crashes. Here is the code now

Code:
["sandbags","Sandbags", [("sand_b_barricade",0)], itp_type_thrown |itp_merchandise|itp_primary ,itcf_throw_stone, 1000 , weight(4)|difficulty(0)|spd_rtng(97) | shoot_speed(30) | thrust_damage(0 ,  blunt)|max_ammo(2)|weapon_length(8),imodbits_none,
   [(ti_on_weapon_attack, [
							 
							  (multiplayer_is_server),
							  (store_trigger_param_1, ":cur_agent"),
							  (agent_get_position, pos2, ":cur_agent"),
							  (try_for_agents, ":cur_agent"),
							  (agent_is_alive, ":cur_agent"),
							  (agent_is_active, ":cur_agent"),
							  (position_set_z_to_ground_level, pos2),
							  (set_spawn_position, pos2),
							  
                              (spawn_scene_prop,"spr_barricade_b"),
							  (particle_system_burst, "psys_dummy_smoke", pos2, 50),
							  (scene_prop_set_slot, reg0, scene_prop_C4_placer, ":cur_agent"),
						])]],
What to do? Should I remove the dummy smoke for testing?
 
Not only that, but the try_for_agents you placed has no try_end with it, so it's spawning things and bursting particles at any active, alive agent-including horses. That's why you're lagging.
 
Alrighty, the script works : 3 Thanks all :razz: And the crashes weren't because of the script. It was because of the collision model. the sandbag wall has 10k faces, and I used the exact same model for collision model. No wonder it exploded.  :lol: Anyways, Ill try to start a landmine code using this as a base code.

Edit: And still regarding my prone animation, any ideas what flags to use in order that guy wouldn't lift his back up? Like it goes 90 degrees :/
 
Theoris said:
Can I use agent_unequip_item and agent_equip_item on items like Head, Body or Foot?
The agent_equip_item operation mostly works - it just doesn't refresh the hair and beard, so equipping a helmet from having none will leave the hair mesh sticking through it - possible workarounds are to equip dummy armor with the naked body parts as the mesh (which would probably get very complicated with different skin colors and hair styles - using tableaus might help a bit), always spawn players with some sort of head armor, or to respawn the player in the same place instead (which can get complicated); agent_unequip_item doesn't seem to work with armor, only weapons. For details see bugs 3071 and 3353.
 
Ah.. so decapitations will not work anyway. Damnit.  :razz:

Edit.
How could one make epic particle systems like in Highlander's western mod? Are there any tutorials?
 
Okay, screw that earlier question, I've got a more important issue.

Question: can a client use x_get_slot, whereas x could be agent or troop? I'm asking because this:
Code:
(agent_get_slot, reg1, ":agent", 50),
always returns zero client-wise, even though it's like 50 on the server. The server even recognizes it being higher than zero. I'm asking because I'm afraid I might have simply crapped up in my presentation. Otherwise I'm going to have to do some shenanigans with server & client events.
 
Status
Not open for further replies.
Back
Top Bottom