• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Confused finding closest point

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
737
Hi

I've just started making an AI system for one of my Pokemon based map. Around the map are 4 different Pokecenters (they act as fountain of health and mana) and so I'm trying to work out a way in which I can get my AI to flee to the closest one. This would normally work happily but in the middle of the map is a gate that cuts of the route to 2 of the Pokecenters.

So what I am needing to do is make them move to the closest Pokecenter but until the quest is completed to open the gate they would only notice the two before passing the gate.

Would anyone be willing to give me a hand in this?
 
Level 10
Joined
Jun 6, 2007
Messages
392
In your case, since the numbers are so small and there's only one relative quest, this might be the easiest way:

  • Events
    • some event to finish the quest
  • Conditions
  • Actions
    • Set QuestDone = true
  • Events
    • flee event
  • Conditions
  • Actions
    • set Pokecenters[0] = position of Pokecenter 0000 <gen>
    • set Pokecenters[1] = position of Pokecenter 0001 <gen>
    • set Pokecenters[2] = position of Pokecenter 0002 <gen>
    • set Pokecenters[3] = position of Pokecenter 0003 <gen>
    • if QuestDone equal to true then
      • then actions
        • set CenterCount = 3
      • else actions
        • set CenterCount = 1
    • set FleePoint = Pokecenters[0]
    • Dist = distance between FleePoint and CurrentPosition
    • for each integer A = 1 to CenterCount do
      • do actions
        • if distance between Pekecenters[A] and FleePoint < Dist then
          • then actions
            • set Dist = distance between Pekecenters[A] and FleePoint
            • set FleePoint = Pekecenters[A]
          • else actions
    • flee to FleePoint
This is more of a pseudo code than a real trigger, but I think it's quite clear. It's important that the first available pokecenters are at indexes 0 and 1.
 
Level 13
Joined
Oct 16, 2010
Messages
737
I've now worked it out in some manner of ways but it ends up working out the same either way.

I don't know what a "pseudo code" is but this trigger is being run by another main trigger, then the action in the main trigger after this trigger has been run will use the point made by this trigger. Either way it works.

Thanks anyway! I may use your method in different maps!
 
Status
Not open for further replies.
Top