Inserting a spell

AlExAlExAlEx

Member
Reaction score
7
Let's take a code from the 4 panda spells it is displayed like this :
Code:
scope SeismicSlam initializer Init

globals
// Configurables:

// Skills:
    private constant integer Abil_id = 'A000'
    // Raw code of the main hero ability.
    private constant integer Abil2_id = 'A007'
    // Raw code of the stomp used at the end.
    private constant integer Flytrick = 'Amrf'
    // Raw code for "Crow Form". Does not need to be changed in most cases.
    
// Units:
    private constant integer Dummy_id = 'u001'
    // Raw code of the dummy "spinning" unit used for the leap.
    private constant integer Treedummy_id = 'u000'
    // Raw code of the dummy unit used to destroy trees.

// Others:
    private constant real Interval = 0.04   // Interval for periodic timer.
    private constant real Diff = 0.00       // Distance from cast point that the unit will land.
    private constant real Timescale = 3.00  // How fast the unit spins.
    private constant string End_anim = "spell slam"
    // End animation of the unit.
    private constant string Dirt_sfx = "NewDirtEXNofire.mdx"
    // Effect made at the end of the spell on land.
    private constant string Water_sfx = "Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl"
    // Same as above but for landing on water.
    private constant boolean Destroytrees = true
    // Whether or not to destroy trees.
    private constant boolean AllowPreload = true
    // Whether or not to allow preloading of the effects.
endglobals

//=======================================================================
private function Area takes integer lvl returns real
    return 225.00 // Area of effect for destroying trees.
endfunction

private function Airtime takes integer lvl returns real
    return 1.45-(0.15*lvl) // Air time of the leap.
endfunction

//=======================================================================//
//  DO NOT TOUCH PAST THIS POINT UNLESS YOU KNOW WHAT YOUR ARE DOING!!   //
//=======================================================================//

private keyword Data

globals
    private integer Total = 0                   
    private Data array D
    private timer Timer = null
    private rect Rect1 = null
    private boolexpr Treefilt = null
    private boolexpr Truefilt = null
    private unit Treedummy = null
    private real Game_maxX = 0.00
    private real Game_minX = 0.00
    private real Game_maxY = 0.00
    private real Game_minY = 0.00
endglobals

//=======================================================================
private function KillEnumDestructables takes nothing returns nothing
    call KillDestructable(GetEnumDestructable())
endfunction

private function TreeCheck takes nothing returns boolean
    local destructable dest = GetFilterDestructable()
    local boolean result
    
    if GetDestructableLife(dest) > 0.405 then
        call ShowUnit(Treedummy,true)
        call SetUnitX(Treedummy,GetWidgetX(dest))
        call SetUnitY(Treedummy,GetWidgetY(dest))
        
        set result = IssueTargetOrder(Treedummy,"harvest",dest)
        call IssueImmediateOrder(Treedummy,"stop")
        call ShowUnit(Treedummy,false)

        return result
    endif
    
    set dest = null
    return false
endfunction

//=======================================================================
private function SafeX takes real x returns real
    if x<Game_minX then
        return Game_minX
    elseif x>Game_maxX then
        return Game_maxX
    endif
    return x
endfunction

private function SafeY takes real y returns real
    if y<Game_minY then
        return Game_minY
    elseif y>Game_maxY then
        return Game_maxY
    endif
    return y
endfunction

//=======================================================================
private function MoveDist takes real Maxdist, integer lvl returns real
    return Maxdist/(Airtime(lvl)/Interval)
endfunction

private function ConvertCount takes integer i, integer lvl returns real
    return (50.00/(Airtime(lvl)/Interval))*i
endfunction

//=======================================================================
private struct Data
    unit cast
    unit dum
    real castx
    real casty
    real cos
    real sin
    real maxdist
    real movedist
    integer i = 1
    integer lvl
    
    static method create takes nothing returns Data
        local Data d = Data.allocate()
        local location loc
        local real angle
        local real targx
        local real targy
        
        set d.cast = GetTriggerUnit()
        set d.castx = GetUnitX(d.cast)
        set d.casty = GetUnitY(d.cast)
        set loc = GetSpellTargetLoc()
        set angle = Atan2((GetLocationY(loc)-d.casty),(GetLocationX(loc)-d.castx))
        set d.cos = Cos(angle)
        set d.sin = Sin(angle)
        set targx = GetLocationX(loc)-Diff*d.cos
        set targy = GetLocationY(loc)-Diff*d.sin
        set d.lvl = GetUnitAbilityLevel(d.cast,Abil_id)
        set d.maxdist = SquareRoot((targx-d.castx)*(targx-d.castx)+(targy-d.casty)*(targy-d.casty))
        set d.movedist = MoveDist(d.maxdist,d.lvl)
        
        set d.dum = CreateUnit(GetOwningPlayer(d.cast),Dummy_id,d.castx,d.casty,angle*bj_RADTODEG)
        call UnitAddAbility(d.dum,Flytrick)
        call UnitRemoveAbility(d.dum,Flytrick)
        call SetUnitTimeScale(d.dum,Timescale)    
        call SetUnitPathing(d.dum,false) 
        call PauseUnit(d.dum,true)
        call ShowUnit(d.cast,false)
        
        set Total = Total + 1
        if Total == 1 then
            call TimerStart(Timer,Interval,true,function Data.Update)
        endif
        set D[Total] = d
        
        call RemoveLocation(loc)
        set loc = null
            
        return d
    endmethod
    
    static method Update takes nothing returns nothing
        local integer i = 1
        local real count
        local real height
        local real speed
        local real newx
        local real newy
        
        loop
            exitwhen i > Total
            
            if D[i].i < (Airtime(D[i].lvl) / Interval) then
                set count = ConvertCount(D[i].i,D[i].lvl)
                set height = (count-25.00) * (count-25.00)
                set speed = D[i].i * D[i].movedist
                set newx = D[i].castx + speed * D[i].cos
                set newy = D[i].casty + speed * D[i].sin
                call SetUnitPosition(D[i].dum,SafeX(newx),SafeY(newy))
                call SetUnitPosition(D[i].cast,SafeX(newx),SafeY(newy))
                call SetUnitFlyHeight(D[i].dum,625.00-height,0.00)
                call SetUnitFlyHeight(D[i].cast,625.00-height,0.00)
                set D[i].i = D[i].i + 1
            else
                call D[i].destroy()
                set D[i] = D[Total]
                set Total = Total - 1
                set i = i - 1
            endif
            
            set i = i + 1
        endloop
        
        if Total <= 0 then
            call PauseTimer(Timer)
            set Total = 0
        endif
    endmethod
    
    private method onDestroy takes nothing returns nothing
        local real newx = GetUnitX(.dum) + Diff * .cos
        local real newy = GetUnitY(.dum) + Diff * .sin
        local unit u = CreateUnit(GetOwningPlayer(.cast),Treedummy_id,newx,newy,0.00)
        
        call SetUnitFlyHeight(.dum,GetUnitDefaultFlyHeight(.cast),0.00)
        call PauseUnit(.dum,false)
        call SetUnitPathing(.dum,true)
        
        if Destroytrees then
            call SetRect(Rect1,newx-Area(.lvl),newy-Area(.lvl),newx+Area(.lvl),newy+Area(.lvl))
            call EnumDestructablesInRect(Rect1,Treefilt,function KillEnumDestructables)
        endif
        
        call UnitAddAbility(u,Abil2_id)
        call SetUnitAbilityLevel(u,Abil2_id,.lvl)
        call IssueImmediateOrder(u,"stomp")
        call UnitApplyTimedLife(u,'BTLF',1.00)
        if IsTerrainPathable(GetUnitX(u),GetUnitY(u),PATHING_TYPE_FLOATABILITY) then
            call DestroyEffect(AddSpecialEffect(Dirt_sfx,newx,newy))
        elseif not IsTerrainPathable(GetUnitX(u),GetUnitY(u),PATHING_TYPE_WALKABILITY) then
            call DestroyEffect(AddSpecialEffect(Water_sfx,newx,newy))
        endif
        
        call RemoveUnit(.dum)
        call SetUnitPosition(.cast,newx,newy)
        call ShowUnit(.cast,true)
        call SetUnitAnimation(.cast,End_anim)
        
        if GetLocalPlayer() == GetOwningPlayer(.cast) then
            call ClearSelection()
            call SelectUnit(.cast,true)
        endif
        
        set .cast = null
        set .dum = null
        set u = null
    endmethod                
endstruct
    
//=======================================================================
private function Actions takes nothing returns nothing 
    call Data.create()
endfunction    

//=======================================================================
private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Abil_id
endfunction

//=======================================================================
private function TrueFilt takes nothing returns boolean
    return true
endfunction

//=======================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    local integer i = 0
    
    set Timer = CreateTimer()
    set Rect1 = Rect(0.00,0.00,1.00,1.00)
    set Treefilt = Filter(function TreeCheck)
    
    set Game_maxX = GetRectMaxX(bj_mapInitialPlayableArea)-64.00
    set Game_maxY = GetRectMaxY(bj_mapInitialPlayableArea)-64.00
    set Game_minX = GetRectMinX(bj_mapInitialPlayableArea)+64.00
    set Game_minY = GetRectMinY(bj_mapInitialPlayableArea)+64.00
    
    set Truefilt = Filter(function TrueFilt)
    
    loop
        call TriggerRegisterPlayerUnitEvent(trig,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Truefilt)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
    
    set Treedummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),Treedummy_id,0.00,0.00,0.00)
    call SetUnitPathing(Treedummy,false)
    call ShowUnit(Treedummy,false)
    
    if AllowPreload then
        call KillUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),Dummy_id,0.00,0.00,0.00))
        call DestroyEffect(AddSpecialEffect(Dirt_sfx,0.00,0.00))
        call DestroyEffect(AddSpecialEffect(Water_sfx,0.00,0.00))
    endif
endfunction

endscope

Where i have to past this so i can use it ingame ?

Thanks anticipated.
 

mordocai

New Member
Reaction score
17
make a new trigger then convert it to custom text. copy and paste everything, then set the configuerables to your abilities and stuff.
Things to change(that you have to)-
private constant integer Abil_id = 'A000'
// Raw code of the main hero ability.

private constant integer Dummy_id = 'u001'
// Raw code of the dummy "spinning" unit used for the leap.

private constant integer Treedummy_id = 'u000'
// Raw code of the dummy unit used to destroy trees.
 

mordocai

New Member
Reaction score
17
just copy the trigger,variables,spell,dummy units. and thats all. then after youve pasted and changed everything just add the ability to your unit
 

AlExAlExAlEx

Member
Reaction score
7
well yeah that's the idea how can i add a trigger as a abiltity(sorry if i'm asking dumb questions but this is my 2nd day in World-Editor)
 

mordocai

New Member
Reaction score
17
if you just copy the spell that this trigger comes with it auto uses the trigger. the trigger itself is programed to be activated when the caster calls(uses) a certain spell. in this case it is A000(in the dummy map), but in your map it will be different.
 

mordocai

New Member
Reaction score
17
you need the freaking ability not just the trigger. then add the ABILITY to your hero....................................
 

Azlier

Old World Ghost
Reaction score
461
Ah, newbs (not noobs). It's fun to watch them argue. Alex, the trigger is automatically triggered when any unit (unless otherwise specified in the spell trigger itself) casts the required spell.

Anyway, first you create the ability in the object editor. To see its raw code, hold Ctrl and press D. This is reversible by repeating the previous actions. Look where the spell's name once was in the left pane. There should be a 4-character code. If this is your first custom spell on this map, then is will be 'A000'. Then, you can plug in the ability in the globals.

Rinse and repeat.

JASS:
scope SeismicSlam initializer Init

globals
// Configurables:

// Skills:
    //                      Z0MG, A000! vvvv
    private constant integer Abil_id = &#039;A000&#039;
    // Raw code of the main hero ability.
    private constant integer Abil2_id = &#039;A007&#039;
    // Raw code of the stomp used at the end.
    private constant integer Flytrick = &#039;Amrf&#039;
    // Raw code for &quot;Crow Form&quot;. Does not need to be changed in most cases.
    
// Units:
    private constant integer Dummy_id = &#039;u001&#039;
    // Raw code of the dummy &quot;spinning&quot; unit used for the leap.
    private constant integer Treedummy_id = &#039;u000&#039;
    // Raw code of the dummy unit used to destroy trees.

// Others:
    private constant real Interval = 0.04   // Interval for periodic timer.
    private constant real Diff = 0.00       // Distance from cast point that the unit will land.
    private constant real Timescale = 3.00  // How fast the unit spins.
    private constant string End_anim = &quot;spell slam&quot;
    // End animation of the unit.
    private constant string Dirt_sfx = &quot;NewDirtEXNofire.mdx&quot;
    // Effect made at the end of the spell on land.
    private constant string Water_sfx = &quot;Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl&quot;
    // Same as above but for landing on water.
    private constant boolean Destroytrees = true
    // Whether or not to destroy trees.
    private constant boolean AllowPreload = true
    // Whether or not to allow preloading of the effects.
endglobals
//=======================================================================
private function Area takes integer lvl returns real
    return 225.00 // Area of effect for destroying trees.
endfunction

private function Airtime takes integer lvl returns real
    return 1.45-(0.15*lvl) // Air time of the leap.
endfunction
 

AlExAlExAlEx

Member
Reaction score
7
I see this evoluates very slow..and i still don't get it..some interactive help would be more usefull(like MSN) if someone want's to help a newb(not noob , noob = guy who dose'nt know something and dose'NT want to know , new = guy who dose'nt know something and WANTS to know) to PM me his MSN/Y!M id i would thank him.
---
Back to the forum help.
I clicked new spell but i can't make it , because the OK buton is off , if i click something from the list it will give the ability that things and..that is'nt want i want(i think).
http://i356.photobucket.com/albums/oo6/unnamed_007/Warcaft/ohnoes.jpg
So..still can't create the ability.
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Ugh, you shouldnt try to use JASS spells for now, since youve only used WE for 2 days

you should hardly make triggered spells, if you want my advice, start by making a maze or a td...

but if you really want to know, you have to create a spell, (you do have to select a base spell from the list) then set all its data to 0, like damage dealt, duration, etc. so it doesnt have an effect on its own. Then press Ctrl-D and replace the A000 in "private constant integer Abil_id = 'A000'" to the code you see where your newly created spell is

Then you have to create 2 units with no model, attack and move speed and once again, change u001 and u000 in
private constant integer Dummy_id = 'u001'
and
private constant integer Treedummy_id = 'u000'
to the raw codes of those 2 new units.
 

AlExAlExAlEx

Member
Reaction score
7
Maybe consider the MSN help thing ?
-----
1.I don't know what a maze is
2.I heard that TD are the last tipe that you sould do..because it uses very much triggers
3.I don't understand..i'l just give up..i don't really need this.
 

garion992

TH.net Regular
Reaction score
17
Do you want me to learn you to do the basic things with WE? a kinda classroom, i will ask you questions and you will answer?
You will learn faster with it then trying hard things at the beginning.
msn: <DELETED>
 

Lumograph090

New Member
Reaction score
22
Maybe consider the MSN help thing ?
-----
1.I don't know what a maze is
2.I heard that TD are the last tipe that you sould do..because it uses very much triggers
3.I don't understand..i'l just give up..i don't really need this.

Just start with simple GUI. I'm assuming you're a high school student, in which case you more than likely have Geometry or Algebra. A lot of simple GUI can be taken almost directly from Algebra in terms of If/Than/Else, X & Y. Etc.

Don't try and read the triggers as a line of code or what have you, but simply as a line of text, a sentence.

Events - a unit starts the effect of an ability

that for example could be taken in the idea of "Bob turned on his radio" (The radio turning on would be the event, the spell being cast)

Conditions - Ability being cast equal to Radio

(We know Bob turned on his radio, so the condition is met)

Actions - Back Street Boys singing

((after our event has taken place, the radio being turned on, and the condition being met (the radio was turned on - ability being cast equal to radio) we now get to enjoy the love that is Back Street Boys))
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
My best advice for someone starting with the editor is to avoid triggers. Took me a year of occasonall messing with it before I finally got it. The first thing you should get used to is the object editor. Its more complicated than the terrian editor but the results are much more fun. The first spell I can remember being proud of was a custom raise dead spell that raised ghouls. The ghouls had a raise dead spell, that raised more ghouls. The effect was hilarious.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top