Wielded_item check

Users who are viewing this thread

Greeting,

I have a question about displaying overlays. Can yuo help me with this? Here you can see small part of code, which is a check for weapon comparing to item  returned from agent_get_wielded_item check.

Code:
    (agent_get_wielded_item,"$magicweapon",":playeragent"),
		(try_begin),
                   (eq,"$magicweapon","itm_tpspmagic1"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells1"),
        (else_try),
                   (eq,"$magicweapon","itm_tpspmagic2"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells2"),
        (else_try),
                   (eq,"$magicweapon","itm_tpspmagic3"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells3"),
        (else_try),
                   (eq,"$magicweapon","itm_grspmagic1"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells4"),
        (else_try),
                   (eq,"$magicweapon","itm_grspmagic2"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells5"),
        (try_end),
    (overlay_set_position, "$smcspellview", pos1),

Check creates overlay to help player understand which spell he can use.  This works for equipped_item check, but equipped means  placed in all slots of body, so its reserved for Aura spells which depends on item equipped in armor slot.

When i am running the game, overlays are created,as you can see.



True problem appears when the player have 2 magic items (checked by this script). Overlay is created not for currently wielded (in hands) but for an item which is last in this check.

I tried to divide checks into different triggers, use local variable instead of global, additionally check special global variable which would allow only 1 successful check etc. All fails.

The game started to display overlay which is currently in the hands of player (even if this is not last). In next, there are 2 variants - if following magic item is placed bellow in this check, the game will display overlay for second and if you will switch to first item, nothing will change. If the first taken item was last in the check, game will not change overlays.

Can you help with this? Probably, i should use another check or smth else?

P.S. Ofc, i can place these checks directly into scripts of magic casting. But this decision have single flaw - overlays will appear after first spellcast - not before.
 
Sorry for starting this) SOLVED. Was need to set alpha on 0 in the beginning of each check, and to any color at the end. Think, this can be left here as an example, still its moderator's will.

Right code:

Code:
    (agent_get_wielded_item,"$magicweapon",":playeragent"),
		(try_begin),
                   (overlay_set_alpha, "$smcspellview", 0x00),
                   (eq,"$magicweapon","itm_tpspmagic1"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells1"),
                   (overlay_set_alpha, "$smcspellview", 0xff),
        (else_try),
                   (overlay_set_alpha, "$smcspellview", 0x00),
                   (eq,"$magicweapon","itm_tpspmagic2"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells2"),
                   (overlay_set_alpha, "$smcspellview", 0xff),
        (else_try),
                   (overlay_set_alpha, "$smcspellview", 0x00),
                   (eq,"$magicweapon","itm_tpspmagic3"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells3"),
                   (overlay_set_alpha, "$smcspellview", 0xff),
        (else_try),
                   (overlay_set_alpha, "$smcspellview", 0x00),
                   (eq,"$magicweapon","itm_grspmagic1"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells4"),
                   (overlay_set_alpha, "$smcspellview", 0xff),
        (else_try),
                   (overlay_set_alpha, "$smcspellview", 0x00),
                   (eq,"$magicweapon","itm_grspmagic2"),
                   (create_mesh_overlay, "$smcspellview", "mesh_smccastspells5"),
                   (overlay_set_alpha, "$smcspellview", 0xff),
        (try_end),
    (overlay_set_position, "$smcspellview", pos1),


This is result of 6 wasted hours in attempt to make decision((((((( so sad(
 
To note: Slots are healthier than globals, for the fact they are more limited and you have more control over it. Globals can be messy.
 
Efe Karacar said:
To note: Slots are healthier than globals, for the fact they are more limited and you have more control over it. Globals can be messy.

Thanks for the advice. But what the specific problems can appear by using global vars? Just interesting. Consider, i will meet em however )
 
Back
Top Bottom