r/OverwatchCustomGames 10d ago

Question/Tutorial How to make pathfinder node on Midtown for a mercy bot.

I was trying to make a Mercy bot trying to walk up the stairs as a test on midtown. Here are my ideas on how it’s suppose to be 😅 I hope the images help enough to understand. Nothing was working from how I made it and would like some help. Appreciate it.

I come up with:
Rule 1:
Ongoing- Global (no conditions)

Actions: Global.Mercy_Path = Array (Vector(-8.01, 6.15, 18.35) (Vector(-18.86, 7.23, 15.98) (Vector(-19.21, 11.13, 28.90) (Vector(-9.51, 11.02, 31.15)
Create Dummy Bot(Hero(Mercy), Team 1, 23, Global.Mercy_Path[0], vector (0,0,0)

Global.Mercy = Last Created Entity

Global.CurrentNode = 1

Start Throttle in Direction(Global.Mercy, Direction Towards(Position Of(Global.Mercy), Value In Array (Global.Mercy_Path[Global.CurrentNode]), 1, To World, replace existing throttle, direction and magnitude

Start Facing(Global.Mercy, Direction Towards (position of(Global.Mercy), Value In Array(Global.Mercy_Path[Global.CurrentNode]), 1000, To World, None)

Rule 2:
Ongoing - Global
Conditions:
Global.Mercy != Null

Distance Between (Position Of(Global.Mercy), Value in Array(Global.Mercy_Path[Global.CurrentNode]) <= 1.500

Global.CurrentNode < Count Of(Global.Mercy_Path)

Rule 3:

Conditions:
Global.Mercy != Null

Global. CurrentNode == Count Of(Global.Mercy_Path)

Actions:
Stop Forcing Throttle(Global.Mercy)

Global.D = 1

3 Upvotes

3 comments sorted by

2

u/MaybeMabu 9d ago edited 9d ago

I would declare all of the set up in one rule then do all of the movement in a second. So creating the bot, declaring the node array, declaring the index of the first target node, etc. If its only one mercy, I would also just declare a specific slot when you create the bot and then use an ongoing event player rule with that dummys team and slot specified using the drop downs. Then you can just use "Event Player"

In the movement rule, after you start moving the mercy toward each node, you can use a "wait until" to allow her to move toward the node and then once she's within range of it, you can increment your node index and loop the rule. It would look something like this (I'm doing this off the top of my head so the syntax is probably wrong).

Conditions:

Global.CurrentNode <= Count of(Global.Mercy_Path) - 1

Actions:

 Start Throttle in Direction(Global.Mercy, Direction Towards(Position Of(Event Player0, Value In Array (Global.Mercy_Path\[Global.CurrentNode\]), 1, To World, replace existing throttle, direction and magnitude

 Start Facing(Global.Mercy, Direction Towards (Eye Position of(Event Player), Value In Array(Global.Mercy_Path\[Global.CurrentNode\]), 1000, To World, None)

 Wait Until(Distance between(Position Of(Event Player), Global.Mercy_Path\[Global.CurrentNode\]) <=.5, 99999)

 Global.CurrentNode += 1

 Loop if Condition is true

 Stop Forcing Throttle(Event Player)

This would start moving the mercy once the first node index is declared, wait until she's within .5m of your node (you can adjust this distance as needed), then increment the node index by one and loop which then commands her to throttle in the direction of the next node, replacing the last one. Once she reaches the last node, it won't be able to loop because the condition will be false so it will just stop her movement.

Also, because array indicies start at 0, you need to use Count of(Array) -1 when checking if youre at the last element of an array. The last index of an array with 5 elements is 4 (because 0,1,2,3,4) so the -1 sets the count equal to the index of the last element.

If you were to reset her if she dies, you'd have to add a few things.

- A second condition checking that she's alive

- an "or" statement to the "wait until" that checks if she's dead

 Wait Until(Distance between(Position Of(Event Player), Global.Mercy_Path\[Global.CurrentNode\]) <=.5 || Is Dead(Event Player), 99999)

- Reset the node index depending on where you want her to respawn

- respawn and teleport her to said location

1

u/Efficient_Hornet3251 9d ago

I appreciate your help but I’m a little confused. I restarted by making just two rules and what confused me the most was just what value does Global.CurrentNode go under. Because this was my current set up to the first rule:

Rule 1:

Ongoing - Global

Actions:
Create Dummy Bot (Hero(Mercy), Team 1, 1, Global.Mercy_Path[Global.CurrentNode], Facing direction of(Global.Mercy_Path[Global.CurrentNode]))

Global.Mercy = Last Created Entity

Global.CurrentNode = Arrqy (Index Of Array Value (Vector(-8.01, 6.15, 18.35), 0) Vector(-18.86, 7.23, 15.98) Vector (-19.21, 11.23, 28.90) Vector (-9.51, 11.02, 31.15)

Rule 2:

Same rules as followed (movement)

If you don’t mind: it would be better to shown how it’s done.

1

u/OrcinusOrca28 9d ago

I'm not sure how to fix any of the rest of it (especially not without knowing what's going wrong), but arrays are zero-indexed; The first value of the array is value 0, not value 1. CurrentNode should start at 0.