[HELP] Placing pickupable items (such as weapons) in a scene?

正在查看此主题的用户

DeepRedCee

Recruit
Hey y'all

I've searched around (alot) and am getting pretty frustrated. How do you place items such as weapons and shields inside a scene ready to be picked up? So every time you enter that scene the item or weapon is always there?

In edit mode you can place objects from Item Kinds but they're just like scene props you can't interact with them or anything.

Cheers for any help
 
If you visit the tutorial training ground (first option), you can see how scene items are transformed into spawned items - this is done by calls to script_replace_scene_items_with_spawn_items_before_ms and replace_scene_items_with_spawn_items_after_ms. This is subject to a number of limitations, such as the number of items per type (slot_item_positions_begin and the slots reserved after it), and the total number of items replaceable (there are only a max of 65 position registers available, you'll need to break down the script into two or more parts if you're reserving certain position registers or have more than that many items that need replacing).
 
thanks dude. having a look at it now, boggling my mind a bit. such a convoluted way to do something so simple, but i suppose that mount and blade really. will update with progress :smile:
 
alright so I got it working - all good, item kinds scene props turn into items which can be picked up.

however, since my mod is multiplayer anyone who tries to join the server crashes due to client server synchronization.

can anyone give us a hand with setting up some sync? thinking I'll have to make it a server side script or something but really i aint sure.

cheers for any help as usual guys!
 
alright, so i put (multiplayer_is_server), in my trigger and it works so people can connect to my server once and everything works fine.

However, when people leave and rejoin they get automatically kicked and cant rejoin. No idea on this one any help would be awesome :smile:

This is what the code looks like:

插入代码块:
  ##item replacement
	 (0, 0, ti_once, [],
    [
	 (multiplayer_is_server),
	 (call_script, "script_replace_scene_items_with_spawn_items_before_ms"),
	 (call_script, "script_replace_scene_items_with_spawn_items_after_ms"),		
	]),
 
script_replace_scene_items_with_spawn_items_before_ms uses the operation replace_scene_items_with_scene_props, which I assume is similar to replace_scene_props and should be used within ti_before_mission_start. I have no idea how that would work in a multiplayer context - probably something like calling it on the client side when they join a server, which your script doesn't (it only initializes it, in the wrong trigger). People more experienced with multiplayer can probably tell you why it's causing a sync error.
 
DeepRedCee 说:
插入代码块:
	 (0, 0, ti_once, [],
    [
	 (multiplayer_is_server),
	 (call_script, "script_replace_scene_items_with_spawn_items_before_ms"),
	 (call_script, "script_replace_scene_items_with_spawn_items_after_ms"),		
	]),
The multiplayer_is_server operation is all that's needed to prevent clients running the code and causing a synchronization error; but those native scripts are almost certainly split up into before_ms and after_ms for a reason: the before_ms script should be called from a ti_before_mission_start mission template trigger, and the after_ms script should be called from a ti_before_mission_start trigger, or a (0, 0, ti_once one, as you have (compare with the Native tutorial usage).

How the scripts seem to work, basically: before mission start a global variable is set to point to pos8 (position register :cool:, then all items are looped over and checked for any scene editor placed instances, if so the position is stored in the current position register pointed at by the global, the pos number stored in a list of item slots, then the global variable incremented to point at the next position register, until all item positions are saved, then the scene editor placed items are all replaced with spr_empty; after mission start, the other script goes through all item slots in the lists, spawning items at the position registers pointed at. This causes some limitations and potential problems: if any other trigger or script modifies position registers 8 or above between the two script calls it will mess up spawned item positions; and you can only have a maximum of 120 items of all types spawned this way: there are only 128 of each type of register (reg0 -> reg127, pos0 -> pos127, s0 -> s127, the higher numbers usable with those names if the python constants are defined), and the global pointer starts at pos8 and goes to pos127 (120 registers); if more are placed, 128 and above will probably truncate back to start from 0 again, overwriting positions of earlier item instances. You probably didn't care much about all that detail, but I just felt like investigating it.

It's possible that the method used by those scripts - for the Native tutorial - do not work in multiplayer; I'd try splitting up the calls as suggested above, and if that doesn't work you probably need to write and test your own feature.
 
Cheers for the help Vornne. It's all working now with no issues.

I've just realised the issue where players are kicked when they try to rejoin predates me adding this feature in...

Not a clue what it could be auto-kicking players but thanks ya'll
 
后退
顶部 底部