OSP Kit QoL Open/close helmet

Users who are viewing this thread

Ikaguia

Grandmaster Knight
put this at the beggining of the file, just like the other common_
Code:
#Open-Close Helmet
open_close_helmet = (
    0, 0, 0, [(key_clicked, key_q),(neg|main_hero_fallen)],
        [
		(get_player_agent_no, ":player_agent"),
		(agent_is_active, ":player_agent"),
		(agent_get_item_slot, ":helmet_1", ":player_agent", ek_head),
		(item_get_slot, ":helmet_2", ":helmet_1", slot_open_close_helmet),
                (gt, ":helmet_2", 0),
                (agent_unequip_item, ":player_agent", ":helmet_1"),
                (agent_equip_item, ":player_agent", ":helmet_2"),
        ])
#Open-Close Helmet
Code:
#Open-Close Helmet
slot_open_close_helmet = 0# any free item slot
#Open-Close Helmet
Code:
  # script_initialize_open_close_helmets
  ("initialize_open_close_helmets",
   [
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
   (try_for_range, ":itm_1", 0, "itm_items_end"),
         (item_get_slot, ":itm_2", ":itm_1", slot_open_close_helmet),
	 (gt, ":itm_2", 0),
	 (item_set_slot, ":itm_2", slot_open_close_helmet, ":itm_1"),#so that you dont have to do both (item_set_slot, "itm_1", "itm_2") and (item_set_slot, ":itm_2", ":itm_1")
   (try_end),
   ]),
Code:
(call_script, "script_initialize_open_close_helmets"),


this code enables the player to open&close his helmet by pressing "q" key
 
You want to use agent_get_item_slot, not agent_get_wielded_item. Put the actual condition (key_clicked) in the conditions, and possibly add a re-arm interval to be more realisitc.
 
Demonwolf said:
So what does this do...?
As is, nothing, until _get_wielded_item is swapped for an _get_item_slot operation since only weapons and shields are "wielded". Once that is corrected, it should swap one item for another--so you would need one separate item that looks like an opened helmet and another separate item entry that looks like a closed helmet. There will be no animation between them, on key press it would just swap from one to the other.

Ikaguia said:
and (key_clicked, key_q),... it is already there
But it wastes computing power in every single frame since it isn't in the conditions block. If the key isn't pressed, none of the rest of the code needs to be read. As it is now, those first few lines are constantly, needlessly, running.
 
No, he obviously did it like I tend to, and wrote something without bothering first :mrgreen:

Try not to give him too hard of a time, guys, the idea's good. 
 
so, should this work?

Code:
#Open-Close Helmet
open_close_helmet = (
    0, 0, 0, [(key_clicked, key_q),],
        [
            (get_player_agent_no, ":player_agent"),
            (try_for_range, ":helmet_1", 0 , "itm_items_end"),
                (troop_has_item_equipped,":player_agent",":helmet_1"),
                (item_get_slot, ":helmet_2", ":helmet_1", slot_item_open_close_helmet),
                (gt, ":helmet_2", 0),
                (agent_unequip_item, ":player_agent", ":helmet_1"),
                (agent_equip_item, ":player_agent", ":helmet_2"),
            (try_end),
        ])
#Open-Close Helmet
 
Unequiping and equiping helmets by operation agent_unequip_item/agent_equip_item causes this:
mb2iq.jpg
*
It doesn't look good...

*Screen taken from BugTracker.
 
ThaneWulfgharn said:
Nope.Dosen't recognise :helmet_1 and :helmet_2.

You need to set up the initialize script with these declarations:
(item_set_slot, "itm_<open_helmet>", slot_open_close_helmet, "itm_<closed_helmet>"),
one line for each helmet that you have the open/close pair for.

And it does look like there is a quotation missing in a few of the places around variable names in the first post. But that's any easy fix.
 
Back
Top Bottom