HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Need Help

06-21-2008, 09:20 AM#1
goldendercon
well i need help with this spell not that the code has a problem but making it follow the JESP standard here's the script:
Collapse JASS:
//first trigger
function Trig_BlazingFlightInit_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000' 
endfunction

function Trig_BlazingFlightInit_Func002001 takes nothing returns boolean
    return ( I2R(GetUnitAbilityLevelSwapped('A003', GetTriggerUnit())) > 0.00 )
endfunction

function Trig_BlazingFlightInit_Func003Func003001 takes nothing returns boolean
    return ( I2R(GetUnitAbilityLevelSwapped('A003', GetTriggerUnit())) > 0.00 )
endfunction

function Trig_BlazingFlightInit_Actions takes nothing returns nothing
    local integer i = 1
    local unit F= GetTriggerUnit()
    local unit array E
    set udg_rotation= 0
    set udg_FlightCaster=GetTriggerUnit()
    if ( Trig_BlazingFlightInit_Func002001() ) then
        call StartTimerBJ( udg_BlazingFlightTimer, false, 30 )
    else
        call StartTimerBJ( udg_BlazingFlightTimer, false, 15.00 )
    endif
    loop
        exitwhen i > 4
        call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(F), PolarProjectionBJ(GetUnitLoc(F), 200.00, ( 90.00 * I2R(i) )), bj_UNIT_FACING )
        set udg_Effe_Unit[i] = GetLastCreatedUnit()
        if ( Trig_BlazingFlightInit_Func003Func003001() ) then
            call UnitApplyTimedLifeBJ( 30.00, 'BTLF', GetLastCreatedUnit() )
        else
            call UnitApplyTimedLifeBJ( 15.00, 'BTLF', GetLastCreatedUnit() )
        endif
        set i = i + 1
    endloop
    call EnableTrigger( gg_trg_FlightMovement )
endfunction

//===========================================================================
function InitTrig_BlazingFlightInit takes nothing returns nothing
    set gg_trg_BlazingFlightInit = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BlazingFlightInit, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_BlazingFlightInit, Condition( function Trig_BlazingFlightInit_Conditions ) )
    call TriggerAddAction( gg_trg_BlazingFlightInit, function Trig_BlazingFlightInit_Actions )
    call Preload("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl")
endfunction


//second trigger:
function Trig_FlightMovement_Actions takes nothing returns nothing
    local unit F=udg_FlightCaster
    local unit E= udg_Effe_Unit[1]
    local unit E2= udg_Effe_Unit[2]
    local unit E3= udg_Effe_Unit[3]
    local unit E4= udg_Effe_Unit[4]
    local integer D=200
    call SetUnitFlyHeightBJ( F, 450.00, 75.00 )
    call SetUnitPositionLoc( E, PolarProjectionBJ(GetUnitLoc(F), 200, ( AngleBetweenPoints(GetUnitLoc(F), GetUnitLoc(E)) + 5.00 )) )
    call SetUnitFlyHeightBJ( E, 450.00, 75.00 )
    call SetUnitPositionLoc( E2, PolarProjectionBJ(GetUnitLoc(F), 200, ( AngleBetweenPoints(GetUnitLoc(F), GetUnitLoc(E2)) - 5.00 )) )
    call SetUnitFlyHeightBJ( E2, 450.00, 75.00 )
    call SetUnitPositionLoc( E3, PolarProjectionBJ(GetUnitLoc(F), 200, ( AngleBetweenPoints(GetUnitLoc(F), GetUnitLoc(E3)) + 5.00 )) )
    call SetUnitFlyHeightBJ( E3, 450.00, 75.00 )
    call SetUnitPositionLoc( E4, PolarProjectionBJ(GetUnitLoc(F), 200, ( AngleBetweenPoints(GetUnitLoc(F), GetUnitLoc(E4)) - 5.00 )) )
    call SetUnitFlyHeightBJ( E4, 450.00, 75.00 )
endfunction

//===========================================================================
function InitTrig_FlightMovement takes nothing returns nothing
    set gg_trg_FlightMovement = CreateTrigger(  )
    call DisableTrigger( gg_trg_FlightMovement )
    call TriggerRegisterTimerEventPeriodic( gg_trg_FlightMovement, 0.04 )
    call TriggerAddAction( gg_trg_FlightMovement, function Trig_FlightMovement_Actions )
endfunction

//third trigger:
function Trig_LeakBuster_Actions takes nothing returns nothing
    call SetUnitFlyHeightBJ( udg_FlightCaster, 1.00, 75.00 )
    set udg_Effe_Unit[1] = null
    set udg_Effe_Unit[2] = null
    set udg_Effe_Unit[3] = null
    set udg_Effe_Unit[4] = null
    set udg_FlightCaster = null
endfunction

//===========================================================================
function InitTrig_LeakBuster takes nothing returns nothing
    set gg_trg_LeakBuster = CreateTrigger(  )
    call TriggerRegisterTimerExpireEventBJ( gg_trg_LeakBuster, udg_BlazingFlightTimer )
    call TriggerAddAction( gg_trg_LeakBuster, function Trig_LeakBuster_Actions )
endfunction

//fourth trigger:

function Trig_GroundedCircle_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_GroundedCircle_Func002001 takes nothing returns boolean
    return ( I2R(GetUnitAbilityLevelSwapped('A003', GetTriggerUnit())) > 0.00 )
endfunction

function Trig_GroundedCircle_Func003Func003001 takes nothing returns boolean
    return ( I2R(GetUnitAbilityLevelSwapped('A003', GetTriggerUnit())) > 0.00 )
endfunction

function Trig_GroundedCircle_Actions takes nothing returns nothing
    local unit C = GetTriggerUnit()
    local integer i = 1
    local integer Ie = 36
    set udg_CCaster = GetTriggerUnit()
    if ( Trig_GroundedCircle_Func002001() ) then
        call StartTimerBJ( udg_CircleTimer[1], false, 30 )
    else
        call StartTimerBJ( udg_CircleTimer[1], false, 15.00 )
    endif
    loop
        exitwhen i > Ie
        call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(C), PolarProjectionBJ(GetUnitLoc(C), 400.00, ( I2R(i) * 10.00 )), bj_UNIT_FACING )
        set udg_Circle_missile[i] = GetLastCreatedUnit()
        if ( Trig_GroundedCircle_Func003Func003001() ) then
            call UnitApplyTimedLifeBJ( 30.00, 'BTLF', GetLastCreatedUnit() )
        else
            call UnitApplyTimedLifeBJ( 15.00, 'BTLF', GetLastCreatedUnit() )
        endif
        set i = i + 1
    endloop
    call EnableTrigger( gg_trg_FlightMovement )
endfunction

//===========================================================================
function InitTrig_GroundedCircle takes nothing returns nothing
    set gg_trg_GroundedCircle = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_GroundedCircle, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_GroundedCircle, Condition( function Trig_GroundedCircle_Conditions ) )
    call TriggerAddAction( gg_trg_GroundedCircle, function Trig_GroundedCircle_Actions )
endfunction

//fifth trigger:
function Trig_CircleMovement_Actions takes nothing returns nothing
    local integer i=1
    local location loc=GetUnitLoc(udg_CCaster)
    local location loc2

    set udg_rotation=udg_rotation+5   

    loop
        exitwhen i>36
        set loc2=GetUnitLoc(udg_Circle_missile[i])

        call SetUnitPositionLoc( udg_Circle_missile[i], PolarProjectionBJ(loc, 400,  udg_rotation + i*10  ))
        call RemoveLocation(loc2)
        set i=i+1
    endloop
endfunction

//===========================================================================
function InitTrig_CircleMovement takes nothing returns nothing
    set gg_trg_CircleMovement = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_CircleMovement, 0.04 )
    call TriggerAddAction( gg_trg_CircleMovement, function Trig_CircleMovement_Actions )
endfunction

//sixth and final trigger
function Trig_CircleNull_Actions takes nothing returns nothing
    local integer i=1
    loop
        exitwhen i>36
        set udg_Circle_missile[i] = null
        set i=i+1
    endloop
    set udg_CCaster = null
endfunction

//===========================================================================
function InitTrig_CircleNull takes nothing returns nothing
    set gg_trg_CircleNull = CreateTrigger(  )
    call TriggerRegisterTimerExpireEventBJ( gg_trg_CircleNull, udg_CircleTimer[1] )
    call TriggerAddAction( gg_trg_CircleNull, function Trig_CircleNull_Actions )
endfunction

if you need a map here's one
Attached Files
File type: w3xFall of Darkness1.w3x (888.3 KB)
06-21-2008, 09:35 AM#2
Themerion
Ah, hello again.

What you're trying to do certainly is possible, but quite tricky. It would be a lot more simple if you use JassNewGenPack. Since I see that you are making your spells in JASS, I would like to ask if you might consider using Resources -> Tools -> JassNewGen.

Collapse With JassNewGenPack:
// First we create our own object type.
// This object will hold all data for the spell (thus we name it Data).

private struct Data
   unit array Circle_Missile[36]
   // + all other things the spell needs
endstruct

function MyTriggerAction takes nothing returns nothing

// When the trigger is run, we create a new object of our own Data-struct.
    local Data d=Data.create()

    local integer i=0
    loop
        exitwhen i==36

// Notice that we use the Circle_Missile in our Data-object, by calling d.CircleMissile
        set d.Circle_Missile[i]=CreateUnit(.......)

        set i=i+1
    endloop

// Now all Circle_Missiles for this spell are stored in the Data-object d
// For each unit this spell is executed, a new Data-object will be created.
endfunction

06-22-2008, 05:20 AM#3
goldendercon
thanks again themerion but i already use jassnewgen pack but i am only starting JASS and i cannot yet go on to vJASS if you could help me with that then i would be happy to try learning vJASS
06-22-2008, 11:02 AM#4
Themerion
vJASS is just an extension to JASS. You write it the same, but vJASS has some cool extra features. That's all. If you want to make your spell MUI, it will get overly complicated (or just horribly slow) if you do not use vJASS-structs.

Structs are pretty easy. Just like a unit has x/y-positions, hit points, a model, etc; a struct can contain different data too. For instance, we can declare a struct named City, which contains a string:

Collapse JASS:
struct City
    string name
endstruct

Now, what do we use it for? Well, to store data!

Collapse JASS:
function DoSomething takes nothing returns nothing
  // This is how you create a new object
  local City myFirstCity = City.create()

    // Will print out "London"
    set myFirstCity.name="London"
    call BJDebugMsg(myFirstCity.name)

   // And for cleaning up:
   call myFirstCity.destroy()
endfunction

We can create as many Cities as we want!

Collapse JASS:
function CreateMoreCities takes nothing returns nothing
    local City city1 = City.create()
    local City city2 = City.create()

    // Each city has its own name, right? :)
    set city1.name = "Riga"
    set city2.name = "Moscow"

    call BJDebugMsg(city2.name)
    call BJDebugMsg(city1.name)
    // Will output:
    // Moscow
    // Riga

   // Muhaha!!
   call city1.destroy()
   call city2.destroy()
endfunction
06-22-2008, 09:09 PM#5
goldendercon
Hey thanks for all your help Themerion

Offtopic: Did you ever like GoldenSun? just an assumption though
06-22-2008, 09:27 PM#6
Themerion
Now, here's an actual 100% MUI spell example using structs. It needs CSData to work properly (CSData is made by Vexorian and is distributed with the CasterSystem).

Since a spell won't be MUI if we use globals, we have to create a timer for each time you use the spell.

Collapse JASS:
 // This spell increases the casting hero's agility by 10 for 30 seconds.

struct Data
    unit theHero
endstruct

// Start reading the function called "Actions"

// This function is run by the timer created below.
function EndActions takes nothing returns nothing

  // Since a Data-object is attached to every timer running this function...
  // We now retrieve it with CSData:
    local Data d=GetCSData( GetExpiredTimer() )

    local unit u = d.theHero

  // Calculate how much agility the hero should have now that the spell ends:
    local real agility = GetHeroAgility(GetSpellAbilityUnit(), false) - 10

  // Set the hero's agility to the correct value.
    call SetHeroAgi(GetSpellAbilityUnit(), agility, true)

  // Cleanup our local variable, and destroy the struct:
    set u=null
    call d.destroy()

  // Destroy the timer
    call DestroyTimer(GetExpiredTimer())
endfunction

//==============================
// START HERE!
//==============================

// Actions is our function run by a unit casting a spell.
function Actions takes nothing returns nothing

  // First, we create a new object of our custom type: Data.
    local Data d=Data.create()

  // Now, we create a new timer.
    local timer Timer=CreateTimer()

  // Increase the hero's agility by 10.
    local real agility = GetHeroAgility(u, false) + 10
    call SetHeroAgi(u, agility, true)

  // Store the CastingUnit in our Data-object
    set d.theHero=GetSpellAbilityUnit()

  // This is our little CSData-trick.
  // Now we "attach" the Data-object to the timer!
    call SetCSData(Timer,d)

  // Start our newly created timer.
    call TimerStart(Timer,30,false,function EndActions)
  // It expires in 30 seconds.
  // false means the timer will only run one time. (One-shot timer)
  // It will run the function EndActions when it is done.

    set Timer=null
endfunction

endscope

Quote:
Offtopic: Did you ever like GoldenSun? just an assumption though

Yeah, I kind of like that game :)
06-22-2008, 09:38 PM#7
goldendercon
thanks, any chance i can add you as a friend/buddy
06-22-2008, 09:41 PM#8
Themerion
Sorry, I don't use Yahoo-messenger.
06-22-2008, 09:50 PM#9
goldendercon
no i mean here in wc3c and/or msn
06-23-2008, 06:05 AM#10
BudgeDragon
well, don't you need an example for the entire spell
06-25-2008, 06:42 AM#11
goldendercon
well yes in fact i do