|
楼主 |
发表于 2006-9-1 21:44:11
|
显示全部楼层
//***************************************************************************
//*
//* Custom Script Code
//*
//***************************************************************************
[jass]function h2i takes handle h returns integer
return h
return 0
endfunction
function i2u takes integer i returns unit
return i
return null
endfunction
function i2tt takes integer i returns texttag
return i
return null
endfunction[/jass]
这里是护盾的实现部分
[jass]function EnShieldFunc3 takes nothing returns nothing
local unit u = i2u(GetStoredInteger(udg_GC,I2S(h2i(GetExpiredTimer())),\"ES_FuncUnit\"))
if GetUnitAbilityLevel(u,\'A000\')>0 then
call UnitRemoveAbility(u,\'A000\')
endif
call SetUnitState(u, UNIT_STATE_LIFE, GetStoredReal(udg_GC,I2S(h2i(u)),\"ES_LifeEdit\"))
call FlushStoredInteger(udg_GC,I2S(h2i(GetExpiredTimer())),\"ES_FuncUnit\")
call DestroyTimer(GetExpiredTimer())
set u = null
endfunction
function EnShieldFunc2 takes nothing returns nothing
local timer tm = CreateTimer()
call StoreInteger(udg_GC,I2S(h2i(tm)),\"ES_FuncUnit\",h2i(GetTriggerUnit()))
call TimerStart(tm,0,false,function EnShieldFunc3)
set tm = null
endfunction
function EnShieldFunc takes nothing returns boolean
local real En = GetStoredReal(udg_GC,I2S(h2i(GetTriggerUnit())),\"En\")
local real dr = RMinBJ(En,GetEventDamage())
local real Hp = GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE)
local real MaxHp = GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_LIFE)
call StoreReal(udg_GC,I2S(h2i(GetTriggerUnit())),\"En\",En-dr)
call StoreReal(udg_GC,I2S(h2i(GetTriggerUnit())),\"ES_LifeEdit\",Hp+dr-GetEventDamage())
if GetEventDamage() < Hp+En and (GetEventDamage()>=MaxHp or Hp+dr>MaxHp) then
if GetEventDamage()>=MaxHp then
call UnitAddAbility(GetTriggerUnit(),\'A000\')//A000 是增加单位生命最大值的技能
call SetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE, GetEventDamage()+1)
endif
call EnShieldFunc2()
else
call SetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE, Hp+dr)
endif
return false
endfunction
function SetEnShield takes nothing returns nothing
local unit u = udg_TempUnit
local trigger t=CreateTrigger()
local triggercondition c = TriggerAddCondition(t, Condition(function EnShieldFunc))
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_DAMAGED)
call StoreReal(udg_GC,I2S(h2i(u)),\"En\",GetUnitPointValue(u))
loop
exitwhen GetUnitState(u, UNIT_STATE_MAX_LIFE) <= 0
call TriggerSleepAction(60)
endloop
call FlushStoredReal(udg_GC,I2S(h2i(u)),\"En\")
call FlushStoredReal(udg_GC,I2S(h2i(u)),\"ES_LifeEdit\")
call TriggerRemoveCondition(t,c)
call DestroyTrigger(t)
set t = null
set c = null
set u = null
endfunction
function AddEnShield takes unit u returns nothing
set udg_TempUnit = u
if GetUnitPointValue(u) > 0 then
call GroupAddUnit(udg_ES_UnitGroup, u)
call ExecuteFunc(\"SetEnShield\")
endif
endfunction[/jass]
//***************************************************************************
//*
//* Triggers
//*
//***************************************************************************
//===========================================================================
// Trigger: Init
//===========================================================================
[jass]function Trig_Init_Func006001002 takes nothing returns boolean
return ( GetUnitPointValue(GetFilterUnit()) > 0 )
endfunction
function Trig_Init_Func006A takes nothing returns nothing
call AddEnShield(GetEnumUnit())
endfunction
function Trig_Init_Func007Func002Func001001 takes nothing returns boolean
return ( GetForLoopIndexA() >= GetForLoopIndexB() )
endfunction
function Trig_Init_Actions takes nothing returns nothing
call InitGameCacheBJ( \"MapName.w3v\" )
set udg_GC = GetLastCreatedGameCacheBJ()
set udg_EnRejSpeed = 1.00
set bj_wantDestroyGroup=true
call ForGroupBJ( GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Init_Func006001002)), function Trig_Init_Func006A )
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set udg_EnBar[GetForLoopIndexA()] = \"\"
set bj_forLoopBIndex = 1
set bj_forLoopBIndexEnd = 10
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
if ( Trig_Init_Func007Func002Func001001() ) then
set udg_EnBar[GetForLoopIndexA()] = ( udg_EnBar[GetForLoopIndexA()] + \"■\" )
else
set udg_EnBar[GetForLoopIndexA()] = ( udg_EnBar[GetForLoopIndexA()] + \"□\" )
endif
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction[/jass]
//===========================================================================
// Trigger: SetEnShield
//===========================================================================
[jass]function Trig_SetEnShield_Conditions takes nothing returns boolean
if ( not ( GetUnitPointValue(GetTriggerUnit()) != 0 ) ) then
return false
endif
return true
endfunction
function Trig_SetEnShield_Actions takes nothing returns nothing
call AddEnShield(GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_SetEnShield takes nothing returns nothing
set gg_trg_SetEnShield = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_SetEnShield, GetPlayableMapRect() )
call TriggerAddCondition( gg_trg_SetEnShield, Condition( function Trig_SetEnShield_Conditions ) )
call TriggerAddAction( gg_trg_SetEnShield, function Trig_SetEnShield_Actions )
endfunction[/jass]
//===========================================================================
// Trigger: EnRej
//===========================================================================
护盾的回复
[jass]function EnRejFunc2 takes nothing returns nothing
local real En = GetStoredReal(udg_GC,I2S(h2i(GetEnumUnit())),\"En\")
local real MaxEn = GetUnitPointValue(GetEnumUnit())
if GetUnitState(GetEnumUnit(), UNIT_STATE_LIFE)>0 and En<MaxEn then
call StoreReal(udg_GC, I2S(h2i(GetEnumUnit())), \"En\", RMinBJ(En + udg_EnRejSpeed,MaxEn))
endif
endfunction
function EnRejFunc takes nothing returns nothing
call ForGroup(udg_ES_UnitGroup, function EnRejFunc2)
endfunction
function Trig_EnRej_Actions takes nothing returns nothing
call TimerStart(udg_TimerForEnRej, 1, true, function EnRejFunc)
endfunction
function InitTrig_EnRej takes nothing returns nothing
set gg_trg_EnRej = CreateTrigger()
call TriggerAddAction(gg_trg_EnRej, function Trig_EnRej_Actions)
endfunction[/jass]
//===========================================================================
// Trigger: ShowEn
//===========================================================================
对选取单位的玩家显示该单位的能量条
[jass]function ShowEn_Func2 takes nothing returns nothing
local real En = GetStoredReal(udg_GC,I2S(h2i(GetTriggerUnit())),\"En\")
local real MaxEn = GetUnitPointValue(GetTriggerUnit())
local integer p = R2I(10*En/MaxEn + 0.5)
local texttag tt = CreateTextTag()
call GroupAddUnit(udg_PlayerSelectGroup, GetTriggerUnit())
call StoreInteger(udg_GC,I2S(h2i(GetTriggerUnit())),\"EnBar\",h2i(tt))
call SetTextTagText(tt, udg_EnBar[p], 0.008)
call SetTextTagPosUnit(tt, GetTriggerUnit(), 0)
call SetTextTagColor(tt, 107, 202, 249, 255)
set tt = null
endfunction
function ShowEn_Func takes nothing returns boolean
if GetUnitPointValue(GetTriggerUnit()) > 0 and IsUnitInGroup(GetTriggerUnit(), udg_PlayerSelectGroup) == false and GetLocalPlayer() == GetTriggerPlayer() then
call ShowEn_Func2()
endif
return false
endfunction
function InitTrig_ShowEn takes nothing returns nothing
local integer i = 0
set gg_trg_ShowEn = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_ShowEn, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
set i = i+1
exitwhen i>11
endloop
call TriggerAddCondition(gg_trg_ShowEn, Condition(function ShowEn_Func))
endfunction[/jass]
//===========================================================================
// Trigger: ShowEnTimer
//===========================================================================
能量条的显示更新
[jass]function EnBarShowFunc2 takes nothing returns nothing
local real En = GetStoredReal(udg_GC,I2S(h2i(GetEnumUnit())),\"En\")
local real MaxEn = GetUnitPointValue(GetEnumUnit())
local integer p = R2I(10*En/MaxEn + 0.5)
local texttag tt = i2tt(GetStoredInteger(udg_GC,I2S(h2i(GetEnumUnit())),\"EnBar\"))
call SetTextTagText(tt, udg_EnBar[p], 0.008)
call SetTextTagPosUnit(tt, GetEnumUnit(), 0)
set tt = null
endfunction
function EnBarShowFunc takes nothing returns nothing
if IsUnitSelected(GetEnumUnit(),GetLocalPlayer()) then
call EnBarShowFunc2()
else
call GroupRemoveUnit(udg_PlayerSelectGroup, GetEnumUnit())
call DestroyTextTag(i2tt(GetStoredInteger(udg_GC,I2S(h2i(GetEnumUnit())),\"EnBar\")))
endif
endfunction
function EnBarShow takes nothing returns nothing
call ForGroup(udg_PlayerSelectGroup, function EnBarShowFunc)
endfunction
function Trig_ShowEnTimer_Actions takes nothing returns nothing
call TimerStart(udg_TimerForEnBar, 0.01, true, function EnBarShow)
endfunction
function InitTrig_ShowEnTimer takes nothing returns nothing
set gg_trg_ShowEnTimer = CreateTrigger()
call TriggerAddAction(gg_trg_ShowEnTimer, function Trig_ShowEnTimer_Actions)
endfunction[/jass]
我也没WE...
JassShop上截的
[ 本帖最后由 Red_Wolf 于 2006-9-1 21:46 编辑 ] |
|