作者gyd (gyd style)
看板WarCraft
标题[WE] 物品合成触发,Jass+Gui
时间Fri May 4 13:53:52 2007
这个构想是hobill先想到,他用的方式是jass
但他的做法需要自己取得填进去item type
临时找不到他,所以我整个jass是直接重写,无法跟他的比较
用法很简单,把Jass整个贴到触发器初始区
然後直接在合成的部分设定如下
(也就是说,使用者只需要贴上Jass,然後利用gui介面就可以使用)
如:古尔+古尔=罗
set ItemStuff[0]=罗
set ItemStuff[1]=古尔
set ItemStuff[2]=古尔
Custom script:call DoItemCompose()
重复的物品只需要重复设一次即可,当然event是unit 得到物品
利用到的变数只有一个
ItemStuff[5] as Type of Item
如果合成配方可能会超过5个,自己修改Jass中所有5这个数字及ItemStuff的容量
最後,因为其中一些东西是我的地图专用变数,所以我贴上来有作修改
可能会有没删乾净或修改完整导致有bug,请加分说一下我再改
使用前在地图中提到是ItemCompose Jass Powered by gyd会更感激
=======================================================================
Jass部分,断行部分请自行组合
稍微解说流程
判断得到的道具是不是合成表内容 -X> 清空ItemStuff内容(a)
↓
逐一拿出ItemStuff(loop)→如果ItemStuff不是no item type -X> 合成,do a
↓
计算该合成原料数量
↓
计算该合成原料拥有量
↓
拥有量超过需要量 -X> 合成条件不足,离开,do a
↓
继续做下一个原料
//道具合成函式:DoItemCompose()
function ClearItemsArray takes nothing returns nothing
//每次合成结束就清空一次原料阵列,这个function总共被呼叫三次,包括合成失败
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 5
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_ItemStuff[GetForLoopIndexA()] = GetItemTypeId(null)
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
function ItemManipulatedCheck takes nothing returns boolean
if ( GetItemTypeId(GetManipulatedItem()) == udg_ItemStuff[1] ) then
return true
endif
if ( GetItemTypeId(GetManipulatedItem()) == udg_ItemStuff[2] ) then
return true
endif
if ( GetItemTypeId(GetManipulatedItem()) == udg_ItemStuff[3] ) then
return true
endif
if ( GetItemTypeId(GetManipulatedItem()) == udg_ItemStuff[4] ) then
return true
endif
if ( GetItemTypeId(GetManipulatedItem()) == udg_ItemStuff[5] ) then
return true
endif
return false
endfunction
function DoItemCompose takes nothing returns nothing
// 针对每个原料
if ( not ItemManipulatedCheck() ) then
call ClearItemsArray()
return
else
endif
set bj_forLoopBIndex = 1
set bj_forLoopBIndexEnd = 5
local integer tempInt = 0
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
// 如果是no-item就离开回圈
exitwhen udg_ItemStuff[GetForLoopIndexB()] == GetItemTypeId(null)
set tempInt = 0
// 计算需要量
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 5
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( udg_ItemStuff[GetForLoopIndexA()] == udg_ItemStuff[GetForLoopIndexB()] ) then
set tempInt = ( tempInt + 1 )
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
// 计算拥有量
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 6
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
if ( GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), GetForLoopIndexA())) == udg_ItemStuff[GetForLoopIndexB()]) then
set tempInt = ( tempInt - 1 )
else
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
// 如果任何一个条件失败就结束
if ( tempInt > 0 ) then
// 结束前清空原料的阵列
call ClearItemsArray()
return
else
endif
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 5
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call RemoveItem( GetItemOfTypeFromUnitBJ(GetTriggerUnit(), udg_ItemStuff[GetForLoopIndexA()]) )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call UnitAddItemByIdSwapped( udg_ItemStuff[0], GetTriggerUnit() )
call AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), "Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl" )
call DestroyEffectBJ( GetLastCreatedEffectBJ() )
// 结束前清空原料的阵列
call ClearItemsArray()
endfunction
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.223.204.171
1F:推 Kendai:推 05/04 13:55
2F:推 Ricrollp:看不懂......>< 05/04 13:56
3F:→ gyd:简单说就是,把jass放进去,你只需要控制gui就可以合成 05/04 13:58
4F:→ gyd:物品的check(包括数量),remove,create都自动做好 05/04 14:00
5F:推 jhunfong:原po有玩暗黑吗...Lo Gul 05/04 14:01
6F:→ slycsboy:HOBILL的也跟他讨论过XD 这个系统整个简化 超赞 05/04 14:02
7F:推 cycu0315:推 05/04 14:02
8F:推 SvcChaos:push 05/04 15:01
9F:推 BlueLex:推 05/04 15:13
10F:→ blackjack0s:想推不能推... 05/04 17:03
11F:推 wix3000:推 我的地图有用类似的了,用触发直接写会lag 05/04 23:42
12F:推 wu2183:推 05/06 23:10
※ 编辑: gyd 来自: 218.171.58.70 (05/07 08:46)