HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Isn't working for some unkown reason, as usual

07-20-2009, 06:07 PM#1
Wizardum
Hello!

I'm creating a simple damage over time system in vJass for practice reasons, but it worked out quite badly.

What happens is that I know the data are stored in the struct array, but after that nothing else happens, no damage, no effects, no nothing.

I have to say, everytime I work on something they never work for the first time, but this is becoming annoying as I can never find the malfunction reason.

anyway here is the code:

Expand DOT code:

I hope someone here can help me.

Thanks in advance!
07-20-2009, 06:13 PM#2
chobibo
Collapse error:
local integer i
i is uninitialized, it causes the function to crash.
07-20-2009, 06:17 PM#3
Wizardum
omg I can't believe it's because of that. Problem solved.
Anyway I didn't knew about that, and I actually learned something.

I'm really appreciated. Here's one cookie
07-21-2009, 08:14 AM#4
Wizardum
and because I don't want to create another topic, now my new spell doesn't work as it should.
It creates missiles in front of the caster across 180 degrees of the target point of the ability which then will move forward at a certain speed damaging units as they touch the missiles.

The thing is, something is messing up the speed values.
The missiles should stop when the variable d.countdis is greater than the variable d.dis ( the max distance ) and so every interval time it increments the d.countdis with the speed value. This works okay, but when I do this:
Collapse Moving part:
set x = GetUnitX( d.moved ) + ( d.speed ) * Cos( d.angle * bj_DEGTORAD )
set y = GetUnitY( d.moved ) + ( d.speed ) * Sin( d.angle * bj_DEGTORAD )
call BJDebugMsg( R2S( d.speed ) )
and call the debug message it returns a huge value. Instead of returning 10., the default speed, it returns 210.

here is the whole code:

Expand Fuuton:

Thanks in advance!
07-21-2009, 09:21 AM#5
chobibo
Try restarting the Editor, I didn't see anything overwriting the speed and d.speed parameter. Still searching the code...
07-21-2009, 09:29 AM#6
Wizardum
restarted and still doesn't work

I can post the map here if you want, don't know if it will serve as anything though
07-21-2009, 09:38 AM#7
chobibo
It's ok if you can post the map, It'll be a lot easier for me to debug it.
07-21-2009, 09:41 AM#8
Wizardum
here it is then. It's the Fuuton Atsugai trigger.

If you have the time could you see the other spell Raiton Gian? it is screwed up as well, angles are wrong when casting, takes a few seconds to unpause the unit when it should be instantly, and only works once, when I try to cast it again it doesn't work.
Attached Files
File type: w3x[vJASS] Raiton Gian.w3x (65.6 KB)
07-21-2009, 09:51 AM#9
Patpup
ok, seems like you redeclared the variables "speed" and "radius" (once as constants once as locals in the create-method). if you rename the locals the create-method takes it should work.
No idea why newgen does not find that mistake, looks like a bug to me.
07-21-2009, 10:05 AM#10
chobibo
Fuuton Atsugai's problem came from the conflicting variable names in your struct and on your globals

Expand variable name conflict:

By converting the global variable name to uppercase, I made the spell work. Here:
Expand quick fix:

Don't use identical identifiers\variable names as it causes conflicts to the code.

EDIT: Patpup is right, I forgot to mention the locals.
07-21-2009, 10:13 AM#11
Patpup
Quote:
Originally Posted by chobibo
Fuuton Atsugai's problem came from the conflicting variable names in your struct and on your globals
[/jass]

I'm afraid you are slightly off there. You probably changed the speed-constants name to determine that - doing that solves the problem. But in fact constant- and member-names do not conflict because members are allways called as this.membername (i.e this.speed).

The problem has something to do with "speed" in the create-method precompiling to "libraryname_speed". I have no idea why that should cause the value to be 210, which is the radius constant (that one has a conflict as well), though...


Edit: you edited faster than me! high-five! ;)
btw: chobibo is right - you should not have constants and struct-members with identical names. It DOES work but its bound to cause horrible, possibly hard to find typo-errors. i.e. if you forget a "." somewhere...
07-21-2009, 10:36 AM#12
Wizardum
nice! learned another thing, didn't knew they would conflict with each other. Thanks a lot!!

I was kinda stupid setting constant globals and then store them in the struct. Now it works perfectly.

Anyway, could any of you check the other trigger please? Raiton Gian?
07-21-2009, 10:51 AM#13
Patpup
Ok, same problem as before, you are using a local variable not initialized. Its the "loop"-function:
Collapse JASS:
private function Loop takes nothing returns nothing
    local Data d
    local integer i = 0
    local integer i2 = 1
    local real array x
    local real array y
    local real array a
    local player p
    local group g = CreateGroup( )
    local unit u

    loop
        exitwhen i >= Total
        set d = dat[i]
        if d.dis >= d.maxdis then
     // >>      set p = GetOwningPlayer( d.source )    << Add this to make it work (in case thats what you inteded "p" to be)
            loop
                set u = FirstOfGroup( dummies )
                exitwhen u == null
                call GroupRemoveUnit( dummies, u )
                if GetOwningPlayer( u ) == p then
                    call RemoveUnit( u )
                endif
            endloop
            call BJDebugMsg( "Dummy removal works" )
//(...)
            endif
        else
//(...)

Without initializing "p" the loop dies as soon as d.dis reaches d.maxdis because it cant compare "GetOwningPlayer(u)" and "p". Once the last unit has been removed from "dummies", however, the function moves on and unpauses the "source"-unit. Thats what causes the delay.

Hope that helps! Got to get back to my own map now ;))

Btw, some things about the movement of those lightning-effects in "RaitonGian":

I can only guess what they are supposed to do, but you got one easy-to-miss typo in there anyways:
Collapse JASS:
set x[0] = GetUnitX( d.source )
            set y[0] = GetUnitY( d.source )
            set x[1] = x[0] + d.dis * Cos( d.a2 * bj_DEGTORAD )
            set y[1] = y[0] + d.dis * Sin( d.a2 * bj_DEGTORAD )
            set x[2] = x[0] + d.dis * Cos( d.a3 * bj_DEGTORAD )
            set y[2] = x[0] + d.dis * Sin( d.a3 * bj_DEGTORAD )

Have a close look at that last line. Hint: He's a girl...(horrible pun)

Furthermore, I guess the effects are supposed to move towards the direction the spell was cast. If thats the case then here is your problem:
Collapse JASS:
            if d.interval >= intervalcheck then
                set d.a2 = GetRandomReal( 0., -45. )
                set d.a3 = GetRandomReal( 0., 45. )
            endif

This means the angles "d.a2" and "d.a3" have no relation whatever to the angle the spell was cast at ("d.angle").
So it should be:
Collapse JASS:
            if d.interval >= intervalcheck then
                set d.a2 = d.angle + GetRandomReal( 0., -45. )
                set d.a3 = d.angle + GetRandomReal( 0., 45. )
            endif

That should fix it. Godspeed.
07-21-2009, 11:22 AM#14
Wizardum
yap it really helped me. Thanks! I hope some day I can return the favor since I can't +rep you anytime soon.

Good luck for your map then.
07-21-2009, 11:47 AM#15
Patpup
You don't have to! I'm really just using this as an excuse to take a break from my own stuff lol (which has more bugs than your regular rainforest it seems). And it kinda pushes your confidence to actually FIND and CORRECT some mistakes, haha.

Anyway I'd like someone more gifted then me to have a look at the problem in that first spell. because I have absolutely no idea why that ".speed"-member got the "radius"-constants value (210) instead of the "speed"-constants (which noone would have noticed because it was 10 as well)...


Good luck to you as well!