This is probably a data/trigger combination. I want an ability to use/show charges, based on how many of item X are in the inventory. However, the item itself in the inventory is type "generic" and doesn't itself function as an "ability" type item.
I can't get charges to add to the ability via trigger, I think maybe because I'm not setting up the cost: cost + fields up correctly in the ability itself. What should they be? Any easy route to do this?
@Bilxor: Go Wait, what do you want exactly? The item recharges the ability when used? The item recharges the ability while in the inventory? The charges can only be used when the unit is carrying the ability? All of those are easy to do.
I want the presence of item X to add 1 charge to an ability and the use of the ability to delete 1 item X from inventory and use 1 charge. So if I have 3 item X in my inventory, I can use my ability 3 times.
Well the item does add charges for the ability... Hmm I'm not sure why I'm not explaining this well enough. Here's a scenario:
A marine has a totally empty inventory = can't use ability Y
Marine picks up 1 ItemX = ability Y becomes usable (with 1 charge)
Ability Y is used = 1 ItemX is destroyed and Ability Y becomes unusable until more ItemX are found
Marine picks up another ItemX = ability Y becomes usable again
Marine drops/sells/gets rid of ItemX = ability becomes unusable
...
I can make the ability show / hide easily on the command card with a requirement that counts the carry behavior of the item. The adding/sutracting/considering of charges is where I'm hung up.
Apart from combining items, you can have an item add charges to an ability by using a carry behavior, which on initial effect uses a modify unit to add charges to the unit's ability. Then final effect removes charges, and using the ability destroys an item in the inventory (use a search area with no or small radius around the carrying unit, and a validator to check for the item type) while also adding a charge to the ability, because it costs 1 charge to cast and 1 charge is removed when the item is destroyed, so 1 more charge must be added to counteract that. I have done all of this before, so it does work. It's how the seeds work in my Dark Deeds map. The only part that I have not done is combined items in the inventory.
I can't get the charges to go up from zero, it just sits there being grayed out. I have my behavior have a initial effect that adds 1 charge through the cost menu and a final effect that removes one charge (-1) through the cost menu... I think maybe my problem is in the cost: cost + menu of the ability itself. What should "location" be set to?
On the item itself, the Cost should not be set to anything because the item is not used up by its own use. An item's cost refers to the item unit, rather than the carrying unit, so it is of no use to us.
In the Ability, the charge location should just be Ability, and the Count (Use) should be 1.
In the Modify Unit effect, select the Ability from the list. Select Caster under Player - Value. To add a charge, set Usage Charge Count to -1. To remove a charge, set it to 1. For some reason I also have Fraction - Charge set to 1, but I don't remember why...
Now that I have my editor open, I'll go through more detail about how it works in my map. The item involved is the WheatSeed, and the ability is PlantWheat.
The Item's Carry Behavior:
<!--The Item is not Caster, apparently, but the Target is also Caster, so that stack times per caster must be unlimited.--><CBehaviorBuffid="CarryingWheatSeed"><InfoFlagsindex="Hidden"value="1"/><InfoIconvalue="Assets\Textures\btn-tips-chrysalis.dds"/><EditorCategoriesvalue="Race:Terran,AbilityorEffectType:Units"/><MaxStackCountvalue="20"/><InitialEffectvalue="WheatSeedAddCharge"/><RefreshEffectvalue="WheatSeedAddCharge"/><FinalEffectvalue="WheatSeedUseCharge"/></CBehaviorBuff>
According to my note, you have to make sure that the buff can stack on the unit, so its MaxStackCount must be greater than 1, the default.
The ability calls a Create Persistent effect. The initial effect of this CP is WheatSeedDoubleCharge, and the expire effect is WheatSeedDestroySearch.
Effect WheatSeedDoubleCharge:
<!--Because there is no way to distinguish between dropping an item and using an item in removing charges, and because the ability does not allow 0 to be the price of cost without messing up charges altogether, it is necessary to ADD a charge upon using the ability, so that charge can then be taken away when the item is destroyed. Also used to give refund in case of cancellation.--><CEffectModifyUnitid="WheatSeedDoubleCharge"><EditorCategoriesvalue="Race:Terran"/><ImpactUnitValue="Caster"/><CostAbil="PlantWheat,Execute"ChargeCountUse="-1"><PlayerValue="Caster"/><FractionCharge="1"/></Cost></CEffectModifyUnit>
In short, the item's carry behavior adds a charge when the unit picks up the item, both in its initial effect and in its refresh effect. It removes a charge when the item is dropped or destroyed.
Clicking the item also calls an Issue Order effect that orders the unit to cast the ability on the target unit.
The Ability calls an effect that at first calls an effect to add another charge, and when it's done is searches for the item and destroys it.
I did not realize, actually, that items could be filters using Required:Hidden. Thanks, DrSuperEvil.
I forgot to get back to this thread, good to see people have the answer for it. But I was going to suggest the same, a small search for a hidden item to destroy it. You only have to make sure you destroy the right item. Because just searching for hidden items may destroy any random item in the unit's inventory.
Thanks so much for going through all the effort to disassemble your ability... I find that the "initial" effect of your carry behavior only triggers when current behavior count is <1, however, so it won't ever add to greater than 1. The way around this, I found, was to have both a carry behavior and an initial behavior applied to the item, with the initial behavior only lasting .08 seconds and the carry behavior lasts for ever. the initial behavior has the + charge, the eternal carry behavior has the - charge.
This is probably a data/trigger combination. I want an ability to use/show charges, based on how many of item X are in the inventory. However, the item itself in the inventory is type "generic" and doesn't itself function as an "ability" type item.
I can't get charges to add to the ability via trigger, I think maybe because I'm not setting up the cost: cost + fields up correctly in the ability itself. What should they be? Any easy route to do this?
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
@Bilxor: Go Wait, what do you want exactly? The item recharges the ability when used? The item recharges the ability while in the inventory? The charges can only be used when the unit is carrying the ability? All of those are easy to do.
I want the presence of item X to add 1 charge to an ability and the use of the ability to delete 1 item X from inventory and use 1 charge. So if I have 3 item X in my inventory, I can use my ability 3 times.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
@Bilxor: Go That's not as simple as making the item add charges for the ability. As I'm not experienced with items I'll have to think about it.
@SoulFilcher: Go
Well the item does add charges for the ability... Hmm I'm not sure why I'm not explaining this well enough. Here's a scenario:
A marine has a totally empty inventory = can't use ability Y
Marine picks up 1 ItemX = ability Y becomes usable (with 1 charge)
Ability Y is used = 1 ItemX is destroyed and Ability Y becomes unusable until more ItemX are found
Marine picks up another ItemX = ability Y becomes usable again
Marine drops/sells/gets rid of ItemX = ability becomes unusable
... I can make the ability show / hide easily on the command card with a requirement that counts the carry behavior of the item. The adding/sutracting/considering of charges is where I'm hung up.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
Problem is combining items smoothly without triggers.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
Apart from combining items, you can have an item add charges to an ability by using a carry behavior, which on initial effect uses a modify unit to add charges to the unit's ability. Then final effect removes charges, and using the ability destroys an item in the inventory (use a search area with no or small radius around the carrying unit, and a validator to check for the item type) while also adding a charge to the ability, because it costs 1 charge to cast and 1 charge is removed when the item is destroyed, so 1 more charge must be added to counteract that. I have done all of this before, so it does work. It's how the seeds work in my Dark Deeds map. The only part that I have not done is combined items in the inventory.
@TrenchaunT: Go
Sounds easy enough. What effect, though, is connected to the search area that serves to destroy the item?
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
Damage with kill flag. Also in the search set it to require hidden.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
I can't get the charges to go up from zero, it just sits there being grayed out. I have my behavior have a initial effect that adds 1 charge through the cost menu and a final effect that removes one charge (-1) through the cost menu... I think maybe my problem is in the cost: cost + menu of the ability itself. What should "location" be set to?
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)
On the item itself, the Cost should not be set to anything because the item is not used up by its own use. An item's cost refers to the item unit, rather than the carrying unit, so it is of no use to us.
In the Ability, the charge location should just be Ability, and the Count (Use) should be 1.
In the Modify Unit effect, select the Ability from the list. Select Caster under Player - Value. To add a charge, set Usage Charge Count to -1. To remove a charge, set it to 1. For some reason I also have Fraction - Charge set to 1, but I don't remember why...
Now that I have my editor open, I'll go through more detail about how it works in my map. The item involved is the WheatSeed, and the ability is PlantWheat.
The Item's Carry Behavior:
According to my note, you have to make sure that the buff can stack on the unit, so its MaxStackCount must be greater than 1, the default.
Effect WheatSeedAddCharge:
Effect: WheatSeedUseCharge:
Ability PlantWheat:
The ability calls a Create Persistent effect. The initial effect of this CP is WheatSeedDoubleCharge, and the expire effect is WheatSeedDestroySearch.
Effect WheatSeedDoubleCharge:
Effect WheatSeedDestroySearch:
Effect WheatSeedDestroy:
In short, the item's carry behavior adds a charge when the unit picks up the item, both in its initial effect and in its refresh effect. It removes a charge when the item is dropped or destroyed.
Clicking the item also calls an Issue Order effect that orders the unit to cast the ability on the target unit.
The Ability calls an effect that at first calls an effect to add another charge, and when it's done is searches for the item and destroys it.
I did not realize, actually, that items could be filters using Required:Hidden. Thanks, DrSuperEvil.
Actually they only are hidden when picked up.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
I forgot to get back to this thread, good to see people have the answer for it. But I was going to suggest the same, a small search for a hidden item to destroy it. You only have to make sure you destroy the right item. Because just searching for hidden items may destroy any random item in the unit's inventory.
That is what the Unit Type validator is for and a search max of 1.
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
@TrenchaunT: Go
Thanks so much for going through all the effort to disassemble your ability... I find that the "initial" effect of your carry behavior only triggers when current behavior count is <1, however, so it won't ever add to greater than 1. The way around this, I found, was to have both a carry behavior and an initial behavior applied to the item, with the initial behavior only lasting .08 seconds and the carry behavior lasts for ever. the initial behavior has the + charge, the eternal carry behavior has the - charge.
<Click Here> To See My Epic Single Player Campaign (LifeForceCampaign.com)