|
好吧,自己解决了,附上演示
- function ArmourLevelUp takes unit u,integer a,integer b,integer n returns nothing
- local integer i=1
- if (( UnitHasItemOfTypeBJ(u, a) == true ) and ( IsUnitType(u, UNIT_TYPE_HERO) == true )) then
- else
- call DisplayTextToPlayer( GetOwningPlayer(u), 0, 0, "你的材料不足" )
- call AdjustPlayerStateBJ( n, GetOwningPlayer(u), PLAYER_STATE_RESOURCE_GOLD )
- return
- endif
- loop
- exitwhen i>6
- if ( GetItemTypeId(UnitItemInSlotBJ(u, i)) == a ) then
- call RemoveItem( UnitItemInSlotBJ(u, i) )
- call UnitAddItemToSlotById( u, b, ( i - 1 ) )
- return
- else
- endif
- set i= i + 1
- endloop
- set u=null
- return
- endfunction
-
-
- function Trig_ArmourLevelUp_Actions takes nothing returns nothing
- local integer a
- local integer b
- local integer c
- local integer n1
- local integer n2
- local integer i = 1
- local unit u = GetTriggerUnit()
- set a = 'I001' //合成材料类型
- set b = 'I007' //二级物品类型
- set c = 'I008' //三级物品类型/
- set n1 = 10 // 金钱补偿
- set n2 = 15 // 金钱补偿
- if ( GetItemTypeId(GetManipulatedItem()) == 'I00E' ) then
- call ArmourLevelUp(u,a,b,n1)
- elseif ( GetItemTypeId(GetManipulatedItem()) == 'I00D' ) then
- call ArmourLevelUp(u,b,c,n2)
- else
- endif
- set u=null
- endfunction
- //===========================================================================
- function InitTrig_ArmourLevelUp takes nothing returns nothing
- set gg_trg_ArmourLevelUp = CreateTrigger( )
- call TriggerRegisterAnyUnitEventBJ( gg_trg_ArmourLevelUp, EVENT_PLAYER_UNIT_PICKUP_ITEM )
- call TriggerAddAction( gg_trg_ArmourLevelUp, function Trig_ArmourLevelUp_Actions )
- endfunction
复制代码 |
|