找回密码
 点一下
查看: 2153|回复: 28

求助JASS的修改

[复制链接]
发表于 2008-8-4 14:25:40 | 显示全部楼层 |阅读模式
求助又来了
请各位高手帮忙改改这个J
[jass]
function Trig_Select_PoFa_______u_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'e008' ) ) then
        return false
    endif
    return true
endfunction
function Trig_Select_PoFa_______u_Func001C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return false
function Trig_Select_PoFa_______u_Func002C takes nothing returns boolean   
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(5) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(6) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(7) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(8) ) ) then
        return false
    endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(9) ) ) then
        return false
    endif
    return true
endfunction
function Trig_Select_PoFa_______u_Actions takes nothing returns nothing
    if ( Trig_Select_PoFa_______u_Func001C() ) then
        call CreateNUnitsAtLoc( 1, 'H003', GetOwningPlayer(GetTriggerUnit()), GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu), bj_UNIT_FACING )
        call RemoveUnit( gg_unit_H003_0002 )
        call TriggerExecute( gg_trg_setup_Hero )
        call DisableTrigger( GetTriggeringTrigger() )
    endif ( Trig_Select_PoFa_______u_Func002C() ) then
        call CreateNUnitsAtLoc( 1, 'H003', GetOwningPlayer(GetTriggerUnit()), GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu), bj_UNIT_FACING )
        call RemoveUnit( gg_unit_H003_0002 )
        call TriggerExecute( gg_trg_setup_Hero )
        call DisableTrigger( GetTriggeringTrigger() )
    else
endfunction
//===========================================================================
function InitTrig_Select_PoFa_______u takes nothing returns nothing
    set gg_trg_Select_PoFa_______u = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Select_PoFa_______u, gg_rct_PoFa )
    call TriggerAddCondition( gg_trg_Select_PoFa_______u, Condition( function Trig_Select_PoFa_______u_Conditions ) )
    call TriggerAddAction( gg_trg_Select_PoFa_______u, function Trig_Select_PoFa_______u_Actions )
endfunction
[/jass]
 楼主| 发表于 2008-8-4 14:26:33 | 显示全部楼层
还有这个 复活后 计时器删不了
[jass]
function Trig_hero_1_dies_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction

function B takes nothing returns nothing
    local timer T = GetExpiredTimer()
    local timerdialog TG =I2TG(GetStoredInteger(udg_cache,I2S(H2I(T)),"TG"))
    local unit U = I2U(GetStoredInteger(udg_cache,I2S(H2I(T)),"Unit"))
    local player P =GetOwningPlayer(U)
    call FlushStoredMission(udg_cache,I2S(H2I(T)))
    call DestroyTimer( T )
    if (P == Player(0) or P == Player(1) or P == Player(2) or P == Player(3) or P == Player(4))then
        call ReviveHero( U, -2537.5, -3044.7, true )//队伍1复活坐标
    endif
    if (P == Player(5) or P == Player(6) or P == Player(7) or P == Player(8) or P == Player(9))then
        call ReviveHero( U, 4471.3, 2320.1, true )//队伍2复活坐标
    endif
    if (GetLocalPlayer()==P)then
        call PanCameraTo(0,0)
    endif
    set U =null
    set T =null
    set TG =null
endfunction

function Trig_hero_1_dies_Actions takes nothing returns nothing
    local timer T =CreateTimer()
    local timerdialog TG = CreateTimerDialog(T)
    call StoreInteger(udg_cache,I2S(H2I(T)),"Unit",H2I(GetTriggerUnit()))
    call StoreInteger(udg_cache,I2S(H2I(T)),"TG",H2I(TG))
    call TimerStart(T,3+2*GetHeroLevel(GetTriggerUnit()),false,function B)//其中3+2*GetHeroLevel为复活时间
    set T =null
    call TimerDialogSetTitle(TG,"复活等待时间")
    if (GetLocalPlayer()==GetOwningPlayer(GetTriggerUnit()))then
        call TimerDialogDisplay(TG,true)
    endif
    set TG =null
endfunction

//===========================================================================
function InitTrig_hero_1_dies takes nothing returns nothing
    set gg_trg_hero_1_dies = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_hero_1_dies, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_hero_1_dies, Condition( function Trig_hero_1_dies_Conditions ) )
    call TriggerAddAction( gg_trg_hero_1_dies, function Trig_hero_1_dies_Actions )
endfunction
[/jass]
回复

使用道具 举报

发表于 2008-8-4 14:30:26 | 显示全部楼层
类T的J看得好累啊
回复

使用道具 举报

发表于 2008-8-4 14:34:19 | 显示全部楼层
endif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
LZ你把我吓到了……………………
回复

使用道具 举报

 楼主| 发表于 2008-8-4 14:34:51 | 显示全部楼层
恩 所以才想化简啊
要不然又累又大
我的知识有限 只改了一点
回复

使用道具 举报

发表于 2008-8-4 14:37:41 | 显示全部楼层
先写T在转为J,我认为不是一个好的习惯,写T和J时思考方式是完全不同的,培养自己Jass的思考方式,扔掉T的思想,才能写出好的程序。


英雄复活那里,计时器貌似你都没删,而不是删不了?
回复

使用道具 举报

发表于 2008-8-4 14:39:14 | 显示全部楼层
第二个:
[codes=jass]
function B takes nothing returns nothing
    local timer T = GetExpiredTimer()
    local timerdialog TG =I2TG(GetStoredInteger(udg_cache,I2S(H2I(T)),"TG"))
    local unit U = I2U(GetStoredInteger(udg_cache,I2S(H2I(T)),"Unit"))
    local player P =GetOwningPlayer(U)
    call FlushStoredMission(udg_cache,I2S(H2I(T)))
//加了下面那句
  call DestroyTimerDialog(TG)
//加了上面那句
    call DestroyTimer( T )
    if (P == Player(0) or P == Player(1) or P == Player(2) or P == Player(3) or P == Player(4))then
        call ReviveHero( U, -2537.5, -3044.7, true )//队伍1复活坐标
    endif
    if (P == Player(5) or P == Player(6) or P == Player(7) or P == Player(8) or P == Player(9))then
        call ReviveHero( U, 4471.3, 2320.1, true )//队伍2复活坐标
    endif
    if (GetLocalPlayer()==P)then
        call PanCameraTo(0,0)
    endif
    set U =null
    set T =null
    set TG =null
endfunction
[/codes]
第二个这样改应该没错了。
回复

使用道具 举报

发表于 2008-8-4 14:47:05 | 显示全部楼层
第一个………………
有问题吗?
(除了endif XXXXXX以外貌似是没什么错误了)
不过你的第一个还有些内存泄露,给你改:
[codes=jass]function Trig_Select_PoFa_______u_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'e008' ) ) then
        return false
    endif
    return true
endfunction
function Trig_Select_PoFa_______u_Func001C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return false
    endif
    return true
function Trig_Select_PoFa_______u_Func002C takes nothing returns boolean   
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(5) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(6) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(7) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(8) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(9) ) ) then
        return false
    endif
    return true
endfunction
function Trig_Select_PoFa_______u_Actions takes nothing returns nothing
local location loc=null
    if ( Trig_Select_PoFa_______u_Func001C() ) then
    set loc=GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu)
        call CreateNUnitsAtLoc( 1, 'H003', GetOwningPlayer(GetTriggerUnit()),loc , bj_UNIT_FACING )
        call RemoveUnit( gg_unit_H003_0002 )
        call TriggerExecute( gg_trg_setup_Hero )
        call DisableTrigger( GetTriggeringTrigger() )
    elseif ( Trig_Select_PoFa_______u_Func002C() ) then
    set loc=GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu)
        call CreateNUnitsAtLoc( 1, 'H003', GetOwningPlayer(GetTriggerUnit()), GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu), bj_UNIT_FACING )
        call RemoveUnit( gg_unit_H003_0002 )
        call TriggerExecute( gg_trg_setup_Hero )
        call DisableTrigger( GetTriggeringTrigger() )
    endif
    call RemoveLocation(loc)
    set loc=null
endfunction
//===========================================================================
function InitTrig_Select_PoFa_______u takes nothing returns nothing
    set gg_trg_Select_PoFa_______u = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Select_PoFa_______u, gg_rct_PoFa )
    call TriggerAddCondition( gg_trg_Select_PoFa_______u, Condition( function Trig_Select_PoFa_______u_Conditions ) )
    call TriggerAddAction( gg_trg_Select_PoFa_______u, function Trig_Select_PoFa_______u_Actions )
endfunction[/codes]
回复

使用道具 举报

发表于 2008-8-4 14:50:37 | 显示全部楼层
给你JASS培训班的

acer01-3C选英雄.w3x

25 KB, 下载次数: 4

meidanzuo-3C选英雄.w3x

19 KB, 下载次数: 4

trevors-绵羊选英雄.w3x

18 KB, 下载次数: 3

回复

使用道具 举报

发表于 2008-8-4 14:51:23 | 显示全部楼层
[codes=jass]
function SelectHero_IsLight takes unit u returns boolean
  local integer id = GetPlayerId(GetOwningPlayer(u))
  return 0 <= id and id <= 4
endfunction
[/codes]

程序虽短,但是我觉得还是有不少你可以学习的

1 如果不是触发器的动作/条件等函数,最好不要用GetTriggerUnit()这类函数,而是改为用参数传入,确保函数的独立性
2 最好能从函数名就能猜测函数的作用,而由于jass的函数大多是围绕一个触发而写的,所以可以加上这个触发的前缀,至于其它的就自己去慢慢体会吧
回复

使用道具 举报

发表于 2008-8-4 14:53:28 | 显示全部楼层
actboy168你是我的强敌!!
回复

使用道具 举报

 楼主| 发表于 2008-8-4 15:24:07 | 显示全部楼层
那怎样把两个J合起来呢
把第一个的 如果是玩家 选择
换成如果是队伍队伍
谢谢 我会找出自己的j思考方式的
回复

使用道具 举报

 楼主| 发表于 2008-8-4 15:25:34 | 显示全部楼层
还有 如果是别的英雄 应该怎么编
能不能用什么代替  我不知道自创英雄的编号
回复

使用道具 举报

 楼主| 发表于 2008-8-4 15:27:20 | 显示全部楼层
没有搜到dota的选英雄J  各位大大谁有啊
回复

使用道具 举报

 楼主| 发表于 2008-8-4 15:53:47 | 显示全部楼层
这一个存不了
怎么办 是不是缺少什么字符 还是没有编自定义脚本
回复

使用道具 举报

 楼主| 发表于 2008-8-4 15:54:02 | 显示全部楼层
[jass]
function Trig_Select_PoFa_______u_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'e008' ) ) then
        return false
    endif
    return true
endfunction
function Trig_Select_PoFa_______u_Func001C takes nothing returns boolean
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(0) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(1) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(2) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(3) ) ) then
        return false
    elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(4) ) ) then
        return false
    endif
    return true
    function Trig_Select_PoFa_______u_Func002C takes nothing returns boolean
        if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(5) ) ) then
            return false
        elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(6) ) ) then
            return false
        elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(7) ) ) then
            return false
        elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(8) ) ) then
            return false
        elseif ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(9) ) ) then
            return false
        endif
        return true
    endfunction
    function Trig_Select_PoFa_______u_Actions takes nothing returns nothing
        local location loc=null
        if ( Trig_Select_PoFa_______u_Func001C() ) then
            set loc=GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu)
            call CreateNUnitsAtLoc( 1, 'H003', GetOwningPlayer(GetTriggerUnit()),loc , bj_UNIT_FACING )
            call RemoveUnit( gg_unit_H003_0002 )
            call TriggerExecute( gg_trg_setup_Hero )
            call DisableTrigger( GetTriggeringTrigger() )
        elseif ( Trig_Select_PoFa_______u_Func002C() ) then
            set loc=GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu)
            call CreateNUnitsAtLoc( 1, 'H003', GetOwningPlayer(GetTriggerUnit()), GetRectCenter(gg_rct_DuiWu_NO_1_FuHuoQu), bj_UNIT_FACING )
            call RemoveUnit( gg_unit_H003_0002 )
            call TriggerExecute( gg_trg_setup_Hero )
            call DisableTrigger( GetTriggeringTrigger() )
        endif
        call RemoveLocation(loc)
        set loc=null
    endfunction
    //===========================================================================
    function InitTrig_Select_PoFa_______u takes nothing returns nothing
        set gg_trg_Select_PoFa_______u = CreateTrigger(   )
        call TriggerRegisterEnterRectSimple( gg_trg_Select_PoFa_______u, gg_rct_PoFa )
        call TriggerAddCondition( gg_trg_Select_PoFa_______u, Condition( function Trig_Select_PoFa_______u_Conditions ) )
        call TriggerAddAction( gg_trg_Select_PoFa_______u, function Trig_Select_PoFa_______u_Actions )
    endfunction
[/jass]
回复

使用道具 举报

发表于 2008-8-4 16:07:45 | 显示全部楼层
装个能检测jass语法错误的软件吧,比如wehelper,jassshop之类
回复

使用道具 举报

 楼主| 发表于 2008-8-4 16:13:31 | 显示全部楼层
JassCraft 行不行
回复

使用道具 举报

发表于 2008-8-4 16:16:39 | 显示全部楼层
gg_unit_H003_0002
gg_trg_setup_Hero
gg_rct_DuiWu_NO_1_FuHuoQu
这三个在地图有吗?
回复

使用道具 举报

发表于 2008-8-4 16:17:41 | 显示全部楼层
没用过,能检测语法错误就行,像这些语法错误的,自己查下就行了
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-24 19:55 , Processed in 0.215694 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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