Wednesday, April 18, 2012

Need Help With Item Combination System

I have been trying to create a system that allows item combination through dragging & dropping items onto one another to create a new item. I know how to write the trigger for the most part, I just do not know how to reference the type of the item that is being "hit" (for lack of a better word).

Any and all help with this would be greatly appreciated. Here is the trigger that I am using(it isn't complete, like I said):

Test

Events

Unit - A unit Is issued an order targeting an object

Conditions

Or - Any (Conditions) are true

Conditions

(Item carried by (Ordered unit) in slot 1) Equal to (Target item of issued order)

(Item carried by (Ordered unit) in slot 2) Equal to (Target item of issued order)

(Item carried by (Ordered unit) in slot 3) Equal to (Target item of issued order)

(Item carried by (Ordered unit) in slot 4) Equal to (Target item of issued order)

(Item carried by (Ordered unit) in slot 5) Equal to (Target item of issued order)

(Item carried by (Ordered unit) in slot 6) Equal to (Target item of issued order)

Actions

-------- IfThenElse For Item Combination --------

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 (Target item of issued order)) Equal to Crown of Kings +5

(Item-type of (Item carried by (Ordered unit) in slot (Integer A))) Equal to Claws of Attack +15

Then - Actions

Hero - Create Mask of Death and give it to (Ordered unit)

Else - Actions

Do nothing

What I am trying to do in this trigger is combine Claws of Attack +15 and Helm of Valor into Mask of Death by dragging and dropping. It does work, but the unfortunate part is that helm of valor can be dropped on any item to create mask of death, not just claws of attack +15 (that is as long as it is in the hero's inventory).

Sorry if any of my post is unclear.|||Issue resolved :).

For anyone who reads this, here is the JASS trigger for it. Note that I have adapted it for any item combination by adding in a description in the field for the required items and the item created.

One last thing, thank you Chunk. One of your old (very, very old) posts helped me to resolve this :).

function Trig_Test_Func002C takes nothing returns boolean

if ( ( UnitItemInSlotBJ(GetOrderedUnit(), 1) == GetOrderTargetItem() ) ) then

return true

endif

if ( ( UnitItemInSlotBJ(GetOrderedUnit(), 2) == GetOrderTargetItem() ) ) then

return true

endif

if ( ( UnitItemInSlotBJ(GetOrderedUnit(), 3) == GetOrderTargetItem() ) ) then

return true

endif

if ( ( UnitItemInSlotBJ(GetOrderedUnit(), 4) == GetOrderTargetItem() ) ) then

return true

endif

if ( ( UnitItemInSlotBJ(GetOrderedUnit(), 5) == GetOrderTargetItem() ) ) then

return true

endif

if ( ( UnitItemInSlotBJ(GetOrderedUnit(), 6) == GetOrderTargetItem() ) ) then

return true

endif

return false

endfunction

function Trig_Test_Conditions takes nothing returns boolean

if ( not Trig_Test_Func002C() ) then

return false

endif

return true

endfunction

//Condition Template for Item Combination

function CDTN_1 takes nothing returns boolean

if ( not ( GetItemTypeId(GetOrderTargetItem()) == '(this is the item type of the item that is dragged; make sure that it is "raw data" type. Also, remove the parenthesis)' ) ) then

return false

endif

if ( not ( GetItemTypeId(UnitItemInSlotBJ(GetOrderedUnit(), udg_HitItem)) == '(this is the item that is being dragged onto; once again, the type must be the raw data name of the item's type)' ) ) then

return false

endif

return true

endfunction

function Trig_Test_Actions takes nothing returns nothing

set udg_HitItem = GetIssuedOrderIdBJ() - 852001

// The code from "if" to "endif" is the code that creates the item. You can copy & paste it within the function Trig_Test_Actions. Make sure you have another condition function for it and that it references that function, as this one does (CDTN_1 is the condition function for this particular code, not that it too can be copied and pasted and used for other item combos. :)

if ( CDTN_1() ) then

call RemoveItem( GetItemOfTypeFromUnitBJ(GetOrderedUnit(), GetItemTypeId(GetOrderTargetItem())) )

call RemoveItem( UnitItemInSlotBJ(GetOrderedUnit(), udg_HitItem) )

call UnitAddItemByIdSwapped( '(this is the item type created for the "combiner"; note once again, the raw data name of the type)', GetOrderedUnit() )

endif

endfunction

//================================================== =========================

function InitTrig_Test takes nothing returns nothing

set gg_trg_Test = CreateTrigger( )

call TriggerRegisterAnyUnitEventBJ( gg_trg_Test, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )

call TriggerAddCondition( gg_trg_Test, Condition( function Trig_Test_Conditions ) )

call TriggerAddAction( gg_trg_Test, function Trig_Test_Actions )

endfunction|||hey i saw your item combo thing, im doing something completely different but that item slot drag drop would really help me out, now does it NEED to be done in jass or is there a gui trig that will work for this, i havent yet looked through your jass trigger but i will and can probably make out most of it, all tho i do not know jass well enough to make it from nothing. if you have that trigger in gui that would really help me out, or at least talk to me on how to change the jass to fit what im doing i guess, if it NEEDs to be done with jass lol, thanks man|||Quote:






View Post

hey i saw your item combo thing, im doing something completely different but that item slot drag drop would really help me out, now does it NEED to be done in jass or is there a gui trig that will work for this, i havent yet looked through your jass trigger but i will and can probably make out most of it, all tho i do not know jass well enough to make it from nothing. if you have that trigger in gui that would really help me out, or at least talk to me on how to change the jass to fit what im doing i guess, if it NEEDs to be done with jass lol, thanks man




hey i saw your item combo thing, im doing something completely different but that item slot drag drop would really help me out, now does it NEED to be done in jass or is there a gui trig that will work for this, i havent yet looked through your jass trigger but i will and can probably make out most of it, all tho i do not know jass well enough to make it from nothing.

____________________

Organisme de credit a la consommation | Organisme maison de credit immobilier |Organisme de rachat de credit en ligne|||K thanks anyway but i figured it all out, very short efficient trig

No comments:

Post a Comment