|
chunge.lua--道具LUA
- function chunge(itemindex, charaindex, toindex, haveitemindex)
- local data1=item.getChar(itemindex,"字段")
- local isopen=other.atoi(other.getString(data1, "|", 1))
- local rehp=other.atoi(other.getString(data1, "|", 2))
- if isopen==0 then
- char.TalkToCli(charaindex, -1, "自动恢复HP开启" , "青色")
- item.setChar(itemindex,"字段","1|"..rehp)
- else
- char.TalkToCli(charaindex, -1, "自动恢复HP关闭" , "青色")
- item.setChar(itemindex,"字段","0|"..rehp)
- end
- end
- function main()
- item.addLUAListFunction( "ITEM_CG", "chunge", "")
- end
battlefinishfunction.lua --战斗结束LUA
- function BattleFinishFunction( charaindex, battletime, battleturn, battletype )
- local itemindex=checkItem(charaindex,30732)
- if itemindex>-1 then
- local data1=item.getChar(itemindex,"字段")
- local isopen=other.atoi(other.getString(data1, "|", 1))
- local rehp=other.atoi(other.getString(data1, "|", 2))
- if rehp<=0 then
- char.DelItem(charaindex,getPos(charaindex,itemindex))
- char.TalkToCli(charaindex, -1, "药剂储存HP消耗完毕,删除" , "青色")
- end
- if isopen>0 then
- local hp=char.getWorkInt(charaindex,"最大HP")
- local nowhp=char.getInt(charaindex,"HP")
- local yu=hp-nowhp
- if yu~= 0 then
- if rehp<yu then
- char.setInt(charaindex,"HP",rehp)
- item.setChar(itemindex,"字段","1|0")
- else
- rehp=rehp-yu
- char.setInt(charaindex,"HP",hp)
- item.setChar(itemindex,"字段","1|"..rehp)
- end
- char.Updata(charaindex,"HP")
- end
- end
- end
- end
- function checkItem(charaindex,itemid)
- for i=9,23 do
- local itemindex=char.getItemIndex(charaindex,i)
- if itemindex>-1 then
- if item.getInt(itemindex,0)== itemid then
- return itemindex
- end
- end
- end
- return -1
- end
- function getPos(charaindex,itemindex)
- for i=9,23 do
- local itemindex1=char.getItemIndex(charaindex,i)
- if itemindex>-1 then
- if itemindex1== itemindex then
- return i
- end
- end
- end
- return -1
- end
|
|