• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Posts moved from FP's tutorial thingy

Status
Not open for further replies.
I didn't get the problem with your first code, I am in a hurry xD
ABout your second code:

Try removing this before the loop:
JASS:
set debug_unit = FirstOfGroup( victims )

and change the loop to:
JASS:
       loop
            set debug_unit = FirstOfGroup( victims )
            exitwhen debug_unit == null
            call GroupRemoveUnit( victims, debug_unit )
            set debug_int = debug_int + 1
        endloop
 
Level 10
Joined
Aug 19, 2008
Messages
491
I actually made a whole lot of experiments on the second problem.
My conclusion is that wc3 don't allow you to post more than 2 messages (BJDebugMsg() or DisplayTextToForce()) without a long pause between them.
I'm not sure why, but when I switched places with them only the 2 first would be shown, and not the second 2, no matter the order of them.

Really strange :bored:
 
Level 10
Joined
Aug 19, 2008
Messages
491
Your report makes no sense, I can print BJDebugMsg all along without any waits near them .... mmm
Did you fixed the problem?

Both the first and the second one :xxd:
I completely remade the spell (not the structure of it), and now it works. I renamed several locals so they made more sence, and it works with only 1 bug:
If a Hero has this spell applied more than 10 times, there will be a 1 hit point permanent increase when it stops looping.
This is not a problem though for the map I'm using this one on.

I also noted another problem, it still seems to lag the first time I use it (even though I have to //Preload section). It doesn't use any special effects, so I wonder what might be causing it.
 
Level 10
Joined
Aug 19, 2008
Messages
491
Ok seriously dude, I'm having major issues with that BJDebugMsg().
I mean, look at this code! Why won't that message be shown?
Other messages shows perfectly, but not this one? WHY?! :cry:

JASS:
    private function Actions takes nothing returns nothing
        //Locals
        local unit caster = GetTriggerUnit()
        local player owner = GetOwningPlayer( caster )
        local location spell_loc = GetSpellTargetLoc()
        local real spellX = GetLocationX( spell_loc )
        local real spellY = GetLocationY( spell_loc )
        local integer level = GetUnitAbilityLevel( caster, SPELL_ID )
        
        local integer p_of_area_1 = ProbabilityOfArea1(level)
        local integer p_of_area_2 = ProbabilityOfArea2(level)
        local integer p_of_area_3 = ProbabilityOfArea3(level)
        local integer p_of_area_4 = ProbabilityOfArea4(level)
        local real area
        
        local integer random = GetRandomInt( 1, 100 )
        local integer debug_int
        local unit debug_unit
        //Endlocals
        
                if ( random <= p_of_area_1 ) then
                    set area = Area(1)
                elseif ( random > p_of_area_1 ) and ( random <= p_of_area_2 ) then
                    set area = Area(2)
                elseif ( random > p_of_area_2 ) and ( random <= p_of_area_3 ) then
                    set area = Area(3)
                elseif ( random > p_of_area_3 ) then
                    set area = Area(4)
                endif
        
        //call TriggerSleepAction( FUSE_DURATION )
        
        set GlobalCaster = caster
        call GroupEnumUnitsInRange( victims, spellX, spellY, area, victim_types )
        
        loop
            set debug_unit = FirstOfGroup( victims )
            exitwhen debug_unit == null
            set debug_int = debug_int + 1
            call GroupRemoveUnit( victims, debug_unit )
        endloop
        call TriggerSleepAction( .28 )
        call BJDebugMsg( "Debug_int == " + I2S( debug_int ) )
            
        
        set caster = null
        set owner = null
        call RemoveLocation( spell_loc )
        set spell_loc = null
    endfunction


EDIT: Nevermind that, it's solved already
 
Last edited:
Level 10
Joined
Aug 19, 2008
Messages
491
Once more, I have a problem. Huge, cause I don't have a f**king clue why it doesn't work.
I'll post the code, then the bugs.
Oh and, please read the "Map notes" on the bottom.

JASS:
scope InsidiousOutrage initializer Initialize
//***************************************************************************
//********************************** SETUP **********************************
//***************************************************************************

    globals
        private constant rect WEST = gg_rct_spawnTeam2b
        private constant rect EAST = gg_rct_spawnTeam2a
        private constant integer SPELL_ID = 'A01R'
        private constant integer DUMMY_ID = 'o005'
    endglobals
    
    private function Duration takes integer level returns real
        return 8. + (2. * level)
    endfunction
    
    private function DelayBetweenOrders takes integer level returns real
        return level * .25
    endfunction
    
//***************************************************************************
//******************************** END SETUP ********************************
//***************************************************************************
    globals
        private unit array User[7]
        private location RandomLoc
        private integer Index
    endglobals

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction
    
    private function RandomOrder takes nothing returns nothing
        set Index = GetTimerData( GetExpiredTimer() )
        if IsPlayerAlly( GetOwningPlayer( User[Index] ), Player(0) ) then
            set RandomLoc = GetRandomLocInRect( WEST )
        else
            set RandomLoc = GetRandomLocInRect( EAST )
        endif
        call IssuePointOrderLoc( User[Index], "attack", RandomLoc )
    endfunction    
//===========================================================================
    private function Actions takes nothing returns nothing
        local timer t = NewTimer()
        local unit caster = GetTriggerUnit()
        local player p = GetOwningPlayer( caster )
        local integer level = GetUnitAbilityLevel( caster, SPELL_ID )
        local integer owner_id = GetPlayerId( p )
        
        set User[owner_id] = GetTriggerUnit()
        call SetTimerData( t, owner_id )
        call TimerStart(  t, DelayBetweenOrders( level ), true, function RandomOrder )
        call TriggerSleepAction( Duration( level ) )
        
        call ReleaseTimer( t )
        set t = null
        set caster = null
        set p = null
    endfunction
//======================================================================
    private function Initialize takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( t, Condition( function Conditions ) )
        call TriggerAddAction( t, function Actions )

        //Preload
        set bj_lastCreatedUnit = CreateUnit( Player( PLAYER_NEUTRAL_PASSIVE ), DUMMY_ID, 0., 0., 0. )
        call UnitAddAbility( bj_lastCreatedUnit, SPELL_ID )
        call KillUnit( bj_lastCreatedUnit )
    endfunction
endscope

1st bug:
No matter where the Hero is, it seems like he wants to run to the center of Playable Map area. I mean it, I tried.
No, there are no mispellings in regions and I know exactly where they're placed.

2nd bug:
The function RandomOrder keeps on looping for an aditional 10 seconds (aproximatly).

Map notes
First of all I'd like to say that this is not a map I'm making, just modding for a project.
Second of all, this spell is MUI, because the map is a "1 Hero team survival".
Thirdly, if you can't solve this, I'll send you the map on a PM.

Help appreciated. I think you deserve some more +rep btw, so I hope I'll get a post to do it on.
 
Level 10
Joined
Aug 19, 2008
Messages
491
mmm
I fear you may be applying bad coding practices. The reason why you use a Timer is so you can avoid using a Wait. Both (Timers and Waits) in the same code make no sense.
Well, then WHY DON'T YOU FUCKING TEACH ME? :xxd:
Nah it's cool, when you're done with exams and stuff I'll be here
Untill then I'm doing the best I can with vJass

anyway I've got another problem. See, I got this really long Else statment in an If/Then/Else.
It uses a hell of a lot of effects, but because of the effect's special 'architecture' I can't use DestroyEffect( AddSpecialEffect() ), so I gotta set them to variables and destroy them that way.
Now, the issue is that I can't use the TriggerSleepAction inside the Else function, because it won't compile and shit. I can't use PolledWait() and I tried moving the special effects to functions instead (and it didn't work).
So my question is, do you know any other way to clean them up? It uses like 40 effects every time it's casted and I don't want them leaking, now do I?
 
Status
Not open for further replies.
Top