A spell that creates "x" number of "y" but only when "l" number of "z" is present

Turnip

New Member
Reaction score
18
I've been trying to creating a trigger that doesn't leak and works efficiently, but so far, I have been unsuccessful.

Example: There is a doctor hero. He has a spell that creates x number of bandages depending on level (level 1 - one bandage, level 2 - two bandages, etc...), but requires y number of scraps of linen before it can be created. However, this linen stacks. So, I only want to remove as much linen as required and not all of it.


Any ideas on how to do it?
 

Exide

I am amazingly focused right now!
Reaction score
448
There's a trigger function that does: 'set item number of charges'.
So, if your hero uses 'Create medpack' ability:

Code:
event
A unit starts the effects of an ability

cond
Abilitiy being cast = *Your_Ability*
(Triggering unit) has item of type *Your_Linen_Item*

Actions
set medpack_point = Position of (Triggering unit)
 Loop (for each Integer A from 1 to (Level of *Your_Ability* of (Triggering unit)) do Actions
 If (Number of charges remaining for *Your_Linen_Item* carried by (Triggering unit) is equal to 0 then
  [COLOR="Red"]Do Nothing[/COLOR]
  else
   set number of charges for *Your_Linen_Item* carried by (Triggering unit) = (current number of charges - 1)
   Create 1 *Bandage* at medpackpoint
Custom script - call RemoveLocation(udg_medpack_point)

Should work.
I don't have WE open, so the triggers aren't perfect, but I bet you get the picture. :p

EDIT: Notice, the 'Do Nothing' function is not necessary for your trigger. I just put it there for you to get the idea.
 

Turnip

New Member
Reaction score
18
Thank you so much - I am very grateful.

Another quick question: Is there a trigger to check if an item has 0 charges, so I can remove it from the hero if it does?
 

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
JASS:
Convert to Bandage
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Animate Dead
    Actions
        For each (Integer A) from 1 to 6, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item carried by (Casting unit) in slot (Integer A)) Equal to (Item carried by (Casting unit) of type Tome of Experience)
                    Then - Actions
                        Hero - Create Tome of Experience and give it to (Casting unit)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Charges remaining in (Item carried by (Casting unit) of type Tome of Experience)) Equal to 0
                            Then - Actions
                                Item - Remove (Item carried by (Casting unit) of type Tome of Experience)
                            Else - Actions
                                Item - Set charges remaining in (Last created item) to ((Charges remaining in (Item carried by (Casting unit) of type Tome of Experience)) - 1)
                    Else - Actions


Maybe that would work, assuming you change the items being carried? :)
 

Turnip

New Member
Reaction score
18
Thanks, however I need the item to be removed even if a spell is not initiated - for example when the item is simply consumed. It doesn't dissapear but instead just goes to 0 charges where it can be used over and over again.

Is this possibly because of the item I based it off of?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top