Hey is it possible in UT2004/UE2 to Modify or Create AI Attributes via UnrealScript. (like Aggression and Accuracy and where are they located ,bot, AI Controller etc)
Hey is it possible in UT2004/UE2 to Modify or Create AI Attributes via UnrealScript. (like Aggression and Accuracy and where are they located ,bot, AI Controller etc)
Last edited by 842Legion; 06-16-2012 at 09:26 AM.
Yes, for both games it is. Mysterial's SuperBots mod is a good example, and shows how to swap out the bot type at runtime via a mutator. Download from here.
"What do you mean it doesn't exist clientside?"
YARM: where player's Lean, Prone, Mantle, Dash, Crouch Jump, 'Parkour' and slide around all with generic realistic weapons!
My Generic Mods for UT2K4:
Yet Another Real-life Mod: Realistic weapons, unoriginal gameplay, w/ cheap CODMW knockoff mutator
TD Vehicles: HUMV, MI4Hound, Motorcycle, IFAV Jeep, UH-60, MH-53 & AH-6 Helicopters, Abrams Tank
Meowcat thank you for replying so quickly, Do you have to replace it with a mutator or can you edit the source? (also are the personality attributes in Classes\bot.uc or somewhere else?)
Well all depends on what you want to do. I think Jafo made a mutator (or maybe it was an external utility) that allowed you to tweak the "personality/combat" settings of the 'named' bots, which could then be selected prior to starting an instant action match by using the "Bot Lists". The named Bots combat personality (aggressiveness, strafing ability, jumpiness etc.) variables are actually stored in either the .upl files in your UT2004/System folder, or some other config file. When the named bots are loaded in game for a match, these stored values are used to set the bots combat personality attributes. And yes, the original variable declaration for those attributes is in bot.uc.
If you wanted to add additional behavior attributes/variables (and the code to actually take the variable into account) you would need to subclass Bot (or probably xBot). If it'ss a new gametype you are creating, you can use the Invasion gametype code as an example of how to use a different AI controller bot. If you just want to use your bot in the normal gametypes (TDM, DM, CTF, BR etc), Mysterial's mutator provides an example of the only 'clean' way to swap out the bot type in real-time in UT2k4.
"What do you mean it doesn't exist clientside?"
YARM: where player's Lean, Prone, Mantle, Dash, Crouch Jump, 'Parkour' and slide around all with generic realistic weapons!
My Generic Mods for UT2K4:
Yet Another Real-life Mod: Realistic weapons, unoriginal gameplay, w/ cheap CODMW knockoff mutator
TD Vehicles: HUMV, MI4Hound, Motorcycle, IFAV Jeep, UH-60, MH-53 & AH-6 Helicopters, Abrams Tank
Meowcat thank you very much, for the record i understand the AI attributes and how to set them in the upl files for each bot, my aim war to find out if i could add new variables or extend the existing AI/bot code to my preference.
Thank you very much for your help much appreciated.![]()
Just want to add one more Question to this thread, With the unrealscript (UE2/UE3/UDK) is the AI system rigid and fixed in C++ or is it more open and malleable to modification? (e.g use neural networks, Genetic Algorithms etc)
Last edited by 842Legion; 06-17-2012 at 08:53 AM.
The AI behavior is completely 'malleable' and open within UnrealScript, the only C++/native code portions are for some very low-level notifications and actions (notifications that other pawns are visible, finding a path on the pathnetwork to a given actor, moving towards a locational goal by setting the pawn's acceleration vector etc.). Even a lot of the native functionality can be 'twisted'/'tweaked' to perform in different ways (look at the Bot's pathfinding calls when "bDevious" is true, it alters the weights of pathnodes to find better flanking paths when sneaking up on it's enemy). That being said, trying to have UnrealScript interact with any external code not written in Unrealscript is very limited (via the TCP/IP and UDP sockets coding). If neural networks and genetic algorithms are memory or code "intense" then performance may suffer greatly if written in UnrealScript.
I think there was a previous project that tried (and may have successfully implemented) a different kind of AI using some other "thinking" algorithms. Depending on what you are trying to do (code experiment for school project etc), you might be better off using the UDK since it already has "hooks" to allow communication between UnrealScript and DLLs.
Last edited by meowcat; 06-17-2012 at 12:19 PM.
"What do you mean it doesn't exist clientside?"
YARM: where player's Lean, Prone, Mantle, Dash, Crouch Jump, 'Parkour' and slide around all with generic realistic weapons!
My Generic Mods for UT2K4:
Yet Another Real-life Mod: Realistic weapons, unoriginal gameplay, w/ cheap CODMW knockoff mutator
TD Vehicles: HUMV, MI4Hound, Motorcycle, IFAV Jeep, UH-60, MH-53 & AH-6 Helicopters, Abrams Tank
It's completely interpreted (despite the fact that you have to compile it into a package), and has pretty much no multithreading support. In fact, Epic Games decided to drop UnrealScript in UE4 probably mostly for the reason that UnrealScript is so slow and hardly threadable.
In the file bot.uc which part of the code sets the variable for Aggression, I want to be sure, so i don't screw anything up. Is it under "function FightEnemy", function ChooseAttackMode, function float RelativeStrength, or another, as it seems they mix with combat style as well.
The function call chain is a little complex.
For any game that is a subclass of UnrealGame.DeathMatch, a series of function calls either at the beginning of the match or as players log in and out, eventually call the 'SpawnBot' function in the GameType. This function either uses a pregiven BotName, or via the UnrealTeamInfo actor, selects some other name and creates a 'RosterEntry' object which is what pulls the .upl file string data for a given bot character (to include its attributes). The RosterEntry object is then passed the newly spawned bot via the gametype's InitializeBot function. The RosterEntry object then sets the bot's accuracy, aggressiveness/baseagressiveness, combat style etc. in this InitBot function.
So in summary, look at the following classes: DeathMatch.uc, RosterEntry.uc, UnrealTeamInfo.uc, xTeamRoster.uc (in xGame folder) starting with the 'AddBot' function.
"What do you mean it doesn't exist clientside?"
YARM: where player's Lean, Prone, Mantle, Dash, Crouch Jump, 'Parkour' and slide around all with generic realistic weapons!
My Generic Mods for UT2K4:
Yet Another Real-life Mod: Realistic weapons, unoriginal gameplay, w/ cheap CODMW knockoff mutator
TD Vehicles: HUMV, MI4Hound, Motorcycle, IFAV Jeep, UH-60, MH-53 & AH-6 Helicopters, Abrams Tank
What I mean is the source function that defines the attribute.
Is there a form of documentation for the unreal script available that covers more then the basics, i know the syntax and most of the elements that are similar to java and C/C++.
Last edited by 842Legion; 06-20-2012 at 05:53 AM.
About ideas for AI, when you spectate bots in first person the Aiming behavior and movement seems to either very mechanical or rather erratic and strange, Is that the Aimerror or a animation problem and is there a fix for it.
I was thinking to make bots aim and view their environment like humans, what about a simulated mouse and have y and x axis and percentage offsets when bots makes movement, just an idea.
I still don't get what exactly you mean by that. The aggressiveness stats are taken from a UPL file and used all over Bot.uc.
For documentation, you can always look at the Unreal Engine Wiki: http://wiki.beyondunreal.com/ The legacy pages there are more focused towards UE2 than the normal pages, however.
About the AI behaviour, it's pretty much how AI works. They track you precisely all the time, and just before firing they apply aim error. Though I'm not sure why there's a discrepancy between the first and third person view, as in third person, it's obviously visible that the bots look up and down, yet in first person their view is locked to the XY plane. So making it more organic should be possible as well.
I think I know what you mean/what you're looking for now. As you already found, it is primarily the FightEnemy code (and if I recall correctly), some of the SquadAI functions that use the bot's Aggressiveness to rate which enemies to select. The Accuracy attribute is used in the AdjustAimError function to affect how much extra slop is added to the Bot shooting direction rotation when firing at an enemy (or aiming ahead of the player when firing projectiles etc.). Obviously these attribute variables could be named anything (var float KittyCat, var byte PuffyClouds), and like you suspected it is only how these variables are used in functions that actually determines their purpose (how they are declared/named etc. does not really matter so long as the var type is conducive for the kind of info/weighting your looking for).
Any attribute variable added by you would only be used by whatever functions you added or modified. What exactly are you trying to do? Just general AI experimentation? Improving the combat AI, or AI for a specific gametype? Better NPCs?
There is very little other explanation of the existing Bot.uc/SquadAI.uc source code but thankfully it is generally pretty straightforward to follow. If you want to understand the UT2k4 bot code any better you will just have to go through the "fun" of reading through it all (like I did) and use the 'ShowDebug' and 'ViewBot' console commands to observe the bots in game to see how when they change states, rate weapons, select enemies, go after weapon pickups etc.
The function 'ExecuteWhatToDoNext' function and the 'WanderOrCamp' functions are good places to start when reading through Bot.uc. Also, take a look at the various 'event' type notifications, they usuallyforce the bot to rethink what it is doing by calling 'WhatToDoNext'.
Last edited by meowcat; 06-21-2012 at 02:22 AM.
"What do you mean it doesn't exist clientside?"
YARM: where player's Lean, Prone, Mantle, Dash, Crouch Jump, 'Parkour' and slide around all with generic realistic weapons!
My Generic Mods for UT2K4:
Yet Another Real-life Mod: Realistic weapons, unoriginal gameplay, w/ cheap CODMW knockoff mutator
TD Vehicles: HUMV, MI4Hound, Motorcycle, IFAV Jeep, UH-60, MH-53 & AH-6 Helicopters, Abrams Tank
All right thanks for clearing things up and those console commands are very good, and yes I'm trying to improve bot/NPC combat AI and experiment with different Functions/Techniques and behaviors.
Is the AI from UE2 similar to UE3? i haven't used UDK much.
Meowcat Thank you very much for everything!![]()
Bookmarks