• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Could someone help me with making a spell

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hello there.

I'm trying to make a pretty advanced spell for someone like me.
I don't have much JASS experience and knowledge, but I just have this spell on my mind for so long that I have to make it for my map.

Is there anyone out there that could make this for me, so I can continue with it and finish it how I want? Or is there someone that could give me some tips about the things described below?
Would be appreciated!

This is what I want:

I want to create ( 1 + Number of units in targeted area ) dummy units.
Those dummy units have to start at the ground but increase to 150 height over 1.5 seconds.
One of the dummy units will just stay at that spot and have a special effect attached.
The other dummies will have to connect Aerial Shackles effect to the units in the targeted area. (Can this be done with effects, or do I have to let them cast an ability?) (This so that every dummy unit picks one target so that there are several chains comming out of the center of where the dummies are)


Don't worry about the looks of the dummy unit or the special effects.
I just want to know how to change the height basically, since that's the issue I'm having right now. I also don't have much experience with timers, so making a timer for 1.5 seconds with something like a 0.05 interval to change height of the units is a bit hard for me. Because I don't know how to change this height and if it's possible to change with such a short timer. Ah yeah and not to forget. Most important of all. How can I add the Aerial Shackles ray between two units? Does it last while one of the units is getting increased height?
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
You may not need dummy units, the effect you described , I think, can be done with lightning using Arial Shackles lightning model. All we have to do is set the (x,y,z) of the points.

I see. That would be perfect.
Could you give me an example of functions I will have to use for that?

And I wanted to put one dummy unit in the middle that looks like a spell effect so the effect raises in height. I suppose this won't work without that dummy unit right? Because you can't move effects?
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
No, you can't move effects but you can move lightning.

Anyway, I will give you the function you need tomorrow, its 2:21 AM. Have to sleep.

But for now you could use the function
JASS:
native AddLightningEx takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning
And
JASS:
native MoveLightningEx takes lightning whichBolt, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns boolean
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Thanks alot.

As for the sleeping part: I guess I'll go do that too;-)

Been experimenting a bit.
What does the 'rate' mean in SetUnitFlyHeight(unit, real height, real rate)?
 
Last edited:
Level 16
Joined
Mar 3, 2006
Messages
1,564
Ok, this is what I understand from you description, you want something like that:


126172-albums1967-picture57846.jpg

 
Level 19
Joined
Oct 12, 2007
Messages
1,821
How quickly the flying height changes.

500 height at 500 rate would make the unit take 1 500/500 = 1 second to get to 500 height.

500 height at 200 rate would make the unit take 1 500/200 = 2,5 seconds to get to 500 height.

So hmm. I was planning to make a 0.05 interval timer to change the height of the unit every 0.05 seconds until 1.5sec has passed. I don't have to do this and I can just set the rate to 100 to make it increase height by 150 over 1.5 seconds??? Isn't this too easy to be true haha:D


@Starq:
I can't see your picture:(
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Saw the picture now.
But I want it like this basically:
The picture is in side view.

Green dot = the spot you cast the spell on.
The red dot is the dummy unit with a special effect attached. This red dot lifts from the cast spot in the air for the first 1.5 seconds.

The orange rays are the lightning effects coming out of that dummy unit towards all units within X range. It is important that while the red dot is lifting (the first 1.5 seconds) the lightning rays also lift with him so that they keep coming out of the center of that dummy unit.
 

Attachments

  • paint.jpg
    paint.jpg
    5.7 KB · Views: 80
Level 19
Joined
Oct 12, 2007
Messages
1,821
The normal units are always on the ground and are not affected by anything but visual stuff like the lightning.
See it like this. There is a big fiery orb in the middle (the dummy unit with a fiery missile special effect atteched) and out of that orb aerial shackles lightning spawns and gets attached to nearby units. But when that orb spawns it takes 1.5 seconds till it reaches its highest point. So the lightning source (that orb) has to increase to that height aswell. The lightning targets (the units on the ground) keep moving with the units.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
You know what.
I show you what I've got so far.
This is the effect of the spell without the visual effects.

Ah and here is a better explanation of the spell idea:

[Flame Shackles]
Summons a fiery orb at the center of the area that grabs units in the area (and units that enter the area as long as the orb lasts) and drags the units towards the center. The strength of the dragging depends on the distance between the unit and the center. At the last 0.5 seconds the shackles will increase drag strength and drag all units to the center to explode; dealing Int*1.2 fire damage to units in the area.
If units stand in the center of the area they won't be dragged so they can still cast spells or attack. And it should be that if a unit wants, he can blink out of the area to escape.. Or some units with really fast movement speed can slowly move out of it...
See it as some sort of quicksand.:)

JASS:
scope FlameShackles initializer init

private struct Data
unit caster
real x
real y
real tempx
real tempy
real speed

real duration
real dmg

static integer array Ar
static integer Total = 0
static timer Time = CreateTimer()
static group g = CreateGroup()
static unit u
static unit dummy

    static method create takes unit u, real x, real y returns Data
        local Data Dat = Data.allocate()
        local integer id = GetPlayerId(GetOwningPlayer(u))
        
        set Dat.caster = u
        set Dat.x = x
        set Dat.y = y
        set Dat.speed = 1.
        set Dat.duration = 5.5
        set Dat.dmg = (GetHeroInt(u, true)*1.2)
        set Dat.dummy = CreateUnit(GetOwningPlayer(u), 'dumm', Dat.x, Dat.y, 0.)

        call AddHeath(GetOwningPlayer(Dat.caster),5) ///This is not important
        call UnitAddAbility(Dat.dummy,'A0KN') ///This is an aura ability so I can see if the dummy is summoned or not

        if Dat.Total == 0 then
            call TimerStart(Dat.Time,0.05,true,function Data.Loop)
        endif
        
        set Dat.Ar[Dat.Total] = Dat
        set Dat.Total = Dat.Total + 1
        
        return Dat
    endmethod
    
    static method Loop takes nothing returns nothing
        local Data Dat
        local integer i = 0
        
        loop
            exitwhen i >= Dat.Total
            set Dat = Dat.Ar[i]
            
            set Dat.duration = Dat.duration - 0.05
            

            call SetUnitFlyHeight(Dat.dummy, 200., 133.33)
            
            //This increases the strength of the pull during the last 0.5 sec//
            if Dat.duration < 0.5 then
                set Dat.speed = Dat.speed + 0.05
            endif
                            
            call GroupEnumUnitsInRange(Dat.g,Dat.x,Dat.y,300.,BOOLEXPR_TRUE)
            
            if Dat.duration <= 0. then
                call DestroyEffect(AddSpecialEffect("war3mapImported\\FlameBomb.mdx",Dat.x,Dat.y))
                call RemoveUnit(Dat.dummy)
                loop
                    set Dat.u = FirstOfGroup(Dat.g)
                    exitwhen Dat.u == null
                    call GroupRemoveUnit(Dat.g,Dat.u)
                    if GetUnitAbilityLevel(Dat.u,'B01M') > 0 then
                        set Dat.dmg = Dat.dmg * 1.2
                    endif
                    call UnitDamageTargetEx(Dat.caster, Dat.u,Dat.dmg , ATTACK_TYPE_MAGIC, DAMAGE_TYPE_SPELLFIRE, false)
                endloop
            endif
            
            loop
                set Dat.u = FirstOfGroup(Dat.g)
                exitwhen Dat.u == null
                call GroupRemoveUnit(Dat.g,Dat.u)
                ///Movement Effect///
                if IsUnitEnemy(Dat.u,GetOwningPlayer(Dat.caster)) and GetWidgetLife(Dat.u) >= .405 and DBPXY(GetUnitX(Dat.u),GetUnitY(Dat.u),Dat.x,Dat.y) < 400. then
                    if DBPXY(GetUnitX(Dat.u),GetUnitY(Dat.u),Dat.x,Dat.y) > 125. then ///DBPXY is a function that checks the Distance Between Points
                        if Dat.x > GetUnitX(Dat.u) then
                            set Dat.tempx = (GetUnitX(Dat.u) + ((150. + DBPXY(GetUnitX(Dat.u),GetUnitY(Dat.u),Dat.x,Dat.y)) / (17.5 * Dat.speed)))
                        else
                            set Dat.tempx = (GetUnitX(Dat.u) - ((150. + DBPXY(GetUnitX(Dat.u),GetUnitY(Dat.u),Dat.x,Dat.y)) / (17.5 * Dat.speed)))
                        endif
                        if Dat.y > GetUnitY(Dat.u) then
                            set Dat.tempy = (GetUnitY(Dat.u) + ((150. + DBPXY(GetUnitX(Dat.u),GetUnitY(Dat.u),Dat.x,Dat.y)) / (17.5 * Dat.speed)))
                        else
                            set Dat.tempy = (GetUnitY(Dat.u) - ((150. + DBPXY(GetUnitX(Dat.u),GetUnitY(Dat.u),Dat.x,Dat.y)) / (17.5 * Dat.speed)))
                        endif
                        call SetUnitPosition(Dat.u, Dat.tempx, Dat.tempy)
                    endif
                endif
            endloop
                
            set Dat.Total = Dat.Total - 1
            set Dat.Ar[i] = Dat.Ar[Dat.Total]
            set i = i - 1
            call Dat.destroy()
            
            set i = i + 1
        endloop
        
        if Dat.Total == 0 then
            call PauseTimer(Dat.Time)
        endif
        
    endmethod
    
endstruct

private function OnCast takes nothing returns boolean
    local Data Dat
    local unit u
    
    if GetSpellAbilityId()=='A0KO' then
        set u = GetTriggerUnit()
        set Dat = Data.create(u,GetSpellTargetX(),GetSpellTargetY())
        set u = null
    endif
    
    return false
endfunction

private function init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    
    call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig, Condition( function OnCast))

    set trig = null
endfunction
endscope

At this moment I'm able to save without errors.
The only thing that happens when I use the spell is that the dummy unit gets summoned.
But he doesn't get removed and I'm not sure if he gains height (can't see him. I added devotion aura to him so I see my unit getting the aura buff)
 
Last edited:
Level 19
Joined
Oct 12, 2007
Messages
1,821
I'm not a very good coder myself.
RaiN. used to make spells for my map.
But since he's inactive I just copy the spells he made and change them a littlebit.
I copied a spell that looks a littlebit like it and changed some things.
Just didn't work out that great on this one.:(

EDIT: found one mistake, but it doesn't fix anything. Just a typo
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
If you can check the code I made and tell me why it's not working I can pretty much finish it myself I think. It's just that the code doesn't seem to work when I use the spell and I don't know why. All it does is summon a dummy unit, but it doesn't seem to move units around.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
I was starting it from scratch so I didn't look at the one you post. So you only need to fix this ?

Well the values in my post are all right already.
It might cost you less effort to just fix mine instead of starting over.
But if you think the way I handle some things is stupid, feel free to change it or start over.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Well the values in my post are all right already.
It might cost you less effort to just fix mine instead of starting over.
But if you think the way I handle some things is stupid, feel free to change it or start over.

No, its not stupidity or anything like that; the problem is that I don't know what was on the mind of the one how wrote the script. So I don't know where to start, perhaps because everyone has his own style in writing the script.

Anyway, it is always good to look at other people work.

Are you in hurry to get the finished spell ?
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
No, its not stupidity or anything like that; the problem is that I don't know what was on the mind of the one how wrote the script. So I don't know where to start, perhaps because everyone has his own style in writing the script.

Anyway, it is always good to look at other people work.

Are you in hurry to get the finished spell ?

Nah I'm not in a hurry or anything.
 
Status
Not open for further replies.
Top