|
经过朱朱提出的不足,我在原基础上修复了一下
希望大家用得上,还有新的评价
//合成需求物品判断<公式成立后删除条件物品,给予合成物品>
//参数<条件单位,反还金币,完成物品,条件物品(1),条件物品(2),条件物品(3),条件物品(4),条件物品(5),条件物品(6)>
[codes=jass]
function CompoundItemEstimate takes unit Unia,integer Gold,integer CompoundItem,integer i0,integer i1,integer i2,integer i3,integer i4,integer i5 returns nothing
local integer array Item
local integer Inta
local integer Intb
local integer Intc
local integer Intd
set Item[0]=i0
set Item[1]=i1
set Item[2]=i2
set Item[3]=i3
set Item[4]=i4
set Item[5]=i5
set Inta=0
set Intb=0
[/codes]
//取得一共要判断多少条件物品,并记录物品栏每一格物品(包括空)
[codes=jass]
loop
exitwhen Inta>5
if Item[Inta]!=0 then
set Intb=Intb+1
endif
set Item[Inta+12]=GetItemTypeId(UnitItemInSlot(Unia,Inta))
set Inta=Inta+1
endloop
[/codes]
//判断物品栏是否有足够的物品,并把判断过的物品记录清空
[codes=jass]
set Intd=Intb
set Inta=0
set Intb=0
set Intc=0
loop
exitwhen Inta>Intd
loop
exitwhen Intb>5
if Item[Intb+12]!=0 and Item[Intb+12]==Item[Inta] then
set Item[Inta+6]=Item[Inta]
set Item[Intb+12]=0
set Item[Inta]=0
set Intc=Intc+1
endif
set Intb=Intb+1
endloop
set Inta=Inta+1
set Intb=0
endloop
[/codes]
//判断是否达成合成公式要求(成功则删除条件物品,失败则反还购买卷轴的金币)
[codes=jass]
set Inta=0
set Intb=0
if Intc>=Intd then
loop
exitwhen Inta>Intd
loop
exitwhen Intb>5
if GetItemTypeId(UnitItemInSlot(Unia,Intb))==Item[Inta+6] then
call RemoveItem(UnitItemInSlot(Unia,Intb))
set Intb=5
endif
set Intb=Intb+1
endloop
set Inta=Inta+1
set Intb=0
endloop
call UnitAddItemById(Unia,CompoundItem)
call DestroyEffect(AddSpecialEffectTarget("合成成功后的特效.mdx",Unia,"origin"))
else
call SetPlayerState(GetOwningPlayer(Unia),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(Unia),PLAYER_STATE_RESOURCE_GOLD)+Gold)
if GetLocalPlayer()==GetOwningPlayer(Unia) then
call StartSound(合成失败的声音消息<例如:gg_snd_Erro>)
call ClearTextMessages()
endif
call DisplayTimedTextToPlayer(GetOwningPlayer(Unia),0.51,0,10,"合成失败的文字消息")
endif
endfunction
[/codes]
//合成卷轴判断
//条件物品为0使可自动跳过判断
[codes=jass]
function ItemCompoundEstimate takes nothing returns nothing
local boolean Booa=GetItemTypeId(GetManipulatedItem())=='卷轴类型1'
local boolean Booa=GetItemTypeId(GetManipulatedItem())=='卷轴类型2'
if Booa then
call CompoundItemEstimate(触发单位,反还金币,'结果物品','条件物品(1)','条件物品(2)','条件物品(3)','条件物品(4)','条件物品(5)','条件物品(6)')
elseif Boob then
call CompoundItemEstimate(触发单位,反还金币,'结果物品','条件物品(1)','条件物品(2)','条件物品(3)','条件物品(4)','条件物品(5)','条件物品(6)')
endif
endfunction
[/codes]
//事件的添加,添加2-11(因为那是我的地图上的最大玩家)玩家单位获得任意物品
[codes=jass]
function InitTrig_Item_Compound takes nothing returns nothing
local integer Inta=2
set gg_trg_Item_Compound=CreateTrigger()
loop
exitwhen Inta>11
call TriggerRegisterPlayerUnitEvent(gg_trg_Item_Compound,Player(Inta),EVENT_PLAYER_UNIT_PICKUP_ITEM,null)
set Inta=Inta+1
endloop
call TriggerAddCondition(gg_trg_Item_Compound,Condition(function ItemCompoundEstimate))
endfunction
[/codes] |
评分
-
查看全部评分
|