|
楼主 |
发表于 2010-8-16 23:02:08
|
显示全部楼层
[jass]
//===========================================================================
//物品系统注册
//===========================================================================
function ItemInit takes integer itemcode,integer trueitem,integer falseitem,integer bookitem,integer unititem,integer money,string icon returns nothing
//local string dis = "ReplaceableTextures\\\\CommandButtons\\\\BTN" + icon + ".blp"
//call SetItemStr("ItemIcon",I2S(trueitem),dis)
//call SetItemInt("ItemMoney",I2S(trueitem),money)
//set dis = null
set udg_Item_True[itemcode] = trueitem
set udg_Item_False[itemcode] = falseitem
set udg_Item_Book[itemcode] = bookitem
if unititem != 0 then
set udg_Item_Unit[itemcode] = unititem
endif
endfunction
//物品注册
function ItemMainInit takes nothing returns nothing
call ItemInit(1,'hslv','I094','I04W','h026',55,"HealingSalve")
call ItemInit(2,'pclr','I095','I04X','h027',45,"PotionOfClarity")
call ItemInit(3,'I00U','I096','I04Y','h028',1700,"MarkOfFire")
//...
call ItemInit(799,'I00Z','I0DF','I0DC',0,0,"HeartOfAszune")
call ItemInit(798,'I013','I0DG','I0DD',0,0,"PotionOfVampirism")
call ItemInit(797,'I040','I0DH','I0DE',0,0,"LionHorn")
call ItemInit(796,'spre','I0BR','I07J',0,3200,"OrbOfFrost")
//...
call ItemInit(801,'I02Y',0,0,0,0,"")
call ItemInit(802,'I02P',0,0,0,0,"")
call ItemInit(803,'I015',0,0,0,0,"")
//...
endfunction
function ItemMixInit takes integer id1, integer id2, integer id3, integer id4, integer id5, integer id6, integer mixid, integer heroid returns nothing
//id1-6 所需装备,mixid 合成装备 heroid 英雄类别
local integer array id
local integer i
local integer total
local integer num = udg_FormulaNum + 1
local integer num10 = num * 10
set id[1] = id1
set id[2] = id2
set id[3] = id3
set id[4] = id4
set id[5] = id5
set id[6] = id6
set udg_FormulaNum = num//第num个合成公式(范围1~800)
if mixid > 800 then
set udg_MixFormula[num10] = heroid//记录专属英雄类别
endif
set udg_MixFormula[num10+7] = mixid//记录合成物品
//记录合成材料及合成材料个数total
set total = 1
loop
exitwhen id[total] == 0 or total > 6
set udg_MixFormula[num10+total] = id[total]
set total = total + 1
endloop
set total = total - 1
set udg_MixFormula[num10+9] = total
//记录物品的合成总数及对应合成公式
set i = 1
loop
exitwhen i > total
set udg_ItemFormNum[id] = udg_ItemFormNum[id] + 1 //id类物品合成公式总数
call SaveItemInt(id,udg_ItemFormNum[id],num) //id类第udg_ItemFormNum[id]个合成公式对应的方法
set i = i + 1
endloop
endfunction
//物品合成注册
function ItemMixStart takes nothing returns nothing
call ItemMixInit(3,4,63,0,0,0,778,0)
call ItemMixInit(3,31,85,0,0,0,754,0)
call ItemMixInit(4,75,0,0,0,0,764,0)
//...
call ItemMixInit(4,23,772,0,0,0,857,'U00I')
call ItemMixInit(4,778,772,0,0,0,809,'U000')
call ItemMixInit(4,744,0,0,0,0,836,'O00K')
//...
endfunction
function SetItemData takes integer kind,integer playid,integer itemcode returns integer
//设置物品自定义值(ABBCCC A:类别 BB:玩家索引 CCC:物品编号)
return kind*100000+playid*1000+itemcode
endfunction
function CountItmesNum takes unit u returns integer//获取单位包内物品数(0-6)
local integer i = 0
local integer j = 0
loop
exitwhen i > 5
if UnitItemInSlot(u, i) != null then
set j = j + 1
endif
set i = i + 1
endloop
return j
endfunction
function GetItemOwnId takes item it returns integer//获取物品所属玩家ID
return S2I(SubString(I2S(GetItemUserData(it)),1,3))
endfunction
function IsItemOwn takes unit u,item it returns boolean //物品是否是单位所属玩家的
if GetPlayerId(GetOwningPlayer(u)) == GetItemOwnId(it) or udg_ColseItem then
return true
else
return false
endif
endfunction
function GetItemCode takes item it returns integer//获取物品编号
return S2I(SubString(I2S(GetItemUserData(it)),3,6))
endfunction
function GetItemKind takes item it returns integer//获取类别 1-真,2-假,3-书,4-通用
return S2I(SubString(I2S(GetItemUserData(it)),0,1))
endfunction
function CreateItemAtLoc takes integer itid,integer pid, real x, real y returns nothing
//itid 物品类型编号 pid 玩家id(0为共享)
local item it
local item it_true
set it = CreateItem(udg_Item_Book[itid],x,y)
call SetItemUserData(it,SetItemData(3,pid,itid))
if pid < 6 then
set x = -6744
set y = -7600
else
set x = 6956
set y = 5371
endif
set it_true = CreateItem(udg_Item_True[itid],x,y)
call SetItemUserData(it_true,SetItemData(1,pid,itid))
call SaveItemAgent(H2I(it),1,it_true)
call SetItemVisible( it_true, false )
set it = null
set it_true = null
endfunction
function CreateItemForUnit takes integer itid,unit u returns nothing
//itid 物品类型编号 u 玩家单位
local item it
local item it_true
local integer pid = GetPlayerId(GetOwningPlayer(u))
local real x
local real y
set it = CreateItem(udg_Item_Book[itid],GetUnitX(u),GetUnitY(u))
call SetItemUserData(it,SetItemData(3,pid,itid))
if pid < 6 then
set x = -6744
set y = -7600
else
set x = 6956
set y = 5371
endif
set it_true = CreateItem(udg_Item_True[itid],x,y)
call SetItemUserData(it_true,SetItemData(1,pid,itid))
call SaveItemAgent(H2I(it),1,it_true)
call SetItemVisible( it_true, false )
call UnitAddItem(u,it)
set it = null
set it_true = null
endfunction
//===========================================================================
function InitTrig_InitFunctions takes nothing returns nothing
set udg_SN_Item_Hash = InitHashtable()
call ItemMainInit()
call ItemMixStart()
endfunction
//出售物品总数
function GetAllItemNumber takes nothing returns integer
return 96
endfunction
//判断是否可拆分合成物品
function IsSplitItem takes integer id returns boolean
if id == 772 or id ==771 or id == 762 or id == 759 then//不可拆分物品编码
return false
else
return true
endif
endfunction
//判断是否出售物品的商店
function IsSellItemUnit takes integer id returns boolean
if id == 'n00Q' or id == 'n00R' or id == 'n003' or id == 'n00U' or id == 'n015' or id == 'n00A' or id == 'n00O' or id == 'n008' or id == 'n014' or id == 'n007' or id == 'n01J' or id == 'n013' or id == 'n01K' then
return true
else
return false
endif
endfunction
//判断是否可共享物品
function IsItemShare takes integer ic returns boolean
if ic == 1 or ic == 2 or ic == 8 or ic == 9 or ic == 10 or ic == 799 or ic == 798 or ic == 797 or ic == 19 then
return true
else
return false
endif
endfunction
//判断是否可叠加物品
function IsItemCharges takes integer id returns boolean
if id == 1 or id == 2 or id == 8 or id == 9 or id == 'hslv' or id == 'pclr' or id == 'I00H' or id == 'I00J' then
return true
else
return false
endif
endfunction
function SplitItem takes unit u, item it returns nothing
local integer i
local integer id
local integer id10
local integer num
local integer total
local integer pid
local real x
local real y
local player p
if IsItemOwn(u,it) then
//call Debug("共有合成公式:"+I2S(udg_FormulaNum))
set num = GetItemCode(it)
if num > GetAllItemNumber() and num < 797 and IsSplitItem(num) then
if num == 776 then
set num = 777
elseif num == 768 then
set num = 769
endif
set id = 1
loop
exitwhen udg_MixFormula[id*10+7] == num or id > udg_FormulaNum
set id = id + 1
endloop
if id <= udg_FormulaNum then
set id10 = id * 10
set total = udg_MixFormula[id10+9]
//call Debug(I2S(num)+" 可拆分 "+I2S(total))
set pid = GetItemOwnId(it)
set x = GetUnitX(u)
set y = GetUnitY(u)
call FlushItemMission(H2I(it))
call RemoveItem(it)
set i = 1
loop
exitwhen i > total
//call Debug(I2S(i)+"-编号-"+I2S(udg_MixFormula[id10+i]))
if i == total then
call SaveItemBool(H2I(u),3628,true)
endif
call CreateItemForUnit(udg_MixFormula[id10+i],u)
set i = i + 1
endloop
call SaveItemBool(H2I(u),3628,false)
//call Debug("拆分成功")
set p = GetOwningPlayer(u)
call DisplayTextToPlayer( p, 0, 0, "|cFFFF0000重铸成功!|r" )
call DestroyEffect(AddSpecialEffectTarget("Abilities\\\\Spells\\\\Other\\\\Incinerate\\\\FireLordDeathExplode.mdl", u, "origin"))
set p = null
endif
else
//call Debug("该物品不可拆分")
set p = GetOwningPlayer(u)
call DisplayTextToPlayer( p, 0, 0, "|cFFFF0000该物品不可重铸!|r" )
call CreateItemForUnit(96,u)
set p = null
endif
endif
endfunction
function SplitDel_Conditions takes nothing returns boolean
if GetItemTypeId(GetManipulatedItem()) == 'I03U' then
call RemoveItem(GetManipulatedItem())
endif
return false
endfunction
function SplitItemAction takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetItemUnit(H2I(t),1)
local item it = GetItemItem(H2I(t),2)
call SplitItem(u,it)
call FlushItemMission(H2I(t))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set u = null
set it = null
endfunction
function SplitItemAction2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetItemUnit(H2I(t),1)
call CreateItemForUnit(96,u)
call FlushItemMission(H2I(t))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
set u = null
endfunction
function Split_Conditions takes nothing returns boolean
local item it = GetSpellTargetItem()
local timer t
local unit u
local player p
if GetSpellAbilityId() == 'A00P' and IsItemOwned(it) and GetItemTypeId(it)!='I03U' then
set u = GetTriggerUnit()
set t = CreateTimer()
call SaveItemAgent(H2I(t),1,u)
call SaveItemAgent(H2I(t),2,it)
call TimerStart(t,0,false,function SplitItemAction)
set t = null
elseif GetSpellAbilityId() == 'A00P' then
set u = GetTriggerUnit()
set p = GetOwningPlayer(u)
call DisplayTextToPlayer( p, 0, 0, "|cFFFF0000该物品不可重铸!|r" )
set t = CreateTimer()
call SaveItemAgent(H2I(t),1,u)
call TimerStart(t,0,false,function SplitItemAction2)
endif
set t = null
set p = null
set it = null
set u = null
return false
endfunction
function mixitemaction takes nothing returns nothing
local timer t = GetExpiredTimer()
call UnitAddItem(GetItemUnit(H2I(t),0),GetItemItem(H2I(t),1))
call FlushItemMission(H2I(t))
call PauseTimer(t)
call DestroyTimer(t)
set t = null
endfunction
[/jass] |
|