• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Item Combining via an Ability

Status
Not open for further replies.
Level 3
Joined
Apr 28, 2007
Messages
71
Ok so I need to create an item combining system like the one found in the Wilderness Survival map(s).

I.E. You have 2 'rocks' in you inventory and when you use the ability 'Combine' they combine into a 'boulder'.

Any help here is appreciated.
 
Level 7
Joined
Oct 14, 2008
Messages
340
  • Events
    • Unit - unit starts effect of an ability
  • Conditions
    • (Ability being cast) equal to Combine
  • Actions
    • If
      • (Unit has item of type (this item))
      • (Unit has item of type (that item))
    • then
      • Hero - remove this item
      • Hero - remove that item
      • Hero - add new item
    • else
Something like this.. help at all? Pretty vague question I'd say
 
Level 3
Joined
Apr 28, 2007
Messages
71
Go play Wilderness Survival in that case. The whole reason I mentioned it was in the hope you would try it to understand what I am asking...

EDIT: I will experiment with this but I'm sure I will encounter some problems...
 
Level 3
Joined
Apr 28, 2007
Messages
71
Maybe I'm missing something but I don't see exactly what part of that post helps me...
 
Level 3
Joined
Apr 28, 2007
Messages
71
@Maximilianx

Thats really great and all but how am I supposed to implement that...I'm interested in item combining not item restriction..

@ap0calypse

Thats not the type of item combining I am looking for...I don't want an "Auto Combine" system, I want the item combining to be triggered by the use of an ability.
 
Level 7
Joined
Oct 14, 2008
Messages
340
Say you put that code in your header..
then you can make a trigger like this:
  • CombineRocks
    • Events
      • Unit starts the effect of an ability
    • Conditions
      • (Ability being cast) equal to Combine
    • Actions
      • set TempInt = CountItemsByType(GetTriggerUnit(), 'rock')
      • if then else multiple functions
        • if
          • (TempInt is greater than or equal to 2)
        • then
          • Hero - Remove item of type Rock
          • Hero - Remove item of type Rock
          • Hero - Give item of type New item
        • else
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
It gets quite complex with 100s of recipes. Thus you may wish to design some kind of jass system where it reduces the number of comparisons and checks done to prevent lag.

As each receipe needs atmost 6 items, you can already greatly reduce the scope by just checking if the unit has the first item in each recepie and only doing a full check if it does.

The only step up in efficiency is if you can get which possiable recepies it can be just from the items the unit is carrying, thus resulting in near no unneded comparisons.
 
Level 3
Joined
Apr 28, 2007
Messages
71
  • Log
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Combine
    • Actions
      • Custom script: set udg_TempInt = CountItemsByType(GetTriggerUnit(), 'rat3')
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInt Greater than or equal to 2
        • Then - Actions
          • Special Effect - Create a special effect attached to the origin of (Casting unit) using Abilities\Spells\Items\AIem\AIemTarget.mdl
          • Set SpecialFX = (Last created special effect)
          • Item - Remove (Item carried by Tribesman[(Player number of (Owner of (Casting unit)))] of type |cfffed312Stick|r)
          • Item - Remove (Item carried by Tribesman[(Player number of (Owner of (Casting unit)))] of type |cfffed312Stick|r)
          • Hero - Create |cfffed312Log|r and give it to Tribesman[(Player number of (Owner of (Casting unit)))]
          • Wait 1.00 seconds
          • Special Effect - Destroy SpecialFX
        • Else - Actions
So I have my trigger like that but it seems it will not work.


Also, when I view my items as Raw Data my custom item 'Stick' has the following name: "|000:rat3" But when I use that:
JASS:
set udg_TempInt = CountItemsByType(GetTriggerUnit(), '|000:rat3')
it promts me with the following error: "Expected Expression"

Any help?
 
Level 3
Joined
Apr 28, 2007
Messages
71
Lol....if you take the time to quickly dig back to previous attempts to help me [Maximillionx], they involve using custom script. And if I am to not use Custom Script than could you kindly guide me to the CountItemsByType equivalent?
 
Level 7
Joined
Oct 14, 2008
Messages
340
There is no CountItemsByType equivalent, if there was i wouldn't have bothered writing the function >_<

umm, my guess is your item's raw code is I000, try that.
and make sure you DO have the global variable TempInt - must be an integer.
 
Level 5
Joined
Jan 25, 2006
Messages
103
oh man i don't know if this is the problem for not working but this event: (Ability being cast) Equal to Combine, should not be there. You should place it in the actions-condition.
I'm sure it should work like this also, but it may create problems when having more items that you would want to combine, since you already do the actions, before checking for item count.

In fact I would do the triggers very differently, just check for items, say units acquires item of type stick, do all the actions you are doing now, just in the actions-condition place unit is issued an order to cast an ability of type combine, as well as the current condition you have.

But yeah, if you stick with this trigger, make sure you have a integer variable.

Also did you place the Jass code?
 
Level 3
Joined
Apr 28, 2007
Messages
71
Just to let everyone know I've fixed my problem using some triggering sent to me be takezgoez, if you want to know how his system works..well then ask him (I'm not at liberty to share other peoples code freely, or am I?)

+Rep to all helpers thank you!
 
Status
Not open for further replies.
Top