• 🏆 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!

[AI] Ai still picks up the same heroes

Status
Not open for further replies.
Level 3
Joined
Jun 9, 2010
Messages
17
Guys..need help to check on the triggers below..

I don't know what goes wrong with them but there are still chances that the AI picks up the same heroes. I used this post
as my reference.


  • For each (Integer A) from 1 to 3, do (If (((Player((Integer A))) controller) Equal to Computer) then do (Trigger - Run AI pick hero left <gen> (checking conditions)) else do (Do nothing))
  • For each (Integer A) from 5 to 7, do (If (((Player((Integer A))) controller) Equal to Computer) then do (Trigger - Run AI pick hero left <gen> (checking conditions)) else do (Do nothing))
  • Actions
    • Set HSS_Ai[1] = Hero1
    • Set HSS_Ai[2] = Hero2
    • Set HSS_Ai[3] = Hero3
    • Set HSS_Ai[4] = Hero4
    • Set HSS_Ai[5] = Hero5
    • Set HSS_Ai[6] = Hero6
    • Set HSS_AiCount = 6
    • Set HSS_RandomAi = (Random integer number between 1 and HSS_AiCount)
    • Set TempPoint = (Center of Teleport After Selecting Left <gen>)
    • Set TempPoint2 = (Center of Teleport After Selecting Right <gen>)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ((Player((Integer A))) is in leftPlayers) Equal to True
      • Then - Actions
        • Unit - Create 1 HSS_Ai[HSS_RandomAi] for (Player((Integer A))) at TempPoint facing Default building facing degrees
        • Unit - Order (Last created unit) to Move To (Center of Unit Spwam Horde Castle <gen>)
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer A))) is in rightPlayers) Equal to True
          • Then - Actions
            • Unit - Create 1 HSS_Ai[HSS_RandomAi] for (Player((Integer A))) at TempPoint2 facing Default building facing degrees
            • Unit - Order (Last created unit) to Move To (Center of Unit Spwam Alliance Castle <gen>)
          • Else - Actions
    • Set HSS_Ai[HSS_RandomAi] = HSS_Ai[HSS_AiCount]
    • Set HSS_AiCount = (HSS_AiCount - 1)
    • Custom script: call RemoveLocation(udg_TempPoint)
    • Custom script: call RemoveLocation(udg_TempPoint2)
Just so you know, i'm using Hero Selection System by Almia as per this Thread. I have tried to make a trigger so that the AI Players choose the random button but it did not go so well. Any suggestion guys?..

Thanks in advance :xxd:
 
You should probably set this on initialization:
  • Init
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set HSS_Ai[1] = Hero1
    • Set HSS_Ai[2] = Hero2
    • Set HSS_Ai[3] = Hero3
    • Set HSS_Ai[4] = Hero4
    • Set HSS_Ai[5] = Hero5
    • Set HSS_Ai[6] = Hero6
    • Set HSS_AiCount = 6
Rather than the actual trigger. At the moment, AICount is reset to 6 so it is still considering the same heroes, so it is ruining the stack-remove process. ;)
 
Level 3
Joined
Jun 9, 2010
Messages
17
You should probably set this on initialization:

I've tried this and the result was still the same.

AICount is reset to 6 so it is still considering the same heroes, so it is ruining the stack-remove process

I'm quite aware about this dude..but do you have better idea on how to solve this?

Don't use integer A/B use your own custom integer.
The problem however is what purge has said.

Changed the integer A to a variable integer but the problem is not solved..

guys thanks for the reply...but I haven't managed to get the problem solved...appreciate any example or thread that I can refer and study to..or any other option that i can go with..

;)
 
Level 3
Joined
Jun 9, 2010
Messages
17
If you are trying to make ai units pick a random hero that no other ai player can get then try my http://www.hiveworkshop.com/forums/...0-0-a-239528/?prev=status=p&u=deathismyfriend template. It returns number that you can use so when the ai selects that hero it is random and will not be the same.

If that is not what you want then please explain better.

Thank you dude..I guess this is what i'm looking for..Tried inserting your trigger into mine but there's a problem at this trigger line:

  • set udg_tempInt2 = GenerateUniqueRandomInteger()
the error says "expected a name"

i'm not quite familiar with this custom trigger..so I don't know how to proceed..

sorry for troubling you but maybe you may give a hint on how do I combine your trigger into mine above..
 
Edit

Try this:
Put these "Set HSS_Ai = Hero"-lines in a Initialization trigger as PurgeandFire has said.
And then put all other actions into the loop and not in an external trigger.
(and you could just set points and remove leak if "Player Integer A is in left/rightPlayers Equal to True", this would reduce some actions if not every player you check passes the condition.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
You could do it like this(fix the leaking actions though):
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Hero_Type_Id[1] = Paladin
      • Set Hero_Type_Id[2] = Archmage
      • Set Hero_Type_Id[3] = Mountain King
      • Set Hero_Type_Id[4] = Blood Mage
      • Set Hero_Type_Max = 4
      • -------- Shuffle Hero Type List --------
      • For each (Integer Loop_Counter) from 1 to Hero_Type_Max, do (Actions)
        • Loop - Actions
          • Set Temp_Int = (Random integer number between Loop_Counter and Hero_Type_Max)
          • -------- Swap Hero[Loop Counter] with Hero[RandomInt Loop Counter to Hero Type Max] --------
          • Set Temp_Id = Hero_Type_Id[Loop_Counter]
          • Set Hero_Type_Id[Loop_Counter] = Hero_Type_Id[Temp_Int]
          • Set Hero_Type_Id[Temp_Int] = Temp_Id
      • -------- Create Heroes (non-repeating) --------
      • Set Temp_Int = Hero_Type_Max
      • For each (Integer A) from 1 to Hero_Type_Max, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Hero_Type_Id[Temp_Int] for Player 1 (Red) at (Player 1 (Red) start location) facing Default building facing degrees
          • -------- Show the order of creation (debug) --------
          • Floating Text - Create floating text that reads (String(Temp_Int)) above (Last created unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set Temp_Int = (Temp_Int - 1)
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
With my system look to see if there is a new version. Then do the same as the examples I have there. If you still can't get it I will try to help you more.

Edit: I believe I see the problem.
I don't return anything so don't use set tempInt = GenerateUniqueRandomInteger()

Do call GenerateUniqueRandomInteger()

It then returns the random integers in an array.
 
Level 3
Joined
Jun 9, 2010
Messages
17
Thanks for the reply guys..you guys surely very helpful..tried infusing chobibo's system but my wc3 got crashed..I will review back the triggering one by one when I have time tomorrow..been a bit busy lately...will revert back to tell the outcome soon..:)
 
Level 3
Joined
Jun 9, 2010
Messages
17
Ok guys...somehow i managed to make the computer controlled player not to pick the same hero between them by following below IcemanBo and PurgeandFire advise:

Put these "Set HSS_Ai = Hero"-lines in a Initialization trigger as PurgeandFire has said.
And then put all other actions into the loop and not in an external trigger.
(and you could just set points and remove leak if "Player Integer A is in left/rightPlayers Equal to True", this would reduce some actions if not every player you check passes the condition.

However, there is still chance they will pick the same hero picked by the user controlled player.

I've been trying to play around with the trigger for about a week now. Since, the AI will only pick the hero after the user controlled do, I don't put user pick hero trigger in the same loop with the AI pick hero trigger.

I believed, there's only one or two more lines of action that has to be put in between the loop of the AI pick hero trigger so that they don't pick the same hero as well as the one picked by the user.

need your input here guys :)
 
Level 3
Joined
Jun 9, 2010
Messages
17
If every single AI copy your choice, then you definitely got a problem over there!
Im not gonna explain everything in details. Here is a dead project which you can use as a template. CLICK ME
The hero picking is working perfectly fine!

hey..thanks...actually my previous hero picking system was ok but after changing to Almia's...this problem arouse..
nice project you have there but it crashes several times before I can end the game

Finally the problem has solved..thanks to IcemanBo for offering to look into my triggering and enlightening the way to handle this issue..

thanks everyone for the help
 
Status
Not open for further replies.
Top