| 12-24-2006, 01:48 AM | #1 |
JASS:function Trig_Recipe_Items_Actions takes nothing returns nothing local unit a = GetManipulatingUnit() if UnitHasItemOfTypeBJ(a, 'belv') == true and UnitHasItemOfTypeBJ(a, 'ciri') == true and UnitHasItemOfTypeBJ(a, 'bgst') == true then call RemoveItem( GetItemOfTypeFromUnitBJ(a, 'bgst') ) call RemoveItem( GetItemOfTypeFromUnitBJ(a, 'ciri') ) call RemoveItem( GetItemOfTypeFromUnitBJ(a, 'belv') ) call UnitAddItemById( a,'I00E' ) call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl", a, "origin" ) ) endif set a = null endfunction //=========================================================================== function InitTrig_Recipe_Items takes nothing returns nothing set gg_trg_Recipe_Items = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Recipe_Items, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddAction( gg_trg_Recipe_Items, function Trig_Recipe_Items_Actions ) endfunction |
| 12-24-2006, 01:56 AM | #2 |
Suggestion: Remove the '==true' parts from the code. Also, this is too complicated to replace?! (Even though it's just another BJ function) JASS:function UnitHasItemOfTypeBJ takes unit whichUnit, integer itemId returns boolean return GetInventoryIndexOfItemTypeBJ(whichUnit, itemId) > 0 endfunction |
| 12-24-2006, 02:01 AM | #3 |
There are a lot of ways to make recipes. For this case since you don't want it dynamic I recomment a loop through the slots of the inventory and asking if UnitItemInSlot is one of those items then checking. would reduce T from 18 to 6, |
| 12-24-2006, 02:07 AM | #4 |
Replace JASS:function InitTrig_Recipe_Items takes nothing returns nothing set gg_trg_Recipe_Items = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Recipe_Items, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddAction( gg_trg_Recipe_Items, function Trig_Recipe_Items_Actions ) endfunction with JASS:function InitTrig_Recipe_Items takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddAction( t, function Trig_Recipe_Items_Actions ) set t = null endfunction Put that in. Just a bit of optimization, saves a few kb of memory, plus its cleaner. I suggest doing this for all your JASS triggers. It's become habit for me. He asked for optimization, thats what he gets XD |
