找回密码
 点一下
查看: 1071|回复: 13

帮忙看下,哪里错了,怎么保存不了呢?

[复制链接]
发表于 2011-6-3 16:29:44 | 显示全部楼层 |阅读模式
function Trig_Unit_DeathConditions takes nothing returns boolean
    return ((GetOwningPlayer(GetTriggerUnit()) == Player(10)) and (IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == false))
endfunction

function Trig_Unit_DeathActions takes nothing returns nothing
    set udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] = ( udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] + 1 )
    call MultiboardSetItemValue( MultiboardGetItem(udg_Panel, GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ())), 1), I2S(udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))]) )
    local unit u = GetTriggerUnit()
    call TriggerSleepAction(2)
    call RemoveUnit( loc_u() )
    set loc_u = null
endfunction

//===========================================================================
function InitTrig_Unit_Death takes nothing returns nothing
    set gg_trg_Unit_Death = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(gg_trg_Unit_Death, Condition(function Trig_Unit_DeathConditions))
    call TriggerAddAction(gg_trg_Unit_Death, function Trig_Unit_DeathActions)
endfunction



本人第一次用J,纯属菜鸟
发表于 2011-6-3 16:31:40 | 显示全部楼层
局部变量需要在函数开始时声明
回复

使用道具 举报

发表于 2011-6-3 16:34:32 | 显示全部楼层
哈❤
基础功不过关。
加紧练习吧,我可是用了大约两天的时间才习惯==的呢,一直都打成=
回复

使用道具 举报

 楼主| 发表于 2011-6-3 16:36:44 | 显示全部楼层
这里解决了,可是那个删除loc_u的动作还是显示错误,怎么回事,如果写错了,应该怎么写
回复

使用道具 举报

发表于 2011-6-3 16:39:11 | 显示全部楼层
loc_u后面的括号是干啥的?
回复

使用道具 举报

 楼主| 发表于 2011-6-3 16:41:05 | 显示全部楼层
饿,复制的时候没删除,后来删除了,还是提示错误。- -于是我尴尬了
回复

使用道具 举报

发表于 2011-6-3 16:42:58 | 显示全部楼层
错误是什么
回复

使用道具 举报

 楼主| 发表于 2011-6-3 16:45:24 | 显示全部楼层
就是无法保存
回复

使用道具 举报

发表于 2011-6-3 16:48:08 | 显示全部楼层
[jass]globals
integer array udg_Killa_Iingter
multiboard udg_Panel
trigger gg_trg_Unit_Death
endglobals
function Trig_Unit_DeathConditions takes nothing returns boolean
    return ((GetOwningPlayer(GetTriggerUnit()) == Player(10)) and (IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == false))
endfunction

function Trig_Unit_DeathActions takes nothing returns nothing
    set udg_Killa_Iingter[1] = ( udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] + 1 )
    call MultiboardSetItemValue( MultiboardGetItem(udg_Panel, GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ())), 1), I2S(udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))]) )
    local unit u = GetTriggerUnit()
    call TriggerSleepAction(2)
    call RemoveUnit(u)
    set u = null
endfunction

//===========================================================================
function InitTrig_Unit_Death takes nothing returns nothing
    set gg_trg_Unit_Death = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(gg_trg_Unit_Death, Condition(function Trig_Unit_DeathConditions))
    call TriggerAddAction(gg_trg_Unit_Death, function Trig_Unit_DeathActions)
endfunction[/jass]
回复

使用道具 举报

发表于 2011-6-3 16:48:35 | 显示全部楼层
[jass]globals
integer array udg_Killa_Iingter
multiboard udg_Panel
trigger gg_trg_Unit_Death
endglobals
function Trig_Unit_DeathConditions takes nothing returns boolean
    return ((GetOwningPlayer(GetTriggerUnit()) == Player(10)) and (IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == false))
endfunction

function Trig_Unit_DeathActions takes nothing returns nothing
    set udg_Killa_Iingter[1] = ( udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] + 1 )
    call MultiboardSetItemValue( MultiboardGetItem(udg_Panel, GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ())), 1), I2S(udg_Killa_Iingter[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))]) )
    local unit u = GetTriggerUnit()
    call TriggerSleepAction(2)
    call RemoveUnit(u)
    set u = null
endfunction

//===========================================================================
function InitTrig_Unit_Death takes nothing returns nothing
    set gg_trg_Unit_Death = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Unit_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition(gg_trg_Unit_Death, Condition(function Trig_Unit_DeathConditions))
    call TriggerAddAction(gg_trg_Unit_Death, function Trig_Unit_DeathActions)
endfunction[/jass]
回复

使用道具 举报

 楼主| 发表于 2011-6-3 16:49:35 | 显示全部楼层
globals

integer array udg_Killa_Iingter

multiboard udg_Panel

trigger gg_trg_Unit_Death

endglobals


这里不用,关系不大的吧?
回复

使用道具 举报

发表于 2011-6-3 16:52:04 | 显示全部楼层
错误也不多,基本上都是不熟练的错误。
首先,局部变量的声明必须放在函数的最前段。
然后,声明的局部变量格式为
[jass] local 变量类型 变量名称
local unit u
[/jass]
既然变量名称为u的话,为什么使用这个变量的时候却找loc_u去了?甚至还加了个括号……

只有调用函数的时候,才需要加括号,因为函数有takes(传递值)一说,你括号里的东西和函数的takes一一对应。
回复

使用道具 举报

 楼主| 发表于 2011-6-3 16:54:44 | 显示全部楼层
恩,多学习,看教程总觉得很难,可是找不到师傅啊。要是自己能掌握Jass就好了。
回复

使用道具 举报

发表于 2011-6-3 16:57:56 | 显示全部楼层
Jass慢慢来,我大约在过年前还是T的忠实用户,但是玩Dota,不会J的话虐AI太没意思了。
最后看着教程改Dota,现在终于算出师了。(开玩笑的)
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-10-5 14:59 , Processed in 0.046036 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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