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

[已解决][Jass]大大帮忙看看这个JASS 问题!

[复制链接]
发表于 2008-5-13 22:31:31 | 显示全部楼层 |阅读模式
constant function Aval_AbilCode takes nothing returns integer
   return 'A02H' //Ability rawcode
endfunction

function Aval_Damage takes unit u returns real
   return (GetUnitAbilityLevel(u,Aval_AbilCode())*45.0)+20.0 //Damage per each snowball
endfunction

function Aval_Number takes unit u returns integer
   return (GetUnitAbilityLevel(u,Aval_AbilCode())*3)+5//Maximum of possible snowballs in line
endfunction

function Aval_Duration takes unit u returns real
   return (GetUnitAbilityLevel(u,Aval_AbilCode())*0.0)+3.0 //Seconds of Avalanche duration
endfunction

constant function Aval_Distance takes nothing returns real
   return 25.0 //Distance between snowballs
endfunction

constant function Aval_MoveSpeed takes nothing returns integer
   return 40 //Speed of Avalanche moving
endfunction

constant function Aval_Dummy_Code takes nothing returns integer
   return 'e009' //Rawcode of dummy unit
endfunction

//========================================================

function Aval_MoveCond takes nothing returns boolean
   local timer t = GetExpiredTimer()
   local unit un = GetHandleUnit(t,"snowball")
   local boolean bool = IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) == false
   set t = null
   set un = null
   return bool
endfunction


function Aval_Move takes nothing returns nothing
   local timer t = GetExpiredTimer()
   local trigger trg = GetHandleTrigger(t, "trigger")
   local unit u = GetHandleUnit(t,"snowball")
   local real ang = GetHandleReal(trg,"angle")
   local real z = GetLocationZ(GetUnitLoc(u)) + GetUnitFlyHeight(u) - 60
   local real x = GetUnitX(u) - Cos(ang*bj_DEGTORAD)*15
   local real y = GetUnitY(u) - Sin(ang*bj_DEGTORAD)*15
   local unit cas = GetHandleUnit(trg,"caster")
   local location loc = Location(x,y)
   local integer i = 0
   if not GetHandleBoolean(t,"turn off") == true then
    set z = z - GetLocationZ(loc)
    call SetHandleReal(t,"height",z )
    call SetUnitFlyHeight(u,z,0)
    call SetUnitX(u,x)
    call SetUnitY(u,y)
   endif
   set trg = null
   set cas = null
   set t = null
   set u = null
   call RemoveLocation(loc)
endfunction

function Aval_InitMove takes nothing returns nothing
   local trigger t = GetTriggeringTrigger()
   local unit cas = GetHandleUnit(t,"caster")
   local real dist = GetHandleReal(t,"distance") + Aval_MoveSpeed()*GetHandleReal(t,"number") + 200
   local real dist2
   local real ang = GetHandleReal(t,"angle")
   local real x = GetHandleReal(t,"x loc") + Cos(ang*bj_DEGTORAD)*dist
   local real y = GetHandleReal(t,"y loc") + Sin(ang*bj_DEGTORAD)*dist
   local integer i = GetRandomInt(Aval_Number(cas)+1,Aval_Number(cas)+3)
   local real int = R2I(GetHandleReal(t,"number"))
   local timer tim = CreateTimer()
   local unit un
   local group g = CreateGroup()
   if i >= (Aval_Number(cas) + 3) then
     call SetHandleReal(t,"number", int + 1.0)
   endif
   set dist2 = Aval_Distance()*GetRandomReal(1,Aval_Number(cas)/2)
   set ang = GetRandomInt(1,2)*180-90 + ang
   set x = x + Cos(ang*bj_DEGTORAD)*dist2
   set y = y + Sin(ang*bj_DEGTORAD)*dist2
   set un = CreateUnit(GetOwningPlayer(cas),Aval_Dummy_Code(),x,y,0)
   call SetUnitPathing(un,false)
   call SetUnitFlyHeight(un,850,0)
   call SetHandleHandle(tim,"trigger",t )
   call SetHandleHandle(tim,"snowball",un)
   call SetHandleBoolean(tim,"turn off",false)
   call SetHandleReal(tim,"height",1)
   call TimerStart(tim,0.05,true,function Aval_Move)
   loop
    exitwhen GetHandleReal(tim,"height") <= 0
    call TriggerSleepAction(0.1)
   endloop
   call SetHandleBoolean(tim,"turn off",true)
   set x = GetUnitX(un)
   set y = GetUnitY(un)
   call GroupEnumUnitsInRange(g,x,y,250.0,Condition(function Aval_MoveCond))
   set i = CountUnitsInGroup(g)
   call UnitDamageTarget(cas,FirstOfGroup(g),Aval_Damage(cas),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
   call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\FrostNova\\FrostNovaTarget.mdl",x,y))
   call FlushHandleLocals(tim)
   call RemoveUnit(un)
   call DestroyTimer(tim)
   set t = null
   set cas = null
   set tim = null
   set un = null
   call DestroyGroup(g)
endfunction

function Aval_TrigAct takes nothing returns nothing
   local unit u = GetTriggerUnit()
   local location loc = GetUnitLoc(u)
   local real ang = AngleBetweenPoints(loc,GetSpellTargetLoc())
   local real dist = DistanceBetweenPoints(loc,GetSpellTargetLoc())
   local trigger t = CreateTrigger()
   call SetHandleHandle(t,"caster",u)
   call SetHandleReal(t,"angle",ang)
   call SetHandleReal(t,"distance",dist)
   call SetHandleInt(t,"number",1)
   call SetHandleReal(t,"x loc",GetLocationX(loc))
   call SetHandleReal(t,"y loc",GetLocationY(loc))
   call TriggerRegisterTimerEvent(t,0.10,true)
   call TriggerAddAction(t,function Aval_InitMove)
   call PolledWait(Aval_Duration(u))
   call FlushHandleLocals(t)
   call TriggerClearActions(t)
   call DestroyTrigger(t)
   set u = null
   call RemoveLocation(loc)
endfunction
//===========================================================================
function Trig_Avalanche_Cond takes nothing returns boolean
    return GetSpellAbilityId() == Aval_AbilCode()
endfunction

function InitTrig_Avalanche takes nothing returns nothing
    set gg_trg_Avalanche = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Avalanche, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Avalanche,Condition(function Trig_Avalanche_Cond))
    call TriggerAddAction(gg_trg_Avalanche,function Aval_TrigAct)
endfunction



我有试过在匹配单位的判断里加了 匹配单位 是 XX()玩家的敌对单位 ==TRUE
但是还是把自己和友军打挂了不知道为什么!
 楼主| 发表于 2008-5-13 22:36:16 | 显示全部楼层
我在这段里加的
function Aval_MoveCond takes nothing returns boolean
  local timer t = GetExpiredTimer()
  local unit un = GetHandleUnit(t,"snowball")
   这是加的==>
  local unit own =  GetHandleUnit(t,"caster")
  local boolean bool = IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) == false  加的==>and
IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(own)) == true
  set t = null
  set un = null
  return bool
endfunction
还是把自己和友军伤害到!
回复

使用道具 举报

发表于 2008-5-13 22:59:12 | 显示全部楼层
还素看这个吧
[jass]
constant function Aval_AbilCode takes nothing returns integer
  return 'A02H' //Ability rawcode
endfunction

function Aval_Damage takes unit u returns real
  return (GetUnitAbilityLevel(u,Aval_AbilCode())*45.0)+20.0 //Damage per each snowball
endfunction

function Aval_Number takes unit u returns integer
  return (GetUnitAbilityLevel(u,Aval_AbilCode())*3)+5//Maximum of possible snowballs in line
endfunction

function Aval_Duration takes unit u returns real
  return (GetUnitAbilityLevel(u,Aval_AbilCode())*0.0)+3.0 //Seconds of Avalanche duration
endfunction

constant function Aval_Distance takes nothing returns real
  return 25.0 //Distance between snowballs
endfunction

constant function Aval_MoveSpeed takes nothing returns integer
  return 40 //Speed of Avalanche moving
endfunction

constant function Aval_Dummy_Code takes nothing returns integer
  return 'e009' //Rawcode of dummy unit
endfunction

//========================================================

function Aval_MoveCond takes nothing returns boolean
  local timer t = GetExpiredTimer()
  local unit un = GetHandleUnit(t,"snowball")
  local boolean bool = IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING) == false
  set t = null
  set un = null
  return bool
endfunction


function Aval_Move takes nothing returns nothing
  local timer t = GetExpiredTimer()
  local trigger trg = GetHandleTrigger(t, "trigger")
  local unit u = GetHandleUnit(t,"snowball")
  local real ang = GetHandleReal(trg,"angle")
  local real z = GetLocationZ(GetUnitLoc(u)) + GetUnitFlyHeight(u) - 60
  local real x = GetUnitX(u) - Cos(ang*bj_DEGTORAD)*15
  local real y = GetUnitY(u) - Sin(ang*bj_DEGTORAD)*15
  local unit cas = GetHandleUnit(trg,"caster")
  local location loc = Location(x,y)
  local integer i = 0
  if not GetHandleBoolean(t,"turn off") == true then
    set z = z - GetLocationZ(loc)
    call SetHandleReal(t,"height",z )
    call SetUnitFlyHeight(u,z,0)
    call SetUnitX(u,x)
    call SetUnitY(u,y)
  endif
  set trg = null
  set cas = null
  set t = null
  set u = null
  call RemoveLocation(loc)
endfunction

function Aval_InitMove takes nothing returns nothing
  local trigger t = GetTriggeringTrigger()
  local unit cas = GetHandleUnit(t,"caster")
  local real dist = GetHandleReal(t,"distance") + Aval_MoveSpeed()*GetHandleReal(t,"number") + 200
  local real dist2
  local real ang = GetHandleReal(t,"angle")
  local real x = GetHandleReal(t,"x loc") + Cos(ang*bj_DEGTORAD)*dist
  local real y = GetHandleReal(t,"y loc") + Sin(ang*bj_DEGTORAD)*dist
  local integer i = GetRandomInt(Aval_Number(cas)+1,Aval_Number(cas)+3)
  local real int = R2I(GetHandleReal(t,"number"))
  local timer tim = CreateTimer()
  local unit un
  local group g = CreateGroup()
  if i >= (Aval_Number(cas) + 3) then
    call SetHandleReal(t,"number", int + 1.0)
  endif
  set dist2 = Aval_Distance()*GetRandomReal(1,Aval_Number(cas)/2)
  set ang = GetRandomInt(1,2)*180-90 + ang
  set x = x + Cos(ang*bj_DEGTORAD)*dist2
  set y = y + Sin(ang*bj_DEGTORAD)*dist2
  set un = CreateUnit(GetOwningPlayer(cas),Aval_Dummy_Code(),x,y,0)
  call SetUnitPathing(un,false)
  call SetUnitFlyHeight(un,850,0)
  call SetHandleHandle(tim,"trigger",t )
  call SetHandleHandle(tim,"snowball",un)
  call SetHandleBoolean(tim,"turn off",false)
  call SetHandleReal(tim,"height",1)
  call TimerStart(tim,0.05,true,function Aval_Move)
  loop
    exitwhen GetHandleReal(tim,"height") <= 0
    call TriggerSleepAction(0.1)
  endloop
  call SetHandleBoolean(tim,"turn off",true)
  set x = GetUnitX(un)
  set y = GetUnitY(un)
  call GroupEnumUnitsInRange(g,x,y,250.0,Condition(function Aval_MoveCond))
  set i = CountUnitsInGroup(g)
  call UnitDamageTarget(cas,FirstOfGroup(g),Aval_Damage(cas),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
  call DestroyEffect(AddSpecialEffect("Abilities\\\\Spells\\\\Undead\\\\FrostNova\\\\FrostNovaTarget.mdl",x,y))
  call FlushHandleLocals(tim)
  call RemoveUnit(un)
  call DestroyTimer(tim)
  set t = null
  set cas = null
  set tim = null
  set un = null
  call DestroyGroup(g)
endfunction

function Aval_TrigAct takes nothing returns nothing
  local unit u = GetTriggerUnit()
  local location loc = GetUnitLoc(u)
  local real ang = AngleBetweenPoints(loc,GetSpellTargetLoc())
  local real dist = DistanceBetweenPoints(loc,GetSpellTargetLoc())
  local trigger t = CreateTrigger()
  call SetHandleHandle(t,"caster",u)
  call SetHandleReal(t,"angle",ang)
  call SetHandleReal(t,"distance",dist)
  call SetHandleInt(t,"number",1)
  call SetHandleReal(t,"x loc",GetLocationX(loc))
  call SetHandleReal(t,"y loc",GetLocationY(loc))
  call TriggerRegisterTimerEvent(t,0.10,true)
  call TriggerAddAction(t,function Aval_InitMove)
  call PolledWait(Aval_Duration(u))
  call FlushHandleLocals(t)
  call TriggerClearActions(t)
  call DestroyTrigger(t)
  set u = null
  call RemoveLocation(loc)
endfunction
//===========================================================================
function Trig_Avalanche_Cond takes nothing returns boolean
    return GetSpellAbilityId() == Aval_AbilCode()
endfunction

function InitTrig_Avalanche takes nothing returns nothing
    set gg_trg_Avalanche = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Avalanche, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Avalanche,Condition(function Trig_Avalanche_Cond))
    call TriggerAddAction(gg_trg_Avalanche,function Aval_TrigAct)
endfunction
[/jass]
回复

使用道具 举报

发表于 2008-5-13 23:13:06 | 显示全部楼层
call GroupEnumUnitsInRange(g,x,y,250.0,Condition(function Aval_MoveCond))

function Aval_MoveCond takes nothing returns boolean这个不是计时器调用的函数
所以在其内部调用 local timer t = GetExpiredTimer()   应该是无效的
caster 明明是绑定在触发器上的    local unit own =  GetHandleUnit(t,"caster")
你通过计时器是得不到的



另外  我不太清楚GetTriggeringTrigger()是否可以传递到单位组动作中
回复

使用道具 举报

 楼主| 发表于 2008-5-14 06:23:04 | 显示全部楼层
那怎么 写呢应该!
回复

使用道具 举报

发表于 2008-5-14 10:16:18 | 显示全部楼层
这技能貌似时间差异出了问题,第一次循环时GetExpiredTimer()没被赋值,0.05秒后才是被赋值,等到循环到第二次时,timer已经改变GetExpiredTimer()又不能用,所以是不是自己人都杀?也就是每0.1判断不到对方是自己的敌人而杀死队友.另外GetExpiredTimer()是相当于全局变量,只有TIMER到期才能改变它,因此只要timer不到期,GetExpiredTimer()都可要在任何函数里用……
回复

使用道具 举报

发表于 2008-5-14 12:40:00 | 显示全部楼层
local unit own =  GetHandleUnit(GetTriggeringTrigger,"caster")
这里没有GetExpiredTimer
回复

使用道具 举报

 楼主| 发表于 2008-5-14 13:02:31 | 显示全部楼层
谢谢LS几位大大,加进去试了下  头几波 敌人和自己人都不受到伤害后几波 友军和敌人都会被伤害到!
地图 大大拿去看看把! 比较直观! Snow Master(2).w3x (88 KB, 下载次数: 5)
回复

使用道具 举报

 楼主| 发表于 2008-5-14 13:03:40 | 显示全部楼层
可以在地图里面改 比较方便!!!
回复

使用道具 举报

发表于 2008-5-14 14:50:56 | 显示全部楼层
自定义变量重复了吧,这样允许保存么?
[codes=jass]
function Aval_MoveCond takes nothing returns boolean
  local timer t = GetExpiredTimer()
  local trigger t = GetTriggeringTrigger()
[/codes]

还有这个触发里莫名其妙的东西很多,看起来是照着下面一个技能写的,但伤害部分似乎是说一个雪球只对一个单位造成伤害,而且它删除触发的时间没有考虑雪球落下的时间

[codes=jass]function Aval_TrigAct takes nothing returns nothing
。。。。
  call PolledWait(Aval_Duration(u))
  //call FlushHandleLocals(t)
    call DisableTrigger(t)//   DestroyTrigger(t) 这里先Disable
    set u = null
  call RemoveLocation(loc)
  call TriggerSleepAction(3)//等雪球全部落下
  call FlushHandleLocals(t)
  call DestroyTrigger(t)
endfunction[/codes]
回复

使用道具 举报

 楼主| 发表于 2008-5-14 15:12:54 | 显示全部楼层
能 保存!
回复

使用道具 举报

 楼主| 发表于 2008-5-14 16:23:28 | 显示全部楼层
啊! 自己解决不了啊!
回复

使用道具 举报

发表于 2008-5-15 10:21:54 | 显示全部楼层
[quote]引用第9楼kook于2008-05-14 14:50发表的  :
[codes=jass]
function Aval_TrigAct takes nothing returns nothing
。。。。
   call PolledWait(Aval_Duration(u))
   //call FlushHandleLocals(t)
      call DisableTrigger(t)//    DestroyTrigger(t) 这里先Disable
      set u = null
   call RemoveLocation(loc)
   call TriggerSleepAction(3)//等雪球全部落下
   call FlushHandleLocals(t)
   call DestroyTrigger(t)
endfunction
[/codes]
就这样改一下能大概解决问题

Snow Master(2).w3x

88 KB, 下载次数: 10

回复

使用道具 举报

 楼主| 发表于 2008-5-15 10:57:55 | 显示全部楼层
谢谢 楼上大大 解决了 !
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-12-22 20:19 , Processed in 0.064028 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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