- Joined
- May 4, 2012
- Messages
- 25
Hello there, I'm new to JASS and decided to write a bit complex AI script in JASScraft. Unfortunately, JASScraft Syntax Checker doesn't help that much, and the script is not running for my Demon-Undead race. I can't upload my map for the size due to custom contents. Here is the script:
Padron my imprudence.
JASS:
globals
player user = Player(0)
player human = Player(1)
constant integer pyroist = 'h00J'
constant integer juggernaught = 'o005'
constant integer sane = 'n00Z'
constant integer breaker = 'n00W'
constant integer harrow = 'n00V'
constant integer annih = 'n00X'
constant integer hero = 'U00Q'
constant integer hero2 = 'U00V'
constant integer array HuUnitID
constant integer HuUnitID[0] = 'h00D' //strider
constant integer HuUnitID[1] = 'e005' //ballista
constant integer HuUnitID[2] = 'h00A' //templar
constant integer HuUnitID[3] = 'h009' //elite
constant integer HuUnitID[4] = 'n009' //archer
constant integer HuUnitID[5] = 'n00E' //crystal
constant integer HuUnitID[6] = 'n00N' //lancer
constant integer HuUnitID[7] = 'n00C' //hydro
constant integer HuUnitID[8] = 'n00D' //antimage
constant integer array HuUnitWght
constant integer HuUnitWght[0] = 3 //strider
constant integer HuUnitWght[1] = 2 //ballista
constant integer HuUnitWght[2] = 1 //templar
constant integer HuUnitWght[3] = 2 //elite
constant integer HuUnitWght[4] = 1 //archer
constant integer HuUnitWght[5] = 2 //crystal
constant integer HuUnitWght[6] = 3 //lancer
constant integer HuUnitWght[7] = 3 //hydro
constant integer HuUnitWght[8] = 1 //antimage
// constant integer RAIN = 'A029'
// constant integer IMMO = 'A00U'
// constant integer INCE = 'ANic'
// constant integer DOOM = 'A02B'
endglobals
//--------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------
function EneTypesCount takes nothing returns integer
local integer count = 0
local integer i = 0
loop
exitwhen i > 7
set count = count + GetPlayerUnitTypeCount(human,HuUnitID[i])
set i = i + 1
endloop
return count
endfunction
function EneTypesWeight takes nothing returns integer
local integer weight = 0
local integer i = 0
loop
exitwhen i > 7
if GetPlayerUnitTypeCount(human,HuUnitID[i]) = 0 then set weight = weight + 0
elseif GetPlayerUnitTypeCount(human,HuUnitID[i]) > 0 then set weight = weight + HuUnitWght[i]
endif
set i = i + 1
endloop
return weight
endfunction
function AssaultForce takes nothing returns nothing
local integer array Random
local integer Slots
local integer ExtraSlots
local integer EneCount = EneTypesCount()
local integer EneWeight = EneTypesWeight()
set ExtraSlots = EneCount - 8
if ExtraSlots < 0 then
set Slots = 8
else set Slots = 8 + ExtraSlots
endif
if (GetPlayerUnitTypeCount(human,HuUnitID[2]) > 0) or (GetPlayerUnitTypeCount(human,HuUnitID[7]) > 0) or (GetPlayerUnitTypeCount(human,HuUnitID[8]) > 0) then
set Random[0] = GetRandomInt(0,2)
if Random[0] == 0 and Slots > 2 then
call CampaignAttackerEx(3,3,3,pyroist)
set Slots = Slots - 2
elseif Random[0] == 1 and Slots > 2 then
call CampaignAttackerEx(2,2,2,breaker)
set Slots = Slots - 2
elseif Random[0] == 2 and Slots > 3 then
call CampaignAttackerEx(1,1,1,breaker)
call CampaignAttackerEx(2,2,2,pyroist)
set Slots = Slots - 3
endif
if EneWeight > 15 and Slots > 1 then
call CampaignAttackerEx(1,1,1,breaker)
set Slots = Slots - 2
endif
endif
if (GetPlayerUnitTypeCount(human,HuUnitID[0]) > 0) or (GetPlayerUnitTypeCount(human,HuUnitID[3]) > 0) or (GetPlayerUnitTypeCount(human,HuUnitID[6]) > 0) then
set Random[1] = GetRandomInt(0,2)
if Random[1] == 0 and Slots > 2 then
call CampaignAttackerEx(3,3,3,CRYPT_FIEND)
set Slots = Slots - 2
elseif Random[1] == 1 and Slots > 1 then
call CampaignAttackerEx(1,1,1,harrow)
set Slots = Slots - 1
elseif Random[1] == 2 and Slots > 2 then
call CampaignAttackerEx(1,1,1,juggernaught)
set Slots = Slots - 2
endif
if EneWeight > 12 and Slots > 1 then
call CampaignAttackerEx(1,1,1,harrow)
set Slots = Slots - 1
endif
endif
if (GetPlayerUnitTypeCount(human,HuUnitID[4]) > 4) then
set Random[2] == GetRandomInt(0,2)
if Random[2] == 0 and Slots > 1 then
call CampaignAttackerEx(1,1,1,annih)
set Slots = Slots - 1
elseif Random[2] == 1 and Slots > 1 then
call CampaignAttackerEx(1,1,1,ABOMINATION)
set Slots = Slots - 1
endif
if EneWeight > 14 and Slots > 2 then
call CampaignAttackerEx(1,1,1,ABOMINATION)
set Slots = Slots - 1
endif
endif
if (GetPlayerUnitTypeCount(human,HuUnitID[5]) > 2) then
if Slots > 1 then
call CampaignAttackerEx(2,2,2,GARGOYLE)
set Slots = Slots - 1
elseif Slots > 1 and GetUpgradeLevel(UPG_FIEND_WEB) >= 1 then
call CampaignAttackerEx(2,2,2,CRYPT_FIEND)
set Slots = Slots - 1
endif
if EneWeight > 14 and Slots > 1 and GetPlayerUnitTypeCount(human,HuUnitID[5]) > 3 then
call CampaignAttackerEx(2,2,2,GARGOYLE)
set Slots = Slots - 1
endif
endif
if (GetUnitCountDone(hero) >= 1) or (GetUnitCountDone(hero2) >= 1) or (GetUnitCountDone(annih) >= 1) then
if Slots > 1 then
call CampaignAttackerEx(1,1,1,OBSIDIAN_STATUE)
set Slots = Slots - 1
endif
if EneWeight > 12 and Slots > 1 then
call CampaignAttackerEx(1,1,1,OBSIDIAN_STATUE)
Slots = Slots - 1
endif
endif
endfunction
function main takes nothing returns nothing
call CampaignAI(ZIGGURAT_1, null)
call ResetCaptainLocs()
call SetBuildUpgrEx( 1,1,1, UPG_CANNIBALIZE )
call SetBuildUpgrEx( 1,1,1, UPG_GHOUL_FRENZY )
call SetBuildUpgrEx( 1,1,1, UPG_FIEND_WEB )
call SetBuildUpgrEx( 1,1,1, UPG_BLK_SPHINX )
call SetBuildUpgrEx( 1,1,1, UPG_UNHOLY_STR )
call SetBuildUpgrEx( 1,1,1, UPG_UNHOLY_ARMOR )
call SetBuildUpgrEx( 1,1,1, UPG_CR_ATTACK )
call SetBuildUpgrEx( 1,1,1, UPG_CR_ARMOR )
loop
InitAssaultGroup()
call CampaignAttackerEx(1,1,1,hero)
call CampaignAttackerEx(1,1,1,hero2)
if GetUnitCountDone(hero) >= 1 or GetUnitCountDone(hero2) >= 1 then
call AssaultForce()
call SuicideOnPlayer(M1,human)
elseif GetUnitCountDone(hero) <= 0 and GetUnitCountDone(hero2) <= 0 then
call CampaignAttackerEx(1,1,1,hero)
call CampaignAttackerEx(1,1,1,hero2)
loop
exitwhen GetUnitCountDone(hero) >= 1 and GetUnitCountDone(hero2) >= 1
call Sleep(1.0)
endloop
call AssaultForce()
call SuicideOnPlayer(M1,human)
endif
endloop
endfunction
Padron my imprudence.