Make a single JJ's CP command not need activator

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

afis
Junior Member
Posts: 26
Joined: June 22nd, 2009, 3:47 pm

Make a single JJ's CP command not need activator

Post by afis »

Simply put, I want to make the "-copy" command from JJ's cheatpack work for all players at the start of game. Ideally without breaking the rest of the CP or having to give them the activator. The map I have already contains JJ's cheat pack so if you could give me directions on what to change I would appreciate it.

The reason I did not post this under map requests is I am hoping to learn how to do it myself for future times.

FYI: The map is TBR 2.0 (The Black Road), a save-load rpg originally cheated by this site.
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: Make a single JJ's CP command not need activator

Post by owner123 »

Here's a CC for it.

Code: Select all

//Under globals
    trigger                 gg_trg_JJCP_Copy           = null
    trigger                 gg_trg_JJCP_Copy_Trig2     = null

Code: Select all

//Under endglobals

function Trig_JJCP_Copy_Func001Func001A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnumUnit()), GetOwningPlayer(GetEnumUnit()), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
endfunction

function Trig_JJCP_Copy_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = S2I(SubStringBJ(GetEventPlayerChatString(), 6, 9999))
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_JJCP_Copy_Func001Func001A )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

function InitTrig_JJCP_Copy takes nothing returns nothing
    set gg_trg_JJCP_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(0), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(1), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(2), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(3), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(4), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(5), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(6), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(7), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(8), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(9), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(10), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(11), "-copy", false )
    call TriggerAddAction( gg_trg_JJCP_Copy, function Trig_JJCP_Copy_Actions )
endfunction

function Trig_JJCP_Copy_Trig2_Func001A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnumUnit()), GetTriggerPlayer(), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
endfunction

function Trig_JJCP_Copy_Trig2_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_JJCP_Copy_Trig2_Func001A )
endfunction


function InitTrig_JJCP_Copy_Trig2 takes nothing returns nothing
    set gg_trg_JJCP_Copy_Trig2 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(0), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(1), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(2), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(3), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(4), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(5), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(6), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(7), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(8), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(9), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(10), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(11), "-copy", true )
    call TriggerAddAction( gg_trg_JJCP_Copy_Trig2, function Trig_JJCP_Copy_Trig2_Actions )
endfunction

Then search for the function called InitCustomTriggers and add these lines.

Code: Select all

    call InitTrig_JJCP_Copy(  )
    call InitTrig_JJCP_Copy_Trig2(  )

I made it in world editor then copied the parts I needed.
Tested and working.
afis
Junior Member
Posts: 26
Joined: June 22nd, 2009, 3:47 pm

Re: Make a single JJ's CP command not need activator

Post by afis »

The first 2 parts seemed easy enough, however I can;t find the "InitCustomTriggers" line anywhere.
Is there a different way to determine where to place those 2 lines?
The closest I found was InitCustomTeams, but I doubt that would work.
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: Make a single JJ's CP command not need activator

Post by owner123 »

TBR is 100% JASS so you must add this.

Code: Select all

function InitCustomTriggers takes nothing returns nothing
    call InitTrig_JJCP_Copy(  )
    call InitTrig_JJCP_Copy_Trig2(  )
endfunction
afis
Junior Member
Posts: 26
Joined: June 22nd, 2009, 3:47 pm

Re: Make a single JJ's CP command not need activator

Post by afis »

finally got it to work, kind of.
Found that I had to add

Code: Select all

call InitCustomTriggers()
under function main to get the trigger to activate.

However this leads me to a new problem with what the trigger actually does. (code in spoiler)
Spoiler:

Code: Select all

function Trig_JJCP_Copy_Func001Func001A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnumUnit()), GetOwningPlayer(GetEnumUnit()), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
endfunction

function Trig_JJCP_Copy_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = S2I(SubStringBJ(GetEventPlayerChatString(), 6, 9999))
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_JJCP_Copy_Func001Func001A )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

function InitTrig_JJCP_Copy takes nothing returns nothing
    set gg_trg_JJCP_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(0), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(1), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(2), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(3), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(4), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(5), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(6), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(7), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(8), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(9), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(10), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(11), "-copy", false )
    call TriggerAddAction( gg_trg_JJCP_Copy, function Trig_JJCP_Copy_Actions )
endfunction

function Trig_JJCP_Copy_Trig2_Func001A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnumUnit()), GetTriggerPlayer(), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
endfunction

function Trig_JJCP_Copy_Trig2_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_JJCP_Copy_Trig2_Func001A )
endfunction

function InitTrig_JJCP_Copy_Trig2 takes nothing returns nothing
    set gg_trg_JJCP_Copy_Trig2 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(0), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(1), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(2), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(3), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(4), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(5), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(6), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(7), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(8), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(9), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(10), "-copy", true )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy_Trig2, Player(11), "-copy", true )
    call TriggerAddAction( gg_trg_JJCP_Copy_Trig2, function Trig_JJCP_Copy_Trig2_Actions )
endfunction
The code provided copies the units but makes the new units property of the activating player. I want it to work like in JJ's pack where the copy belongs to the same person the first unit did. The reason for this is I was planning to use this trigger to create enemies to train off of, this map is an rpg after all. Could someone please suggest a way to fix this and make the copies same owner as original unit.
Thank you
owner123
Super Moderator
Posts: 1943
Joined: February 3rd, 2009, 11:28 pm

Re: Make a single JJ's CP command not need activator

Post by owner123 »

Sorry for the inconvenience. Here it is.
Spoiler:

Code: Select all

function Trig_JJCP_Copy_Func001Func001A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnumUnit()), GetOwningPlayer(GetEnumUnit()), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
endfunction

function Trig_JJCP_Copy_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = S2I(SubStringBJ(GetEventPlayerChatString(), 6, 9999))
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_JJCP_Copy_Func001Func001A )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

function InitTrig_JJCP_Copy takes nothing returns nothing
    set gg_trg_JJCP_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(0), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(1), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(2), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(3), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(4), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(5), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(6), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(7), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(8), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(9), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(10), "-copy", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_JJCP_Copy, Player(11), "-copy", false )
    call TriggerAddAction( gg_trg_JJCP_Copy, function Trig_JJCP_Copy_Actions )
endfunction

function Trig_JJCP_Copy_Trig2_Func001A takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetEnumUnit()), GetOwningPlayer(GetEnumUnit()), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
endfunction

function Trig_JJCP_Copy_Trig2_Actions takes nothing returns nothing
    call ForGroupBJ( GetUnitsSelectedAll(GetTriggerPlayer()), function Trig_JJCP_Copy_Trig2_Func001A )
endfunction
Assuming I copied the right code, it will work.