paulocf Posted June 18, 2013 Share Posted June 18, 2013 "This triggers when a bot locates an enemy, This event can be cancelled to prevent the bot from chasing players" Only players? Isn't there a way to, for example, cancelEvent() if the bot is 10 meters away from a certain player? I tried and script ignores... function cancelDogChaseEnemy(theEnemy) if getElementData(source, "guardian_dog") then if theEnemy then if not getElementData(theEnemy, "zombie") then -- Attacks only zombies cancelEvent() -- this is respected, won't attack players return end outputChatBox("#FFD36BGuardian-dog:#FF0000 GRRRRR! Hawf hawf!", getElementData(source, "dog_owner"), 255, 255, 255, true) local dx, dy, dz = getElementPosition(getElementData(source, "dog_owner")) -- Dog owner's position local ex, ey, ez = getElementPosition(theEnemy) -- Enemy's position -- If distance between spotted enemy and owner is higher than pre-defined var, dog won't attack if getDistanceBetweenPoints3D(ex, ey, ez, dx, dy, dz)>10 then cancelEvent() -- ignored, will continue towards another ped ignoring this cancelEvent() end else cancelEvent() end end end addEvent("onBotFindEnemy", true) addEventHandler("onBotFindEnemy", getRootElement(), cancelDogChaseEnemy) I tried changing modes on-the-fly, and the bot will simply bug (and sometimes even not changing bot mode) and run to infinity. Is this a bug? Link to comment
Moderators IIYAMA Posted June 18, 2013 Moderators Share Posted June 18, 2013 https://wiki.multitheftauto.com/wiki/Sl ... setBotWait 1 Features 2 Server Events 2.1 onBotFindEnemy 2.2 onBotWasted 2.3 onBotSpawned 2.4 onBotFollow 3 Server Functions 3.1 spawnBot 3.2 setBotHunt 3.3 setBotWait 3.4 setBotChase 3.5 setBotFollow 3.6 setBotGuard 3.7 getBotTeam 3.8 setBotTeam 3.9 getBotAttackEnabled 3.10 setBotAttackEnabled 3.11 getBotMode 3.12 isPedBot 3.13 setBotWeapon 4 Credits Link to comment
paulocf Posted June 18, 2013 Author Share Posted June 18, 2013 I know about that and I'll give it a shot, it's just that I'm afraid of changing modes because it usually leads the bot to run to infinity... anyways, thank you! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now