HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mana Burn for Contest <having issues>

05-20-2007, 10:28 PM#1
Devouring-One
I've been trying to get something together for the spell contest, but I've come across a knot that I can't seem to untangle myself. I'm making a mana burn spell that sucks mana out of the target and sends it to the caster in a blue ball of energy, who then uses that mana to create a fireball to send back to the target. Right now, it creates a "mana ball" and has it fly around in circles. Anytime a unit comes within range of it, it creates the fireball and doesn't destroy it. I know how to fix the not getting destroyed problem, but I don't know what I did wrong with the target / homing part. Any help out there?
Collapse JASS:
globals
   unit array caster //these are arrays so that I can make this affect multiple units simultaneously later. MUI, I believe its called.
   unit array target 
   integer i = -1
endglobals

function fireballreturn takes nothing returns nothing
   local integer x
   set x = GetRandomInt(1,2)
   if x == 1 then
      call SetUnitAnimation(caster[i], "attack1")
   else
      call SetUnitAnimation(caster[i], "attack2")
   endif
   call DamagingProjectileLaunchTarget(caster[i], "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl", 300, 0, GetUnitX(caster[i]), GetUnitY(caster[i]), 0, target[i], 0, 50, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE)
endfunction

function manaball takes nothing returns nothing
   if GetUnitState(target[i], UNIT_STATE_MANA) < 25 then
      call DisplayTextToPlayer(GetTriggerPlayer(), 0,0, "Target lacks sufficient mana.")
   else
      call SetUnitState(target[i], UNIT_STATE_MANA, GetUnitState(target[i], UNIT_STATE_MANA)-25)
      call CollisionMissile_Create("Doodads\\Cityscape\\Props\\MagicRunes\\MagicRunes0.mdl", GetUnitX(target[i]), GetUnitY(target[i]), AngleBetweenPoints(GetUnitLoc(caster[i]),GetUnitLoc(target[i])), 300, 100, 1800, 0, true, 5, function fireballreturn)
      call CollisionMissile_SetTargetPointLoc(caster[i], GetUnitLoc(caster[i]))
   endif
endfunction
Collapse Trigger "Begin":
function InitTrig_Begin takes nothing returns nothing
    call OnAbilityEffect('ACsw',"step1")
endfunction

function step1 takes nothing returns nothing
   set i = i+1
   if i > 200 then // 200 is a reasonable number, right?
      set i = 0
   endif
   set caster[i] = GetTriggerUnit()
   set target[i] = GetSpellTargetUnit()
   call manaball()
endfunction
05-21-2007, 02:55 AM#2
Vexorian
Hi, don't ever, ever use such a name like i for a global name.

Also, I think you need to attach the i to the CollisionMissile, the best current way would be to use CollisionMissile_SetTag, then instead of using the global i you use the one attached to the missile.
05-21-2007, 12:04 PM#3
TheSecretArts
uh oh, hes getting help from Vex... now my GUI based (JASS deleaked) spell is doomed . Yea, as vex said, its generally good practice to use unique names for variables...
05-23-2007, 10:05 PM#4
Devouring-One
OK, I'll try that, thanks. But I can't right now, I am not at home. I would have responded earlier, but my house computer is having issues with WC3C again... We will (hopefully) be switching ISPs here in a short while, but untill then, my veiwing capabilities are extremely limited.

Meaning, I may be getting in touch with you (Vex) via email to try to sort this out again.

But, untill then, thanks much!

Collapse JASS:
globals
   unit array caster
   unit array target 
   integer IntegeralInt = -1
endglobals

function fireballreturn takes nothing returns nothing
   local integer x
   set x = GetRandomInt(1,2)
   if x == 1 then
      call SetUnitAnimation(caster[IntegeralInt], "attack1")
   else
      call SetUnitAnimation(caster[IntegeralInt], "attack2")
   endif
   call DamagingProjectileLaunchTarget(caster[IntegeralInt], "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl", 300, 0, GetUnitX(caster[IntegeralInt]), GetUnitY(caster[IntegeralInt]), 0, target[IntegeralInt], 0, 50, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE)
endfunction

function manaball takes nothing returns nothing
   if GetUnitState(target[IntegeralInt], UNIT_STATE_MANA) < 25 then
      call DisplayTextToPlayer(GetTriggerPlayer(), 0,0, "Target lacks sufficient mana.")
   else
      call SetUnitState(target[IntegeralInt], UNIT_STATE_MANA, GetUnitState(target[IntegeralInt], UNIT_STATE_MANA)-25)
      call CollisionMissile_Create("Doodads\\Cityscape\\Props\\MagicRunes\\MagicRunes0.mdl", GetUnitX(target[IntegeralInt]), GetUnitY(target[IntegeralInt]), AngleBetweenPoints(GetUnitLoc(caster[IntegeralInt]),GetUnitLoc(target[IntegeralInt])), 300, 100, 1800, 0, true, 5, function fireballreturn)
      call CollisionMissile_SetTargetPointLoc(caster[IntegeralInt], GetUnitLoc(caster[IntegeralInt]))
   endif
endfunction

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

function InitTrig_Begin takes nothing returns nothing
    call OnAbilityEffect('ACsw',"step1")
    call DisplayTextToForce(GetPlayersAll(), "Running...")
endfunction

function step1 takes nothing returns nothing
   set IntegeralInt = IntegeralInt+1
   if IntegeralInt > 200 then // 200 is a reasonable number, right?
      set IntegeralInt = 0
   endif
   set caster[IntegeralInt] = GetTriggerUnit()
   set target[IntegeralInt] = GetSpellTargetUnit()
   call manaball()
endfunction
05-26-2007, 12:44 AM#5
Vexorian
Collapse JASS:
globals
   unit array caster
   unit array target 
   integer IntegeralInt = -1
endglobals

function fireballreturn takes nothing returns nothing
 local integer x
 local unit u=GetTriggerCollisionMissile()
 local integer id = CollisionMissile_GetTag(u)

  if(GetTriggerUnit()==null) then
      // collision missile explosion event
     set u=null
      return
  endif

   set x = GetRandomInt(1,2)
   if x == 1 then
      call SetUnitAnimation(caster[id], "attack1")
   else
      call SetUnitAnimation(caster[id], "attack2")
   endif
   call DamagingProjectileLaunchTarget(caster[id], "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl", 300, 0, GetUnitX(caster[IntegeralInt]), GetUnitY(caster[id]), 0, target[id], 0, 50, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE)


    call CollisionMissile_Destroy(u)
 set u=null
endfunction

function manaball takes nothing returns nothing
 local unit m
   if GetUnitState(target[IntegeralInt], UNIT_STATE_MANA) < 25 then
      call DisplayTextToPlayer(GetTriggerPlayer(), 0,0, "Target lacks sufficient mana.")
   else
      call SetUnitState(target[IntegeralInt], UNIT_STATE_MANA, GetUnitState(target[IntegeralInt], UNIT_STATE_MANA)-25)
      set m= CollisionMissile_Create("Doodads\\Cityscape\\Props\\MagicRunes\\MagicRunes0.mdl", GetUnitX(target[IntegeralInt]), GetUnitY(target[IntegeralInt]), AngleBetweenPoints(GetUnitLoc(caster[IntegeralInt]),GetUnitLoc(target[IntegeralInt])), 300, 100, 1800, 0, true, 5, function fireballreturn)
      call CollisionMissile_SetTargetPointLoc(m, GetUnitLoc(caster[IntegeralInt]))

      call CollisionMissile_SetTag(m,IntegeralInt)
   endif
endfunction

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

function InitTrig_Begin takes nothing returns nothing
    call OnAbilityEffect('ACsw',"step1")
    call DisplayTextToForce(GetPlayersAll(), "Running...")
endfunction

function step1 takes nothing returns nothing
   set IntegeralInt = IntegeralInt+1
   if IntegeralInt > 200 then // 200 is a reasonable number, right?
      set IntegeralInt = 0
   endif
   set caster[IntegeralInt] = GetTriggerUnit()
   set target[IntegeralInt] = GetSpellTargetUnit()
   call manaball()
endfunction