Hero + Item Snippets

Status
Not open for further replies.

Darg

Administrator
Reaction score
49
Consume Multiple Tomes at Once

So your hero just bought a pack of 50 tomes, but you find you have to click them 50 times to use them! Frustrating, isn't it?

Here's how to get your hero to use all those tomes in one go.

auto-consume multiple tomes.w3x
 

Attachments

  • auto-consume multiple tomes.w3x
    17.9 KB · Views: 757

Sp3tZn4z

Cool Member
Reaction score
2
Hero + Item Triggers

Hero-type restricted items
this trigger makes sure certain hero's cant use certain items so if u want bows only available for bow-type hero's or swords for sword-type of hero's you need this :cool:

Code:
[B]Hero -type restricted items[/B]

Events 
   + Unit - A unit owned by player 1 (red) Acquires an item
   + Unit - A unit owned by player 2 (blue) Acquires an item
   + Unit - A unit owned by player 3 (teal) Acquires an item
   + Unit - A unit owned by player 4 (purple) Acquires an item
Conditions
   + (Item-type of (Item being manipulated)) Equal to your item
   + Or -Any (Conditions) are true
         + (Unit-type of (Hero Manipulating item)) Equal to Hero I
         + (Unit-type of (Hero Manipulating item)) Equal to Hero II
         + (Unit-type of (Hero Manipulating item)) Equal to Hero III        
         + (Unit-type of (Hero Manipulating item)) Equal to Etc .........
Actions
   + Hero - Drop (Item being manipulated) from (Hero manipulating item)

you can add more players and heroes if wanted
Thx to xxconanxxx who helped me alot
 
H

HunteRKilleR

Guest
For all you beginners a simple hero respawn (instant)
Code:
Events:
   Unit-A unit dies
Conditions:
   ((Triggering Unit) is a Hero) is equal to true
Actions:
   Hero - Instantly revive (Triggering Unit) At (region), show revival graphics.
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Drop 1 charge only

Here is a simpel but useful trigger that allow you to only drop 1 charge of an item insteed af all charges. Very usefull if you use the Item Combiner above.

Code:
Drop Item With charges
    Events
        Unit - A unit Loses an item
    Conditions
        (Charges remaining in (Item being manipulated)) Greater than 1
    Actions
        Wait 0.00 seconds
        Hero - Create (Item-type of (Item being manipulated)) and give it to (Hero manipulating item)
        Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item being manipulated)) - 1)
        Item - Set charges remaining in (Item  being manipulated) to 1
 
L

Lloren

Guest
for thoes rpg map makers that have items randomly dropped by creeps but dont want to have the items just sit there forever, here is a trigger that will remove the items in a set time.

this one will remove the item anywhere from 30-40 sec after beeing dropped.

Code:
item controll
    Events
        Time - Every 10.00 seconds of game time
    Conditions
    Actions
        Item - Pick every item in (Playable map area) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Custom value of (Picked item)) Greater than or equal to 3
                    Then - Actions
                        Item - Remove (Picked item)
                    Else - Actions
                        Item - Set the custom value of (Picked item) to ((Custom value of (Picked item)) + 1)

add this one so that if a hero picks up and redrops the item the "timmer" will restart

Code:
item cont
    Events
        Unit - A unit Loses an item
    Conditions
    Actions
        Item - Set the custom value of (Last dropped item) to 0
 
P

Persen

Guest
These codes require a variable of type "Unit", and a trigger to set it:

Set selectedHero
Code:
    Events
        Player - Player 1 (Red) Selects a unit
    Conditions
        (Triggering unit) is A Hero equals to true
    Actions
        Set selectedHero = (Triggering unit)

Set item charges
Code:
    Events
        Player - Player 1 (Red) types a chat message containing -charges - as A substring
    Conditions
        (selectedHero is A Hero) Equal to True
    Actions
        Item - Set charges remaining in (Item carried by selectedHero in slot 1) to (Integer((Substring((Entered chat string), 12, (Length of (Entered chat string))))))
EDIT: This will set the charges of the item in slot 1, to the number that is after the second dash. Use 0 for infinite.
 
P

Persen

Guest
FastCast
Code:
    Events
        Time - Every 1.00 seconds of game time
        Unit - A unit owned by Player 1 (Red) Stops casting an ability
        Unit - A unit owned by Player 1 (Red) Finishes casting an ability
    Conditions
    Actions
        Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
            Loop - Actions
                Unit - Reset ability cooldowns for (Picked unit)

This code resets the cooldown of all abilities of all units owned by player 1.
 

Nenad

~Choco Coronet~ Omnomnom
Reaction score
137
Hero revival time by level

Ok this is a little complicated trigger so im gonna display step by step

first the trigger as it should be

Code:
Events- Unit - A unit Dies
    Conditions
        ((Dying unit) is A Hero) Equal to True
    Actions
        Countdown Timer - Start (Last started timer) as a One-shot timer that will expire in ((Real((Level of (Dying unit) x (somthing)))) x (somthing) seconds
        Countdown Timer - Create a timer window for (Last started timer) with title Hero Revive in
        Countdown Timer - Show (Last Created Timer Window)
        Wait - ((Real((Level of (Dying unit) x (somthing)))) x (somthing) seconds
        Countdown Timer - Destroy (Last created timer window)
        Hero - Instantly revive (Dying Unit) at (Place Region Here), Show revival

so thats the trigger now what has to be done

1) Go to Start Timer
2) Fill in the Timer with your timer varable
3) Keep it as a One-Shot timer
4) Click the 30.00 part
5) click the first 1.00 part
6) go to function list
7) click Conversion - Convert Integer to Real
8) click the blue part
9) click Unit - Level of unit
10) click Triggering Unit
11) scroll up on the menu under function and click click Event Response - Dying Unit
12) click OK once.
13) click the second 1.00 part
14) change that part to anything u want
15) click ok and change the + into x
16) click ok once
17) click the second 1.00 part now
18) change to anything u want and click ok

Countdown Timer - Start (Your Variable Here) as a One-shot timer that will expire in ((Real((Level of (Dying unit) x (somthing)))) + somthing seconds.

That Somthing is the number u want the first one is the level x tims number so if it was 2 and ure hero lvl was 1 the first part would be 2 seconds

The second somthing is the number u want to add on the first time

The your variable is a normal variable time that u make by going to edit variables and create variable timer and thats it

the credits go to player 11 who helped me for this trigger and since its complicated i thought to post it here
 
R

Renshin

Guest
Combining Items

Here is an effective way for combining items.

Code:
Troll king
    Events
        Unit - A unit Acquires an item
    Conditions
        ((Triggering unit) has an item of type Quaterstaff) Equal to True
        ((Triggering unit) has an item of type Demon Edge) Equal to True
        ((Triggering unit) has an item of type Blade of the Troll King ) Equal to True
    Actions
        Item - Remove (Item carried by (Triggering unit) of type Quaterstaff)
        Item - Remove (Item carried by (Triggering unit) of type Demon Edge)
        Item - Remove (Item carried by (Triggering unit) of type Blade of the Troll King )
        Hero - Create Blade of the Troll King  and give it to (Triggering unit)
        Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Items\AIam\AIamTarget.mdl
 

Gotham

New Member
Reaction score
7
About shields, one handed weapons and two handed weapons...

With this you can set what weapons are the heros allowed to use (i.e. only two swords OR one sword and one shield OR one bow OR one staff, etc.).
Hope you like it.

<change the values in conditions for ones of your choice>
<there are two variables, integer type, with an array of size 12 (Hands & Shield)>

When a unit acquires a shield, what happens?
Code:
AShield
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Shield of Protection
                (Item-type of (Item being manipulated)) Equal to Arcanite Shield
    Actions
        Set Hands[(Player number of (Owner of (Hero manipulating item)))] = (Hands[(Player number of (Owner of (Hero manipulating item)))] + 1)
        Set Shield[(Player number of (Owner of (Hero manipulating item)))] = (Shield[(Player number of (Owner of (Hero manipulating item)))] + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Shield[(Player number of (Owner of (Hero manipulating item)))] Greater than 1
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Only one shield at ...
            Else - Actions
                Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Hands[(Player number of (Owner of (Hero manipulating item)))] Greater than 2
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Only two one handed...
            Else - Actions
                Do nothing

If the units drops the shield...
Code:
DShield
    Events
        Unit - A unit Loses an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Shield of Protection
                (Item-type of (Item being manipulated)) Equal to Arcanite Shield
    Actions
        Set Hands[(Player number of (Owner of (Hero manipulating item)))] = (Hands[(Player number of (Owner of (Hero manipulating item)))] - 1)
        Set Shield[(Player number of (Owner of (Hero manipulating item)))] = (Shield[(Player number of (Owner of (Hero manipulating item)))] - 1)

(this two triggers have an extra variable that only allows one shield)


If someone acquires a One Handed Weapon...
Code:
AOneHand
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Dagger of Escape
                (Item-type of (Item being manipulated)) Equal to Claws of Attack
    Actions
        Set Hands[(Player number of (Owner of (Hero manipulating item)))] = (Hands[(Player number of (Owner of (Hero manipulating item)))] + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Hands[(Player number of (Owner of (Hero manipulating item)))] Greater than 2
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Only two one handed...
            Else - Actions
                Do nothing

If the units drops...
Code:
DOneHand
    Events
        Unit - A unit Loses an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Dagger of Escape
                (Item-type of (Item being manipulated)) Equal to Claws of Attack
    Actions
        Set Hands[(Player number of (Owner of (Hero manipulating item)))] = (Hands[(Player number of (Owner of (Hero manipulating item)))] - 1)

Good, not too different to the shields triggers. But with the two handed weapons? Simply +/- 2.
Code:
ATwoHands
    Events
        Unit - A unit Acquires an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Searing Blade
                (Item-type of (Item being manipulated)) Equal to Staff of Accuracy
                (Item-type of (Item being manipulated)) Equal to Bow of Agility
    Actions
        Set Hands[(Player number of (Owner of (Hero manipulating item)))] = (Hands[(Player number of (Owner of (Hero manipulating item)))] + 2)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Hands[(Player number of (Owner of (Hero manipulating item)))] Greater than 2
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Only one two handed...
            Else - Actions
                Do nothing

If drops...
Code:
DTwoHands
    Events
        Unit - A unit Loses an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Searing Blade
                (Item-type of (Item being manipulated)) Equal to Staff of Accuracy
                (Item-type of (Item being manipulated)) Equal to Bow of Agility
    Actions
        Set Hands[(Player number of (Owner of (Hero manipulating item)))] = (Hands[(Player number of (Owner of (Hero manipulating item)))] - 2)

Sorry if I have some grammar errors, I'm from Argentina =P
 

Rad

...
Reaction score
228
Combine charged items into 1

Code:
Stackable Items
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-class of (Item being manipulated)) Equal to Purchasable
    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-type of (Item being manipulated)) Equal to (Item-type of (Item carried by (Hero manipulating item) in slot (Integer A)))
                        (Item being manipulated) Not equal to (Item carried by (Hero manipulating item) in slot (Integer A))
                    Then - Actions
                        Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A)) to ((Charges remaining in (Item being manipulated)) + (Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))))
                        Item - Remove (Item being manipulated)
         [b]optional[/b] > Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: (Combined  + ((String((Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer A))))) + ((Name of (Item carried by (Hero manipulating item) in slot (Integer A))) + !)))
                    Else - Actions
                        Do nothing

This should work for all purchasable items, so be sure they have a set amount of charges for maximum functionality!
 
A

Appie

Guest
Buy and Stack Items, even when inventory is full

EDIT:
I found a bug in my code so I edited it. Also made some improvements.
For the ones who already implemented this in their game, I put the changes in dark blue.

==========================================================


Ok, I shall start from the beginning, and try to give a clear description of what these triggers are for and how u can use them.
I'm not going to explain the JASS code.


PURPOSE:
The main goal is to have items that have a charge (like healing potions) take only 1 inventory slot. So that when u buy 2 healing potions u will actually get 1 potion with 2 charges instead of 2 potions with each 1 charge. (I hope this is clear)


DIFFICULTY
The problem with this system is, that when your units inventory is full, you are unable to buy items. So there are no charges added to your items.


SOLUTION
I made 2 versions of all items that I wanted to put together. 1 version is the real one. The second one is a dummy that has no abilities but uses automatically when acquired. In my shops I sell the dummy ones. Because they are automatically used when acquired, u can buy them even if your inventory is full (like tomes). I then use a trigger to catch this event and use the trigger to add the real item to the unit.
I also use a trigger to change the items back to dummies when they are dropped.

This might seem a bit far-fetched, but it is the only way I got it working.


STEP BY STEP
Here i will give a step by step guide of what you need to do, to implement this in your game.

1.
Make your items. When you are sure they are finished and working correctly, make a copy of them.

2.
The copy has the same name as the original. This might be confussing but leave it this way (the items need to be identical for the player). Now we need to make some changes in 1 of them. Pick 1 of the identical items and delete all abilities (Abilities - Abilities) of it. Also set Stats - Use automatically when aquired to True. This item shall I call the dummy item.
For the other item it is important to set the hitpoints (Stats - Hit Points) of the item to the same value as the gold cost (Stats - Gold Cost).

3.
We need to add the dummy item to a shop. (I'm gonna assume u know how to add items to a shop). To make sure we add the right item to the shop, we are gonna look at the raw data values of the items. Go to the menu View/Display values as raw data. Now look for your items in the list.

Let's say u made an item based on the healing potion, and u called it "Elixer". Then you should look for something like this: I005:phea (Elixer)
When you look at the first 4 characters, you can see that they are different for all items. These are the ID's of your items.

Now search for the ID of your dummy-item. Then add that item to your shop (Make sure u check if u added the right one).

4.
Now we need to make 2 triggers. Make a trigger called "PutItemsTogether" and a trigger called "DropItemsPutTogether". Now convert both triggers to custom text. Do this by selecting the trigger and go to menu Edit/Convert to custom text.
Next replace the text in both triggers by what you find here

This comes in "PutItemsTogether"
Code:
function Trig_PutItemsTogether_Actions takes nothing returns nothing
    // VARIABLES
    local integer intCOUNTER
    local integer intCHARGES
    local integer intITEM_TYPEID = 0
    local boolean blnSTOP = false
    [COLOR=Navy]local boolean blnEMPTYSLOTS = false[/COLOR]
    local item itemMANIPULATED
    local item itemINVENTORY
    local unit unitTRIGGERING
    [COLOR=Navy]local texttag txtTAG[/COLOR]


    // INIT VARIABLES
    set unitTRIGGERING = [COLOR=Navy]GetManipulatingUnit( )[/COLOR]
    set itemMANIPULATED = GetManipulatedItem( )


    // GET THE TYPEID OF THE ACQUIRED ITEM
    // ELIXER
    if GetItemTypeId( itemMANIPULATED ) == [B]'I005'[/B] then
        set intITEM_TYPEID = [B]'I00P'[/B]
    endif


    // LOOK FOR ITEM AND INCREASE CHARGES
    if intITEM_TYPEID != 0 then  
        set intCHARGES = GetItemCharges( itemMANIPULATED )
        set intCOUNTER = 1
        loop
        exitwhen intCOUNTER > 6 or blnSTOP        
            set itemINVENTORY = UnitItemInSlotBJ( unitTRIGGERING, intCOUNTER )
            [COLOR=Navy]if itemINVENTORY == null then
                set blnEMPTYSLOTS = true
            else
                if intITEM_TYPEID == GetItemTypeId( itemINVENTORY ) then
                    call SetItemCharges( itemINVENTORY , GetItemCharges( itemINVENTORY ) + intCHARGES )
                    set blnSTOP = true
                endif
            endif[/COLOR]

            set intCOUNTER = intCOUNTER + 1
        endloop


        // IF ITEM ISN'T IN INVENTORY [COLOR=Navy]AND THERE IS A FREE SLOT[/COLOR], WE CREATE A NEW ITEM
        if not blnSTOP then
            [COLOR=Navy]if blnEMPTYSLOTS then
                // CREATE ITEM
                call CreateItemLoc( intITEM_TYPEID, GetUnitLoc( unitTRIGGERING ) )
                set itemINVENTORY = GetLastCreatedItem( )
                call SetItemCharges( itemINVENTORY, intCHARGES )
                call UnitAddItemSwapped( itemINVENTORY, unitTRIGGERING )
            else
                // GIVE GOLD BACK (ITEM COST == ITEM LIFE)
                call AdjustPlayerStateBJ( R2I( GetItemLifeBJ( itemMANIPULATED ) ), GetOwningPlayer( unitTRIGGERING ), PLAYER_STATE_RESOURCE_GOLD )
                call CreateTextTagUnitBJ( "Inventory is full.", unitTRIGGERING, 0.00, 10, 90.00, 90.00, 0.00, 10.00 )
                set txtTAG = GetLastCreatedTextTag()
                call SetTextTagPermanentBJ( txtTAG, false )
                call SetTextTagVelocityBJ( txtTAG, 0, 90 )
                call SetTextTagAgeBJ( txtTAG, 1.00 )
                call SetTextTagLifespanBJ( txtTAG, 4.00 )
                call SetTextTagFadepointBJ( txtTAG, 3.00 )
                call TriggerSleepAction( 5.00 )            
                call DestroyTextTagBJ( txtTAG )
            endif[/COLOR]
        endif
    endif
endfunction

//===========================================================================
function InitTrig_PutItemsTogether takes nothing returns nothing
    set gg_trg_PutItemsTogether = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_PutItemsTogether, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_PutItemsTogether, function Trig_PutItemsTogether_Actions )
endfunction

This comes in "DropItemsPutTogether"
Code:
function Trig_DropItemsThatCanBePutTogether_Actions takes nothing returns nothing
    // VARIABLES
    local unit unitTRIGGERING
    local item itemDROPPED
    local integer intDROPPED_TYPEID = 0
    local integer intCHARGESDROPPED
    local location locITEM


    // INIT VARIABLES
    set unitTRIGGERING = [COLOR=Navy]GetManipulatingUnit( )[/COLOR]
    set itemDROPPED = GetManipulatedItem( )


    // GET THE TYPEID OF THE ACQUIRED ITEM
    // ELIXER
    if GetItemTypeId( itemDROPPED ) == [B]'I00P'[/B] then
        set intDROPPED_TYPEID = [B]'I005'[/B]
    endif


    // CREATE NEW ITEM AND REMOVE DROPPED ITEM
    [COLOR=Navy]set intCHARGESDROPPED = GetItemCharges( itemDROPPED )
    if intDROPPED_TYPEID != 0 and intCHARGESDROPPED != 0 then
        call TriggerSleepAction( 0.01 )  //THIS IS NEEDED BECAUSE THE ITEM ISN'T DROPPED YET
        if not IsItemHiddenBJ( itemDROPPED ) then
            set locITEM = GetItemLoc( itemDROPPED )
            call RemoveItem( itemDROPPED )
            call CreateItemLoc( intDROPPED_TYPEID, locITEM )
            call SetItemCharges( GetLastCreatedItem( ), intCHARGESDROPPED )
        endif
    endif[/COLOR]
endfunction

//===========================================================================
function InitTrig_DropItemsPutTogether takes nothing returns nothing
    set gg_trg_DropItemsPutTogether = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_DropItemsPutTogether, EVENT_PLAYER_UNIT_DROP_ITEM )
    call TriggerAddAction( gg_trg_DropItemsPutTogether, function Trig_DropItemsThatCanBePutTogether_Actions )
endfunction

5.
There is only 1 thing u need to change now. The trigger uses the ID's of your items, so you need to replace these with your own (I placed them in BOLD). U need to replace 'I005' by the ID of your dummy-item and 'I00P' by your real item.

6.
For every item you need to add something to both triggers:

Add to "PutItemsTogether" just below // GET THE TYPEID OF THE ACQUIRED ITEM:
Code:
if GetItemTypeId( itemMANIPULATED ) == [B]'DUMMY_ID'[/B] then
    set intITEM_TYPEID = [B]'ID'[/B]
endif

Add to "DropItemsPutTogether" just below // GET THE TYPEID OF THE DROPPED ITEM
Code:
 if GetItemTypeId( itemDROPPED ) == [B]'ID'[/B] then
     set intDROPPED_TYPEID = [B]'DUMMY_ID'[/B]
 endif



END
That's it. It might seem much, but once u have imported the triggers it's very little work. Hope u can use it.
 
Reaction score
125
Picking A Hero

How to get a Hero by moving a Wisp into a region:

Code:
hero picking
    Events
        Unit - A unit enters Region 000 <gen>
    Conditions
        (Unit-type of (Entering Unit)) Equal to Wisp
    Actions
        Unit - Create 1 Footman for (Owner of (Entering Unit)) at (Center of Region 001 <gen>) facing Default building facing degrees
        Camera - Pan camera for (Owner of (Entering Unit)) to (Center of Region 001 <gen>) over 2.00 seconds
        Game - Display to (All players) the text: ((Player  + (Name of (Owner of (Entering Unit)))) + ((( Has Selected the  + (Name of (Last created unit))) +  And Entered The Battle Field)))
        Unit - Remove (Entering Unit) from the game
 

emjlr3

Change can be a good thing
Reaction score
395
Code:
adv recipes
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) has an item of type Stygian Desolator) Equal to True
            Then - Actions
                Set Styg = 0
                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-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Mithril Hammer +26
                                Styg Less than or equal to 2
                            Then - Actions
                                Set Styg = (Styg + 1)
                            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Styg Equal to 2
                    Then - Actions
                        For each (Integer B) from 1 to 6, do (Actions)
                            Loop - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Item-type of (Item carried by (Triggering unit) in slot (Integer B))) Equal to Mithril Hammer +26
                                        Styg Greater than 0
                                    Then - Actions
                                        Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
                                        Set Styg = (Styg - 1)
                                    Else - Actions
                        Item - Remove (Item carried by (Triggering unit) of type Stygian Desolator)
                        Set Temporary_Point = (Position of (Triggering unit))
                        Item - Create Stygian Desolator at Temporary_Point
                        Hero - Give (Last created item) to (Triggering unit)
                        Special Effect - Create a special effect at Temporary_Point using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                        Custom script:   call RemoveLocation( udg_Temporary_Point )
                        Wait 2.00 seconds
                        Special Effect - Destroy (Last created special effect)
                    Else - Actions
            Else - Actions

had to figure this out for my AOS, this is how to combine items into a new one, when more then 1 of the same item are needed

this is an example for DotA, for the stygian desolator, you need 2 mithril hammers, and a stygian desolator recipe scroll, and this trigger makes them into a stygian desolator item

for editing:

the variable styg is an integer
the variable tomporary_point is a point, and is jsut needed for no memory leak at that step
since 2 are needed, you set stg up to 2, the remove them , and give the unit the item, change the styg needed for however many items of the same that are needed
 

Jo.O

Bored...
Reaction score
69
It makes you only able to have one sword at a time one shield at a time etc.

NOTE: This code is for weapons. so i used PERMANENT for ALL my weapons. ALSO this is only for player 1, so you will have to make more than one code and variables if you have more players.

Code:
WeaponPlayer1
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-class of (Item being manipulated)) Equal to Permanent
                OnlyWeapon1 Equal to False
            Then - Actions
                Set OnlyWeapon1 = True
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-class of (Item being manipulated)) Equal to Permanent
                        Only1Weapon1 Equal to True
                    Then - Actions
                        Trigger - Turn off AbleDrop1 <gen>
                        Item - Move (Item being manipulated) to (Position of (Triggering unit))
                        Game - Display to Player Group - Player 1 (Red) the text: You already have a ...
                        Wait 0.05 seconds
                        Trigger - Turn on AbleDrop1 <gen>
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-class of (Item being manipulated)) Equal to Permanent
                                OnlyWeapon1 Equal to False
                            Then - Actions
                                Set OnlyWeapon1 = True
                            Else - Actions
                                Do nothing
Change the text to eg. "You already have a weapon. Drop it if you want this one".

Note: The OnlyWeapon1 is a variable of type: Boolean set to False at start.



This is also only for player 1.
Code:
AbleDrop1
    Events
        Unit - A unit Loses an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-class of (Item being manipulated)) Equal to Permanent
                OnlyWeapon1 Equal to True
            Then - Actions
                Set OnlyWeapon1 = False                
            Else - Actions
                Do Nothing

Good Luck.
 
L

LedZepplin

Guest
This is a simpler version of Elthanor's gun triggers. His triggers had Gold as the clips and Lumber as the rounds. My version works only with Lumber as the arrows and the Lumber also decreases for each shot fired.

Code:
Arrows     
Events
        Unit - A unit Is attacked
    Conditions
        ((Unit-type of (Attacking unit)) Equal to Archer) 
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Owner of (Attacking unit)) Current lumber) Greater than 0
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                    Then - Actions
                        Player - Set (Owner of (Attacking unit)) Current lumber to (((Owner of (Attacking unit)) Current lumber) - 1)
                    Else - Actions
                        Do nothing
            Else - Actions
                Unit - Order (Attacking unit) to Stop
 

lllidan

New Member
Reaction score
22
Combining Items by Clicking​

I wasn't sure if this was here yet.

-Go to the abilities tab in the object editor and go to Finger of Death item (it's under Special, Items).
-Then change all the effects to nothing like reducing the damage done to 0 etc. Then add item as the targets allowed.
-Next create a new custom item using one of the charged wands.
-Change the name, icon, and effects as you would normally, but add the ability Finger of Death (item) to it. (You can change the name of the finger of death if you like.)
-This "wand" is the item that you will click first and then click another item to combine with it.
-Make sure the wand has only one charge, unless you want the original item to stay.

Having done that create a trigger like this:


Code:
Combining Items
    Events
        Unit - A unit Begins casting an ability
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Ability being cast) Equal to Finger of Death (item) [COLOR=Blue](or the changed name)[/COLOR]
                (Item-type of (Target item of ability being cast)) Equal to [COLOR=Blue]<the item you want it to combine with>[/COLOR]
            Then - Actions
                Item - Create [COLOR=Blue]<the item you want to be made>[/COLOR] at (Position of (Target item of ability being cast))
                Item - Remove (Target item of ability being cast)
            Else - Actions
 

SFilip

Gone but not forgotten
Reaction score
633
Item Stacking System​
Note: Since I now released Item Stacking System II this one can be considered as obsolete so it is recommended that you do not use it anymore.

Considering the fact Appie's system wouldn't work for me i had to make my own...

What it does?
Every time you pick up a stackable item (healing potion, ankh of reincarnation or anything else) it will stack instead of taking a new item slot.
You need 2 triggers for this:
Code:
Acquire
    Events
        Unit - A unit Acquires an item
    Conditions
        (Custom value of (Item being manipulated)) Equal to 0
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Potion of Healing
                (Item-type of (Item being manipulated)) Equal to Potion of Mana
                [COLOR=Red]>>add new items here<<[/COLOR]
    Actions
        Hero - Drop (Item being manipulated) from (Hero manipulating item)
        Item - Set the custom value of (Item being manipulated) to 1
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Hero manipulating item) has an item of type (Item-type of (Item being manipulated))) Equal to True
            Then - Actions
                Item - Set charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated))) to ((Charges remaining in (Item carried by (Hero manipulating item) of type (Item-type of (Item being manipulated)))) + (Charges remaining in (Item being manipulated)))
                Item - Remove (Item being manipulated)
            Else - Actions
                Hero - Give (Item being manipulated) to (Hero manipulating item)
Code:
Lose
    Events
        Unit - A unit Loses an item
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Potion of Healing
                (Item-type of (Item being manipulated)) Equal to Potion of Mana
                [COLOR=Red]>>add new items here<<[/COLOR]
    Actions
        Item - Set the custom value of (Item being manipulated) to 0

Now the only thing you need to do here is to make a list of items you want stackable. To do this simply add new conditions below >>add new items here<< in both triggers.
Example:
Code:
    Conditions
        (Custom value of (Item being manipulated)) Equal to 0
        Or - Any (Conditions) are true
            Conditions
                (Item-type of (Item being manipulated)) Equal to Ankh of Reincarnation
                (Item-type of (Item being manipulated)) Equal to Healing Wards
Hope this is clear; it makes Ankh of Reincarnation and Healing Wards stackable.
 

Bunnyburn

New Member
Reaction score
8
This is a much simpler version of the trigger that limts heroes from carrying more than one weapon, shield, etc at a time. The equipment is put into classifications, such as weapons are misc., armor is artifact, shields are charged, etc. TO modify it for different equipment all that must be changed are the conditions, change the classification to what your working with, the slot the item is moved to, and the item slots that are checked for other items of the same class.

Code:
Weapon
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-class of (Item being manipulated)) Equal to Miscellaneous
    Actions
        Unit - Order (Hero manipulating item) to move (Item being manipulated) to inventory slot 1
        Wait 0.01 seconds
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Or - Any (Conditions) are true
                    Conditions
                        (Item-class of (Item carried by (Hero manipulating item) in slot 2)) Equal to Miscellaneous
                        (Item-class of (Item carried by (Hero manipulating item) in slot 5)) Equal to Miscellaneous
                        (Item-class of (Item carried by (Hero manipulating item) in slot 3)) Equal to Miscellaneous
                        (Item-class of (Item carried by (Hero manipulating item) in slot 4)) Equal to Miscellaneous
                        (Item-class of (Item carried by (Hero manipulating item) in slot 6)) Equal to Miscellaneous
            Then - Actions
                Hero - Drop (Item being manipulated) from (Hero manipulating item)
                Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: You can only wield ...
            Else - Actions
                Do nothing

The Event is simply when a unit picks up an item, the condition just checks what class this item is, then the action moves that item to a certain slot, then it checks all slots except that one for the item, if another item of the same type is picked up, the old item is moved from that slot, and the new one put in its place, but then there is an item of that type in the slots it checks, so that last aquired item is dropped, and a message is displayed.
The onlly downside to this trigger is it makes keeping your inventory organized difficult, but one trigger will work for every hero on the map.
 

Romek

Super Moderator
Reaction score
963
Player Ally Trigger

I made this trigger for a map I was making, It allies players.

Variables:

Player Colour, Integer, array [12]

Code:
Initialization
    Events
        Map initialization
    Conditions
    Actions
        Set PlayerColour[1] = Red
        Set PlayerColour[2] = Blue
        Set PlayerColour[3] = Teal
        Set PlayerColour[4] = Purple
        Set PlayerColour[5] = Yellow
        Set PlayerColour[6] = Orange
        Set PlayerColour[7] = Green
        Set PlayerColour[8] = Pink
        Set PlayerColour[9] = Gray
        Set PlayerColour[10] = Light Blue
        Set PlayerColour[11] = Dark Green
        Set PlayerColour[12] = Brown



Code:
Ally 1
    Ally 1
    Events
        Player - Player 1 (Red) types a chat message containing -ally as A substring
    Conditions
    Actions
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Equal to PlayerColour[(Integer A)]
                        (Substring((Entered chat string), 7, (Length of (Entered chat string)))) Not equal to PlayerColour[(Player number of (Triggering player))]
                    Then - Actions
                        Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                        Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + ( has allied  + ((Name of (Player((Integer A)))) + !)))
                    Else - Actions

repeat for every player. Nothing needs changing except for the line: (change for different players)

Code:
Player - Player 1 (Red) types a chat message containing -ally as A substring

here is the Unally Trigger:

Code:
Unally 1
    Events
        Player - Player 1 (Red) types a chat message containing -unally as A substring
    Conditions
    Actions
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Substring((Entered chat string), 9, (Length of (Entered chat string)))) Equal to PlayerColour[(Integer A)]
                        (Substring((Entered chat string), 9, (Length of (Entered chat string)))) Not equal to PlayerColour[(Player number of (Triggering player))]
                    Then - Actions
                        Player - Make (Triggering player) treat (Player((Integer A))) as an Enemy
                        Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + ( has declared war on  + ((Name of (Player((Integer A)))) + !)))
                    Else - Actions

only change 1 line: (for different players)
Code:
Player - Player 1 (Red) types a chat message containing -unally as A substring
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top