Function MeleeRandomHeroLoc
- Line
- 8561
- Location
- blizzard.j
- Constant?
- no
- Type
- function
- Arguments
- player p, integer id1, integer id2, integer id3, integer id4, location loc
- Returns
- unit
| 8561 | function MeleeRandomHeroLoc takes player p, integer id1, integer id2, integer id3, integer id4, location loc returns unit |
| 8562 | local unit hero = null |
| 8563 | local integer roll |
| 8564 | local integer pick |
| 8565 | local version v |
| 8566 | |
| 8567 | // The selection of heroes is dependant on the game version.
|
| 8568 | set v = VersionGet() |
| 8569 | if (v == VERSION_REIGN_OF_CHAOS) then |
| 8570 | set roll = GetRandomInt(1,3) |
| 8571 | else
|
| 8572 | set roll = GetRandomInt(1,4) |
| 8573 | endif
|
| 8574 | |
| 8575 | // Translate the roll into a unitid.
|
| 8576 | if roll == 1 then |
| 8577 | set pick = id1 |
| 8578 | elseif roll == 2 then |
| 8579 | set pick = id2 |
| 8580 | elseif roll == 3 then |
| 8581 | set pick = id3 |
| 8582 | elseif roll == 4 then |
| 8583 | set pick = id4 |
| 8584 | else
|
| 8585 | // Unrecognized id index - pick the first hero in the list.
|
| 8586 | set pick = id1 |
| 8587 | endif
|
| 8588 | |
| 8589 | // Create the hero.
|
| 8590 | set hero = CreateUnitAtLoc(p, pick, loc, bj_UNIT_FACING) |
| 8591 | if bj_meleeGrantHeroItems then |
| 8592 | call MeleeGrantItemsToHero(hero) |
| 8593 | endif
|
| 8594 | return hero
|
| 8595 | endfunction
|