• 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.

help for my new race

Status
Not open for further replies.
Level 1
Joined
Dec 30, 2010
Messages
1
hi, am new and i speek french but i understand english (not totaly)
my problem is that i want to make a new race.But at the begin i have my main town and my paysan(or other constructor) and i want remplace this by my town and my paysant of my new race. Exemple when the game begin i want whrite in chat (goblin race) and my town begin the town of goblin and my workers begins goblin worker's.

my experience:
am a expert for editor
am a beginner for scripting (in french is déclencheur) am not sure is scripting
the things have:

-initiations
-condition
-action
am a beginner but i understand the principe
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
First, copy this code and put it in the header of your map:

JASS:
function FindNearestMine takes real x, real y, real dist returns unit
    local group g = CreateGroup()
    local real tempDist
    local unit u
    
    set bj_meleeNearestMineDist = 4000001
    set bj_meleeNearestMine = null
    call GroupEnumUnitsInRange( g, x, y, dist, null )
    
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        
        set tempDist = (GetUnitX(u) - x) * (GetUnitX(u) - x) + (GetUnitY(u) - y) * (GetUnitY(u) - y)
        if tempDist < bj_meleeNearestMineDist then
            set bj_meleeNearestMineDist = tempDist
            set bj_meleeNearestMine = u
        endif
        call GroupRemoveUnit(g, u)
    endloop
    
    call DestroyGroup(g)
    set g = null
    
    return bj_meleeNearestMine
endfunction

function SetupUnits takes nothing returns nothing
    local unit      nearestMine
    local real      startX = GetStartLocationX( GetPlayerStartLocation(udg_Player) )
    local real      startY = GetStartLocationY( GetPlayerStartLocation(udg_Player) )
    local real      peonX
    local real      peonY
    local real      angle
    local unit      townHall = null

    set nearestMine = FindNearestMine( startX, startY, bj_MELEE_MINE_SEARCH_RADIUS )
    if (nearestMine != null) then
        // Spawn Town Hall at the start location.
        set townHall = CreateUnit( udg_Player, udg_TownhallType, startX, startY, bj_UNIT_FACING )
        
        // Spawn Peasants near the mine.
        set angle = Atan2( startY - GetUnitY(nearestMine), startX - GetUnitX(nearestMine))
        set peonX = GetUnitX(nearestMine) + 320. * Cos( angle )
        set peonY = GetUnitY(nearestMine) + 320. * Sin( angle )
        call CreateUnit(udg_Player, udg_BuilderType, peonX + 0.00 * 64., peonY + 1.00 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX + 1.00 * 64., peonY + 0.15 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX - 1.00 * 64., peonY + 0.15 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX + 0.60 * 64., peonY - 1.00 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX - 0.60 * 64., peonY - 1.00 * 64., bj_UNIT_FACING)
    else
        // Spawn Town Hall at the start location.
        set townHall = CreateUnit(udg_Player, udg_TownhallType, startX, startY, bj_UNIT_FACING)
        
        // Spawn Peasants directly south of the town hall.
        set peonX = startX
        set peonY = startY - 224.00
        call CreateUnit(udg_Player, udg_BuilderType, peonX + 2.00 * 64., peonY + 0.00 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX + 1.00 * 64., peonY + 0.00 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX + 0.00 * 64., peonY + 0.00 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX - 1.00 * 64., peonY + 0.00 * 64., bj_UNIT_FACING)
        call CreateUnit(udg_Player, udg_BuilderType, peonX - 2.00 * 64., peonY + 0.00 * 64., bj_UNIT_FACING)
    endif

    call SetPlayerState(udg_Player, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)

    if GetLocalPlayer() == udg_Player then
        call SetCameraPosition(peonX, peonY)
        call SetCameraQuickPosition(peonX, peonY)
    endif
    
    set townHall = null
    set nearestMine = null
endfunction

Like this:
headercode.jpg



Then you need to create 3 variables:
necessaryvariables.jpg

(You can get to this screen by pressing CTRL + B inside the trigger editor).


Back to the trigger editor: in the trigger "Melee Initialization" (or whatever it may be in French), remove the action "Melee Game - Create starting units (for all players)".
Instead, create these actions:

  • Set TownhallType = [Town hall type]
  • Set BuilderType = [Builder type]
  • Set Player = [Player for which the units are created]
  • Custom script: call SetupUnits()
Change the first 3 and DO NOT touch the last line.

The full trigger would look like this:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Use melee time of day (for all players)
      • Melee Game - Limit Heroes to 1 per Hero-type (for all players)
      • Melee Game - Give trained Heroes a Scroll of Town Portal (for all players)
      • Melee Game - Set starting resources (for all players)
      • Melee Game - Remove creeps and critters from used start locations (for all players)
      • Melee Game - Run melee AI scripts (for computer players)
      • Melee Game - Enforce victory/defeat conditions (for all players)
      • Set TownhallType = [Town hall type]
      • Set BuilderType = [Builder type]
      • Set Player = [Player for which the units are created]
      • Custom script: call SetupUnits()
 
Last edited:
Status
Not open for further replies.
Top