ineedbots / iw3_bot_warfare

The Bot Warfare mod for CoD4
https://www.moddb.com/mods/bot-warfare
48 stars 7 forks source link

Bots spinning in different directions cant walk straight #22

Closed exeLocates closed 9 months ago

exeLocates commented 1 year ago

Hello, I'm trying to implement the bots into a mod, I have them set to only go to allies and be 1 bot only, he keeps spinning in random directions aiming in and out of his gun and walking backwards and forwards. sometimes he will follow the waypoints for 1 second then go back to spinning in random directions.

Clearly the bot is following the waypoints, it is on shipment and the waypoints loaded correct. I'm trying to ascertain as to what the bot is trying to target or follow but keeps getting stuck in a loop somewhere trying to find a nonexistent target?

However when I try to print bot.target or bot.script_target or bot.script_goal they all return undefined.

I would love to get in contact on discord if possible, I highly appreciate your project my friend. My discord is Locates#4189

exeLocates commented 1 year ago

it seems to be loop notifying new_goal_internal which then notifys kill_goal which causes the doWalk method to keep reoccurring then stopping in a loop.

exeLocates commented 1 year ago

I put the exact same files into a different mod and the bots worked perfect. how could this be?

exeLocates commented 1 year ago

File reference: _bot_internal.gsc Method reference: doWalk( goal, dist, isScriptGoal ) I have added after line 1909: iPrintln("Current Waypoint Goal: " + current); inside the while ( current >= 0 ) loop.

Method reference: walk_loop() I have added after line 1665: iPrintln("goal : " + goal); inside the if(level.waypointCount) statement.

Result on the mod that the bots spin and walk back n forth: image

Result on the mod that the bots work correct (EXACT SAME SCRIPTS) image

Clearly the bot is not going to waypoints in order and randomly bouncing back n forth between them. I am wondering how this could be possible? is it new_goal_internal being notified? what else could it be?

Thank you @ineedbots in advance :)

ineedbots commented 1 year ago

The code that actually has the bots move in a direction is movetowards( goal ).

This method can only stop executing when the bot is near the goal: https://github.com/ineedbots/cod4x_bot_warfare/blob/master/main_shared/maps/mp/bots/_bot_internal.gsc#L1966

Or when kill_goal is notified on the bot. https://github.com/ineedbots/cod4x_bot_warfare/blob/master/main_shared/maps/mp/bots/_bot_internal.gsc#L1886

kill_goal can be notified in many ways, the most common one is here: https://github.com/ineedbots/cod4x_bot_warfare/blob/master/main_shared/maps/mp/bots/_bot_internal.gsc#L1858

Try searching for notify( "kill_goal" ); in the code base to find all occurances.

ineedbots commented 1 year ago

I have no idea how your mod is interacting with this, so I dont know how your bots are not pathing properly.

exeLocates commented 1 year ago

I have no idea how your mod is interacting with this, so I dont know how your bots are not pathing properly.

This is why its so peculiar, my mod does not even interact with it at all. I haven't changed or added anything besides how the bot selects a team (level.axis / level.allies don't work since the mod has different menu options) Otherwise everything is the same.

I have added Bot warfare to many different mods using the exact same files I have used here, it has always worked perfectly, truly puzzled here.

exeLocates commented 1 year ago

cleanUpAStar is being called constantly via kill_goal, however I've put a iPrintLn underneath every single notify kill_goal and none of them print. so how could kill_goal be notified??

I'm still trying to figure this out and i keep ending up back at square one.

If you could find a spare 10min of your time anyday please let me know I would really appreciate it, I'm sure you would be able to put me on the right path if you saw it live. my discord is Locates#4189

exeLocates commented 1 year ago

I believe the issue is with new_goal_internal, so it goes into walk_loop, gets the goal like it should and then does doWalk but does not stay in doWalk and immediately exits it repeats walk_loop and keeps doing that infinitely.

When I remove killwalkonevents from doWalk() the bot walks to the given goal like it should, however the bot is stuttering as if it was rubber banding

exeLocates commented 1 year ago

the main issues seem to be movetowards( goal ) and new_goal_internal, when i set if( time > 3000 ) in movetowards() lower, such as if( time > 50 ) then the rubber banding disappears

exeLocates commented 1 year ago

image what could be the reason for this line constantly being run every 0.1 second?

exeLocates commented 1 year ago

Hey, hope you come online soon and are able to help me out!

My discord is: exelocates

I know we could fix this very fast over discord and I would love to compensate you for your time!

Hope you come back soon :)

exeLocates commented 1 year ago

Hey, following up and would love to connect on discord.

Willing to paypal $50

ineedbots commented 9 months ago

I don't know what you are trying to accomplish, sorry. The most basic way of telling a bot to move to a goal is using the SetScriptGoal function in the maps\mp\bots_bot_utility. https://github.com/ineedbots/iw3_bot_warfare/blob/master/maps/mp/bots/_bot_utility.gsc#L457

https://github.com/ineedbots/iw3_bot_warfare/blob/master/maps/mp/bots/_bot_script.gsc#L3815 For an example of the bot going to the domination flag.