• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[JASS] Starcraft 1.5 Trigger Rewriting Help

Status
Not open for further replies.
Level 7
Joined
Jan 1, 2005
Messages
133
Due to the new patch 1.24 stuffing up all my Starcraft maps i need some help rewriting all my custom JASS triggers to function in with the new patch.

Alot of the custom script coding i didn't make and all the JASS coding i didn't make either but im hoping some bright minded JASS experts will be able to help me fix the broken triggers i have atm

All members who submit help will be added to my projects credit section thats a promise.
 
Level 7
Joined
Jan 1, 2005
Messages
133
Handle Varible Fix

Ok so i guess we should start at the Handle Varibles;

Here is what i had before patch 1.24

JASS:
//*********************************************************************************************
//*
//*  Handle Variables
//*
//*********************************************************************************************

//=============================================================================================
//  Return Bug Exploiters
//=============================================================================================
function HandleVars_GetInt takes handle h returns integer
    return h
    return 0
endfunction

//=============================================================================================
function LocalVars takes nothing returns gamecache
    return InitGameCache("jasslocalvars.w3v")
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(HandleVars_GetInt(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(HandleVars_GetInt(subject)), name, HandleVars_GetInt(value) )
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(HandleVars_GetInt(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(HandleVars_GetInt(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(HandleVars_GetInt(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(HandleVars_GetInt(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(HandleVars_GetInt(subject)), name)
    return null
endfunction

function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(HandleVars_GetInt(subject)), name)
endfunction

function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(HandleVars_GetInt(subject)), name)
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(HandleVars_GetInt(subject)) )
endfunction

function PylonCondition takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'e007' )
endfunction

After checking each line i had to remove a few lines and thanks to ap0calypse i I was able to fix the function HandleVars_GetInt coding. So this is what i have thats working atm

JASS:
//*********************************************************************************************
//*
//*  Handle Variables
//*
//*********************************************************************************************

//=============================================================================================
//  Return Bug Exploiters
//=============================================================================================
function HandleVars_GetInt takes handle h returns integer
    return GetHandleId(h)
endfunction
//=============================================================================================
function LocalVars takes nothing returns gamecache
    return InitGameCache("jasslocalvars.w3v")
endfunction

function PylonCondition takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'e007' )
endfunction
 
Level 8
Joined
Aug 4, 2006
Messages
357
I think this is what you need:
JASS:
/*******************************************************************************************
 Faux Handle Vars
 ----------------
    Do not use these functions for new stuff, it is just not the right thing to do...

    The intention of Faux Handle Vars is to be a patch fix for a map's migration to
  patch 1.24 This library might not cover all uses of handle vars, some of them are just
  impossible with the new rules set in patches 1.23b and 1.24, but they should work for
  most of the cases....

    All of them but the SetHandle*** ones are inline friendly. I follow the interface
  in official Kattana's handle vars from wc3jass.com, if your handle vars functions
  look different, then you were not using handle vars but another thing...

*******************************************************************************************/

//==========================================================================================
library HandleVars initializer init

 globals
    private hashtable ht
 endglobals
 
    // too bad the Handle vars' old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
        if(value==null) then
            call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
        else
            call SaveAgentHandle( ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
        if value==0 then
            call RemoveSavedInteger(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveInteger(ht, GetHandleId(subject), StringHash(label), value)
        endif        
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
        if (value == false) then
            call RemoveSavedBoolean(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveBoolean(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
        if (value == 0.0) then
            call RemoveSavedReal(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveReal(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
        if ((value=="") or (value==null)) then
            call RemoveSavedString(ht, GetHandleId(subject), StringHash(label)) 
        else
            call SaveStr(ht, GetHandleId(subject), StringHash(label), value) //yay for blizz' consistent naming scheme...
        endif
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        debug call BJDebugMsg("[debug] What the heck? Why would you call HandleHandle I guess this was caused by a search and replace mistake")
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return LoadInteger(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return LoadBoolean(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return LoadStr(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return LoadReal(ht, GetHandleId(subject), StringHash(label))
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
             if(value==null) then
                call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
             else
                call Save$NAME$Handle( ht, GetHandleId(subject), StringHash(label), value)
             endif
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return Load$NAME$Handle( ht, GetHandleId(subject), StringHash(label))
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")


    function FlushHandleVars takes agent subject returns nothing
        call FlushChildHashtable(ht, GetHandleId(subject))
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
        call FlushHandleVars(subject)
    endfunction


    private function init takes nothing returns nothing
        set ht=InitHashtable()
    endfunction

endlibrary

It replaces most of the old functionality of HandleVars with stuff that works for the new patch. You can still keep your pylon condition.

By the way, you need JassNewGen pack to compile the vJass code into regular vJass. You can get it here.
 
Level 7
Joined
Jan 1, 2005
Messages
133
I think this is what you need:
JASS:
/*******************************************************************************************
 Faux Handle Vars
 ----------------
    Do not use these functions for new stuff, it is just not the right thing to do...

    The intention of Faux Handle Vars is to be a patch fix for a map's migration to
  patch 1.24 This library might not cover all uses of handle vars, some of them are just
  impossible with the new rules set in patches 1.23b and 1.24, but they should work for
  most of the cases....

    All of them but the SetHandle*** ones are inline friendly. I follow the interface
  in official Kattana's handle vars from wc3jass.com, if your handle vars functions
  look different, then you were not using handle vars but another thing...

*******************************************************************************************/

//==========================================================================================
library HandleVars initializer init

 globals
    private hashtable ht
 endglobals
 
    // too bad the Handle vars' old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
        if(value==null) then
            call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
        else
            call SaveAgentHandle( ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
        if value==0 then
            call RemoveSavedInteger(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveInteger(ht, GetHandleId(subject), StringHash(label), value)
        endif        
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
        if (value == false) then
            call RemoveSavedBoolean(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveBoolean(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
        if (value == 0.0) then
            call RemoveSavedReal(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveReal(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
        if ((value=="") or (value==null)) then
            call RemoveSavedString(ht, GetHandleId(subject), StringHash(label)) 
        else
            call SaveStr(ht, GetHandleId(subject), StringHash(label), value) //yay for blizz' consistent naming scheme...
        endif
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        debug call BJDebugMsg("[debug] What the heck? Why would you call HandleHandle I guess this was caused by a search and replace mistake")
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren't because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return LoadInteger(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return LoadBoolean(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return LoadStr(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return LoadReal(ht, GetHandleId(subject), StringHash(label))
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
             if(value==null) then
                call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
             else
                call Save$NAME$Handle( ht, GetHandleId(subject), StringHash(label), value)
             endif
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return Load$NAME$Handle( ht, GetHandleId(subject), StringHash(label))
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Player","player")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Widget","widget")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Destructable","destructable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Item","item")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Unit","unit")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ability","ability")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Timer","timer")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trigger","trigger")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerCondition","triggercondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerAction","triggeraction")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TriggerEvent","event")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Force","force")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Group","group")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Location","location")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Rect","rect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("BooleanExpr","boolexpr")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Sound","sound")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Effect","effect")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("UnitPool","unitpool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("ItemPool","itempool")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Quest","quest")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("QuestItem","questitem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("DefeatCondition","defeatcondition")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TimerDialog","timerdialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Leaderboard","leaderboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Multiboard","multiboard")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("MultiboardItem","multiboarditem")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Trackable","trackable")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Dialog","dialog")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Button","button")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("TextTag","texttag")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Lightning","lightning")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Image","image")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Ubersplat","ubersplat")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Region","region")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogState","fogstate")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("FogModifier","fogmodifier")
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle("Hashtable","hashtable")


    function FlushHandleVars takes agent subject returns nothing
        call FlushChildHashtable(ht, GetHandleId(subject))
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
        call FlushHandleVars(subject)
    endfunction


    private function init takes nothing returns nothing
        set ht=InitHashtable()
    endfunction

endlibrary

It replaces most of the old functionality of HandleVars with stuff that works for the new patch. You can still keep your pylon condition.

By the way, you need JassNewGen pack to compile the vJass code into regular vJass. You can get it here.

Thank you maskedpoptart for the code, It works after i used the NewGen WE so thank you for that. I've added you to the credits section as well.
 
Level 7
Joined
Jan 1, 2005
Messages
133
Ok so now i need to fix this trigger

JASS:
//===========================================================================
// Trigger: ShowPylonField
//===========================================================================
function Trig_ShowPylonField_Func003C takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'e007' ) ) then
        return false
    endif
    if ( not ( GetOwningPlayer(GetTriggerUnit()) == GetTriggerPlayer() ) ) then
        return false
    endif
    return true
endfunction

function Trig_ShowPylonField_Conditions takes nothing returns boolean
    if ( not Trig_ShowPylonField_Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_ShowPylonField_Func001A takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_ShowPylonField_Func002001002001 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'e007' )
endfunction

function Trig_ShowPylonField_Func002001002002 takes nothing returns boolean
    return ( IstUnfertig(GetFilterUnit()) == false )
endfunction

function Trig_ShowPylonField_Func002001002 takes nothing returns boolean
    return GetBooleanAnd( Trig_ShowPylonField_Func002001002001(), Trig_ShowPylonField_Func002001002002() )
endfunction

function Trig_ShowPylonField_Func002A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'h00J', GetTriggerPlayer(), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
    call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100.00, 100.00, 100.00, 50.00 )
endfunction

function Trig_ShowPylonField_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h00J'), function Trig_ShowPylonField_Func001A )
    call ForGroupBJ( GetUnitsOfPlayerMatching(GetTriggerPlayer(), Condition(function Trig_ShowPylonField_Func002001002)), function Trig_ShowPylonField_Func002A )
endfunction

//===========================================================================
function InitTrig_ShowPylonField_Original_Copy takes nothing returns nothing
    set gg_trg_ShowPylonField_Original_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_ShowPylonField_Original_Copy, Player(0), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_ShowPylonField_Original_Copy, Player(1), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_ShowPylonField_Original_Copy, Player(2), true )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_ShowPylonField_Original_Copy, Player(3), true )
    call TriggerAddCondition( gg_trg_ShowPylonField_Original_Copy, Condition( function Trig_ShowPylonField_Conditions ) )
    call TriggerAddAction( gg_trg_ShowPylonField_Original_Copy, function Trig_ShowPylonField_Actions )
endfunction

This 2 functions here are causing me problems.

JASS:
function Trig_ShowPylonField_Func002001002002 takes nothing returns boolean
    return ( IstUnfertig(GetFilterUnit()) == false )
endfunction

function Trig_ShowPylonField_Func002001002 takes nothing returns boolean
    return GetBooleanAnd( Trig_ShowPylonField_Func002001002001(), Trig_ShowPylonField_Func002001002002() )
endfunction

Any ideas??
 
Level 8
Joined
Aug 4, 2006
Messages
357
I don't see anything there that would get screwed up just by patch 1.24. Are you sure those functions were working properly before?

Anyway, that trigger could be coded a lot better. You should learn some basic JASS skills so you can at least rewrite triggers converted from GUI.
 
Level 7
Joined
Jan 1, 2005
Messages
133
I don't see anything there that would get screwed up just by patch 1.24. Are you sure those functions were working properly before?

Anyway, that trigger could be coded a lot better. You should learn some basic JASS skills so you can at least rewrite triggers converted from GUI.

Yes the code worked fine before patch 1.24 but i think thats because it was made with WE Unlimited. The problem is i can't save my maps with the full trigger intact and the too functions i have put up as being problem areas are what come up with errors in WE even NewGen. I was hoping it would be a simple rewrite of the code but it must not be that easy.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Yes the code worked fine before patch 1.24 but i think thats because it was made with WE Unlimited. The problem is i can't save my maps with the full trigger intact and the too functions i have put up as being problem areas are what come up with errors in WE even NewGen. I was hoping it would be a simple rewrite of the code but it must not be that easy.

Don't ever use WE-Unlimited to edit maps.
 
Level 7
Joined
Jan 1, 2005
Messages
133
Don't ever use WE-Unlimited to edit maps.

Yeah i have stopped using that editor now. But i got this coding from another map the Lost Temple Samuro map which was triggered using WE Unlimited and it took me alot of trial and error to implenement into my maps. not my ability to trigger in JASS. This is why im asking for help not to be told to learn JASS i guess ill just leave this trigger stuff out of my maps.
 
Level 8
Joined
Aug 4, 2006
Messages
357
Alright I converted that trigger to vJass. I assumed "IstUnfertig" was a function you defined somewhere else in the map; I think that's what was causing the problem. What is that function supposed to do? According to an online translator, it means "IsUnfinished". I assume that checks if a unit is alive, so I replaced it with something that checks if the unit is alive... if that's not what "IstUnfertig" is supposed to do, let me know. Anyway here's the new trigger. Test it out and let me know if it works:
JASS:
scope ShowPylonField initializer Init
//===========================================================================
// Trigger: ShowPylonField
//===========================================================================
globals
    //these next two constants are rawcodes for units. In object editor, press ctrl+D to view rawcodes.
    private constant integer SOME_UNIT_ID = 'e007' //replace SOME with the name of this unit type, in caps. For example, PEASANT_UNIT_ID = 'hpea'
    private constant integer SOME_OTHER_UNIT_ID = 'h00J' //replace SOME_OTHER with name of this unit type.
    
    private boolexpr conditionFilter
    private boolexpr creationFilter
    private group tempGroup
endglobals

private function Conditions takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) == SOME_UNIT_ID and GetOwningPlayer(GetTriggerUnit()) == GetTriggerPlayer()
endfunction

private function RemoveEnumUnit takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function CreationCheck takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == SOME_UNIT_ID and not IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD)
endfunction

function CreateSomeOtherUnit takes nothing returns nothing
    local unit createdUnit = CreateUnit( GetTriggerPlayer(), SOME_OTHER_UNIT_ID, GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()), bj_UNIT_FACING )
    call SetUnitVertexColor( createdUnit, 255, 255, 255, 127 )
endfunction

private function Actions takes nothing returns nothing
    call GroupClear(tempGroup)
    set bj_groupEnumTypeId = SOME_OTHER_UNIT_ID
    call GroupEnumUnitsOfPlayer(tempGroup, GetTriggerPlayer(), filterGetUnitsOfPlayerAndTypeId)
    call ForGroup( tempGroup, function RemoveEnumUnit )
    call GroupClear(tempGroup)
    call GroupEnumUnitsOfPlayer(tempGroup, GetTriggerPlayer(), creationFilter)
    call ForGroup( tempGroup, function CreateSomeOtherUnit )
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger( )
    set conditionFilter = Filter(function Conditions)
    set creationFilter = Filter(function CreationCheck)
    set tempGroup = CreateGroup()
    
    call TriggerRegisterPlayerUnitEvent( trig, Player(0), EVENT_PLAYER_UNIT_SELECTED, conditionFilter )
    call TriggerRegisterPlayerUnitEvent( trig, Player(1), EVENT_PLAYER_UNIT_SELECTED, conditionFilter )
    call TriggerRegisterPlayerUnitEvent( trig, Player(2), EVENT_PLAYER_UNIT_SELECTED, conditionFilter )
    call TriggerRegisterPlayerUnitEvent( trig, Player(3), EVENT_PLAYER_UNIT_SELECTED, conditionFilter )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope
 
Level 7
Joined
Jan 1, 2005
Messages
133
maskedpoptart Thank you for the going to the trouble of rewritting that trigger for me. I feel really selfish and kinda stupid for my last comment about people wanting me to learn JASS. I can tell just by looking at that coding that you took some time out of your own time to rewrite it for me and i can't thank you more. I do have more triggers i need fixing but i also would like to understand how you made some a complex efficient trigger as well.

What is the easiest way to learn JASS like is there a program that can teach me what all the functions mean and how to structure a JASS that you know of???

Also heres the next Trigger. It should be pretty simiular to the Showplyonfiled trigger with a few extra parts to it.

JASS:
//===========================================================================
// Trigger: Pylons New
//===========================================================================
function Trig_Pylons_New_Func004C takes nothing returns boolean
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_e009") ) ) then
        return true
    endif
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_e00A") ) ) then
        return true
    endif
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_e00C") ) ) then
        return true
    endif
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_e00B") ) ) then
        return true
    endif
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_h00H") ) ) then
        return true
    endif
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_h00I") ) ) then
        return true
    endif
    if ( ( GetIssuedOrderIdBJ() == String2OrderIdBJ("custom_h00K") ) ) then
        return true
    endif
    return false
endfunction

function Trig_Pylons_New_Conditions takes nothing returns boolean
    if ( not Trig_Pylons_New_Func004C() ) then
        return false
    endif
    return true
endfunction

function Trig_Pylons_New_Func002Func007A takes nothing returns nothing
    call RemoveUnit( GetEnumUnit() )
endfunction

function Trig_Pylons_New_Func002Func008001002001 takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) == 'e007' )
endfunction

function Trig_Pylons_New_Func002Func008001002002 takes nothing returns boolean
    return ( IstUnfertig(GetFilterUnit()) == false )
endfunction

function Trig_Pylons_New_Func002Func008001002 takes nothing returns boolean
    return GetBooleanAnd( Trig_Pylons_New_Func002Func008001002001(), Trig_Pylons_New_Func002Func008001002002() )
endfunction

function Trig_Pylons_New_Func002Func008A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'h00J', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
    call SetUnitVertexColorBJ( GetLastCreatedUnit(), 100.00, 100.00, 100.00, 50.00 )
endfunction

function Trig_Pylons_New_Func002Func009C takes nothing returns boolean
    if ( ( udg_Pylon == null ) ) then
        return true
    endif
    return false
endfunction

function Trig_Pylons_New_Func002C takes nothing returns boolean
    if ( not Trig_Pylons_New_Func002Func009C() ) then
        return false
    endif
    return true
endfunction

function Trig_Pylons_New_Actions takes nothing returns nothing
    set udg_Pylon = FindPylon( GetOrderPointLoc(), GetOwningPlayer(GetOrderedUnit()), Condition(function PylonCondition) )
    if ( Trig_Pylons_New_Func002C() ) then
        call IssuePointOrderByIdLoc( GetOrderedUnit(), udg_Order, GetUnitLoc(udg_Pylon) )
        call IssuePointOrderLocBJ( GetOrderedUnit(), "move", GetUnitLoc(GetOrderedUnit()) )
        call SetUnitFacingToFaceLocTimed( GetOrderedUnit(), GetOrderPointLoc(), 0.25 )
        call ErrorMsg( GetOwningPlayer(GetTriggerUnit()), "You must build near a Pylon !" )
        set udg_Pylon = null
        call TriggerSleepAction( 0.01 )
        call ForGroupBJ( GetUnitsOfPlayerAndTypeId(GetOwningPlayer(GetTriggerUnit()), 'h00J'), function Trig_Pylons_New_Func002Func007A )
        call ForGroupBJ( GetUnitsOfPlayerMatching(GetOwningPlayer(GetTriggerUnit()), Condition(function Trig_Pylons_New_Func002Func008001002)), function Trig_Pylons_New_Func002Func008A )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Pylons_New_Original_Copy takes nothing returns nothing
    set gg_trg_Pylons_New_Original_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Pylons_New_Original_Copy, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddCondition( gg_trg_Pylons_New_Original_Copy, Condition( function Trig_Pylons_New_Conditions ) )
    call TriggerAddAction( gg_trg_Pylons_New_Original_Copy, function Trig_Pylons_New_Actions )
endfunction
 
Level 8
Joined
Aug 4, 2006
Messages
357
night_wolveX, I really don't have the time right now to rewrite your entire map. I am working on too many other projects. For that trigger, there are only two things that might be wrong with it: "IstUnfertig" and "ErrorMsg". If these two functions are not defined somewhere else in your map, they will cause compile errors to show up when you save the map. If they aren't defined somewhere else in your map, do the following:

Replace IstUnfertig(GetFilterUnit()) == false with IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD).

For the error message, you may want to put this script in a blank trigger in your map, with the trigger name "SimError":
JASS:
library SimError initializer init
//**************************************************************************************************
//*
//*  SimError
//*
//*     Mimic an interface error message
//*       call SimError(ForPlayer, msg)
//*         ForPlayer : The player to show the error
//*         msg       : The error
//*    
//*     To implement this function, copy this trigger and paste it in your map.
//* Unless of course you are actually reading the library from wc3c's scripts section, then just
//* paste the contents into some custom text trigger in your map.
//*
//**************************************************************************************************

//==================================================================================================
    globals
        private sound error
    endglobals
    //====================================================================================================

    function SimError takes player ForPlayer, string msg returns nothing
        set msg="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+msg+"|r"
        if (GetLocalPlayer() == ForPlayer) then
            call ClearTextMessages()
            call DisplayTimedTextToPlayer( ForPlayer, 0.52, 0.96, 2.00, msg )
            call StartSound( error )
        endif
    endfunction

    private function init takes nothing returns nothing
         set error=CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
         //call StartSound( error ) //apparently the bug in which you play a sound for the first time
                                    //and it doesn't work is not there anymore in patch 1.22
    endfunction

endlibrary
Then, you should replace ErrorMsg with SimError.

As for learning Jass, you should read some of the tutorials. Here is one that may help get you started: Jass: A Concise Introduction
 
Status
Not open for further replies.
Top