|
发表于 2007-4-8 22:01:35
|
显示全部楼层
最终决定删除这个帖子~~因为似乎已经对论坛的程序造成奇怪的影响~~
内容复制如下~~
伤害显示系统V2.0
高效、环保的全局伤害显示系统
可随时为单位绑定或移除伤害显示
可为任意玩家设置是否显示伤害
演示中附有使用说明
主函数如下:
jass: Copy code
function ShowDamage_Func takes nothing returns boolean
local texttag tt
if GetEventDamage() > 0 then
set tt = CreateTextTag()
if udg_DamShowOn[GetPlayerId(GetLocalPlayer())] then
call SetTextTagText(tt, I2S(R2I(GetEventDamage()))+"!", 0.023)
call SetTextTagPos(tt, GetUnitX(GetTriggerUnit()),GetUnitY(GetTriggerUnit()),50)
call SetTextTagColor(tt, 255, 202, 149, 255)
call SetTextTagVelocity(tt, 0, TextTagSpeed2Velocity(50))
call SetTextTagFadepoint(tt, 0.2)
endif
call SetTextTagPermanent(tt, false)
call SetTextTagLifespan(tt, 1)
endif
set tt = null
return false
endfunction
function ShowDamage takes unit u, boolean showOn returns nothing
local trigger t
local triggercondition c
local integer i
if showOn then
if not HaveStoredInteger(udg_GC,I2S(h2i(u)),"DamShowTrigger") then
set t = CreateTrigger()
set c = TriggerAddCondition(t, Condition(function ShowDamage_Func))
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_DAMAGED)
call StoreInteger(udg_GC,I2S(h2i(u)),"DamShowTrigger",h2i(t))
call StoreInteger(udg_GC,I2S(h2i(t)),"TriggerCondition",h2i(c))
endif
if udg_DamShow_alwaysOn then
if HaveStoredInteger(udg_GC,I2S(h2i(u)),"DamShowNum") then
set i = GetStoredInteger(udg_GC,I2S(h2i(u)),"DamShowNum")
call FlushStoredInteger(udg_GC,I2S(h2i(u)),"DamShowNum")
set udg_DamShow_GroupCount = udg_DamShow_GroupCount-1
set udg_DamShow_GroupUnit = udg_DamShow_GroupUnit[udg_DamShow_GroupCount]
call StoreInteger(udg_GC,I2S(h2i(udg_DamShow_GroupUnit)),"DamShowNum",i)
endif
set udg_DamShow_alwaysOn = false
else
if not HaveStoredInteger(udg_GC,I2S(h2i(u)),"DamShowNum") then
set udg_DamShow_GroupUnit[udg_DamShow_GroupCount] = u
call StoreInteger(udg_GC,I2S(h2i(u)),"DamShowNum",udg_DamShow_GroupCount)
set udg_DamShow_GroupCount = udg_DamShow_GroupCount+1
endif
endif
else
set t = i2tg(GetStoredInteger(udg_GC,I2S(h2i(u)),"DamShowTrigger"))
set c = i2tc(GetStoredInteger(udg_GC,I2S(h2i(t)),"TriggerCondition"))
set i = GetStoredInteger(udg_GC,I2S(h2i(u)),"DamShowNum")
set udg_DamShow_GroupCount = udg_DamShow_GroupCount-1
set udg_DamShow_GroupUnit = udg_DamShow_GroupUnit[udg_DamShow_GroupCount]
call StoreInteger(udg_GC,I2S(h2i(udg_DamShow_GroupUnit)),"DamShowNum",i)
call FlushStoredInteger(udg_GC,I2S(h2i(u)),"DamShowNum")
call FlushStoredInteger(udg_GC,I2S(h2i(u)),"DamShowTrigger")
call FlushStoredMission(udg_GC,I2S(h2i(t)))
call TriggerRemoveCondition(t,c)
call DestroyTrigger(t)
endif
set t = null
set c = null
endfunction
function DamShow_TimerFunc takes nothing returns nothing
local integer i=0
loop
exitwhen i >= udg_DamShow_GroupCount
if GetUnitState(udg_DamShow_GroupUnit, UNIT_STATE_MAX_LIFE) <= 0 then
call ShowDamage(GetEnumUnit(), false)
endif
set i=i+1
endloop
endfunction
function InitDamShow takes nothing returns nothing
call TimerStart(CreateTimer(),60.0,true,function DamShow_TimerFunc)
endfunction |
|