• 🏆 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 Issue, how to solve this?

Status
Not open for further replies.
Level 4
Joined
Jun 11, 2005
Messages
34
Ok so i have this problem with the Computer AI and i have no idea how im supposted to solve this..

Im using the trigger to enable the melee AI because i want it activated for some of the computer players in my map but i dont want it activated for one of the computer players. Because if the melee AI is used for that one player he acts really strange and i dont want that so i thought: Hey perhaps i should make that player a Neutral player so the melee AI dont apply.. BUT then there is no AI what so ever.. no skills are used (thats not on auto cast)

So my question would be: How do i enable the melee AI for all players but one?
Or How do i make so a neutral player have the standard AI (Using skills, etc)
 
Level 12
Joined
Apr 16, 2010
Messages
584
Try putting this action before line where you enable Ai script
  • Custom script: if ( GetLocalPlayer() == Player(0) ) then
in this line there's a number 0 which means Player 1 Red, if you want Player 2 Blue type 1, f Player 3 Teal type 2 ...
After you created this action create put the action to enable AI and then another action:
  • Custom script: endif
So in the end you will this:
  • Actions
    • Custom script: if ( GetLocalPlayer() == Player(0) ) then
    • -------- Enable AI here --------
    • Custom script: endif
But you'll need to do this to every player to whom you want AI working, i never tried whis with AI but i'm sure this will work.
But there's a faster way like this:
  • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Custom script: if ( GetLocalPlayer() == Player(GetForLoopIndexA()) ) then
      • -------- Enable AI here --------
      • Custom script: endif
This way you will enable Ai only to players from 1st to 12th, and that's what you want i guess.
Hope this will help you.
 
Level 4
Joined
Jun 11, 2005
Messages
34
Thx for the response Stanley but as im not used to using custom scripts could you help me build the trigger correctly?

- I want Player 2,3,4,5,6,7 and 8 to have the Melee AI
- And i want Player 11 to be a computer without the Melee AI

Sorry but im just havent used any custom scripts before i just used the standard trigger for the AI (Melee Game - Run Melee AI Scripts (for computer players))

Would be much easier if it where a trigger like this: Run Melee AI Scripts for (Player Group) wouldnt it?
 
Level 12
Joined
Apr 16, 2010
Messages
584
Sure, wait few minutes and it will be done.
  • Actions
    • For each (Integer A) from 2 to 8, do (Actions)
      • Loop - Actions
        • Custom script: if ( GetLocalPlayer() == Player(GetForLoopIndexA()) ) then
        • -------- Run the AI here, i don't know hot cuz i never tried) --------
        • -------- Maybe this, below --------
        • Melee Game - Run melee AI scripts (for computer players)
        • Custom script: endif
    • -------- But i'm not sure that this will work for this action so --------
    • AI - Start melee AI script for (Player((Integer A))): map.ai //Why not use this action?
 
Level 4
Joined
Jun 11, 2005
Messages
34
About the AI- Start melee Ai Scrip for (Player) i have tried that but if i run it for a computer he does nothing. It does say something about "map.ai" you probably need to enter something there for it to work
 
Level 4
Joined
Jun 11, 2005
Messages
34
Yay i just figured out how to use that trigger!

Depending on the race the computer is you replace "map.ai" with for example "human.ai" then that player will get the melee ai...

This is great this now solves my problem but thanks anyway for helping
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
@Stanley
GetLocalPlayer()
That returns the player who executes the line. In single player for example, it will always return P1.

Instead of
JASS:
GetForLoopIndexA()
use
JASS:
bj_forLoopAIndex

@Slimmo:
You can extract the melee ai files from the MPQ file. Import it to your map. Then run the AI script for the players you want.

Or create your own AI file with the AI editor. Remember to import object data to the AI editor if you have custom units and abilities.
 
Status
Not open for further replies.
Top