SC2Mapster Forums

Development > Data

Being able to buy ammunitions only if you don't have a full magazine already.

  • 16 posts
    #1 Nov 15, 2012 at 00:39 UTC - 0 likes

    Hello everyone, yeah I know my title is pretty weird, but here the point :

    In the mod I'm working on, I made it so heroes are playable with new customed abilities. Actually, Raynor is playable and can use his Grenades/Plasma Rifle/Chrono-charge. I managed to make a way to buy ammunitions (charges) by using the same ability the vulture uses with his spider mines. But now, I want this ability to become unusable (so the button should go grey) as soon as the number of charges is maxed. Respectively : 5,3,1.

    Basically, to be more clear, Raynor as a button on menu 1, that leads to menu 2. In menu 2 there is 4 buttons, 1 to buy a charge from each ability and one to exit the menu. If I have let's say 4,0,1, I want to be able to buy one more grenade, 3 more plasma charges and I want the button to buy a chrono charge to become grey. Until I use the ability "Chrono-Faille (in french)".

    Regarding how my mod actually is, I can still buy them, but the number of charges being maxed, I litterally pay for nothing.

    I guess it's gonna be a validator thing, which I absolutely don't know about (I tried to read tutoriels, but the fact is, I don't even know in which section of the validator should I look so....

    Anyone can help ?

    Thanks in advance !! :)

    #2 Nov 15, 2012 at 21:25 UTC - 0 likes

    You need a Requirement that counts the charges and only returns true if less than 4. As you mentioned use the vulture one as inspiration.

    #3 Nov 15, 2012 at 21:46 UTC - 0 likes

    @DrSuperEvil: Go

    The fact is, I was sure the vulture had one, but when I played the regular game (launched Starcraft 2 in my campaign normally), I noticed that the vulture didn't stop to be able to build new mines, even when it had 3 mines already.

    I'm still pretty sure it stopped before. So what the hell happened anyway ? oO

    I looked into the vulture's memory, and found nothing about that either. No requirement of that kind anywhere...

    What should I do then ? I don't know how to make a requirement for such an ability.

    Last edited Nov 15, 2012 by samourai23
    #4 Nov 17, 2012 at 13:19 UTC - 0 likes

    Ok, I really really tried, but can't get it to work...

    Here's a few I did, but none of them work. Everytime, it either set the ability to buy grenades to "always work" or "never work", and I have no clue why... : (I directly give you the expression as I use a french version and don't know what the exact translations are.)

    CountAbil(TossGrenade,QueuedOnly) < 5

    CountAbil(TossGrenade,QueuedOnly) != 5

    AllowAbil(TossGrenade,0) != 5

    AllowAbil(TossGrenade,0) < 5

    I have no idea why those don't work... I hope someone can figure it out, because I'm running out of imagination here :(

    PS: I also tried using other stuff than "QueuedOnly". But it never worked either so...

    #5 Nov 17, 2012 at 19:40 UTC - 0 likes

    See your problem, my bad. Validators can count charges use the Unit Compare Charge Used validators. Give the unit hidden buffs validated by the validators and then make requirements that look for if the buff is active (disabled counts as not having the buff).

    Last edited Nov 17, 2012 by DrSuperEvil
    #6 Nov 17, 2012 at 22:32 UTC - 0 likes

    @DrSuperEvil: Go

    Well I FINALLY managed to make it work. I used an ability to give charges to one while it takes one away from the other and vice-versa.

    I have a problem on another side though : I made Raynor (Commando) to be able to switch to Raynor (Sniper) and vice-versa (the way siege tanks does). But I want this ability to not work while I'm buying ammunitions. (Since you dont get them directly, it take 10, 20 or 60 seconds)

    I tried to make a requirement, but it didn't work.... In fact, I want it to also not work while Raynor use Stimpack. That one I managed to do it though.

    So any clue on how to do that ? I tried to copy the gateway ability to turn into a warp gate (while you make a unit, the button to turn into warp gate goes grey). But I didn't find what the heck causes that oO

    I hope you can help me :)

    Thanks again !

    PS: I'm willing to do what you said with the validators to make the button leading to menu 2 go grey. But I have no idea how to that, could you exactly tell me what to do, and where exactly to put the validator ? And then what requirement am I supposed to make ?

    Last edited Nov 17, 2012 by samourai23
    #7 Nov 18, 2012 at 00:43 UTC - 0 likes

    You make a validator that counts the charges for each munition type. You make a buff behaviour for each munition type. You use the validators to disable the buffs and set the buffs to hidden. You make a requirement that counts the buffs completed at unit compared to a constant for the use part of the requirement editor.

    #8 Nov 18, 2012 at 13:04 UTC - 0 likes

    @DrSuperEvil: Go

    I'm sorry, but I still don't know how to do :s I may sound like a retard but I really need to know the exact procedure, plus, english not being my first language (and so not playing an english version) makes it very harder for me to know what exact stuff I have to make :/

    I don't know what a buff behaviour is for example, when I translate it, it says "buff" is an animal so...

    #9 Nov 18, 2012 at 19:41 UTC - 0 likes

    The Buff type of behaviour is the most commonly used, one in game for example the Marauder - Slow buff which is applied to units when it attacks.

    You will be using the buffs to act as a counter for your charges that your requirement then uses because it cannot do so directly.

    Create a Unit Compare Charge Used validator for each of your ammo types. Set the Validator: Ability field to your abilities that use charges. Set Validator: Charge to the Cost: Cost - Charge - Link value of the ability (needs to by typed in manually). Set Validator: Compare field to Greater Than. Set Validator: Location to Unit.

    Create a Buff type behaviour for each of your ammo types and set the Behavior: Validators (Disable) field to the validator you just created for that ammo type. Set the flag called Hidden under Stats: Flags to enabled.

    Create a Requirement for each ammo type. Set the Use part of the logic tree to use an Equals logic node that links to a Count Behavior and a Constant node types. Set the Count Behavior nodes to the Buff behaviour for that ammo type in the Alias field and the State field to Completed At Unit. Set the constant to 1.

    With this setup the validator will disable the buff if the charges are max resulting in the requirement making the button grey.

    Last edited Nov 18, 2012 by DrSuperEvil
    #10 Nov 19, 2012 at 21:03 UTC - 0 likes

    @DrSuperEvil: Go

    Thanks, but where exactly am I supposed to put the requirement ? I put it in the button in the "ability" field of Raynor, but the button end up being grey directly, and asking me to be in the buff I made to be enable

    #11 Nov 19, 2012 at 21:36 UTC - 0 likes

    Thought you wanted the button to be greyed out? Can you not rename the buff so it has the name of the text that you need?

    You could always add a requirement to the Command Card of the unit for the button that opens the Sub Menu.

    Last edited Nov 19, 2012 by DrSuperEvil
    #12 Nov 19, 2012 at 22:02 UTC - 0 likes

    @DrSuperEvil: Go

    Yeah I want it to be greyed out, but I want it greyed out ONLY when I don't have any charges left.

    That button leads to menu 2, in which you can call mercenaries. There is 5 buttons.

    One to call 6 War Pigs; One to call 4 Devil Dogs; One to call 3 Hammer Security; One to call 4 reapers mercenaries and 2 ghost mercenaries; and One to call 2 War Pigs and 3 Skibi Angels.

    These 5 abilities share the same charge - link. And they are made from the ability "Factory - formation copy".

    So basically, I have 5 charges at the beginning for all 5 buttons, when I click on one, I'm left with 4 for all etc, until 0. When it reached 0, I want menu 2 to not be possibly re-entered (greyed out).

    See ? :)

    EDIT: Sorry, I forgot I asked 3 questions... I guess you answered the very first one, right ? I managed to get it working another way already though :p

    And I then told you about the one about the button leading to menu 2, and the one that forbids to switch to Raynor (Sniper) when you're actually buying ammos. I hope I didn't confuse you too much xD

    I still need to know how to make these two.

    Thanks for helping anyway, and sorry if you just bugged while reading me :s

    Last edited Nov 19, 2012 by samourai23
    #13 Nov 19, 2012 at 23:02 UTC - 0 likes

    Ok, now I am confused.

    So you want to prevent the Morph type ability used during the weapon swap while in the ammo menu?

    What third question?

    #14 Nov 19, 2012 at 23:26 UTC - 0 likes

    @DrSuperEvil: Go

    Sorry I confused you :s

    Actually, I want to prevent the Morph type ability from being used while an ammo is being bought. Which means while it is in the queue.

    That means that whenever Raynor has something in the queue, the morph button gets greyed out.

    The third question is not about Raynor (Commando), but about Raynor (Sniper). Basically, the Raynor you turn into when you hit that morph button.

    Well, Raynor (Sniper) has his own abilities. One of them is to "Call for backup". To do so, I made a button that leads to another menu (menu 2), in which there is 6 others buttons.

    One to call 6 War Pigs; One to call 4 Devil Dogs; One to call 3 Hammer Security; One to call 4 reapers mercenaries and 2 ghost mercenaries; One to call 2 War Pigs and 3 Skibi Angels; and one to exit the sub-menu.

    These 5 abilities share the same charge - link. And they are made from the ability "Factory - formation copy".

    So basically, I have 5 charges at the beginning for all 5 buttons, when I click on one, I'm left with 4 for all etc, until 0. When it reaches 0, I want menu 2 to not be possibly re-entered (greyed out).

    I hope I've un-confused you :)

    #15 Nov 20, 2012 at 19:38 UTC - 0 likes

    Use a Unit Order Queue validator put in the Morph ability under the Ability: Validator Array field. Although I would need more details as to how your ammo buy system is set up.

    Just use the same requirement that counts charges as I told you to make and put it in the Requirements field of the command card for the submenu. You just need to alter the Validator: Compare and Validator: Value fields.

    Last edited Nov 20, 2012 by DrSuperEvil
    #16 Nov 20, 2012 at 20:39 UTC - 0 likes

    Well basically, to buy ammos, I use the exact same process than the vulture's spider mines ability to buy more mines.

    I use one for the grenades, one for the plasma rifle and one for the chrono-bomb. That's all.

    And about the sub-menu requirement, I tried to get it to not be re-entered but it didn't work, am I doing something wrong...? :/

    Last edited Nov 20, 2012 by samourai23
  • 16 posts

You must login to post a comment. Don't have an account? Register to get one!