Bot Movement "explanation is below" #721
Replies: 1 comment
-
maybe someone can help me to include this into the playerbots. i dont code for over 11 years and its my first try on these. Key Features: Bots will move dynamically and avoid standing still in combat. They actively adjust their position based on their target and the surrounding environment. Bots check for harmful spells that may be affecting them (e.g., boss mechanics) and will take action to avoid being hit by dangerous effects, such as AoE damage. Bots can interact with clickable objects in the game world, such as portals, quest items, levers, and other interactive objects. Bots will intelligently switch targets when multiple enemies are present. If a bot's current target is not the only threat, it will look for and engage additional enemies (e.g., adds or secondary mobs) to behave more like a real player. The script allows server administrators to easily add new harmful spells or interactive objects by modifying the HarmfulSpells or InteractableObjects lists. The script covers a wide range of dungeons and raids, from Classic to WotLK, including encounters with complex mechanics, teleporters, and interactive objects. The script is designed to continuously update bot behavior during the game session, listening for specific events and triggering actions accordingly. |
Beta Was this translation helpful? Give feedback.
-
local UPDATE_INTERVAL = 2000
local SAFE_RADIUS = 5.0
local AOE_CHECK_RADIUS = 8.0
-- Zauber, die schädliche Flächen oder Mechaniken darstellen
local HarmfulSpells = {
-- Classic
68983, 41193, 39378, 19775, 19281, 24340, 23302, 41192, 40623, 46773,
}
-- Interaktive Objekte: Portale, Teleporter, Quest-Gegenstände für alle Dungeons und Raids
local InteractableObjects = {
-- Classic
[179104] = "Portal zu Molten Core", [181219] = "Schatztruhe - Onyxia",
}
-- Funktion zur Vermeidung von schädlichen Zaubern und Mechaniken
local function CheckAndAvoidAOE(bot)
for _, spellId in ipairs(HarmfulSpells) do
if bot:HasAura(spellId) then
local x, y, z = bot:GetX(), bot:GetY(), bot:GetZ()
local newX = x + math.random(-SAFE_RADIUS, SAFE_RADIUS)
local newY = y + math.random(-SAFE_RADIUS, SAFE_RADIUS)
bot:MoveTo(newX, newY, z)
return true
end
end
return false
end
-- Funktion zur Aktualisierung der Bewegung der Bots im Kampf
local function UpdateBotMovement(bot)
local target = bot:GetVictim()
if target then
if CheckAndAvoidAOE(bot) then return end
local x, y, z = target:GetX(), target:GetY(), target:GetZ()
local offsetX = math.random(-SAFE_RADIUS, SAFE_RADIUS)
local offsetY = math.random(-SAFE_RADIUS, SAFE_RADIUS)
bot:MoveTo(x + offsetX, y + offsetY, z)
local nearbyEnemy = bot:GetNearestEnemy()
if nearbyEnemy and nearbyEnemy ~= target then
bot:SetTarget(nearbyEnemy)
end
end
end
-- Funktion zur Interaktion mit Objekten
local function InteractWithObjects(bot)
for objectId in pairs(InteractableObjects) do
local gameObject = bot:GetNearestGameObject(objectId)
if gameObject and bot:GetDistance(gameObject) < 5.0 then
bot:UseGameObject(gameObject)
end
end
end
-- Hauptfunktion zur Aktualisierung des Verhaltens der Bots
local function UpdateBotBehavior(event, bot)
if bot:IsPlayerBot() then
UpdateBotMovement(bot)
InteractWithObjects(bot)
end
end
-- Registrieren der Ereignisse
RegisterPlayerEvent(28, UpdateBotBehavior)
Beta Was this translation helpful? Give feedback.
All reactions