Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   JASS/AI scripts tutorials (http://www.wc3c.net/forumdisplay.php?f=650)
-   -   Introduction to JASS (http://www.wc3c.net/showthread.php?t=74894)

SHAƎDY 04-15-2010 02:34 AM

I always thought that this tutorial should use BJDebugMsg() instead of DisplayTextToForce().

WarriorRos 03-23-2011 03:42 PM

Q: i want the AI to attack a unit, so 4 example a put:
call AttackMoveKillA ('o00N:otrb') --> code of my custom unit
but then, i want the AI to keep attackin the player after the unit is dead, how can i do that?

an other thing: i've use ur method to make an ai. Just like urs but with humans, and is rare cause one player
seems fine, it gather gold, but don't attack
and the other, with the SAME ai, but with changed attack groups, don't even move :S
what is wrong? i leave here the code
(I leave in the code ur comments to guide me, maybe thats it)

globals
// We put the globals variables here
player MyVictim = Player(1)
endglobals

function ConfigureAI takes nothing returns nothing
call SetSlowChopping( true ) //AI will do a normal harvesting
call SetPeonsRepair( true ) //AI will repair damaged structures
call SetTargetHeroes( true )
endfunction

function hero_levels takes nothing returns integer
local integer hero = GetHeroId()
local integer level = GetHeroLevelAI()
local integer a = 0
if hero == PALADIN then
if level == 1 or level == 3 or level == 5 then
set a = HOLY_BOLT
endif
if level == 2 or level == 4 or level == 7 then
set a = DEVOTION_AURA
endif
if level >= 8 or level == 9 or level == 10 then
set a = DIVINE_SHIELD
endif
if level == 6 then
set a = RESURRECTION
endif
endif
return a
endfunction

function main takes nothing returns nothing
// Tier 1 Buildings
call SetBuildUnitEx( 1, 1, 1, TOWN_HALL ) // <==(1)
call SetBuildUnit( 15, PEASANT )
call SetBuildUnitEx( 1, 2, 3, HOUSE )
call SetBuildUnitEx( 1, 1, 2, BARRACKS )
call SetBuildUnit( 1, HUMAN_ALTAR )
call SetBuildUnit( 1, BLACKSMITH )
call CampaignDefenderEx( 3, 3, 4, FOOTMAN ) // <==(2)
call CampaignDefenderEx( 2, 2, 2, RIFLEMAN )
call CampaignDefenderEx( 1, 2, 4, GUARD_TOWER )

// Tier 2 buildings
call SetBuildUnit( 1, KEEP )
call SetBuildUnitEx( 1, 1, 2, WORKSHOP )
// Tier 3 buildings
call SetBuildUnit( 1, CASTLE )
call SetBuildUnitEx( 0, 1, 1, AVIARY )
// Extra
call SetReplacements(1, 2, 3)
// **********************************
// * End Building Strategy *
// **********************************

// **********************************
// * Attack Strategy *
// **********************************
//*** WAVE 1 ***
call InitAssaultGroup() // <==(1)
call CampaignAttackerEx( 1, 1, 2, FOOTMAN ) // <==(2)
call CampaignAttackerEx( 1, 1, 2, PRIEST )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim ) // <==(3)
//*** Basic upgrades from BlackSmith ***
call SetBuildUpgrEx( 1, 1, 1, UPG_MELEE )
call SetBuildUpgrEx( 1, 2, 2, UPG_RANGED )
call SetBuildUpgrEx( 0, 1, 1, UPG_DEFEND )

//*** WAVE 2 *** Between 2 or 3 minutes after Wave 1
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, FOOTMAN )
call CampaignAttackerEx( 1, 2, 3, RIFLEMAN )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
//*** Defend Upg for easy mode
call SetBuildUpgrEx( 1, 1, 1, UPG_DEFEND )

//*** WAVE 3 *** Between 2 or 3 minutes after Wave 2
call InitAssaultGroup()
call CampaignAttackerEx( 4, 4, 5, FOOTMAN )
call CampaignAttackerEx( 1, 2, 4, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, 'hcth' )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
//*** WAVE 4 *** Between 2 or 3 minutes after Wave 3
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, FOOTMAN )
call CampaignAttackerEx( 1, 2, 4, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 2, 'hcth' )
call CampaignAttackerEx( 1, 1, 1, TANK )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
//*** Medium Upg
call SetBuildUpgrEx( 0, 1, 2, UPG_SORCERY )
call SetBuildUpgrEx( 1, 1, 3, UPG_LEATHER )
call SetBuildUpgrEx( 1, 2, 3, UPG_ARMOR )
//*** WAVE 5 *** Between 3 or 4 minutes after Wave 4
call InitAssaultGroup()
call CampaignAttackerEx( 3, 3, 3, FOOTMAN )
call CampaignAttackerEx( 1, 1, 1, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 0, 1, 1, KNIGHT )
call CampaignAttackerEx( 1, 1, 2, TANK )
call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
//*** Priest Upg
call SetBuildUpgrEx( 0, 1, 2, UPG_PRAYING )
//*** WAVE 6 *** Between 3 or 4 minutes after Wave 5
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 2, 2, KNIGHT )
call CampaignAttackerEx( 0, 1, 1, 'hcth' )
call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
//*** Ultimate Upg
call SetBuildUpgrEx( 0, 0, 1, UPG_ARTILLERY )
call SetBuildUpgrEx( 1, 2, 2, UPG_TANK )
call SetBuildUpgrEx( 0, 2, 3, UPG_MASONRY )
call SetBuildUpgrEx( 0, 1, 1, UPG_BREEDING )
call SetBuildUpgrEx( 0, 0, 1, UPG_GUN_RANGE )

loop //Init the infinite attack loop
//*** WAVE 7 *** Between 3 or 5 minutes after Wave 6
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, FOOTMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 1, 1, 'hcth' )
call CampaignAttackerEx( 1, 1, 2, RIFLEMAN )
call CampaignAttackerEx( 0, 1, 2, KNIGHT )
call CampaignAttackerEx( 1, 1, 2, TANK )
call SuicideOnPlayerEx( M5, M4, M4, MyVictim )
//*** WAVE 8 *** Between 3 or 5 minutes after Wave 7
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, KNIGHT )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 1, 1, TANK )
call CampaignAttackerEx( 1, 2, 3, RIFLEMAN )
//*** WAVE 9 *** Between 4 or 6 minutes after Wave 8
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, FOOTMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 1, 1, TANK )
call CampaignAttackerEx( 1, 2, 3, KNIGHT )
call CampaignAttackerEx( 0, 1, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 2, 'hcth' )
call SuicideOnPlayerEx( M6, M5, M4, MyVictim )
endloop
// **********************************
// * Attack Strategy never ends *
// **********************************

endfunction


An other Q: how can I make the AI to attack a destructible?

all of this is because im making a map where a city of tauren is attack by a legion of humans, and the objective of the humans is to destroy the DOOR 1st, then keep atakin to destroy the base of the taurens.


All times are GMT. The time now is 06:05 PM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services