
paulocf
Members-
Posts
26 -
Joined
-
Last visited
Everything posted by paulocf
-
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!
-
"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?
-
Thing is I didn't see MTA as separate from GTA, it was a foggy concept until now and yeah I was being stupid. In normal MMORPGs things happen independent of anyone because everything relies on the server, the opposite happens with MTA and that was a core concept I was missing. Now it's more clear though, I'll make the bosses more "moment-based" than permanent.
-
Thanks so much, I see... I was doing that but wanted a more realistic approach, guess I'll revert current script.
-
So, I decided to put an image here that hopefully will explain better my issue. Blue = Maximum distance de boss can go from his spawn point, if he goes out of bounds he resets, this causes him to go back to his spawnning position while recovering 10%HP/sec. Orange = It seems to be field of view in MTA (140meters it seems), when someone goes out of an object/ped's field of view they are not shown, they disappear due to distance. Now, the script WORKS while the player is within the monster's field of view, however, when they leave their field of view (black arrows in the image) the script breaks. Example 1: The monster is coming my way, I run a ton faster than him and get out of his sight, because he disappears to me the script breaks and no longer detects when he goes out of bounds, so he keeps chasing me forever (i.e. beyond maximum distance from spawn point). When I return close to his spawn point or where he was lastly, he returns back to that point and behaves accordingly. Example 2: The monster is returning to his spawn point, I run a ton faster than him and get out of his sight, because he disappears to me the script breaks and he doesn't move at all, when I return and he comes into sight he proceeds to move back to his spawn point. The script DOES work because I put several outputChatBox's to check if the timers are running, and indeed they are, it seems that being in sight/out of sight causes the ped not to respond to the script, or simply stops working as if slothbot would depend on someone being close to the bot for their action to be reported back to the server. Of course this is not intended, bot should be independent of anything and should move/exist on their own. Could someone please help me?
-
BUMP! Script goal: Have a boss aggro on someone and chase that person (default slothbot behavior), and head back to spawn point if the boss goes 50meters away from spawn point while recovering HP. Issue: Script works while the bots are in someone's sight, when they go out of sight bots behave weirdly and stop doing what they were told to do, as if they weren't client-independent.
-
I'm using this script server-side: -- Constants table MYPVEMOD = { ["BossMaxDistance"] = 50 } createTeam ( "MyPvE-Bosses", 255, 230, 0 ) local BTeam = getTeamFromName ( "MyPvE-Bosses" ) -- Find Z rotation between two 2d vectors (enemy and his target) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end addCommandHandler( "test1", function( plr, cmd) local x, y, z = getElementPosition( plr ); local skinz = math.random ( 300, 310 ) outputChatBox("Spawnning bot near you with skin #"..skinz..".") local ped = exports [ "slothBot" ]:spawnBot ( x+10, y+10, z, 270, skinz, 0, 0, BTeam, math.random ( 4, 9 ), "waiting")--, true ); if ped then local px, py, pz = getElementPosition(ped) setElementData(ped, "mypvemod.boss", true) setElementData(ped, "mypvemod.boss_resetPosX", px) setElementData(ped, "mypvemod.boss_resetPosY", py) setElementData(ped, "mypvemod.boss_resetPosZ", pz) setElementData(ped, "mybooname", "Ped"..tostring(math.random(20,300))) -- Start boss position tracking to keep him within spawn point radius (BossMaxDistance value) setTimer(bossTrackPosition, 500, 1, ped) else outputChatBox("Ped could not be created!") end end ) function onBotWastedCheck(theKiller, theWeapon, theBodypart) outputChatBox("Ped "..getElementData(source, "mybooname").." killed.") end addEvent("onBotWasted", true) addEventHandler("onBotWasted", getRootElement(), onBotWastedCheck) -- Tracks boss position function bossTrackPosition(boss) if (isElement(boss)) then local x, y, z = getElementPosition(boss) local rx, ry, rz = getElementData(boss, "mypvemod.boss_resetPosX"), getElementData(boss, "mypvemod.boss_resetPosY"), getElementData(boss, "mypvemod.boss_resetPosZ") -- Trigger reset when boss goes too far from spawn position (distance defined in BossMaxDistance constant) if (getDistanceBetweenPoints3D(x, y, z, rx, ry, rz) > MYPVEMOD["BossMaxDistance"]) then local tx, ty, tz = getElementPosition(getElementData(boss, "target")) local rotX, rotY, rotZ = getElementRotation(boss) rotZ = findRotation(x, y, tx, ty) setElementRotation(boss, rotX, rotY, rotZ) exports [ "slothBot" ]:setBotGuard(boss, rx, ry, rz, true) setElementData(boss, "mypvemod.boss_invulnerable", true) setTimer(bossReturnToSpawnPoint, 500, 1, boss) -- Break tracking position, boss is returning to spawn point from now on (resetting) else setTimer(bossTrackPosition, 500, 1, boss) end end end -- Returns boss to his spawn point function bossReturnToSpawnPoint(boss) local x, y, z = getElementPosition(boss) local rx, ry, rz = getElementData(boss, "mypvemod.boss_resetPosX"), getElementData(boss, "mypvemod.boss_resetPosY"), getElementData(boss, "mypvemod.boss_resetPosZ") outputChatBox("Distance: "..getDistanceBetweenPoints3D(x, y, z, rx, ry, rz)) -- Outputs distance from spawn point if (getDistanceBetweenPoints3D(x, y, z, rx, ry, rz) < 10) then -- Back in place setElementData(boss, "mypvemod.boss_invulnerable", false) exports [ "slothBot" ]:setBotWait(boss) -- Becomes aggressive again setTimer(bossTrackPosition, 1000, 1, boss) -- Track boss's position again once it's in place else --outputChatBox("Recovering HP.") setElementHealth(boss, getElementHealth(boss)+10) -- Returning and recovering 10%HP/sec. setTimer(bossReturnToSpawnPoint, 1000, 1, boss) end end Timer layout was inspired by slothbot, it works beautifully by the way.
-
So I'm making a script to spawn 'bosses' in specific locations in the map, I'm still testing my reset function that resets the bot whenever he goes too far from spawn point while recovering his HP on the way back. So far so good, BUT something weird is happening when a bot goes out of sight: I've put and outputChatBox to show the distance from his spawn point when he's going back to his spawn position (done through setBotGuard), when he is going back and goes out of my sight distance message doesn't change, it outputs like: "Distance: 43.48467", "Distance: 43.48467" and keeps repeating; same happens when he's coming my way to attack me, if I leave the area where he should be limited from leaving while being out of the his sight, he keeps coming and ignores the script, when I move within the area he appears back to his spawnning position and behave accordingly. It seems there is a lack of sync between client and server for slothbot, or I'm missing something, I've searched about stream-in and out but got no luck and I feel that's the reason... can someone help me?
-
Wiki says: "makes the bot move to the specific coords and stay there while attacking any enemies" Say a bot is in chasing or hunting mode and I setBotGuard to a position, he teleports instead of moving there, is this the expected behavior? How can I make the bot moves to some position instead of teleporting there? I'm using slothbot for this, so a solution compatible with it would be appreciated. @Edit Wait, I just realized I had two timers on and messed up everything, but even after disabling the wrong timer and having setBotGuard there the bot wouldn't stop chasing me, is it possible to break this mode and force into guarding a certain position? I'm aiming to make a way to "reset" the bot (like MMORPGs), he goes back to spawning position recovering all his HP along the way. @Solved So sorry, setBotGuard is working correctly, I ran into several errors that I'm ashamed of lol... first forgot to turn timer on for the boss position tracker, second tried calling setBotGuard as if it was a normal function (exported functions have different syntax), third... well there's not third, it's working perfectly. =X
-
I see what you mean, but this script can't rely on server responses because it depends on client's actions and someone can fake lagging issues OR actually have lagging issues... it is a protection system and has to be checked client-side.
-
Yes. The only way to make sure that no one can get the script is not sending it to the players. How would that be done? What if I set 1.3.2 as the min. version required?
-
So a client-side script has "cache" option on meta.xml, the file is downloaded and deleted after loading into memory, is there a way to actually extract the script from the memory or somehow get the script in the process? There's a guy telling me he managed to get my script, not sure if I should trust him or not and that's why I want to make sure it is protected. And it's funny cause it isn't THAT complicated, why would someone ever want to steal it?
-
Yes but not only that, I need to detect: local player entering a colshape, vehicle in which localplayer is driving entering a colshape, and a thrown-out car which was thrown by localplayer. If I don't filter for localplayer everything client-side is shared among all logged players, which is not intended. Edit: Would this work out? addEventHandler("onClientPlayerDamage", getLocalPlayer(), myFunction) getLocalPlayer() instead of getRootElement()? I saw this in a DayZ mode, so I take it works only for that client?
-
It works almost perfectly, but I need to check vehicles being controlled or thrown at the colshape, I really needed to know if the event is triggered for the localPlayer so I'd know if they were in a car, or the vehicle thrown at the base was controlled by them. If there isn't a way to tell by who the event was started, I might go for your idea... thanks!
-
Let me elaborate better: I have a script that detects if a player has entered a colshape client-side and push him back, there is a protected base inside the colshape so the shape acts as a shield. Then I proceed to outputChatBox("You're being watched!", 255, 0, 0), but this message is sent to everyone in the server as if the detection would count towards people that enters a colshape and is *close* to the localplayer, the message should be sent only to the person who is trying to enter a base, not everyone around (this is why I chose a client-side event, instead of a server-side). It starts: addEventHandler("onClientColShapeHit", getRootElement(), function(hitElement, matchingDimension)
-
Hi there! So I have an issue, I want to send a message to local player when something made BY HIM happens, is there a way to know if the event was triggered by the local player rather than a close other player?
-
Just wondering, do colshapes still not have rotations? I'm running into so many design issues because I can't rotate cuboids.
-
I love you and feel very stupid, thanks.
-
Simple as that, I swear I couldn't find a function to do that and it has nothing to do with events, I want to force a player to leave the vehicle or at least "detach" one from another so I can change vehicle's position and not move the player. Main reason for this is that when I kick a player controlling a car, the car disappears, so I want to have the vehicle at a certain position and separate from the player before kicking them.
-
@adrenalineSYS, thanks, I'll not use vehicles in my game! ^^ @50p, sorry for how confusing I may be sounding, I'm quite new to MTA modding. I was told there is a limit of types of objects existing in the game. I'll use an example: say GTA has 100 VEHICLES, with its own model and texture, is it possible to create my own vehicles apart from GTA default system and assign them their own models, texture, id, and overall "existence" within the game or am I limited to GTA system? Say, I want to have a total (it's an example, actual value would be like 800 or something) of 3 monsters (monstrous chicken, evil imp, and hypno-dancer), 2 NPCs (Innkeeper, and bank manager), and a pool of 4 characters (classes) the player can choose from (archer, warrior, mesmer, and mage). Each entity has model, and texture (skin), do I have to make everything fit into GTA already built-in ID-driven system, or can I make all my things apart and load and handle them as I wish? I could make an engine from scratch, but this project is an experiment and creating an engine from scratch takes a lot of work, that's why I'll be using MTA's extended modding interface as a "platform" to build my game onto. Hope you understood.
-
@50p, that's what I needed to know, element-specific limit and total element limit (32 and 65535), but it's not the skins. Let me try and elaborate better, I've heard you have X number of SKINS for vehicles (Skins, Models, etc, think like they're synonyms), so if there are 40 valid ID models, I can only have 40 valid skins for vehicles, is that so? Thanks for all the answers, much appreciated!
-
Hum, just to ensure, this is for concurrent peds on-game right? I mean, simultaneously spawned, I need to know this to keep track of ped destruction/respawn so that the limit doesn't get out of bounds. Also, what's the deal with IDs in GTA? Is GTA limited to any specific number of skins for peds, players, objects? Are these IDs shared among all visible elements? Can I extend the limit of skins for each element?
-
Hi there people, I'm starting a new big project and got a few questions regarding how far MTA can be used as a platform for modding. I'm the scripter who wrote the bases script (dantashost is my brother's account), so I think 50p reminds of me! Anyways, the questions are: 1) What's the limit of players, and Peds (bots) a server can have? 2) Since I'll be developing a MMORPG-like game mode I'll need melee "attacks" and projectile "attacks", is it possible to create projectile in shape of "skills", "magic"? (like a fireball) How is creating projectiles in shape of skills related to textures and animations (what file types are used)? 3) How does a ped behave and what limitations does it have? I've been reading about Slothbot and it seems wise to use it as the "enemy", but the enemy bot must be able to attack other enemy bot, can peds do it on their own or am I required to use Slothbot? 4) As one expect, all MMORPGs have something called "cooldown" or "recharge" for skills, that's the time a skill is locked until it's useable again. Would it lag client to have timers to handle skill recharges? Phew, that's it. Please just answer if you really understand, if anything is confusing I can rewrite my questions. If you are expert enough you can PM so I can ask a bit more advanced stuff... Thanks in advance!