找回密码
 点一下
查看: 2945|回复: 9

星际争霸Protoss的护盾系统模拟

[复制链接]
发表于 2006-8-21 11:26:50 | 显示全部楼层 |阅读模式
模拟星际争霸Protoss的护盾系统,
设置单位Point Value(传说被翻译为附带经验值的DD)即可设置护盾最大值,默认值为100
初始化触发中可修改EnRejSpeed,设置护盾回复速度,
EN能量条仅对选取单位的玩家显示,如图所示,
当然玩家1选取单位的能量条是不会对玩家2显示的
多人游戏测试过,没有问题。

EN护盾系统.w3x

23 KB, 下载次数: 141

发表于 2006-8-28 11:30:12 | 显示全部楼层

呵呵!!!

能把代码贴出来吗?~
回复

使用道具 举报

DeadFish 该用户已被删除
发表于 2006-8-29 20:23:46 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 发表于 2006-8-31 15:28:10 | 显示全部楼层
用T做的话肯定都是Custom Script了,感觉和J也没什么区别了
回复

使用道具 举报

发表于 2006-9-1 17:28:49 | 显示全部楼层

.............

网吧里面没有WE,家里的网络出了点问题  把代码贴上来好不?
回复

使用道具 举报

xingcan 该用户已被删除
发表于 2006-9-1 21:10:04 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| 发表于 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 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2006-9-1 21:48:40 | 显示全部楼层
原帖由 xingcan 于 2006-9-1 21:10 发表
怎样吧J放在T里面,就像ShowEn那样子,那个T里面没有事件,条件,动作,只有JASS


菜单 - 编辑 - 转化为自定义代码
回复

使用道具 举报

发表于 2006-9-5 12:32:06 | 显示全部楼层

这个 ~

或许这个东西的局限性太大了
回复

使用道具 举报

发表于 2006-12-26 18:44:03 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-4-28 19:55 , Processed in 0.054852 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表