[Solved] Struct instance not displayed properly

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
Hello and Good Evening,

I would like to ask someone to look over this short library here, where I am trying to use BPowers missile system, to create projectiles using a struct-like syntax.
What the following code should do, is create up to 3 bullets in a row and fire them with a short delay.

What it actually does, is create 3 missile structs, passes them to the timer, creates 3 tester peasants at 3 different locations, BUT:

only moves one visible bullet to one of these target locations. (?)

Sry I really do not see, what I am doing wrong.... Can someone help me?



JASS:
library VEN requires GM, Missile

globals
     [...]
     location LOC = Location( 0., 0.)
     Missile missile // reserves a struct reference for BPowers missile system
endglobals

private struct VendettaEx extends array
        // this extends BPowers missile system and manages vendetta bullets
       
        implement MissileStruct
    endstruct
   
   
private function FireProjectilesVendettaEx takes nothing returns nothing
        // this enables a vendetta weapon to send out delayed projectiles
        set t       = GetExpiredTimer()
        set missile = GetTimerData( t)
        call ReleaseTimer( t)
        set t       = null
        call VendettaEx.launch( missile)
        call BJDebugMsg("projectile fired: " +I2S(missile))
    endfunction
       
    public function VENDETTA_SHOOT takes unit u, integer wIndex, player p, integer projectiles, real wpX, real wpY, real targX, real targY returns nothing
        // this executes the actual shooting request after the ammo was checked 
        // !!! called by Vendetta_Abilities
        local integer i     = 1
        local real height   = 0.
        local real speed    = 0.
        local real damage   = 0.
        local real scale    = 0.
       
        set GM_VEN_REAL[wIndex+210] = 20. // store time out and this weapon as shooting
        call MoveLocation( LOC, targX, targY)
        set height          = GetLocationZ( LOC)
        set CURRENT_AMMO    = LoadInteger( GM_VEN_TABLE, GetHandleId( u), 1)
        // get current ammo type
        if CURRENT_AMMO == GM_ID_ITEM_VEN_AMMO_VEN_NORMAL then
            set s       = "war3mapImported\\Bullet.mdx"
            set speed   = 10.
            set damage  = 20.
            set scale   = 1.5
        [.. etc ..]
        endif
       
        call IssueImmediateOrder( u, "stop")
        call SetUnitAnimationByIndex( u, 2)
        call BJDebugMsg("weapon main")
       
        // shoot up to 3 projectiles of current ammo
        loop
            exitwhen i > projectiles
            set x                   = targX + GetRandomReal( -500., 500)
            set y                   = targY + GetRandomReal( -500., 500)
            call CreateUnit( Player(0), 'hpea', x, y, 0.)
            // amgle = Atan2( y - wpY, x - wpX)
            set missile             = Missile.create( wpX, wpY, 65., Atan2( y - wpY, x - wpX), HM_DistanceBetweenLoc( wpX, wpY, x, y), height)
            set missile.speed       = speed
            set missile.damage      = damage
            set missile.collision   = 32.
            set missile.model       = s
            set missile.scale       = scale
            set missile.source      = u
            set missile.owner       = p

            // shoot the projectiles with a tiny delay
            set t = NewTimerEx( missile)
            call TimerStart( t, 0.1 * I2R(i) , false, function FireProjectilesVendettaEx)
       
            // next projectile ?
            set s       = null
            set i       = i + 1
        endloop
       
        set s = null
    endfunction

endlibrary


thanks for reading this and best regards :)
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
oh god, I totally overlooked that stupid shitty s=null ....

well, IcemanBo, thank you so much! Sometimes, easy stuff is hard to see if one is too much in to the details.

This is solved thanks to you :)
 
Status
Not open for further replies.
Top