HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Converting a spell to use xecollider ?!

08-23-2009, 11:18 AM#1
Komaqtion
Hi!

As I can't seem to get the help I want in my spell thread I thought I'd post here too :D

I've created this spell, which was working fine, though the mods here at wc3c wanted me to use xecollider for some stuff...

Basically the spell creates some explosions around the caster, then sends out "fireballs" arounds it, that crawl along the ground...
These deal dps, and when they reach a certain point, they create another explosion, and dissapear.
Here's the description:
A small description of the spell:
Description

The hero will create a series of explosion around himself, before letting out small "balls" of fire, tumbling and dealing damage to enemies they come across! As a finish, explosions will appear when the balls get destroyed.

Level 1 - 75 damage on first explosion, 20 damage per second at the fire balls and lastly, 100 damage on the final explosion.

Level 2 - 100 damage on first explosion, 40 damage per second at the fire balls and lastly, 150 damage on the final explosion.

Level 3 - 125 damage on first explosion, 60 damage per second at the fire balls and lastly, 200 damage on the final explosion.



And here's the first, working code (Without xe...):
Expand Tormental Wrath:

Though, as i said, I wanted to implement xe into this :S

Though I have no idea how it works, as this is my first vJASS spell ever, and I haven't looked into xe before :S

So, here's my "tried-to-implement-xecollider-script":
Expand JASS:

Though, I getting tons of errors, and as soon as I fix one of them, more appear :(

My current error is "Syntax Error" on this line:
Collapse JASS:
        set S[i].collisionSize=(Range_Small())
        set S[i].setTargetPoint(xu+I2R(DISTANCE)*Cos(I2R(i*(360/(ANGLES)))*bj_DEGTORAD),yu+I2R(DISTANCE)*Sin(I2R(i*(360/(ANGLES)))*bj_DEGTORAD))
        set i = i+1

Any ideas ? :S
Attached Files
File type: w3xFirst Spell by Komaqtion! TU.w3x (95.5 KB)
08-23-2009, 12:23 PM#2
Anitarf
call, not set.

Ayway, I wouldn't use .setTargetPoint for this, I would simply give the xecollider a starting speed (set S[i].speed = SLIDE_SPEED), direction (set S[i].direction = i*2*bj_PI/ANGLES) and duration (set S[i].expirationTime = TIME) and then let it go.

Now that I look at your code, it's fairly complicated and there are plenty of confusing things happening (for example, why call GroupRefresh before a GroupEnum? That does nothing.), it might be easier to start from scratch than editing it.
08-23-2009, 12:31 PM#3
Komaqtion
Ok :(

EDIT: This seems to work, but I have not idea what to put in there :S

Collapse JASS:
    static method create takes unit u returns Data
        local Data d = Data.allocate(1.,1.,1.)
        set d.caster = u
        set d.owner = GetOwningPlayer(d.caster)
        return d
    endmethod
I now know it's a real (As the "create" method in xecollider takes 3 reals, so I checked there) but what would make sense to put in there ? :S

EDIT: Here's my current code...
Expand JASS:

Right now, the fx's are created, but only 1 of them moves... The other ones are destroyed right after creation :(

And also, I still don't know what to put in the local Data d = Data.allocate(1.,1.,1.) line :S

Btw, how would I go about to use the onUnitHit method ? :S
08-24-2009, 12:38 PM#4
Komaqtion
Bump !

C'mon ! :D
Please help, I really need this, and for further work too :D
08-24-2009, 01:01 PM#5
Anitarf
Wel, for starters, the spell is fairly complicated, I still don't know how exactly it's supposed to work. In it's most simple form (just launching a bunch of projectiles outwards in a circle), all you need is one xecollider-extending struct of which you create N instances when the spell is cast.

Collapse JASS:
private struct Projectile extends xecollider
    unit caster // You will probably need this unit when dealing damage.

    method onUnitHit takes unit hitTarget returns nothing
        // The code you write here will run whenever the projectile hits a unit.
    endmethod

    method onDestroy takes nothing returns nothing
        // Do the end explosions stuff here.
    endmethod
endstruct

private function onSpellCast takes nothing returns nothing
    local integer i=0
    local unit caster=GetTriggerUnit()
    local real x=GetUnitX(caster)
    local real y=GetUnitY(caster)
    local real a=GetUnitFacing(caster)*bj_DEGTORAD //Facing angle in radians.
    local Projectile p
    loop
        exitwhen i>=PROJECTILE_COUNT
        set p=Projectile.create(x,y,a)
        set p.caster=caster
        set p.direction=a
        set p.speed=SLIDE_SPEED
        set p.expirationTime=TIME
        set a=a+(2*bj_PI/PROJECTILE_COUNT)
        set i=i+1
    endloop
endfunction
08-24-2009, 01:42 PM#6
Komaqtion
Ok...

So this is the current code... But now absolutely nothing happens :(

Expand JASS:
08-24-2009, 01:50 PM#7
Anitarf
Collapse JASS:
set d = Data.create(d.cx, d.cy, a)
d is not initialized at this point yet, so your thread crashes, which any debug message placed after that line would show. What you want to use there are the x and y values.
08-24-2009, 01:53 PM#8
Komaqtion
Thanks :D

Just one more question... How would I go about changing this to be the same angles as the colliders ? :S

(It's for the explosions a bit "nearer" the caster :D)

Collapse JASS:
        set dx = xu+EXPLOSION_OFFSET*Cos(I2R(i*(360/(ANGLES)))*bj_DEGTORAD)
        set dy = yu+EXPLOSION_OFFSET*Sin(I2R(i*(360/(ANGLES)))*bj_DEGTORAD)
08-24-2009, 11:47 PM#9
Anitarf
Quote:
Just one more question... How would I go about changing this to be the same angles as the colliders ? :S
You already had it that way in your previous code, oh, except you forgot Cos and Sin.
Collapse JASS:
        set x2 = x+EXPLOSION_OFFSET*Cos(a)
        set y2 = y+EXPLOSION_OFFSET*Sin(a)
08-25-2009, 06:07 AM#10
Komaqtion
Ok then :D Thanks !!!

Just 1 more question... The projectiles no longer deal damage :(
And this debug msg doesn't show :( ("Should dmg!")
How would I go about making it damage all units near it ? :S
Because it seems that this doesn't work:
Collapse JASS:
    method onUnitHit takes unit hitTarget returns nothing
        //call BJDebugMsg("Might dmg!")
        if hitTarget != .cast and IsUnitAlly(hitTarget, .play) and GetUnitTypeId(hitTarget) != XE_DUMMY_UNITID then
            call UnitDamageTarget(.cast, hitTarget, Damage_Small(.lvl), true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
            call GroupAddUnit(.grp,hitTarget)
            call GroupRemoveUnit(Temp,hitTarget)
            call BJDebugMsg("Should dmg!")
        endif
    endmethod
08-25-2009, 12:53 PM#11
0zyx0
IsUnitAlly()? Should the spell only do damage to allied units? If not, that's where your problem is.
08-25-2009, 01:12 PM#12
Komaqtion
Yeah XD Noticed that now XD It's supposed to be IsUnitAlly(hitTarget,.cast) != true XD

EDIT: Ok... Think this is the final product !
Take a look, and see if there's something which can be improved ? :o
I used the loopControl method from xecollider to do the periodic damage for the projectiles, and works great now :D

Please, any notes and suggestions are very welcome !! Otherwise I'll submit this :D:D

Expand JASS:
08-26-2009, 01:39 PM#13
Komaqtion
BumP :P
08-26-2009, 02:52 PM#14
Anitarf
This is more an issue with the spell design than spell code, but I find it much more intuitive when spell projectiles deal their damage once when they hit a unit, instead of dealing damage over time as long as they are in contact with the unit. That way, the player has a much better idea of how much damage the spell will actually do.
08-26-2009, 03:02 PM#15
0zyx0
*In the documentation, you don't have to explain how to setup xebasic, you can assume people have already done that.
*Get rid of the INTERVAL constant.
*TIME/INTERVAL * TIME is always equal to time.
*You could use xedamage to deal damage. Don't worry, it is not as hard as using xecollider. Just create one xedamage at map initialization and use it when needed.