Need Help w/ Item Doubler

sentrywiz

S

sentrywiz

Found a few resources regarding combining same items. I can say I had success understanding this, but I do not get why it doesn't work for another pair of items. Here is the GUI code and the explanation below, hopefully you can help me.

  • Claws
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |c0099CCFFJawbreaker|r
    • Actions
      • For each (Integer A) from 1 to 6, do (If ((Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to |c0099CCFFJawbreaker|r) then do (Set SameItems = (SameItems + 1)) else do (Do nothing))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SameItems Equal to 2
        • Then - Actions
          • Hero - Drop (Item carried by (Hero manipulating item) of type |c0099CCFFJawbreaker|r) from (Hero manipulating item)
          • Item - Remove (Last dropped item)
          • Hero - Drop (Item carried by (Hero manipulating item) of type |c0099CCFFJawbreaker|r) from (Hero manipulating item)
          • Item - Remove (Last dropped item)
          • Hero - Create |c0099CCFFClaws|r and give it to (Hero manipulating item)
          • Special Effect - Create a special effect attached to the overhead of (Hero manipulating item) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Set SameItems = 0
I think it was Razorbrain who made the triggers. Don't remember. In anycase, these are bit modified for my use but they combine two jawbreakers to create claws. The thing that doesn't work is another trigger like this one, trying to combine two claws into one rapier.

  • Rapier
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to |c0099CCFFClaws|r
    • Actions
      • For each (Integer A) from 1 to 6, do (If ((Item-type of (Item carried by (Hero manipulating item) in slot (Integer A))) Equal to |c0099CCFFClaws|r) then do (Set SameItems = (SameItems + 1)) else do (Do nothing))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SameItems Equal to 2
        • Then - Actions
          • Hero - Drop (Item carried by (Hero manipulating item) of type |c0099CCFFClaws|r) from (Hero manipulating item)
          • Item - Remove (Last dropped item)
          • Hero - Drop (Item carried by (Hero manipulating item) of type |c0099CCFFClaws|r) from (Hero manipulating item)
          • Item - Remove (Last dropped item)
          • Hero - Create |c0099CCFFRapier|r and give it to (Hero manipulating item)
          • Special Effect - Create a special effect attached to the overhead of (Hero manipulating item) using Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Set SameItems = 0
The only way this worked is when I put the second trigger in the first and when you would buy another jawbreaker and you have two claws in inventory, then they get fused. But I want it instantly. This is what I want the trigger to do:

- You buy Jawbreaker.
- You buy another Jawbreaker, and instead of having them both - the triggers remove two Jawbreakers and give you Claws.
- You buy another Jawbreaker.
- When you try to buy the second Jawbreaker, and them two to fuse in claws, the triggers are supposed to notice you have two claws in inventory and remove all jawbreaker and claws then just give you a Rapier.
 
Last edited by a moderator:

Chaosy

Tutorial Reviewer
Level 39
Joined
Jun 9, 2011
Messages
13,083
this works. just edit the items for combine 2 claws
  • Untitled Trigger 003
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to (Item-type of Your_item)
    • Actions
      • Set Weapon_count = (Weapon_count + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Weapon_count Equal to 2
        • Then - Actions
          • Item - Remove (Item carried by (Hero manipulating item) of type (Item-type of Your_item))
          • Hero - Create (Item-type of Your_item) and give it to (Hero manipulating item)
        • Else - Actions
and add this to unbug it.
  • Untitled Trigger 004
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to (Item-type of Your_item)
    • Actions
      • Set Weapon_count = (Weapon_count - 1)
 
Level 37
Joined
Mar 6, 2006
Messages
9,242
Try this: Link


  • Init 2
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set ht = (Last created hashtable)
      • -------- From which item to what item --------
      • Custom script: call SaveInteger(udg_ht, 'rat3', 0, 'rat6')
      • Custom script: call SaveInteger(udg_ht, 'rat6', 0, 'rat9')
      • Custom script: call SaveInteger(udg_ht, 'rat9', 0, 'ratc')
      • Custom script: call SaveInteger(udg_ht, 'ratc', 0, 'ratf')
  • Get Item 2
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set u = (Triggering unit)
      • Set it = (Item being manipulated)
      • Custom script: set udg_int = GetHandleId(udg_u)
      • Custom script: set udg_int2 = GetItemTypeId(udg_it)
      • -------- The item can be combined --------
      • Custom script: if HaveSavedInteger(udg_ht, udg_int2, 0) then
      • -------- The hero has item of that type --------
      • Custom script: if HaveSavedHandle(udg_ht, udg_int, udg_int2) then
      • Custom script: call RemoveItem(LoadItemHandle(udg_ht, udg_int, udg_int2))
      • Item - Remove (Item being manipulated)
      • Custom script: call RemoveSavedHandle(udg_ht, udg_int, udg_int2)
      • Custom script: call UnitAddItemById(udg_u, LoadInteger(udg_ht, udg_int2, 0))
      • Custom script: else
      • Custom script: call SaveItemHandle(udg_ht, udg_int, udg_int2, udg_it)
      • Custom script: endif
      • Custom script: endif
  • Lose Item
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Set u = (Triggering unit)
      • Set it = (Item being manipulated)
      • Custom script: set udg_int = GetHandleId(udg_u)
      • Custom script: set udg_int2 = GetItemTypeId(udg_it)
      • -------- The item can be combined --------
      • Custom script: if HaveSavedInteger(udg_ht, udg_int2, 0) then
      • Custom script: call RemoveSavedHandle(udg_ht, udg_int, udg_int2)
      • Custom script: endif


In the first trigger, use ra codes to tell which item types can be combined to hat item types. You can see raw codes by clicking Ctrl + D in object editor.

For example
  • Custom script: call SaveInteger(udg_ht, 'rat3', 0, 'rat6')
rat3 = Claws of attack +3
rat6 = Claws of attack +6

Two +3 claws combine into one +6 claw.
Two +6 into one +9 and so on.

If you have one +3, one +6 and you pick up +3, you end up with one +9.
 

sentrywiz

S

sentrywiz

Darkgrom's way is simpler and better for me to understand. I will probably implement that.

But I still don't understand how will that unbug the system, when I have two triggers that try fuse things. I should add the lose item trigger to unbug them?

But Maker's system is the way I wanna go if I ever understand his scripts. For a full-proof map item doubling system

+rep to both of you
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
@sentrywiz

Yes, darkgrom's way is much simpler and more understand, but you know why it has to be like that ?
It is because it doesn't support multi-unit using it.

Example, Unit A triggers the trigger, then at the same time Unit B triggers it too.
The Weapon_count variable will become 2 because it tracks all kinds of unit

As for Maker system, it supports multi-unit because it keep tracks all units at a time.

Note: The simpler the matter is, the simpler it will work.
 

sentrywiz

S

sentrywiz

This thread is done, I've used some of the ideas provided here and coded it myself.

@defskull - I can't disagree more, the simpler and more effective matters are much harder to code or realize through ideas than much complex things. Thing is - the simpler the matter is, it means it is more user-friendly and thus its simpler so that anyone can do it. But this takes your skills to the max.
 
Top