HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

strange problem

02-19-2006, 05:01 AM#1
Linera
I finished typing my functions in the custom map script:
Collapse JASS:
//Item Table Functions
function RanDistReset takes nothing returns nothing
    set udg_randDistCount = 0
endfunction

function RanDistAddItem takes integer inID, real inChance returns nothing
    set udg_randDistID[udg_randDistCount] = inID
    set udg_randDistChance[udg_randDistCount] = inChance
    set udg_randDistCount = udg_randDistCount + 1
endfunction

function RanDistChoose takes nothing returns integer
    local real sum = 0
    local real chance = 0
    local integer index
    local integer foundID = -1
    local boolean done

    // No items?
    if (udg_randDistCount == 0) then
        return -1
    endif

    // Find sum of all chances
    set index = 0
    loop
        set sum = sum + udg_randDistChance[index]

        set index = index + 1
        exitwhen index == udg_randDistCount
    endloop

    // Choose random number within the total range
    set chance = GetRandomReal(0.01, sum)

    // Find ID which corresponds to this chance
    set index = 0
    set sum = 0
    set done = false
    loop
        set sum = sum + udg_randDistChance[index]

        if (chance <= sum) then
            set foundID = udg_randDistID[index]
            set done = true
        endif

        set index = index + 1
        if (index == udg_randDistCount) then
            set done = true
        endif

        exitwhen done == true
    endloop

    return foundID
endfunction

//Drop Tables
function Drop_Table_0001 takes nothing returns integer
local integer itemID = 0

        call RanDistReset(  )
        call RanDistAddItem( 'I000', 0.39 )
        call RanDistAddItem( 'I001', 0.03 )
        call RanDistAddItem( 'I002', 0.06 )
        call RanDistAddItem( 'I003', 0.06 )
        call RanDistAddItem( 'I004', 0.06 )
        call RanDistAddItem( 'I005', 0.03 )
        call RanDistAddItem( 'I006', 0.03 )
        call RanDistAddItem( 'I007', 0.03 )
        call RanDistAddItem( 'I008', 12.41 )
        call RanDistAddItem( 'I009', 2.21 )
        call RanDistAddItem( 'I00A', 0.49 )
        call RanDistAddItem( -1, 77 )
        set itemID = RanDistChoose(  )
return itemID
endfunction

None of the following triggers will not run(which is all of my triggers):
Collapse JASS:
function Trig_Dreadlord_dies_Copy_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetDyingUnit()) == 'H000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Dreadlord_dies_Copy_Actions takes nothing returns nothing
    local integer itemID = 0

    call CreateNUnitsAtLoc( 1, 'h001', GetOwningPlayer(GetKillingUnitBJ()), GetUnitLoc(GetDyingUnit()), bj_UNIT_FACING )
    set udg_tempunit = GetLastCreatedUnit()
    call UnitApplyTimedLifeBJ( 60, 'BTLF', udg_tempunit )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 6
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set itemID = Drop_Table_0001()
        call UnitAddItemByIdSwapped(itemID, udg_tempunit )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Dreadlord_dies_Copy takes nothing returns nothing
    set gg_trg_Dreadlord_dies_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dreadlord_dies_Copy, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Dreadlord_dies_Copy, Condition( function Trig_Dreadlord_dies_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Dreadlord_dies_Copy, function Trig_Dreadlord_dies_Copy_Actions )
endfunction
Trigger:
hero
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 11, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Collapse And - All (Conditions) are true
Collapse Conditions
((Player((Integer A))) controller) Equal to User
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Unit - Create 1 Dark Ranger for (Player((Integer A))) at (Center of (Playable map area)) facing Default building facing degrees
Hero - Set (Last created unit) Hero-level to 3000, Hide level-up graphics
Collapse Else - Actions
Do nothing
Trigger:
hero dies
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Unit-type of (Dying unit)) Equal to Dark Ranger
Collapse Actions
Hero - Instantly revive (Dying unit) at (Center of (Playable map area)), Show revival graphics
Trigger:
show map
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 11, do (Actions)
Collapse Loop - Actions
Visibility - Create an initially Enabled visibility modifier for (Player((Integer A))) emitting Visibility across (Playable map area)
Trigger:
random spawn
Collapse Events
Time - Every 5.00 seconds of game time
Conditions
Collapse Actions
Unit - Create 1 Demon for Neutral Hostile at (Random point in (Playable map area)) facing Default building facing degrees
Cinematic - Ping minimap for (All players) at (Position of (Last created unit)) for 1.00 seconds

Why won't my triggers run?
02-19-2006, 08:48 AM#2
Jacek
Your JASS triggers look like 100% conversion from GUI. How does exactly they doesn't run? random spawn trigger looks ok so should run.
02-19-2006, 05:46 PM#3
Linera
my triggers won't run at all, like they're not even there.
02-19-2006, 05:56 PM#4
Vexorian
sympthons sound as if something was causing the main thread to crash.

but well you can just use these BJ functions:

Collapse JASS:
//===========================================================================
function RandomDistReset takes nothing returns nothing
    set bj_randDistCount = 0
endfunction

//===========================================================================
function RandomDistAddItem takes integer inID, integer inChance returns nothing
    set bj_randDistID[bj_randDistCount] = inID
    set bj_randDistChance[bj_randDistCount] = inChance
    set bj_randDistCount = bj_randDistCount + 1
endfunction

//===========================================================================
function RandomDistChoose takes nothing returns integer
    local integer sum = 0
    local integer chance = 0
    local integer index
    local integer foundID = -1
    local boolean done

    // No items?
    if (bj_randDistCount == 0) then
        return -1
    endif

    // Find sum of all chances
    set index = 0
    loop
        set sum = sum + bj_randDistChance[index]

        set index = index + 1
        exitwhen index == bj_randDistCount
    endloop

    // Choose random number within the total range
    set chance = GetRandomInt(1, sum)

    // Find ID which corresponds to this chance
    set index = 0
    set sum = 0
    set done = false
    loop
        set sum = sum + bj_randDistChance[index]

        if (chance <= sum) then
            set foundID = bj_randDistID[index]
            set done = true
        endif

        set index = index + 1
        if (index == bj_randDistCount) then
            set done = true
        endif

        exitwhen done == true
    endloop

    return foundID
endfunction


Anyways check if you don't have arrays set to have a huge index number for initial values
02-19-2006, 06:39 PM#5
Linera
i think the problem is in my globals
i have 2 globals set at array of 8000

And i can't use those functions as randomadditem uses a integer and i need real
02-19-2006, 07:57 PM#6
Vexorian
Hmn well I don't think it should be a huge problem.

Instead of 80.3 and 12.4 of weights you can use 803 and 124.

But well Why do you initialize those arrays to 8000 values? You are aware that the size thing the variable editor is talking about is bullcrap and it actually refers to initializing of indexes?

Cause all arrays are always of a limit of 8192
02-19-2006, 08:09 PM#7
Linera
I dropped the 2 arrays down to 500 each and now my triggers work fine.