Spanish / Pedido! - Entidades que sigan waypoint

Author
Message
miltonmdq
4
Years of Service
User Offline
Joined: 9th Apr 2020
Location:
Posted: 30th Apr 2020 22:49
Hola! alguien tendrua un script lua que haga que las entidades sigan waypoint? es para hacer autos dando vueltas por la ciudad
graciass
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 1st May 2020 07:34
Adjunte este script a la entidad que quiera utilizar, como por ejemplo un coche.


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
miltonmdq
4
Years of Service
User Offline
Joined: 9th Apr 2020
Location:
Posted: 1st May 2020 14:18
Hola, gracias por responder, pongo ese script, y la entidad con las siguientes configuraciones pero no me funciona, se queda estatica la entidad
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 1st May 2020 14:29
Haga clic en la entidad y elija propiedades.
Cambie la estática a 0 en lugar de a una.

Hope that makes sense. Google translated.
RIP
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

New:
Intel(R) Core(TM) i5-8400 CPU @ 2.81GHz, 12GB RAM, Nvidia gtx1050ti 4gb, Windows 10 Home 64bit, Screen resolution 1920 x 1080. System Passmark 3774




miltonmdq
4
Years of Service
User Offline
Joined: 9th Apr 2020
Location:
Posted: 1st May 2020 14:41
Hi dear PM, yes the entity is on dynamic mode but it still on the same place.. thank u so much
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 1st May 2020 17:56
Vaya a propiedades del objeto y ponga:
Always Active = YES
IsImmobile = NO
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
miltonmdq
4
Years of Service
User Offline
Joined: 9th Apr 2020
Location:
Posted: 1st May 2020 19:51
Mira, esta todo asi... he subido un video para que lo vean
no se quiere mover xd

[video=youtube]https://youtu.be/R6Tx9hrzoZM[/video]

(https://youtu.be/R6Tx9hrzoZM) el enlace por las dudas que no salga...

Y este es el script que esta usando que es el mismo que me diste vos


local state = {}
local pathindex = {}
local pathpointindex = {}
local pathdirection = {}
local movespeed = {}
local rotationOffset = {}

function follow_waypoints_init(e)
state[e] = "find a waypoint"
movespeed[e] = 60
rotationOffset[e] = 180
end

function follow_waypoints_main(e)

if state[e] == "find a waypoint" then
pathindex[e],pathpointindex[e],pathdirection[e] = GetNearestWaypoint(e)
if pathindex[e] > -1 then
state[e] = "follow waypoints"
else
state[e] = "no path"
end
elseif state[e] == "follow waypoints" then
pathindex[e],pathpointindex[e],pathdirection[e] = FollowWaypointPath(e,pathindex[e],pathpointindex[e],pathdirection[e],movespeed[e])
elseif state[e] == "no path" then
PromptLocal(e,"No path found near me!")
end
PromptLocal(e,"path index = "..pathindex[e].." , point index = "..pathpointindex[e].." , direction = "..pathdirection[e])
end

function follow_waypoints_exit(e)

end

function GetNearestWaypoint(e)
PathIndex = -1
PathPointIndex = -1
PathDirection = -1
pClosest = 99999
for pa = 1, AIGetTotalPaths(), 1 do
for po = 1 , AIGetPathCountPoints(pa), 1 do
pDX = g_Entity[e]['x'] - AIPathGetPointX(pa,po)
pDZ = g_Entity[e]['z'] - AIPathGetPointZ(pa,po)
pDist = math.sqrt(math.abs(pDX*pDX)+math.abs(pDZ*pDZ))
if pDist < pClosest and pDist < 200 then
pClosest = pDist
PathIndex = pa
PathPointIndex = po
if po > AIGetPathCountPoints(pa) then
PathDirection = -1
else
PathDirection = 1
end
end
end -- po
end -- pa
return PathIndex, PathPointIndex, PathDirection
end

function FollowWaypointPath(e,pathid,pointid,pathdirection,speed)
dpx = AIPathGetPointX(pathid,pointid)
dpz = AIPathGetPointZ(pathid,pointid)
CollisionOff(e)
RotateToPoint(e,dpx,dpz,rotationOffset)
MoveForward(e,speed)
CollisionOn(e)
tDistX = g_Entity[e]['x'] - dpx
tDistZ = g_Entity[e]['z'] - dpz
DistFromPath = math.sqrt(math.abs(tDistX*tDistX)+math.abs(tDistZ*tDistZ))
if DistFromPath < 50 then
maxpathpoints = AIGetPathCountPoints(pathid)
if pathdirection == 1 then
pointid = pointid + pathdirection
if pointid > maxpathpoints then
pathdirection = -1
pointid = maxpathpoints-1
end
else
pointid = pointid + pathdirection
if pointid < 1 then
pathdirection = 1
pointid = 2
end
end
end
return pathid, pointid, pathdirection
end

function RotateToPoint(e,x,z,offset)
if g_Entity[e] ~= nil and x > 0 and z > 0 then
local destx = x - g_Entity[e]['x']
local destz = z - g_Entity[e]['z']
local angle = math.atan2(destx,destz)
angle = angle * (180.0 / math.pi)
if angle < 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
SetRotation(e,0,angle+offset,0)
return angle
end
end
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 2nd May 2020 07:11
A ver, varias cosas:

1- subir un video al foro
Este es el link de youtube: https://youtu.be/R6Tx9hrzoZM y esta es la parte que nos interesa: R6Tx9hrzoZM, selecciónelo y arriba tiene el tag de video, pulse youtube y ya está.

Quote: "
"


2- Postear un script:
Copia/pega el script, luego seleccionarlo y pulse el tag de LUA arriba en el menú.

3- Acostúmbrese a probar los scripts tal como los recibe, luego cuando ya este seguro que trabaja bien, haga los cambios que quiera, así estará seguro que el fallo no está en el script.

El script se llama "follow waypoints" no "car follow waypoints"

Siempre que cambie el nombre de un script, también cámbielo en el script, o sino déjelo como está, o no le funcionara.


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
miltonmdq
4
Years of Service
User Offline
Joined: 9th Apr 2020
Location:
Posted: 2nd May 2020 14:20
Si, hago eso pero me sale ese error ... estoy usando ese codigo, y puse de nombre del archivo ''follow_waypoint.lua''
[img]null[/img]
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 2nd May 2020 18:04
Intentelo con este, pruebelo y no cambie nada.


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM

Login to post a reply

Server time is: 2024-04-26 06:31:25
Your offset time is: 2024-04-26 06:31:25