wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > JASS/AI scripts tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 04-23-2007, 12:37 AM   #16
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

Ok, 1 question: After you write your jass ai script, how do you get it to be that Ai file?
Joker is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 04-23-2007, 05:16 AM   #17
Av3n
Roar!
 
Av3n's Avatar


Project Leader: TBR
Project Member: PoC
 
Join Date: May 2006
Posts: 1,854

Submissions (7)

Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)

Hero #4 extra-official winner2008 Spell olympics - Fire - BronzeHero Contest #3 - 3rd Place

Default

Try using Jass shop pro or something and change its file extention to .ai

-Av3n
__________________

Thanks to FatherTime for the sig
.:
Current ProjectsSubmissions
Power of CorruptionMy Terrain
The Black RoadMy Resources
Strikeforce
Twitter
Av3n is offline   Reply With Quote
Old 04-24-2007, 08:52 PM   #18
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

Ok Jasscraft can do it.
More questions: Do Ai scripts need triggers? or is it just a lot of functions on one script?

Moyack only uses Player(0) for his victim. What if the other player isnt Player(0)? Would i have to make a variable for each player or what?

Last edited by Joker : 04-24-2007 at 08:56 PM.
Joker is offline   Reply With Quote
Old 04-24-2007, 10:09 PM   #19
Av3n
Roar!
 
Av3n's Avatar


Project Leader: TBR
Project Member: PoC
 
Join Date: May 2006
Posts: 1,854

Submissions (7)

Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)Av3n is a jewel in the rough (240)

Hero #4 extra-official winner2008 Spell olympics - Fire - BronzeHero Contest #3 - 3rd Place

Default

Well just thinking about it no you import the .ai file into your map and use triggers to run it. just change the player number to your victim or add new ones if you want

-Av3n
__________________

Thanks to FatherTime for the sig
.:
Current ProjectsSubmissions
Power of CorruptionMy Terrain
The Black RoadMy Resources
Strikeforce
Twitter
Av3n is offline   Reply With Quote
Old 04-25-2007, 01:25 PM   #20
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

Yes, you can set the target players you want, even more you can create a function to define the target player. Suppose you have several players (Player 3, 5 and 7) and you want that the AI attack them randomly. You can do something like this:

Collapse JASS:
function GetRandomPlayer takes nothing returns player // Add this function to your AI code
    // Your AI player must be different from this selection
    // Remember that player 1 is Player(0) in JASS and so on.
    local integer i = 0
    loop
        exitwhen i == 2 or i == 4 or i == 6 //Here, you set the target players you want to select.
        set i = GetRandomInt(0, 11)
    endloop
    return Player(i)
endfunction

function main takes nothing returns nothing

// Building code goes here

//*** WAVE 1 *** 
    call InitAssaultGroup() // <==(1)
    call CampaignAttackerEx( 2, 3, 3, ARCHER ) // <==(2)
    call CampaignAttackerEx( 0, 1, 2, HUNTRESS ) 
    call CampaignAttackerEx( 0, 1, 1, BALLISTA ) 
    call SuicideOnPlayerEx( M2, M3, M3, GetRandomPlayer() ) // Change MyVictim by the custom function
endfunction

If you change MyVictim variable by the function, you are giving to the AI the ability to attack different targets, in a random way.
moyack is offline   Reply With Quote
Old 04-26-2007, 01:01 AM   #21
Joker
User
 
Joker's Avatar
 
Join Date: Sep 2006
Posts: 687

Joker will become famous soon enough (32)Joker will become famous soon enough (32)

Default

Well, what about your contest? Everyone is going to be either Player(0) or Player(1) right?

also, can someone answer this?
Quote:
Originally Posted by me
More questions: Do Ai scripts need triggers? or is it just a lot of functions on one script?
Joker is offline   Reply With Quote
Old 04-26-2007, 04:18 AM   #22
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

  1. In the contest... No, the AI will detect its player slot and the enemies player slots automatically by using a set of functions, and it's in that way because this is a melee AI, which has more complexity than a campaign AI. To clarify: A melee AI and a campaign AI aims the same purpose, but with different approaches. A campaign AI has enemies and locations predefined, melee AI doesn't, so the melee AI requires more code to detect and react accordingly than a Campaign AI.
  2. A jass AI code is a script which runs in parallel with the triggers map, but they are not the same, in fact jass AI has functions which can't be found in normal triggers. Anyways, you can make a trigger send data to a AI script, and change the AI behavior in that way. Unfortunately you can't do the opposite.

All of this can be seen in my tutorial, I suggest to read it again.
moyack is offline   Reply With Quote
Old 12-01-2009, 08:39 PM   #24
leric
User
 
Join Date: Nov 2009
Posts: 80

leric has little to show at this moment (0)

Default

Quote:
Originally Posted by moyack
Anyways, you can make a trigger send data to a AI script, and change the AI behavior in that way. Unfortunately you can't do the opposite.

Do you mean .ai file cannot access natives in .j file? I trying to create a melee ai which will require to alot of natives from common.j to do the bidding. is it possible? If not then is there any alternative?
leric is offline   Reply With Quote
Old 12-09-2009, 11:58 AM   #25
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

Sorry for the late answer, I'm not active in this site as I were...


Quote:
Originally Posted by leric
Do you mean .ai file cannot access natives in .j file? I trying to create a melee ai which will require to alot of natives from common.j to do the bidding. is it possible? If not then is there any alternative?
Technically common.ai can use all the natives in common.j, but some of them simply don't work (like triggers, groupenum, etc).

What I mean is that you can send data to the AI script with triggers (link), but the AI script can't save data in globals done in the trigger editor. There's a possibility of doing that kind of communication using gamecache as a bridge (Thanks to Archmage Owenalacaster). Unfortunately, it has not been fully tested to confirm its reliability.
moyack is offline   Reply With Quote
Old 01-13-2010, 07:22 PM   #26
ThDreadlord
User
 
Join Date: Jan 2010
Posts: 2

ThDreadlord has little to show at this moment (0)

Default

Awsome tutorial i wanna thanks you a lot and congratulate you for the knowledge you acquired.That's right, there are nearly no tutorials about AI or the less exsisting aren't clear enough to explain important points.Still,i got a simple question about a JASS function that i found in a campaign AI of Blizzard used in a human chapter here it is:
call SuicideUnits( MEAT_WAGON, ABOMINATION, GHOUL, NECRO, SKEL_WARRIOR, LICH, 0, 0, 0, 0 )
It has been used at the end of the Ai script,just before the endfunction.Do you have an idea of its role ?I will be really grateful.
ThDreadlord is offline   Reply With Quote
Old 01-14-2010, 03:19 AM   #27
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

Quote:
Originally Posted by ThDreadlord
Awsome tutorial i wanna thanks you a lot and congratulate you for the knowledge you acquired.That's right, there are nearly no tutorials about AI or the less exsisting aren't clear enough to explain important points.Still,i got a simple question about a JASS function that i found in a campaign AI of Blizzard used in a human chapter here it is:
call SuicideUnits( MEAT_WAGON, ABOMINATION, GHOUL, NECRO, SKEL_WARRIOR, LICH, 0, 0, 0, 0 )
It has been used at the end of the Ai script,just before the endfunction.Do you have an idea of its role ?I will be really grateful.
It would be great to see the full AI script to get a clear idea, but I can guess this function will send all the units of those types to fight without any chances to flee (that's the reason of the name suicide), in order to make the final battle.

Here's the code in common.ai

Collapse JASS:
function SuicideUnits takes integer u1, integer u2, integer u3, integer u4, integer u5, integer u6, integer u7, integer u8, integer u9, integer uA returns nothing
    call Trace("MASS SUICIDE - this script is now technically done\n") //xxx

    call PrepFullSuicide()
    loop
        call SuicideUnitA(u1)
        call SuicideUnitA(u2)
        call SuicideUnitA(u3)
        call SuicideUnitA(u4)
        call SuicideUnitA(u5)
        call SuicideUnitA(u6)
        call SuicideUnitA(u7)
        call SuicideUnitA(u8)
        call SuicideUnitA(u9)
        call SuicideUnitA(uA)
    endloop
endfunction

hmmm, it seems I wasn't wrong....
moyack is offline   Reply With Quote
Old 01-16-2010, 08:54 AM   #28
ThDreadlord
User
 
Join Date: Jan 2010
Posts: 2

ThDreadlord has little to show at this moment (0)

Default

Well so that function was designed to order all units of the types specified on the function,to attack with nor mercy nor flee on the specified player.Ok thanks for the show i will try yo understand the rest myself now
Once more thanks for the tutorial Yeah !
ThDreadlord is offline   Reply With Quote
Old 01-29-2010, 07:24 PM   #29
Cheeseburgers
User
 
Join Date: Jan 2010
Posts: 1

Cheeseburgers has little to show at this moment (0)

Default

im brand new to jass, and im kinda understand the tutorial, but im having alittle trouble uploading to my campain. Because it keeps saying it needs to be a melee map. Could someone help me please?

Thanks for the tutorial
Cheeseburgers is offline   Reply With Quote
Old 03-19-2010, 04:37 PM   #30
Deatheriin
User
 
Join Date: Mar 2010
Posts: 1

Deatheriin has little to show at this moment (0)

Default

It is indeed an awesome tutorial. I'm new to coding in general, and this is one of the first tuts I've looked into, and I find it really good. I understand most things.
However I've got a question. How sensitive is the game loading time and the time initializing the game once started compared to the length of the code? For instance, how much difference would it do if you put the final three waves that you looped, and made them in a separate function which you then later call on in the waves? That way you'll only have to write them once and then have them called on. Or does the calling itself take more time and recourse than the actual code itself? (Not that I think it does, but asking never hurts. :P)

PS
Your English has a few mistakes here and there, but it's fully understandable and readable. No worries! :D
DS
Deatheriin is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:06 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

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