wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 03-09-2010, 07:50 PM   #1
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default [JASS] Trigger works only once

Ok, I guess the title says quite a lot already: In my map, the spell ( = the code ) can run only once, then it won't work anymore.
All that stuff like Jumping_Unit_A or udg_Real_Numbers or similar shouldn't interest you, those only make the spell work. The problem is reproducing it.

Please note that the trigger is not yet optimized, i want to get it working first.

Code:
Hidden information:

Trigger:
Collapse Ereignisse
Map initialization
Conditions
Collapse Aktionen
Set Real_Numbers[1] = 50.00 //those variables are just constants, unimportant for my problem.
Set Real_Numbers[2] = 100.00
Set Real_Numbers[3] = 150.00
Set Real_Numbers[4] = 900.00
Set Real_Numbers[5] = 0.01
Set Real_Numbers[6] = 100.00
Set Real_Numbers[7] = 150.00
Set Real_Numbers[8] = 200.00
Set Real_Numbers[9] = 250.00
Visibility - Disable black mask
Visibility - Disable fog of war
Game - Set the time of day to 12.00
Game - Turn the day/night cycle Off
Game - Display to (All players) the text: Welcome to my map: ...
Hashtable - Create a hashtable
Set Jump_Hashtable = (Last created hashtable)
Collapse Player group - Pick every player in (All players matching (((Matching player) slot status) Gleich Spielt)) and do (Actions)
Collapse Schleifen - Aktionen
Unit - Create 1 Klingenmeister for (Picked player) at (Center of (Playable map area)) facing Vorgabe für Gebäude-Ausrichtung degrees
Unit - Add Krähengestalt to (Last created unit)
Unit - Remove Krähengestalt from (Last created unit)
Collapse JASS:
function SR takes real r, integer i1, integer i2 returns nothing
 call SaveRealBJ(r, i1, i2, udg_Jump_Hashtable)
endfunction

function SL takes location l, integer i1, integer i2 returns nothing
 call SaveLocationHandleBJ( l, i1, i2, udg_Jump_Hashtable )
endfunction

function SU takes unit u, integer i1, integer i2 returns nothing
 call SaveUnitHandleBJ( u, i1, i2, udg_Jump_Hashtable )
endfunction


function LR takes integer i1, integer i2 returns real
 return LoadRealBJ(i1, i2, udg_Jump_Hashtable)
endfunction

function LL takes integer i1, integer i2 returns location
 return LoadLocationHandleBJ(i1, i2, udg_Jump_Hashtable)
endfunction 

function LU takes integer i1, integer i2 returns unit
 return LoadUnitHandleBJ(i1, i2, udg_Jump_Hashtable)
endfunction


function Jump takes nothing returns nothing
    local unit B
    local real R1
    local real R2
    local real R3
    local location L1
    local integer i = 1
    local integer j = 7
    local integer k = 1
    local timer t = GetExpiredTimer()

loop
    if LR(15,1) == 0.00 then
        call PauseTimer(t)
        call DestroyTimer(t)
        set t = null
        exitwhen true
    elseif i > R2I(LR(15,1)) then
        exitwhen true
    elseif LU(i,j) == null then
        set i = i+1
        set j = 7
    else
        set B = LU(i,j)
        set R1 = GetLocationX(GetUnitLoc(B)) - GetLocationX(LL(i, j-1))
        set R2 = GetLocationY(GetUnitLoc(B)) - GetLocationY(LL(i, j-1))
        if SquareRoot(R1*R1+R2*R2) >= LR(i, j-5) then
            call SetUnitFlyHeight( B, 0.00, 9000.00 )
            call SetUnitTimeScalePercent( B, 100.00 )
            call SetUnitAnimation( B, "stand" )
            call SetUnitPathing( B, true )
            set L1 = GetUnitLoc(B)
            set R1 = GetUnitFacing(B)
            set R2 = GetLocationX(L1) + 100.00 * Cos(R1 * bj_DEGTORAD)
            set R3 = GetLocationY(L1) + 100.00 * Sin(R1 * bj_DEGTORAD)
            call UnitDamagePoint(B, 0, 50.00, R2, R3, udg_Real_Numbers[( 6 + GetUnitAbilityLevel(B,'A000') )], true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            set L1 = null
            call PauseUnit(B, false)
            call SR(LR(15,1)-1.00,15,1)
            loop
                if LU(i, j+(k*7)) == null then
                    exitwhen true
                else
                    set k = k+1
                endif
            endloop
            if k == 1 then
                call SR(0.00, i, 1) //I know it's horrible...
                call SR(0.00, i, 2)
                call SR(0.00, i, 3)
                call SR(0.00, i, 4)
                call SR(0.00, i, 5)
                call SL(null, i, 6)
                call SU(null, i, 7)
            else
                call SR(LR(i, (k*7) - 6), i, 1)
                call SR(LR(i, (k*7) - 5), i, 2)
                call SR(LR(i, (k*7) - 4), i, 3)
                call SR(LR(i, (k*7) - 3), i, 4)
                call SR(LR(i, (k*7) - 2), i, 5)
                call SL(LL(i, (k*7) - 1), i, 6)
                call SU(LU(i, (k*7)    ), i, 7)
                call SR(0.00, i, (k*7) - 6)
                call SR(0.00, i, (k*7) - 5)
                call SR(0.00, i, (k*7) - 4)
                call SR(0.00, i, (k*7) - 3)
                call SR(0.00, i, (k*7) - 2)
                call SL(null, i, (k*7) - 1)
                call SU(null, i, (k*7)    )
            endif
        else
            set R1 = GetLocationX(GetUnitLoc(B)) + ( LR(i, j-6) * udg_Real_Numbers[5] ) * Cos(LR(i, j-2) * bj_DEGTORAD)
            set R2 = GetLocationY(GetUnitLoc(B)) + ( LR(i, j-6) * udg_Real_Numbers[5] ) * Sin(LR(i, j-2) * bj_DEGTORAD)
            set L1 = Location(R1,R2)
            call SetUnitPositionLoc( B, L1 )
            set R1 = GetLocationX(L1) - GetLocationX(LL(i, j-1))
            set R2 = GetLocationY(L1) - GetLocationY(LL(i, j-1))
            set R3 = SquareRoot(R1*R1 + R2*R2)
            call SetUnitFlyHeight( B, (LR(i, j-4)*Pow(R3, 2.00)+(LR(i, j-3)*R3) - (GetLocationZ(L1) - GetLocationZ(LL(i, j-1)))), 99999.00 )
            set L1 = null  
            set j = j+7
        endif
        set B = null      
    endif
endloop
endfunction

function Trig_Initalisation_Kopieren_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

/////////////////////////////////////////////////////////////////////////////////////////
////////////////all functions above this block are only to be called/////////////////////
/////////////////////////////////////////////////////////////////////////////////////////

function Trig_Initalisation_Kopieren_Actions takes nothing returns nothing

    local unit     Jumping_Unit        = GetSpellAbilityUnit()
    local player   Jumping_Unit_Owner  = GetOwningPlayer(Jumping_Unit)
    local integer  Player_Number       = GetPlayerId(Jumping_Unit_Owner)+1
    local location Jumping_Unit_Start  = GetUnitLoc(Jumping_Unit)
    local location Jumping_Unit_Aim
    local real     Jumping_Unit_MS
    local real     Jumping_Unit_Distance
    local real     Jumping_Unit_Height_Difference
    local real     Jumping_Unit_Angle
    local real     Jumping_Unit_A
    local real     Jumping_Unit_B

//Helpers
    local location L1
    local real R1
    local real R2
    local real R3
    local integer I = 1
    local timer t = CreateTimer()


    set L1 = GetUnitLoc(GetSpellTargetUnit())
    set R1 = bj_RADTODEG * Atan2(GetLocationY(Jumping_Unit_Start) - GetLocationY(L1), GetLocationX(Jumping_Unit_Start) - GetLocationX(L1))
     set Jumping_Unit_Angle = R1 + 180.00
    set R2 = GetLocationX(L1) + udg_Real_Numbers[6] * Cos(R1 * bj_DEGTORAD)
    set R3 = GetLocationY(L1) + udg_Real_Numbers[6] * Sin(R1 * bj_DEGTORAD)
     set Jumping_Unit_Aim = Location(R2,R3)
    set L1 = null
    set bj_lastCreatedUnit = CreateUnitAtLoc(Jumping_Unit_Owner, 'o000', Jumping_Unit_Aim, bj_UNIT_FACING)
    set L1 = GetUnitLoc(bj_lastCreatedUnit)
    set R1 = GetLocationX(L1) - GetLocationX(Jumping_Unit_Aim)
    set R2 = GetLocationY(L1) - GetLocationY(Jumping_Unit_Aim)
    set L1 = null

    if SquareRoot(R1*R1 + R2*R2) <= 5.00 then
        call RemoveUnit( bj_lastCreatedUnit )

        set Jumping_Unit_MS                = GetUnitMoveSpeed(Jumping_Unit) + udg_Real_Numbers[GetUnitAbilityLevel(Jumping_Unit, 'A000')]
            set R1 = GetLocationX(Jumping_Unit_Start) - GetLocationX(Jumping_Unit_Aim)
            set R2 = GetLocationY(Jumping_Unit_Start) - GetLocationY(Jumping_Unit_Aim)
            set R3 = SquareRoot(R2*R2 + R1*R1)
        set Jumping_Unit_Distance = R3
        set Jumping_Unit_Height_Difference = GetLocationZ(Jumping_Unit_Aim) - GetLocationZ(Jumping_Unit_Start)
        set Jumping_Unit_A                 = ( ( -0.50 * ( udg_Real_Numbers[4] * ( Jumping_Unit_Distance / Jumping_Unit_MS ) ) ) / Pow(Jumping_Unit_Distance, 2.00) )
        set Jumping_Unit_B                 = ( ( Jumping_Unit_Height_Difference + ( 0.50 * ( udg_Real_Numbers[4] * ( Jumping_Unit_Distance / Jumping_Unit_MS ) ) ) ) / Jumping_Unit_Distance )

        call PauseUnit(Jumping_Unit, true)
        call SetUnitTurnSpeed( Jumping_Unit, 1.00 )
        call SetUnitFacingTimed(Jumping_Unit, Jumping_Unit_Angle, 0)
        call SetUnitPathing( Jumping_Unit, false )
        call SetUnitTimeScalePercent( Jumping_Unit, ( ( 0.90 * ( Jumping_Unit_MS * 100.00 ) ) / Jumping_Unit_Distance )) 
        call SetUnitAnimation( Jumping_Unit, "Attack Slam" )
        call SR(LR(15,1)+1.00, 15, 1)


call DisplayTextToForce(GetPlayersAll(), "Springende Einheiten: "+I2S(R2I(LR(15,1))))

loop
if LU(Player_Number, I*7) == null then
call SR(Jumping_Unit_MS,       Player_Number, ((I-1)*7) + 1)
call SR(Jumping_Unit_Distance, Player_Number, ((I-1)*7) + 2)
call SR(Jumping_Unit_A,        Player_Number, ((I-1)*7) + 3)
call SR(Jumping_Unit_B,        Player_Number, ((I-1)*7) + 4)
call SR(Jumping_Unit_Angle,    Player_Number, ((I-1)*7) + 5)
call SL(Jumping_Unit_Start,    Player_Number, ((I-1)*7) + 6)
call SU(Jumping_Unit,          Player_Number, ((I-1)*7) + 7)
exitwhen true
else
set I = I+1
endif
endloop

        call TimerStart(t, udg_Real_Numbers[5], true, function Jump)
        set t = null
    else
        call RemoveUnit( bj_lastCreatedUnit )
        call DisplayTextToPlayer(Jumping_Unit_Owner, 0, 0, "|cFFFF0000The targeted location is not pathable.|r")
    endif

endfunction

function InitTrig_Initalisation takes nothing returns nothing
    set gg_trg_Initalisation = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Initalisation, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Initalisation, Condition( function Trig_Initalisation_Kopieren_Conditions ) )
    call TriggerAddAction( gg_trg_Initalisation, function Trig_Initalisation_Kopieren_Actions )
endfunction


if you want to have a closer look at the map as a whole, tell me so and i will upload it.
Rep will be given to anyone who can indeed help me.
oh yeah, and please don't spam me with advices to get vJASS.

Thank you for your time!
-Idontneedaname
__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 03-09-2010, 07:57 PM   #2
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Collapse JASS:
local location Jumping_Unit_Aim
...
set Jumping_Unit_Aim = Location(R2,R3)
Why?
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 03-09-2010, 09:15 PM   #3
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

that question is indeed vague...
why what?
__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Old 03-09-2010, 09:19 PM   #4
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

With changing the orders of the variable you can init all inside the local declaration.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 03-09-2010, 09:42 PM   #5
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

like this?

code

Collapse JASS:
    local location L1 = GetUnitLoc(GetSpellTargetUnit())
    local real R1     = bj_RADTODEG * Atan2(GetUnitY(GetSpellAbilityUnit()) - GetLocationY(L1), GetUnitX(GetSpellAbilityUnit()) - GetLocationX(L1))
    local real R2     = GetLocationX(L1) + udg_Real_Numbers[6] * Cos(R1 * bj_DEGTORAD)
    local real R3     = GetLocationY(L1) + udg_Real_Numbers[6] * Sin(R1 * bj_DEGTORAD)
    local integer I   = 1
    local timer t     = CreateTimer()
    
    
    local unit     Jumping_Unit        = GetSpellAbilityUnit()
    local player   Jumping_Unit_Owner  = GetOwningPlayer(Jumping_Unit)
    local integer  Player_Number       = GetPlayerId(Jumping_Unit_Owner)+1
    local location Jumping_Unit_Start  = GetUnitLoc(Jumping_Unit)
    local location Jumping_Unit_Aim    = Location(R2, R3)
    local real     Jumping_Unit_Angle  = R1 + 180
    local real     Jumping_Unit_MS
    local real     Jumping_Unit_Distance
    local real     Jumping_Unit_Height_Difference
    local real     Jumping_Unit_A
    local real     Jumping_Unit_B

__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Old 03-09-2010, 09:55 PM   #6
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

Exactly.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 03-09-2010, 10:15 PM   #7
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

Allright, imported into the original map.
Thank you so far; but actually this wasn't what i asked for ;)

edit: whatever, rep given. you helped me after all!
__________________

Thanks to Neonex for the idea.

Last edited by Idontneedaname : 03-09-2010 at 10:15 PM.
Idontneedaname is offline   Reply With Quote
Old 03-09-2010, 10:18 PM   #8
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

No need to give me rep for that.
I thought it could solve problems.

Anyway, I guess you should print the values and check differences.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Old 03-09-2010, 10:23 PM   #9
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

I think the error can be located quite easily by some experienced dudes, since this code (the variables, the parable, etc.) does actually work - but only once. Gonna try displaying the values, allright. Expect an answer tomorrow!
__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Old 03-09-2010, 11:00 PM   #10
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

Values get all stored correctly. Got to be something with the call
__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Old 03-11-2010, 12:27 PM   #11
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

*bump* - problem still not solved, I need help!
__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Old 03-11-2010, 01:28 PM   #12
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Sorry, but the way you write your spell makes it incredibly difficult to read. I don't see any obvious problems, I suspect it might be an issue with the data you store in the hashtable getting messed up but I have absolutely no intention of debugging that mess. It would help immensly if you coded your spells in vJass using structs.
__________________
Anitarf is offline   Reply With Quote
Old 03-11-2010, 01:45 PM   #13
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

Whoa. I added all those named variables before I requested help here and now it's not understandable.
Fail.
Would a shortened version help?

EDIT:
I think i can reduce the problem to this:
Collapse JASS:
function SU takes unit u, integer i1, integer i2 returns nothing
 call SaveUnitHandleBJ( u, i1, i2, udg_Jump_Hashtable )
endfunction

function LU takes integer i1, integer i2 returns unit
 return LoadUnitHandleBJ(i1, i2, udg_Jump_Hashtable)
endfunction

//....


        call SU(null, i, 7)
        call DisplayTextToForce(GetPlayersAll(), "|cff0000ff"+UnitId2StringBJ(GetUnitTypeId(LU(i,7) ) )+"|r")


this does still give a name, while it shouldn't
__________________

Thanks to Neonex for the idea.

Last edited by Idontneedaname : 03-11-2010 at 02:42 PM.
Idontneedaname is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 01:06 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services