HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Collision missile...im out of ideas to fix this!

09-09-2007, 05:11 AM#1
waaaks
Collapse JASS:
function Missile_Impact takes nothing returns nothing
 local timer t = GetExpiredTimer()
 local unit targ = GetTriggerUnit()
 local unit cast = GetAttachedUnit( t, "cast" )
 local location loc = GetUnitLoc(cast)
 local location loc2 = GetUnitLoc(targ)
 local integer l
 local integer dopt
 set dopt = DamageTypes(ATTACK_TYPE_SIEGE,DAMAGE_TYPE_FORCE) 
 set l = GetUnitAbilityLevel( cast, 'A03X' )
  if IsUnitEnemy(targ, GetOwningPlayer(cast)) == true and IsUnitAliveBJ(targ) == true then
   call DamageUnitByOptions(cast, targ, 100 + l*100, dopt)
   call CS_MoveUnitLoc(targ, loc)
   call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Polymorph\\PolyMorphDoneGround.mdl", loc2 ))
  endif
 call RemoveLocation(loc)
 call RemoveLocation(loc2)
 set loc = null
 set loc2 = null
 set cast = null
 set targ = null  
endfunction

function Missile_Start takes nothing returns nothing
 local timer t = CreateTimer()
 local unit cast = GetSpellAbilityUnit()
 local location loc1 = GetUnitLoc(cast)
 local location loc2 = GetSpellTargetLoc()
 local real face = AngleBetweenPoints(loc1, loc2)
 call AttachObject( t, "cast", cast )
 call CollisionMissile_CreateLoc( "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl", loc1, face, 1000.0, 0, 1000.0, 50.0, false, 125.0, function Missile_Impact )
 call RemoveLocation(loc1)
 call RemoveLocation(loc2)
 set loc1 = null
 set loc2 = null
 set cast = null 
endfunction

//===========================================================================
function InitTrig_Missile takes nothing returns nothing
 call OnAbilityEffect( 'A03X', "Missile_Start" )
endfunction

heres the trigger of the spell

what i want here for my spell....is to move enemy units that get hit or collides with the collisionmissile unit to the caster of the spell and damage them

but the problem is...also the caster moves, not in the caster's location but center of the map...also moving the units that collides with the missile....and not just enemies but also ally units...and lastly it wont damage the unit that collides with the missile...

i need help to fix this trigger...

note that i added a local timer to attach the local caster variable...cause i dont know how to attach the variable...thats why i created a timer so that i can attach the variable to it...

this is the last spell im making for my map's version 6 so please help
09-09-2007, 06:32 AM#2
Vexorian
Your code, does not make any sense, at all.

You are attaching some info to a timer that is never even started, and then you create a collisionmissile and somehow expect that its collisionevent will have GetExpiredTimer() and that it will somehow return the timer you created.

You need to attach the info to the collision missile itself...
09-09-2007, 10:56 AM#3
waaaks
Ok enough of that trigger...now i made another trigger that stuns the units that collide with the missile

ive done it right
but the problem is, it also stuns my units, and as i observed, sometimes it creates the caster for me and sometimes for the owner of the units that collide with the missile

i think the problem here, is the GetTriggerUnit() because in the functions, vex just said "now GetTriggerUnit() responses to the unit that collides with the missile"

and the worst problem is...there will be two GetTriggerUnit()
one is the unit that casts the spell
while the second one is the unit that collides with the missile

thats why sometimes it creates caster for the owner of the unit that collides with the missile

is there no event responses for the units that collide with the missile?
because i think that makes the trigger more worst

and the only thing i want here is...
create a collision missile for the caster, and when it collides with ENEMY units, then a dummy caster owned by the caster will cast stormbolt to the units that collides with the missile...

simple enough, but very confusing...

can anyone give me a SHORT trigger that uses the collisionmissile_create function correctly?

the inferno trigger is too messy, thats why i cant understand it....

heres the code for the spell
Collapse JASS:
function Missile_Impact takes nothing returns nothing
 local unit targ = GetTriggerUnit()
 local unit m = GetTriggerCollisionMissile()
 local location loc1 = GetUnitLoc(m)
 local unit cast = GetAttachedUnit( loc1, "cast" )
 call CasterSetCastSourceLoc(loc1)
 call CasterSetRecycleDelay(3.0)
 call CasterCastAbility(GetOwningPlayer(cast), 'A001', "thunderbolt", targ, false) 
 call RemoveLocation(loc)
 set loc = null
 set cast = null
 set targ = null
 set m = null  
endfunction

function Missile_Start takes nothing returns nothing
 local unit cast = GetSpellAbilityUnit()
 local location loc1 = GetUnitLoc(cast)
 local location loc2 = GetSpellTargetLoc()
 local real face = AngleBetweenPoints(loc1, loc2)
 call AttachObject( loc1, "cast", cast )
 call CollisionMissile_CreateLoc( "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl", loc1, face, 1000.0, 0, 1000.0, 50.0, false, 125.0, function Missile_Impact )
 call RemoveLocation(loc1)
 call RemoveLocation(loc2)
 set loc1 = null
 set loc2 = null
 set cast = null 
endfunction

//===========================================================================
function InitTrig_Missile takes nothing returns nothing
 call OnAbilityEffect( 'A000', "Missile_Start" )
endfunction
09-09-2007, 01:11 PM#4
Vexorian
You are now attaching info to a point? I said you should attach information to the collision missile, why aren't you doing it? And there would be one triggering unit in Missile_Start and different one in Missile_Impact, event responses only copy themselves to functions in the same thread, Missile_Impact got another thread, you cannot attach things to locations since a point is never the same handle...


first trigger:

Collapse JASS:
function Missile_Impact takes nothing returns nothing
 local unit targ = GetTriggerUnit()
 local unit cast = GetAttachedUnit( GetTriggerCollisionMissile(), "cast" )
 local location loc
 local location loc2
 local integer l
 local integer dopt

    if(targ==null) then
        //the collision missile dies, it calls this function but trigger unit is null
        call CleanAttachedVars(GetTriggerCollisionMissile())
        set cast=null
        return
    endif
    set loc  = GetUnitLoc(cast) //there is no reason to use locations here though.
    set loc2 = GetUnitLoc(targ)
    set dopt = DamageTypes(ATTACK_TYPE_SIEGE,DAMAGE_TYPE_FORCE) 
    set l = GetUnitAbilityLevel( cast, 'A03X' )
    if IsUnitEnemy(targ, GetOwningPlayer(cast)) and IsUnitAliveBJ(targ) then
       call DamageUnitByOptions(cast, targ, 100 + l*100, dopt) //Is it necessary to use DamageUnitByOptions if the only option used is DamageTypes ?
       call CS_MoveUnitLoc(targ, loc)
       call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Polymorph\\PolyMorphDoneGround.mdl", loc2 ))
    endif
    call RemoveLocation(loc)
    call RemoveLocation(loc2)

 set loc = null
 set loc2 = null
 set cast = null
 set targ = null  
endfunction

function Missile_Start takes nothing returns nothing
 local unit cast = GetSpellAbilityUnit()
 local location loc1 = GetUnitLoc(cast)
 local location loc2 = GetSpellTargetLoc()
 local real face = AngleBetweenPoints(loc1, loc2)
 local unit m

    set m=CollisionMissile_CreateLoc( "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl", loc1, face, 1000.0, 0, 1000.0, 50.0, false, 125.0, function Missile_Impact )
     call AttachUnit(m,"cast")
 call RemoveLocation(loc1)
 call RemoveLocation(loc2)
 set loc1 = null
 set loc2 = null
 set cast = null 
 set m=null
endfunction

//===========================================================================
function InitTrig_Missile takes nothing returns nothing
 call OnAbilityEffect( 'A03X', "Missile_Start" )
endfunction

now that there is vJass and collisionmissiles have the Tag functions, you don't need attach variables at all, it is also good to learn some tricks like scopes make the code easier to write without all those extra prefixes and suffixes , not to mention the spell becomes JESP almost automatically...

Collapse JASS:

scope Missile

globals
    private constant integer SPELL_ID  = 'A03X'
endglobals

private struct missiledata
    unit castingunit
endstruct


private function Impact takes nothing returns nothing
 local unit targ = GetTriggerUnit()
 local missiledata D= missiledata( CollisionMissile_GetTag(GetTriggerCollisionMissile()) )
 local location loc
 local location loc2
 local integer l
 local integer dopt

    if(targ==null) then
        //the collision missile dies, it calls this function but trigger unit is null
        call D.destroy()
        return
    endif
    set loc  = GetUnitLoc(D.castingunit)
    set loc2 = GetUnitLoc(targ)
    set dopt = DamageTypes(ATTACK_TYPE_SIEGE,DAMAGE_TYPE_FORCE) 
    set l = GetUnitAbilityLevel( D.castingunit, SPELL_ID )
    if IsUnitEnemy(targ, GetOwningPlayer(D.castingunit)) and IsUnitAliveBJ(targ) then
       call DamageUnitByOptions(D.castingunit, targ, 100 + l*100, dopt) //Is it necessary to use DamageUnitByOptions if the only option used is DamageTypes ?
       call CS_MoveUnitLoc(targ, loc)
       call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Polymorph\\PolyMorphDoneGround.mdl", loc2 ))
    endif
    call RemoveLocation(loc)
    call RemoveLocation(loc2)

 set loc = null
 set loc2 = null
 set targ = null  
endfunction

private function Start takes nothing returns nothing
 local unit cast = GetSpellAbilityUnit()
 local missiledata D = missiledata.create()
 local location loc1 = GetUnitLoc(cast)
 local location loc2 = GetSpellTargetLoc()
 local real face = AngleBetweenPoints(loc1, loc2)
 local unit m

     set D.castingunit = cast
     set m=CollisionMissile_CreateLoc( "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl", loc1, face, 1000.0, 0, 1000.0, 50.0, false, 125.0, function Missile_Impact )
     call CollisionMissile_SetTag(m , integer(D) )

 call RemoveLocation(loc1)
 call RemoveLocation(loc2)
 set loc1 = null
 set loc2 = null
 set cast = null 
 set m=null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
 call OnAbilityEffect( 'A03X', SCOPE_PRIVATE+"Start" )
endfunction

endscope
09-11-2007, 08:18 AM#5
waaaks
now i get it...thanks...
Collapse JASS:
call AttachUnit(m,"cast")
where did u get this function? AttachUnit?
is this right?

can i use this? in the trigger?
Collapse JASS:
call AttachObject(cast, "cast", m)
because i think theres no function in CScache such as AttachUnit?
09-11-2007, 01:03 PM#6
Vexorian
yeah probably, it is the same
09-12-2007, 04:36 AM#7
waaaks
got another problem...

ive got the first scope trigger to work, i made another skill and trigger then copy pasted the scope trigger and modified some of it, but it doesnt work....it doesnt even creates the missile unit

Missile (works)
Collapse JASS:
scope Missile

globals
    private constant integer SPELL_ID  = 'A003' //Rawcode for spell
    private constant integer DUMMY_ID  = 'A004' //Rawcode for dummy spell
    private constant string  ORDER_ID  = "thunderbolt" //order id of the dummy spell
    private constant string  SFX       = "Abilities\\Spells\\Other\\FrostBolt\\FrostBoltMissile.mdl" //missile effect
    private constant real    COLLISION = 400.0 //collision size of the missile
    private constant real    SPEED     = 1000.0 //missile speed
    private constant real    RANGE     = 1000.0 //missile max range
    private constant real    Z_OFFSET  = 50.0 //missile's flying height
    private constant real    SCALE     = 5.0 //missile's scaling
endglobals

private struct missiledata
    unit castingunit
endstruct


private function Impact takes nothing returns nothing
 local unit targ = GetTriggerUnit()
 local unit m = GetTriggerCollisionMissile()
 local missiledata D= missiledata( CollisionMissile_GetTag(GetTriggerCollisionMissile()) )
 local location loc
 local location loc2
 local location loc3
 local integer l
 local integer dopt

    if(targ==null) then
        call D.destroy()
        return
    endif
    set loc  = GetUnitLoc(D.castingunit)
    set loc2 = GetUnitLoc(targ)
    set loc3 = GetUnitLoc(m)
    call SetUnitScale(m, SCALE, SCALE, SCALE)
    call CasterSetCastSourceLoc(loc3)
    call CasterSetRecycleDelay(3.00) 
    set l = GetUnitAbilityLevel( D.castingunit, SPELL_ID )
    if IsUnitEnemy(targ, GetOwningPlayer(D.castingunit)) and IsUnitAliveBJ(targ) then
       call CasterCastAbilityLevel(GetOwningPlayer(D.castingunit), DUMMY_ID, l, ORDER_ID, targ, false ) 
    endif
    call RemoveLocation(loc)
    call RemoveLocation(loc2)

 set loc = null
 set loc2 = null
 set targ = null  
endfunction

private function Start takes nothing returns nothing
 local unit cast = GetTriggerUnit()
 local missiledata D = missiledata.create()
 local location loc1 = GetUnitLoc(cast)
 local location loc2 = GetSpellTargetLoc()
 local real face = AngleBetweenPoints(loc1, loc2)
 local unit m

     set D.castingunit = cast
     set m=CollisionMissile_CreateLoc( SFX, loc1, face, SPEED, 0, RANGE, Z_OFFSET, false, COLLISION, function Impact )
     call CollisionMissile_SetTag(m , integer(D) )

 call RemoveLocation(loc1)
 call RemoveLocation(loc2)
 set loc1 = null
 set loc2 = null
 set cast = null 
 set m=null
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
 call OnAbilityEffect( SPELL_ID, SCOPE_PRIVATE+"Start" )
endfunction

endscope

EtheralDagger (didnt work)
Collapse JASS:
scope EtheralDagger

globals
    private constant integer EDSPELL_ID   = 'A006'
    private constant real    EDRANGE      = 1000.0
    private constant real    EDCOLLISION  = 300.0
    private constant real    EDSPEED      = 1000.0
    private constant real    EDZ_OFFSET   = 50.0
    private constant real    EDSCALE      = 3.0
    private constant real    EDDMG        = 50.0
    private constant string  EDSFX        = "Abilities\\Weapons\\BloodElfMissile\\BloodElfMissile.mdl"
    private constant string  EDSFX1       = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
    private constant string  EDSFX2       = "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl"
endglobals

private struct data
    unit caster
endstruct

private function EDImpact takes nothing returns nothing
 local unit targ = GetTriggerUnit()
 local unit m = GetTriggerCollisionMissile()
 local data E= data(CollisionMissile_GetTag(GetTriggerCollisionMissile()))
 local location loc
 local location loc2
 local integer l
  if (targ==null) then
   call E.destroy()
   return
  endif
  set loc = GetUnitLoc(E.caster)
  set loc2 = GetUnitLoc(targ)
  call SetUnitScale(m, EDSCALE, EDSCALE, EDSCALE)
  set l = GetUnitAbilityLevel(E.caster, EDSPELL_ID)
  if IsUnitEnemy(targ, GetOwningPlayer(E.caster)) == true and IsUnitAliveBJ(targ) == true then
   call UnitDamageTargetBJ(E.caster, targ, l*EDDMG, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
   call DestroyEffect(AddSpecialEffectLoc(EDSFX1, loc2))
  else
   if IsUnitEnemy(targ, GetOwningPlayer(E.caster)) == false and IsUnitAliveBJ(targ) == true then
    call SetUnitLifeBJ(targ, l*EDDMG)
    call DestroyEffect(AddSpecialEffectLoc(EDSFX2, loc2))
   endif
  endif
  call RemoveLocation(loc)
  call RemoveLocation(loc2)
  set loc = null
  set loc2 = null
  set targ = null
endfunction

private function EDStart takes nothing returns nothing
 local unit cast = GetTriggerUnit()
 local data E= data.create()
 local location loc1 = GetUnitLoc(cast)
 local location loc2 = GetSpellTargetLoc()
 local real face = AngleBetweenPoints(loc1, loc2)
 local unit m
 set E.caster = cast
 set m = CollisionMissile_CreateLoc(EDSFX, loc1, face, EDSPEED, 0.0, EDRANGE, EDZ_OFFSET, false, EDCOLLISION, function EDImpact)
 call CollisionMissile_SetTag(m, integer(E))
 call RemoveLocation(loc1)
 call RemoveLocation(loc2)
 set loc1 = null
 set loc2 = null
 set cast = null
 set m = null  
endfunction

//===========================================================================
public function InitTrig_EtheralDagger takes nothing returns nothing
    call OnAbilityEffect(EDSPELL_ID, SCOPE_PRIVATE+"EDStart")
endfunction

endscope

i based off missile to breath of fire, and it works, while i based off etheral dagger to shock wave and didn't work....its so weird because it didn't work, even if the trigger is so simmilar to the missile trigger, i think this is a bug?
09-12-2007, 04:42 AM#8
Vexorian
Collapse JASS:
public function InitTrig_EtheralDagger takes nothing returns nothing
    call OnAbilityEffect(EDSPELL_ID, SCOPE_PRIVATE+"EDStart")
endfunction
09-12-2007, 04:45 AM#9
waaaks
ah shi*.....thanks :D i hate myself!
11-05-2008, 06:23 PM#10
Kyrbi0
*Ethereal

--EDIT--

Dangit, sorry admin's, completely forgot to check the date... yet again... :/