Picking Up And Equipping Weapons/ Items In Scenes

正在查看此主题的用户

Flanged

Sergeant Knight
Hello,

I did quite a few searches, thinking it must've been done before, but there doesn't seem to be any free-use scripts to allow the player to pick up a weapon or item (shield, etc.) in a scene and use it.  I think this is implemented widely in Warband, but I'm still working in 1.011, and a function like this would really help.  Is it possible?

I have already implemented GetAssista's script for picking up and throwing scene props:
http://forums.taleworlds.com/index.php/topic,93567.0.html


It's great  fun - thanks GetAssista!

But what I need now is something that would let me pick up a scene prop gun or blade and use it as a normal equipped weapon.  It would be best if there was no necessity for a dialogue screen, or a reloading of the whole scene, in order to equip the weapon, as this would maybe interfere with other scripts running in the scenes, especially the ones based on timers.

Does anyone know if this is even possible?  Like I say, it's for 1.011, with it's slightly more limited functions.
Any help is appreciated.

 
I don't know, but like you mentioned it is standard in warband. It just works with the F key like other interactable items in game, no menus or anything, hit F when you're looking at it right and it's in your hand. Maybe you can get warband and do your mod in there?
 
It sounds like you could create a scene_prop_slot in module_constants.py to hold a related item. Then in you script or mission trigger you would check the prop that was picked up. If it was related to a valid item(you would need a default value of -1) you would remove the scene_prop and replace it with the item or weapon set for that prop.
 
In 1.011 you could use the (spawn_item) operation, but I can't tell you how it could be used; I haven't experimented with it yet.
 
Thanks for the help guys, unfortunately I can't seem to get it to work.  I am trying to add pick-uppable weapons to Quick Battles, and had another idea that could do the job, maybe more simply.  Can anyone tell me what exactly stops the player from being able to access a standard chest during a Quick Battle?  I have a chest containing items set up to appear in the scene, and the option to open it appears, but pressing F does nothing - I've tried changing the mission template in various ways that should allow a chest and the inventory to be accessible, but it doesn't seem to work...

Can anybody help?

Also, does the "troop_add_item" command, used through a dialog, not work in 1.011?  I've got Ramun the slave trader in my scene, renamed and re-equipped, and his dialog is changed so that he should give me his spare club like he used to do in the old days of Zendar... but he doesn't give me it, and there seems to be no good reason why...  It's pretty annoying.  This is all that's holding me back now, and if I can get a solution it'll be great.
 
I was trying to get it to work with a standard Native chest for now... the little box appears saying "Open" but pressing F has no effect.

I will try what you suggest - a new scene prop with the container flag.  It would work better that way.  I just hope there isn't some limitation in the mission_template that's stopping me from having inventory access, otherwise the chest method won't work.
 
I don't know if it works with 1.011, but the Warband module system has this script that can be called under ti_before_mission_start:

插入代码块:
  # script_replace_scene_items_with_spawn_items_before_ms
  # Input: none
  # Output: none
  ("replace_scene_items_with_spawn_items_before_ms",
    [
      (try_for_range, ":item_no", all_items_begin, all_items_end),
        (scene_item_get_num_instances, ":num_instances", ":item_no"),
        (item_set_slot, ":item_no", slot_item_num_positions, 0),
        (assign, ":num_positions", 0),
        (try_for_range, ":cur_instance", 0, ":num_instances"),
          (scene_item_get_instance, ":scene_item", ":item_no", ":cur_instance"),
          (prop_instance_get_position, "$g_position_to_use_for_replacing_scene_items", ":scene_item"),
          (store_add, ":cur_slot", slot_item_positions_begin, ":num_positions"),
          (item_set_slot, ":item_no", ":cur_slot", "$g_position_to_use_for_replacing_scene_items"),
          (val_add, ":num_positions", 1),
          (val_add, "$g_position_to_use_for_replacing_scene_items", 1),
          (item_set_slot, ":item_no", slot_item_num_positions, ":num_positions"),
        (try_end),
        (replace_scene_items_with_scene_props, ":item_no", "spr_empty"),
      (try_end),
     ]),
 
I found out that you can spawn items on entry points from within a mission template. I found this under one of the mission templates for the tutorial scene, and just copied it and messed around with the numbers.

      (ti_before_mission_start, 0, 0, [],
      [

(assign, "$g_position_to_use_for_replacing_scene_items", pos:cool:,
        (call_script, "script_replace_scene_items_with_spawn_items_before_ms"),

  ]),


(0, 0, ti_once, [],
      [
        (call_script, "script_replace_scene_items_with_spawn_items_after_ms"),
       
        (entry_point_get_position, pos1, 50),
        (set_spawn_position, pos1),
        (spawn_horse, "itm_charger", imod_champion),

        (entry_point_get_position, pos1, 51),
        (set_spawn_position, pos1),
        (spawn_item, "itm_sniper_crossbow", 0),

]),

I'm not too sure what positions are used for (i.e. where it says "pos1"). If someone could clarify that, I would be much appreciative. What I do know, though, is that it works :lol:


I also added a horse in there, as you may have noticed. Works just as good as the items.

Anyway, just put copy the code from the spoiler and add it under the trigger block within the mission template you are using for your scene. And then place the entry points where you want the items to be in your scene.
 
positional registers are used by the game to specify a point and orientation within the game, relative to an original as set in mission_templates. You can fetch it from many get_position operations, and you can shift/rotate them around and such. It doesn't have to be an entry point - agents, scene props, and such will also work. Also, you don't need to use those scripts - they're simply used in the tutorial to replace scene prop items (which are stored with the scene) with scene items that the player can actually use. Spawning an item dynamically is probably better - the scene props have fixed ids, so if you change the order of the items, then item 595 and 596 will spawn instead of the second set of practice bow and arrows.
 
后退
顶部 底部