|
其实就是每次英雄受到伤害时,记录伤害来源
助攻系统.w3x
(24 KB, 下载次数: 213)
[codes=jass]
globals
gamecache udg_GC
string array udg_Name
timer udg_GameTimer
integer udg_DamageIndex
real array udg_DamageTime
integer array udg_DamageSource
integer array udg_Damaged
constant real udg_SATime = 10.00
trigger gg_trg_DamgedEvent
trigger gg_trg_Init
endglobals
function H2I takes handle h returns integer
return h
return 0
endfunction
function H2S takes handle h returns string
return I2S(H2I(h))
endfunction
function GetBoolean takes string pTable,string pKey returns boolean
return GetStoredBoolean(udg_GC,pTable,pKey)
endfunction
function SetBoolean takes string pTable,string pKey,boolean pData returns nothing
call StoreBoolean(udg_GC,pTable,pKey,pData)
endfunction
function FastFlush takes string pTable returns nothing
call FlushStoredMission(udg_GC,pTable)
endfunction
function GetName takes integer i returns string
return udg_Name
endfunction
function GetGameTime takes nothing returns real
return TimerGetElapsed(udg_GameTimer)
endfunction
function IsPlayerA takes integer p returns boolean
return (0 <= p and p <= 5)
endfunction
function IsPlayerB takes integer p returns boolean
return (6 <= p and p <= 11)
endfunction
function GetPlayerAB takes integer i, integer ab returns integer
return (ab * 6 + i)
endfunction
function InitTrig_Init takes nothing returns nothing
local integer i = 0
call FogEnable(false)
call FogMaskEnable(false)
call MeleeStartingAI()
set udg_GameTimer = CreateTimer()
set udg_GC = InitGameCache( "Jass.w3v" )
set udg_Name[0]="|c00ff0000"+GetPlayerName(Player(0))+"|r"
set udg_Name[1]="|c000042ff"+GetPlayerName(Player(1))+"|r"
set udg_Name[2]="|c001ce6b9"+GetPlayerName(Player(2))+"|r"
set udg_Name[3]="|c00540081"+GetPlayerName(Player(3))+"|r"
set udg_Name[4]="|c00fffc00"+GetPlayerName(Player(4))+"|r"
set udg_Name[5]="|c00ff8000"+GetPlayerName(Player(5))+"|r"
set udg_Name[6]="|c0020c000"+GetPlayerName(Player(6))+"|r"
set udg_Name[7]="|c00e55bb0"+GetPlayerName(Player(7))+"|r"
set udg_Name[8]="|c00959697"+GetPlayerName(Player(8))+"|r"
set udg_Name[9]="|c007ebff0"+GetPlayerName(Player(9))+"|r"
set udg_Name[10]="|c00106246"+GetPlayerName(Player(10))+"|r"
set udg_Name[11]="|c004e2a04"+GetPlayerName(Player(11))+"|r"
set udg_DamageIndex = 1
//游戏开始
call TimerStart(udg_GameTimer,99999.00,false,null)
endfunction
function DamagedList takes nothing returns nothing
set udg_DamageTime[udg_DamageIndex] = GetGameTime()
set udg_DamageSource[udg_DamageIndex] = GetPlayerId(GetOwningPlayer(GetEventDamageSource()))
set udg_Damaged[udg_DamageIndex] = GetPlayerId(GetOwningPlayer(GetTriggerUnit()))
//call BJDebugMsg(I2S(udg_DamageIndex)+":["+I2S(R2I(udg_DamageTime[udg_DamageIndex]))+"] "+I2S(udg_DamageSource[udg_DamageIndex])+" attack "+I2S(udg_Damaged[udg_DamageIndex]))
set udg_DamageIndex = udg_DamageIndex + 1
if udg_DamageIndex == 8000 then
set udg_DamageIndex = 1
endif
endfunction
function DamageRun takes nothing returns boolean
call ExecuteFunc("DamagedList")
return false
endfunction
function DamageRegister takes unit u returns nothing
local trigger t = CreateTrigger()
call SetBoolean(H2S(u), "DamageRegisterAlready", true)
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_DAMAGED)
call TriggerAddCondition(t,Condition(function DamageRun))
set t=null
endfunction
function DamageRegisterCheck takes nothing returns boolean
local unit u = GetTriggerUnit()
if IsUnitType(u, UNIT_TYPE_HERO)==true and IsUnitIllusion(u)==false then
if GetBoolean(H2S(u), "DamageRegisterAlready")== false then
call DamageRegister(u)
endif
endif
return false
endfunction
function DamageRegisterCheck_Filter takes nothing returns boolean
local unit u = GetFilterUnit()
if IsUnitType(u, UNIT_TYPE_HERO)==true and IsUnitIllusion(u)==false then
if GetBoolean(H2S(u), "DamageRegisterAlready")== false then
call DamageRegister(u)
endif
endif
return false
endfunction
function InitTrig_DamgedEvent takes nothing returns nothing
local region rectRegion = CreateRegion()
local group g = CreateGroup()
local boolexpr filter = Condition(function DamageRegisterCheck_Filter)
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, filter)
call DestroyBoolExpr(filter)
call DestroyGroup(g)
set g = null
set filter = null
set gg_trg_DamgedEvent = CreateTrigger()
call RegionAddRect(rectRegion, bj_mapInitialPlayableArea)
call TriggerRegisterEnterRegion(gg_trg_DamgedEvent, rectRegion, null)
call TriggerAddCondition(gg_trg_DamgedEvent,Condition(function DamageRegisterCheck))
endfunction
function IsKiller takes integer killer,integer dead returns boolean
local integer i = udg_DamageIndex - 1
local real t = 0.00
local real time = GetGameTime()
loop
set t = time - udg_DamageTime
exitwhen t > udg_SATime or i == udg_DamageIndex
if udg_DamageSource == killer and udg_Damaged == dead then
set udg_DamageSource = -1
set udg_Damaged = -1
return true
endif
set i = i - 1
if i==0 then
set i = 8000-1
endif
endloop
return false
endfunction
function GetSAString takes unit dying,unit killing returns string
local integer d = GetPlayerId(GetOwningPlayer(dying))
local integer k = GetPlayerId(GetOwningPlayer(killing))
local integer j
local string s = " 助攻: "
local boolean bool = false
local integer i = 0
loop
if IsPlayerA(k) then
set j = GetPlayerAB(i, 0)
else
set j = GetPlayerAB(i, 1)
endif
if k != j and IsKiller(j, d) then
if bool then
set s = s + "/" + GetName(j)
else
set s = s + GetName(j)
endif
set bool = true
endif
set i = i + 1
exitwhen i >= 6
endloop
if bool then
return s
endif
return " "
endfunction
function GetKillString takes unit dying, unit killing returns string
local integer d = GetPlayerId(GetOwningPlayer(dying))
local integer k = GetPlayerId(GetOwningPlayer(killing))
if killing == null then
set k = d
endif
if IsPlayerA(d) then
if IsPlayerA(k)then
if (k == d) then
return GetName(d) + " 刚刚自杀了!"
else
return GetName(d) + " 刚刚被他的队友 " + GetName(k) + " 杀死了!"
endif
elseif IsPlayerB(k) then
return GetName(k) + " 刚刚杀死了 " + GetName(d) + GetSAString(dying, killing)
endif
elseif IsPlayerB(d) then
if IsPlayerB(k)then
if(k == d)then
return GetName(d) + " 刚刚自杀了!"
else
return GetName(d) + " 刚刚被他的队友 " + GetName(k) + " 杀死了!"
endif
elseif IsPlayerA(k) then
return GetName(k) + " 刚刚杀死了 " + GetName(d) + GetSAString(dying, killing)
endif
endif
return GetName(d) + " 刚刚被中立生物杀死了。"
endfunction
[/codes] |
评分
-
查看全部评分
|