User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: How to change Equipped Weapons?

  1. #1
    クールな男
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    35
    Posts
    5,587
    Mentioned
    20 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,594
    Level
    27
    vBActivity - Bars
    Lv. Percent
    96.73%

    How to change Equipped Weapons?

    So what would be the correct syntax to change Link's equipped weapons? I have the quest rule set so that you can equip any weapon to either A or B. I would also like to know how you can return the value of what is in item slot A and B.

    CODE: Show
    item script ItemSelector{
    void run(int a, int b){

    int a_equip;
    int b_equip;

    a_equip = GetEquipmentA();
    b_equip = GetEquipmentB();

    if (a_equip == b){
    Link->SelectAWeapon(b);
    }

    if (b_equip == b){
    Link->SelectBWeapon(b);
    }
    }
    }



    That's just me dickin' around, trying to figure it out. Also when using SelectAWeapon() and SelectBWeapon() - what is it referencing exactly? The item number itself, or the order number of the items in the inventory?

  2. #2
    Octorok CaRmAgE's Avatar
    Join Date
    Oct 2008
    Location
    Historia
    Age
    35
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,334
    Level
    12
    vBActivity - Bars
    Lv. Percent
    42.57%
    Link->Select?Weapon() accepts a direction for the subscreen cursor to move, not an item id or subscreen index. So, unfortunately, you'll have to cycle through all the items Link has until the correct ones are selected. Tested this in ZC; works rather well.

    CODE: Show
    item script ItemSelector{
    // int a: Item ID that button 'A' should be set to
    // int b: Item ID that button 'B' should be set to
    void run(int a, int b){
    if (a == GetEquipmentB()){
    // 'B' currently has the item needed on 'A', so move it out of the way.
    Link->SelectBWeapon(DIR_RIGHT);
    if(a == GetEquipmentB()){
    // Link only has two items to choose from. Don't know how to handle this case.
    Quit();
    }
    }
    int a_equip = GetEquipmentA();
    if(Link->Item[a]){ // Make sure Link has the item in question
    while (a != GetEquipmentA()){
    // Cycle through the items until the correct item for 'A' is found
    Link->SelectAWeapon(DIR_RIGHT);
    if(a_equip == GetEquipmentA()){
    // Item not found. Subscreen not setup correctly!
    break;
    }
    }
    }
    if (a == b){
    // You can't set both slots to the same item.
    Quit();
    }
    int b_equip = GetEquipmentB();
    if(Link->Item[b]){ // Make sure Link has the item in question
    while (b != GetEquipmentB()){
    // Cycle through the items until the correct item for 'B' is found
    Link->SelectBWeapon(DIR_RIGHT);
    if(b_equip == GetEquipmentB()){
    // Item not found. Subscreen not setup correctly!
    break;
    }
    }
    }
    }
    }


    The only case this script can't handle properly is when Link only has two items to equip and you want to swap them. I don't know if it is possible to do that short of temporarily giving Link a third item that's on the subscreen, then taking it away when you're done. Also, this script assumes that pressing right repeatedly will move the cursor over every item in the subscreen, so if you somehow designed your subscreen to not work like that, then I apologize. This should at least be a good starting point, though.

  3. #3
    クールな男
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    35
    Posts
    5,587
    Mentioned
    20 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,594
    Level
    27
    vBActivity - Bars
    Lv. Percent
    96.73%
    So there's no way to change a specific weapon in a particular slot through zscript? Because that's what I'm after.

  4. #4
    Octorok CaRmAgE's Avatar
    Join Date
    Oct 2008
    Location
    Historia
    Age
    35
    Posts
    494
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,334
    Level
    12
    vBActivity - Bars
    Lv. Percent
    42.57%
    Well, in that case, I have no clue. (Admittedly, I am also interested to know if this is possible.)

  5. #5
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    35
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,620
    Level
    25
    vBActivity - Bars
    Lv. Percent
    1.33%
    Actually @SUCCESSOR solved this.

    First, check that Link actually owns the weapon you're looking for.
    Then, run a loop that keeps selecting in a single direction (He used right) until the current weapon selected matches the one you are looking for.


    If you don't check that Link owns the item, though... infinite loops might occur.

  6. #6
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    37
    Posts
    4,436
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,562
    Level
    30
    vBActivity - Bars
    Lv. Percent
    51.98%
    I have functions for these... hold on.

    CODE: Show
    //Changes B to specified item
    void SetItemB(int it)
    {
    //save current item to mark where we started
    int storeB = GetEquipmentB();

    //move to next item before checking conditions
    do Link->SelectBWeapon(DIR_RIGHT);

    //if Item B is the right item or the item we started at stop
    while(GetEquipmentB() != it && storeB != GetEquipmentB())
    }

    //Change A to specified item
    void SetItemA(int it)
    {
    //save current item to mark where we started
    int storeA = GetEquipmentA();

    //move to next item before checking conditions
    do Link->SelectAWeapon(DIR_RIGHT);

    //stop if Item A is the right item or the item we started at
    while(GetEquipmentA() != it && storeA != GetEquipmentA())
    }


    MoscowModder brought up a possible issue of all items not all being accessible on some custom subscreens by moving through them to the right. I didn't think that was possible but then again I don't make custom subscreens.

  7. #7
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    37
    Posts
    4,436
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,562
    Level
    30
    vBActivity - Bars
    Lv. Percent
    51.98%
    Quote Originally Posted by MasterSwordUltima View Post
    I would also like to know how you can return the value of what is in item slot A and B.

    Also when using SelectAWeapon() and SelectBWeapon() - what is it referencing exactly? The item number itself, or the order number of the items in the inventory?
    Items in A and B are stored in Link->Equipment. Check std_functions to see which portions of it the GetEquipment functions grab.

    The item select function just moves through the currently selectable items in the subscreen left or right. I don't know if Up or Down do anything at all. Up and down may work as they should in the subscreen. I have never tried. I have no idea how ZC organizes item that link currently has.

  8. #8
    クールな男
    MasterSwordUltima's Avatar
    Join Date
    Jul 2001
    Location
    Keystonia
    Age
    35
    Posts
    5,587
    Mentioned
    20 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    8,594
    Level
    27
    vBActivity - Bars
    Lv. Percent
    96.73%
    I found Zoria's ItemHandling.zh and it adds some functions for SetItemA and SetItemB - which is super handy. What I'm trying to achieve is; dummy items are used to represent different versions of candles in the subscreen - when a dummy item is used it will remove all instances of the candle, then add that specific level candle, and then replace the ItemA or ItemB (depending on which slot the dummy item is in) with the candle class item.

    My issue with the subscreen selection setup is that the candle itemclass itself should not be directly selectable on the subscreen.

  9. #9
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    35
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,620
    Level
    25
    vBActivity - Bars
    Lv. Percent
    1.33%
    That is going to run you into some major problems, unfortunately, as the item must be able to be selected in the subscreen for the SetItemA and SetItemB functions to work.

    You may have to script a custom subscreen for your actual inventory (and override the Start button with it), and then use the built-in subscreen as a dumping ground for all the effect items that you then manage with SetItemA and SetItemB. Messy.

    I had planned something like this, but only generically (It was going to be Super Metroid-style item selection, pressing start changes the icon highlight by adding an item and switches the item in the subscreen with the SetItem property, all while disabling the actual subscreen).


    I'm not sure where you'd start, honestly. Maybe @Saffith has some wisdom on the matter.

  10. #10
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    37
    Posts
    4,436
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,562
    Level
    30
    vBActivity - Bars
    Lv. Percent
    51.98%
    Quote Originally Posted by MasterSwordUltima View Post
    I found Zoria's ItemHandling.zh and it adds some functions for SetItemA and SetItemB - which is super handy. What I'm trying to achieve is; dummy items are used to represent different versions of candles in the subscreen - when a dummy item is used it will remove all instances of the candle, then add that specific level candle, and then replace the ItemA or ItemB (depending on which slot the dummy item is in) with the candle class item.

    My issue with the subscreen selection setup is that the candle itemclass itself should not be directly selectable on the subscreen.
    I love how PureZC members just seem to love using my functions in their headers without giving me any credit or even headsup. I don't ask for credit. I don't even feel the need for people to ask me if it's okay to use my scripts that I've shared publicly for their own purposes(to date @bigjoe is the only person that has done this, i think, good man). It's the decent thing to do, though. Isn't it? It is a little funny hearing people talk about headers I never heard of and finding out they contain my code.

    Anyway. If you don't want any actual candle items selectable then simply don't have them in the subscreen when the scripts aren't using them. You will still need a spot for them so that they are selectable or else they can't be used. That's just how ZC works.

    I did essentially the same thing as you are doing. Yours simply has a couple more steps. Basically:

    Dummy item used -> trigger ffc -> ffc gives candle item that corresponds with dummy item -> switch equipped dummy item with real item -> set proper input for item to be used
    -> wait a frame for the input to take effect (may need to disable other inputs) -> switch back to dummy item - > take away real item.

    That should be the gist of it. Obviously, you may have more going on or approach it a little different. You may be able to pull it off with just item scripts since triggering the real item could trigger another item script to carry out the rest of the steps(since items scripts only last one frame). If you want I can send you the prototype i made for 4 item slots(if I can find it). It was kinda hacked together and involved a custom subscreen, but it all worked with few exceptions(mostly it didn't account for expendable items).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social