• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[AI] Replacement is not doing anything

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
I started recently learning AI, I started with this tutorial. But there are those line that say:

Let's explain the new functions:
  1. SetReplacements(e, n, i) : Set how many times the AI replaces killed defenders, in the code above, it makes this replacement once for easy mode, twice for normal mode and three times in insane mode.
  2. CampaignDefenderEx(e, n, i, UnitID) : similar to SetUnitBuild , but the units trained with this function will be replaced if they're killed n times according with the function SetReplacements .
I make this code in my map:

JASS:
globals
endglobals

function main takes nothing returns nothing
    call CampaignAI(MOON_WELL,null)
    call SetSlowChopping(true)
    call SetPeonsRepair(false)
    call SetReplacements( 1, 2, 3 )
    call CampaignDefenderEx( 1, 1, 1, ARCHER )
endfunction
The problem is that every time I kill the trained archer, the AI replaces it with another one indefinitely, not according to the number in the SetReplacements function.

I hope that someone could help me especially that I asked many questions about AI before but no one was able answer (are there members on THW that understand AI ?)

Thanks.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Could you post the code of SetReplacements?
What code ? Its up there in the first post; this white box with the JASS code inside it is the AI code I am using in my map.

Here it is again:

JASS:
globals
endglobals

function main takes nothing returns nothing
    call CampaignAI(MOON_WELL,null)
    call SetReplacements( 1, 2, 3 )
    //call SetReplacementCount(5)
    call CampaignDefenderEx( 1, 1, 1, ARCHER )
endfunction
 
Level 15
Joined
Feb 15, 2006
Messages
851
What code ? Its up there in the first post; this white box with the JASS code inside it is the AI code I am using in my map.

Here it is again:

JASS:
globals
endglobals

function main takes nothing returns nothing
    call CampaignAI(MOON_WELL,null)
    call SetReplacements( 1, 2, 3 )
    //call SetReplacementCount(5)
    call CampaignDefenderEx( 1, 1, 1, ARCHER )
endfunction
He's asking for the code inside SetReplacements(). Unfortunately this behavior is not strange, remember that the Ai reacts in a repetitive event and sometimes the ordered behavior does not react well. Please confirm me in what AI difficulty are you testing. Have you checked for a long time how many archer the AI trains??
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
He's asking for the code inside SetReplacements(). Unfortunately this behavior is not strange, remember that the Ai reacts in a repetitive event and sometimes the ordered behavior does not react well. Please confirm me in what AI difficulty are you testing. Have you checked for a long time how many archer the AI trains??

Normal, and it kept training for more than 13 times and I am sure it may have continued on if I didn't quit the game.

I also tested the game in the normal way not the fast one.
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
After a lot of testing and web searching I finally found what does this function do.

With the aid of those 2 links link1 , link2 I found that it works only for pre-placed units, it replaces every pre-placed unit N times. Let's say you have pre-placed 2 archers and 3 huntress and you set the SetReplacementCount to 5 then those units will be replaced 5 times only for each one, this has nothing to do with AddDefenders.
 
Status
Not open for further replies.
Top