• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Redefine a Function?

Status
Not open for further replies.
Level 18
Joined
Sep 2, 2005
Messages
1,029
OK. so what I want to do it I want to make a function, with the same name as an existing blizzard function, so when the blizzard function gets called, it uses mine instead as it's more locally defined. I can't remember for the life of me what it's called but we did it all the time in java and vb.net.

I want to have my map use a custom MeleeStartingUnits function, which can be called from a standard melee init gui thing.

JASS:
function MeleeStartingUnitsEnt takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
    local boolean  useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
    local real     unitSpacing   = 64.00
    local location wispLoc
    local location heroLoc
    local real     peonX
    local real     peonY
    local unit     seed

    if (doPreload) then
        //call Preloader( "scripts\\NightElfMelee.pld" )
    endif

        // Spawn Seed of Rebirth at the start location.
        set peonX = GetLocationX(startLoc)
        set peonY = GetLocationY(startLoc)
        set seed = CreateUnitAtLoc(whichPlayer, 'e000', startLoc, bj_UNIT_FACING)

        // Set random hero spawn point to be just south of the start location.
        set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)

    if (doHeroes) then
        // If the "Random Hero" option is set, start the player with a random hero.
        // Otherwise, give them a "free hero" token.
        if useRandomHero then
            call MeleeRandomHeroLoc(whichPlayer, 'Edem', 'Ekee', 'Emoo', 'Ewar', heroLoc)
        endif
    endif

    if (doCamera) then
        // Center the camera on the initial Wisps.
        call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
        call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
    endif
    
    set seed = null
endfunction

function MeleeStartingUnits2 takes nothing returns nothing
    local integer  index
    local player   indexPlayer
    local location indexStartLoc
    local race     indexRace

    call Preloader( "scripts\\SharedMelee.pld" )

    set index = 0
    loop
        set indexPlayer = Player(index)
        if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
            set indexStartLoc = GetStartLocationLoc(GetPlayerStartLocation(indexPlayer))

            // Create initial starting units
                call MeleeStartingUnitsEnt(indexPlayer, indexStartLoc, true, true, true)
        endif

        set index = index + 1
        exitwhen index == bj_MAX_PLAYERS
    endloop
    
endfunction

There's my code. I had to rename MeleestartingUnits to MeleeStartingUnits2 so I could save. I'd rather use the default call in init instead of having to call a different function. Any advice?
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
I think I know what you mean

You want to have the whole thing done without needing to constantly go back and forth between triggers to custom text

The way I do it, is I do that once, and get a script and a trigger variable that I know will be called from the "main" in the full Jass script

From there, I do every single trigger as a udg trigger (User Defined Global), and setup all their actions, events and conditions, that one trigger called by the main becomes my new main for the triggers (because I can edit it)

I don't do them all at once, just setup the placing so it isn't a pain in the ass to organize new triggers

On the top of that script, you should place all of your other functions, the actions to be carried out, the conditions, and useful functions like PolarCoordX() or a DataSystem

Oh wait, eh, I don't really do AI scripts, nor have I ever even worked with one
But thats how I set up my regular triggers for a customed map
 
Status
Not open for further replies.
Top