java吧 关注:1,288,100贴子:12,813,890
  • 0回复贴,共1
GetPlayer():ListenForEvent("attacked", function(inst)
local rand=math.random(6)
if rand == 1 then
if GetPlayer().components.talker then
GetPlayer().components.talker:Say"I'm bleeding!"
end
GetPlayer().isbleeding = true
GetPlayer().isbleedingnotified = true
end
end
end)
GetPlayer():DoPeriodicTask(1, function(inst)
if GetPlayer().isbleeding == true and GetPlayer().components.health and GetPlayer().components.sanity then
GetPlayer().components.health:DoDelta(-2)
GetPlayer().components.sanity:DoDelta(-1)
else
GetPlayer().isbleeding = false
GetPlayer().isbleedingnotified = false
end
end)
GetPlayer():DoPeriodicTask(5, function(inst)
if GetPlayer().isbleeding == true and GetPlayer().isbleedingnotified == false and GetPlayer().components.talker then
GetPlayer().components.talker:Say"I'm still bleeding!\nI need to heal!"
else
GetPlayer().isbleedingnotified = false
end
end)
end)
自己想加个先行条件, if health <= .7 then,这么加啊,总是弹出错误,表示自己什么都不会


IP属地:河南1楼2015-09-22 00:41回复