VVr0ngVVay

Members
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

0 Neutral

About VVr0ngVVay

  • Rank
    Square

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. npc_functions_s.Lua function enableHLCForNPC(npc,walkspeed,accuracy,drivespeed) if not isElement(npc) or getElementType(npc) ~= "ped" then outputDebugString("Invalid ped argument",2) return false end if all_npcs[npc] then outputDebugString("HLC already enabled",2) return false end if walkspeed and not NPC_SPEED_ONFOOT[walkspeed] then outputDebugString("Invalid walkspeed argument",2) return false end if accuracy then accuracy = tonumber(accuracy) if not accuracy or accuracy < 0 or accuracy > 1 then outputDebugString("Invalid accuracy argument",2) return false end end if drivespeed then drivespeed = tonumber(drivespeed) if not drivespeed or drivespeed < 0 then outputDebugString("Invalid drivespeed argument",2) return false end end addEventHandler("onElementDataChange",npc,cleanUpDoneTasks) addEventHandler("onElementDestroy",npc,destroyNPCInformationOnDestroy) all_npcs[npc] = true setElementData(npc,"npc_hlc",true) --addNPCToUnsyncedList(npc) setNPCWalkSpeed(npc,walkspeed or "run") setNPCWeaponAccuracy(npc,accuracy or 1) setNPCDriveSpeed(npc,drivespeed or 40/180) return true end function disableHLCForNPC(npc) if not isElement(npc) or getElementType(npc) ~= "ped" then outputDebugString("Invalid ped argument",2) return false end if not all_npcs[npc] then outputDebugString("HLC not enabled",2) return false end clearNPCTasks(npc) removeEventHandler("onElementDataChange",npc,cleanUpDoneTasks) removeEventHandler("onElementDestroy",npc,destroyNPCInformationOnDestroy) destroyNPCInformation(npc) removeElementData(npc,"npc_hlc") removeElementData(npc,"npc_hlc:walk_speed") removeElementData(npc,"npc_hlc:accuracy") removeElementData(npc,"npc_hlc:drive_speed") return true end function setNPCWalkSpeed(npc,speed) if not npc or not all_npcs[npc] then outputDebugString("Invalid ped argument",2) return false end if speed ~= "walk" and speed ~= "run" and speed ~= "sprint" and speed ~= "sprintfast" then outputDebugString("Invalid speed argument",2) return false end setElementData(npc,"npc_hlc:walk_speed",speed) return true end function setNPCWeaponAccuracy(npc,accuracy) if not npc or not all_npcs[npc] then outputDebugString("Invalid ped argument",2) return false end accuracy = tonumber(accuracy) if not accuracy or accuracy < 0 or accuracy > 1 then outputDebugString("Invalid accuracy argument",2) return false end setElementData(npc,"npc_hlc:accuracy",accuracy) return true end function setNPCDriveSpeed(npc,speed) if not npc or not all_npcs[npc] then outputDebugString("Invalid ped argument",2) return false end speed = tonumber(speed) if not speed or speed < 0 then outputDebugString("Invalid speed argument",2) return false end setElementData(npc,"npc_hlc:drive_speed",speed) return true end ------------------------------------------------ function addNPCTask(npc,task) if not npc or not all_npcs[npc] then outputDebugString("Invalid ped argument",2) return false end if not isTaskValid(task) then outputDebugString("Invalid task argument",2) return false end local lasttask = getElementData(npc,"npc_hlc:lasttask") if not lasttask then lasttask = 1 setElementData(npc,"npc_hlc:thistask",1) else lasttask = lasttask+1 end setElementData(npc,"npc_hlc:task."..lasttask,task) setElementData(npc,"npc_hlc:lasttask",lasttask) return true end function clearNPCTasks(npc) if not npc or not all_npcs[npc] then outputDebugString("Invalid ped argument",2) return false end local thistask = getElementData(npc,"npc_hlc:thistask") if not thistask then return end local lasttask = getElementData(npc,"npc_hlc:lasttask") for task = thistask,lasttask do removeElementData(npc,"npc_hlc:task."..task) end removeElementData(npc,"npc_hlc:thistask") removeElementData(npc,"npc_hlc:lasttask") return true end function setNPCTask(npc,task) if not npc or not all_npcs[npc] then outputDebugString("Invalid ped argument",2) return false end if not isTaskValid(task) then outputDebugString("Invalid task argument",2) return false end clearNPCTasks(npc) setElementData(npc,"npc_hlc:task.1",task) setElementData(npc,"npc_hlc:thistask",1) setElementData(npc,"npc_hlc:lasttask",1) return true end function isTaskValid(task) local taskFunc = taskValid[task[1]] return taskFunc and taskFunc(task) or false end actions_s.Lua function makeNPCWalkToPos(npc,x,y,z,maxtime) local px,py,pz = getElementPosition(npc) local walk_dist = NPC_SPEED_ONFOOT[getNPCWalkSpeed(npc)]*maxtime*0.001 local dx,dy,dz = x-px,y-py,z-pz local dist = getDistanceBetweenPoints3D(0,0,0,dx,dy,dz) dx,dy,dz = dx/dist,dy/dist,dz/dist local maxtime_unm = maxtime if dist < walk_dist then maxtime = maxtime*dist/walk_dist walk_dist = dist end local model = getElementModel(npc) x,y,z = px+dx*walk_dist,py+dy*walk_dist,pz+dz*walk_dist local rot = -math.deg(math.atan2(dx,dy)) local move = true if check_cols then local box = call(server_coldata,"createModelIntersectionBox",model,x,y,z,rot) local boxprev = call(server_coldata,"getElementIntersectionBox",npc) move = not call(server_coldata"doesModelBoxIntersect",box,getElementDimension(npc),boxprev) end if move then setElementPosition(npc,x,y,z,false) setPedRotation(npc,rot) if check_cols then call(server_coldata,"updateElementColData",npc) end return maxtime else setElementPosition(npc,px,py,pz) setPedRotation(npc,getPedRotation(npc)) return maxtime_unm end end function makeNPCWalkAlongLine(npc,x1,y1,z1,x2,y2,z2,off,maxtime) local x_this,y_this,z_this = getElementPosition(npc) local walk_dist = NPC_SPEED_ONFOOT[getNPCWalkSpeed(npc)]*maxtime*0.001 local p2_this = getPercentageInLine(x_this,y_this,x1,y1,x2,y2) local p1_this = 1-p2_this local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) local p2_next = p2_this+walk_dist/len local p1_next = 1-p2_next local x_next,y_next,z_next local maxtime_unm = maxtime if p2_next > 1 then maxtime = maxtime*(1-p2_this)/(p2_next-p2_this) x_next,y_next,z_next = x2,y2,z2 else x_next = x1*p1_next+x2*p2_next y_next = y1*p1_next+y2*p2_next z_next = z1*p1_next+z2*p2_next end local model = getElementModel(npc) local rot = -math.deg(math.atan2(x2-x1,y2-y1)) local move = true if check_cols then local box = call(server_coldata,"createModelIntersectionBox",model,x_next,y_next,z_next,rot) local boxprev = call(server_coldata,"getElementIntersectionBox",npc) move = not call(server_coldata,"doesModelBoxIntersect",box,getElementDimension(npc),boxprev) end if move then setElementPosition(npc,x_next,y_next,z_next,false) setPedRotation(npc,rot) if check_cols then call(server_coldata,"updateElementColData",npc) end return maxtime else setElementPosition(npc,x_this,y_this,z_this) setPedRotation(npc,getPedRotation(npc)) return maxtime_unm end end function makeNPCWalkAroundBend(npc,x0,y0,x1,y1,z1,x2,y2,z2,off,maxtime) local x_this,y_this,z_this = getElementPosition(npc) local walk_dist = NPC_SPEED_ONFOOT[getNPCWalkSpeed(npc)]*maxtime*0.001 local p2_this = getAngleInBend(x_this,y_this,x0,y0,x1,y1,x2,y2)/math.pi*2 local p1_this = 1-p2_this local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) local p2_next = p2_this+walk_dist/len local p1_next = 1-p2_next local x_next,y_next,z_next,a_next local maxtime_unm = maxtime if p2_next > 1 then maxtime = maxtime*(1-p2_this)/(p2_next-p2_this) x_next,y_next,z_next = x2,y2,z2 a_next = -math.deg(math.atan2(x0-x1,y0-y1)) else x_next,y_next = getPosFromBend(p2_next*math.pi*0.5,x0,y0,x1,y1,x2,y2) z_next = z1*p1_next+z2*p2_next local x_next_front,y_next_front = getPosFromBend(p2_next*math.pi*0.5+0.01,x0,y0,x1,y1,x2,y2) a_next = -math.deg(math.atan2(x_next_front-x_next,y_next_front-y_next)) end local model = getElementModel(npc) local move = true if check_cols then local box = call(server_coldata,"createModelIntersectionBox",model,x_next,y_next,z_next,a_next) local boxprev = call(server_coldata,"getElementIntersectionBox",npc) move = not call(server_coldata,"doesModelBoxIntersect",box,getElementDimension(npc),boxprev) end if move then setElementPosition(npc,x_next,y_next,z_next,false) setPedRotation(npc,a_next) if check_cols then call(server_coldata,"updateElementColData",npc) end return maxtime else setElementPosition(npc,x_this,y_this,z_this) setPedRotation(npc,getPedRotation(npc)) return maxtime_unm end end --[[function makeNPCWalkAlongLine(npc,x1,y1,z1,x2,y2,z2,off,maxtime) local x_this,y_this,z_this = getElementPosition(npc) local walk_dist = NPC_SPEED_ONFOOT[getNPCWalkSpeed(npc)]*maxtime*0.001 local p2_this = getPercentageInLine(x_this,y_this,x1,y1,x2,y2) local p1_this = 1-p2_this local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) local p2_next = p2_this+off/len local p1_next = 1-p2_next local x_next,y_next,z_next = p1_next*x1+p2_next*x2,p1_next*y1+p2_next*y2,p1_next*z1+p2_next*z2 local next_dist = getDistanceBetweenPoints3D(x_this,y_this,z_this,x_next,y_next,z_next) if p2_next > 1 then local p_next = (1-p2_this)/(p2_next-p2_this) local p_this = 1-p_next x_next = x_this*p_this+x_next*p_next y_next = y_this*p_this+y_next*p_next z_next = z_this*p_this+z_next*p_next local next_dist = getDistanceBetweenPoints3D(x_this,y_this,z_this,x_next,y_next,z_next) if next_dist < walk_dist then maxtime = maxtime*next_dist/walk_dist setPedRotation(npc,-math.deg(math.atan2(x_next-x_this,y_next-y_this))) else local distmult = walk_dist/next_dist x_next = (x_next-x_this)*distmult+x_this y_next = (y_next-y_this)*distmult+y_this z_next = (z_next-z_this)*distmult+z_this end setElementPosition(npc,x_next,y_next,z_next,false) setPedRotation(npc,-math.deg(math.atan2(x_next-x_this,y_next-y_this))) return maxtime else if next_dist < walk_dist then local next2_dist = walk_dist-next_dist local p2_next2 = p2_next+next2_dist/len if p2_next2 > 1 then maxtime = maxtime*(walk_dist-(p2_next2-1)*len)/walk_dist x_next,y_next,z_next = x2,y2,z2 else local p1_next2 = 1-p2_next2 x_next = p1_next2*x1+p2_next2*x2 y_next = p1_next2*y1+p2_next2*y2 z_next = p1_next2*z1+p2_next2*z2 end setElementPosition(npc,x_next,y_next,z_next,false) setPedRotation(npc,-math.deg(math.atan2(x2-x1,y2-y1))) return maxtime else local distmult = walk_dist/next_dist x_next = (x_next-x_this)*distmult y_next = (y_next-y_this)*distmult z_next = (z_next-z_this)*distmult setPedRotation(npc,-math.deg(math.atan2(x_next,y_next))) x_next,y_next,z_next = x_next+x_this,y_next+y_this,z_next+z_this setElementPosition(npc,x_next,y_next,z_next,false) return maxtime end end end function makeNPCWalkAroundBend(npc,x0,y0,x1,y1,z1,x2,y2,z2,off,maxtime) local x_this,y_this,z_this = getElementPosition(npc) local walk_dist = NPC_SPEED_ONFOOT[getNPCWalkSpeed(npc)]*maxtime*0.001 local p2_this = getAngleInBend(x_this,y_this,x0,y0,x1,y1,x2,y2)/math.pi*2 local p1_this = 1-p2_this local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2)*math.pi*0.5 local p2_next = p2_this+off/len local p1_next = 1-p2_next local x_next,y_next = getPosFromBend(p2_next*math.pi*0.5,x0,y0,x1,y1,x2,y2) local z_next = p1_next*z1+p2_next*z2 local next_dist = getDistanceBetweenPoints3D(x_this,y_this,z_this,x_next,y_next,z_next) if p2_next > 1 then local p_next = (1-p2_this)/(p2_next-p2_this) local p_this = 1-p_next x_next = x_this*p_this+x_next*p_next y_next = y_this*p_this+y_next*p_next z_next = z_this*p_this+z_next*p_next local next_dist = getDistanceBetweenPoints3D(x_this,y_this,z_this,x_next,y_next,z_next) if next_dist < walk_dist then maxtime = maxtime*next_dist/walk_dist else local distmult = walk_dist/next_dist x_next = (x_next-x_this)*distmult+x_this y_next = (y_next-y_this)*distmult+y_this z_next = (z_next-z_this)*distmult+z_this end setElementPosition(npc,x_next,y_next,z_next,false) setPedRotation(npc,-math.deg(math.atan2(x_next-x_this,y_next-y_this))) return maxtime else if next_dist < walk_dist then local next2_dist = walk_dist-next_dist local p2_next2 = p2_next+next2_dist/len if p2_next2 > 1 then maxtime = maxtime*(walk_dist-(p2_next2-1)*len)/walk_dist x_next,y_next,z_next = x2,y2,z2 else local p1_next2 = 1-p2_next2 x_next = p1_next2*x1+p2_next2*x2 y_next = p1_next2*y1+p2_next2*y2 z_next = p1_next2*z1+p2_next2*z2 end setElementPosition(npc,x_next,y_next,z_next,false) setPedRotation(npc,-math.deg(math.atan2(x2-x1,y2-y1))) return maxtime else local distmult = walk_dist/next_dist x_next = (x_next-x_this)*distmult y_next = (y_next-y_this)*distmult z_next = (z_next-z_this)*distmult setPedRotation(npc,-math.deg(math.atan2(x_next,y_next))) x_next,y_next,z_next = x_next+x_this,y_next+y_this,z_next+z_this setElementPosition(npc,x_next,y_next,z_next,false) return maxtime end end end]] function makeNPCDriveToPos(npc,x,y,z,maxtime) local car = getPedOccupiedVehicle(npc) local px,py,pz = getElementPosition(car) local speed = getNPCDriveSpeed(npc) local drive_dist = speed*50*maxtime*0.001 local dx,dy,dz = x-px,y-py,z-pz local dist = getDistanceBetweenPoints3D(0,0,0,dx,dy,dz) dx,dy,dz = dx/dist,dy/dist,dz/dist local rx,ry,rz = math.deg(math.asin(dz)),0,-math.deg(math.atan2(dx,dy)) local vx,vy,vx local maxtime_unm = maxtime if dist < drive_dist then maxtime = maxtime*dist/drive_dist drive_dist = dist vx,vy,vz = 0,0,0 else vx,vy,vz = dx*speed,dy*speed,dz*speed end local model = getElementModel(car) x,y,z = px+dx*drive_dist,py+dy*drive_dist,pz+dz*drive_dist local move = true if check_cols then local box = call(server_coldata,"createModelIntersectionBox",model,x,y,z,rz) local boxprev = call(server_coldata,"getElementIntersectionBox",car) move = not call(server_coldata,"doesModelBoxIntersect",box,getElementDimension(car),boxprev) end if move then setElementPosition(car,x,y,z,true) setElementRotation(car,rx,ry,rz) setElementVelocity(car,vx,vy,vz) setVehicleTurnVelocity(car,0,0,0) setElementPosition(npc,x,y,z) if check_cols then call(server_coldata,"updateElementColData",car) end return maxtime else setElementPosition(car,px,py,pz,true) setElementRotation(car,getElementRotation(car)) setElementVelocity(car,0,0,0) setVehicleTurnVelocity(car,0,0,0) return maxtime_unm end end function makeNPCDriveAlongLine(npc,x1,y1,z1,x2,y2,z2,off,maxtime) local car = getPedOccupiedVehicle(npc) local x_this,y_this,z_this = getElementPosition(car) local speed = getNPCDriveSpeed(npc) local drive_dist = speed*50*maxtime*0.001 local p2_this = getPercentageInLine(x_this,y_this,x1,y1,x2,y2) local p1_this = 1-p2_this local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) local p2_next = p2_this+drive_dist/len local p1_next = 1-p2_next local x_next,y_next,z_next local dirx,diry,dirz = (x2-x1)/len,(y2-y1)/len,(z2-z1)/len local vx,vy,vz local maxtime_unm = maxtime if p2_next > 1 then maxtime = maxtime*(1-p2_this)/(p2_next-p2_this) x_next,y_next,z_next = x2,y2,z2 vx,vy,vz = 0,0,0 else x_next = x1*p1_next+x2*p2_next y_next = y1*p1_next+y2*p2_next z_next = z1*p1_next+z2*p2_next vx,vy,vz = dirx*speed,diry*speed,dirz*speed end local model = getElementModel(car) local rx,ry,rz = math.deg(math.asin(dirz)),0,-math.deg(math.atan2(dirx,diry)) local move = true if check_cols then local box = call(server_coldata,"createModelIntersectionBox",model,x_next,y_next,z_next,rz) local boxprev = call(server_coldata,"getElementIntersectionBox",car) move = not call(server_coldata,"doesModelBoxIntersect",box,getElementDimension(car),boxprev) end if move then setElementPosition(car,x_next,y_next,z_next,true) setElementRotation(car,rx,ry,rz) setElementVelocity(car,vx,vy,vz) setVehicleTurnVelocity(car,0,0,0) setElementPosition(npc,x_next,y_next,z_next) if check_cols then call(server_coldata,"updateElementColData",car) end return maxtime else setElementPosition(car,x_this,y_this,z_this,true) setElementRotation(car,getElementRotation(car)) setElementVelocity(car,0,0,0) setVehicleTurnVelocity(car,0,0,0) return maxtime_unm end end function makeNPCDriveAroundBend(npc,x0,y0,x1,y1,z1,x2,y2,z2,off,maxtime) local car = getPedOccupiedVehicle(npc) local x_this,y_this,z_this = getElementPosition(car) local speed = getNPCDriveSpeed(npc) local drive_dist = speed*50*maxtime*0.001 local p2_this = getAngleInBend(x_this,y_this,x0,y0,x1,y1,x2,y2)/math.pi*2 local p1_this = 1-p2_this local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) local p2_next = p2_this+drive_dist/len local p1_next = 1-p2_next local x_next,y_next,z_next local dirx,diry,dirz,vx,vy,vz local maxtime_unm = maxtime if p2_next > 1 then maxtime = maxtime*(1-p2_this)/(p2_next-p2_this) x_next,y_next,z_next = x2,y2,z2 dirx,diry,dirz = x1-x0,y1-y0,z1-z2 local dirlen = 1/getDistanceBetweenPoints3D(0,0,0,dirx,diry,dirz) dirx,diry,dirz = dirx*dirlen,diry*dirlen,dirz*dirlen vx,vy,vz = 0,0,0 else x_next,y_next = getPosFromBend(p2_next*math.pi*0.5,x0,y0,x1,y1,x2,y2) z_next = z1*p1_next+z2*p2_next local x_next_front,y_next_front = getPosFromBend(p2_next*math.pi*0.5+0.01,x0,y0,x1,y1,x2,y2) local z_next_front = z1*(p1_next-0.01)+z2*(p2_next+0.01) dirx,diry,dirz = x_next_front-x_next,y_next_front-y_next,z_next_front-z_next local dirlen = 1/getDistanceBetweenPoints3D(0,0,0,dirx,diry,dirz) dirx,diry,dirz = dirx*dirlen,diry*dirlen,dirz*dirlen vx,vy,vz = dirx*speed,diry*speed,dirz*speed end local model = getElementModel(car) local rx,ry,rz = math.deg(math.asin(dirz)),0,-math.deg(math.atan2(dirx,diry)) local move = true if check_cols then local box = call(server_coldata,"createModelIntersectionBox",model,x_next,y_next,z_next,rz) local boxprev = call(server_coldata,"getElementIntersectionBox",car) move = not call(server_coldata,"doesModelBoxIntersect",box,getElementDimension(car),boxprev) end if move then setElementPosition(car,x_next,y_next,z_next,true) setElementRotation(car,rx,ry,rz) setElementVelocity(car,vx,vy,vz) setVehicleTurnVelocity(car,0,0,0) setElementPosition(npc,x_next,y_next,z_next) if check_cols then call(server_coldata,"updateElementColData",car) end return maxtime else setElementPosition(car,x_this,y_this,z_this,true) setElementRotation(car,getElementRotation(car)) setElementVelocity(car,0,0,0) setVehicleTurnVelocity(car,0,0,0) return maxtime_unm end end actions_c.Lua function stopAllNPCActions(npc) stopNPCWalkingActions(npc) stopNPCWeaponActions(npc) stopNPCDrivingActions(npc) setPedControlState(npc,"vehicle_fire",false) setPedControlState(npc,"vehicle_secondary_fire",false) setPedControlState(npc,"steer_forward",false) setPedControlState(npc,"steer_back",false) setPedControlState(npc,"horn",false) setPedControlState(npc,"handbrake",false) end function stopNPCWalkingActions(npc) setPedControlState(npc,"forwards",false) setPedControlState(npc,"sprint",false) setPedControlState(npc,"walk",false) end function stopNPCWeaponActions(npc) setPedControlState(npc,"aim_weapon",false) setPedControlState(npc,"fire",false) end function stopNPCDrivingActions(npc) local car = getPedOccupiedVehicle(npc) if not car then return end local m = getElementMatrix(car) local vx,vy,vz = getElementVelocity(car) vy = vx*m[2][1]+vy*m[2][2]+vz*m[2][3] setPedControlState(npc,"accelerate",vy < -0.01) setPedControlState(npc,"brake_reverse",vy > 0.01) setPedControlState(npc,"vehicle_left",false) setPedControlState(npc,"vehicle_right",false) end function makeNPCWalkToPos(npc,x,y) local px,py = getElementPosition(npc) setPedCameraRotation(npc,math.deg(math.atan2(x-px,y-py))) setPedControlState(npc,"forwards",true) local speed = getNPCWalkSpeed(npc) setPedControlState(npc,"walk",speed == "walk") setPedControlState(npc,"sprint", speed == "sprint" or speed == "sprintfast" and not getPedControlState(npc,"sprint") ) end function makeNPCWalkAlongLine(npc,x1,y1,z1,x2,y2,z2,off) local x,y,z = getElementPosition(npc) local p2 = getPercentageInLine(x,y,x1,y1,x2,y2) local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) p2 = p2+off/len local p1 = 1-p2 local destx,desty = p1*x1+p2*x2,p1*y1+p2*y2 makeNPCWalkToPos(npc,destx,desty) end function makeNPCWalkAroundBend(npc,x0,y0,x1,y1,x2,y2,off) local x,y,z = getElementPosition(npc) local len = getDistanceBetweenPoints2D(x1,y1,x2,y2)*math.pi*0.5 local p2 = getAngleInBend(x,y,x0,y0,x1,y1,x2,y2)/math.pi*2+off/len local destx,desty = getPosFromBend(p2*math.pi*0.5,x0,y0,x1,y1,x2,y2) makeNPCWalkToPos(npc,destx,desty) end function makeNPCShootAtPos(npc,x,y,z) local sx,sy,sz = getElementPosition(npc) x,y,z = x-sx,y-sy,z-sz local yx,yy,yz = 0,0,1 local xx,xy,xz = yy*z-yz*y,yz*x-yx*z,yx*y-yy*x yx,yy,yz = y*xz-z*xy,z*xx-x*xz,x*xy-y*xx local inacc = 1-getNPCWeaponAccuracy(npc) local ticks = getTickCount() local xmult = inacc*math.sin(ticks*0.01 )*1000/math.sqrt(xx*xx+xy*xy+xz*xz) local ymult = inacc*math.cos(ticks*0.011)*1000/math.sqrt(yx*yx+yy*yy+yz*yz) local mult = 1000/math.sqrt(x*x+y*y+z*z) xx,xy,xz = xx*xmult,xy*xmult,xz*xmult yx,yy,yz = yx*ymult,yy*ymult,yz*ymult x,y,z = x*mult,y*mult,z*mult setPedAimTarget(npc,sx+xx+yx+x,sy+xy+yy+y,sz+xz+yz+z) if isPedInVehicle(npc) then setPedControlState(npc,"vehicle_fire",not getPedControlState(npc,"vehicle_fire")) else setPedControlState(npc,"aim_weapon",true) setPedControlState(npc,"fire",not getPedControlState(npc,"fire")) end end function makeNPCShootAtElement(npc,target) local x,y,z = getElementPosition(target) local vx,vy,vz = getElementVelocity(target) local tgtype = getElementType(target) if tgtype == "ped" or tgtype == "player" then x,y,z = getPedBonePosition(target,3) local vehicle = getPedOccupiedVehicle(target) if vehicle then vx,vy,vz = getElementVelocity(vehicle) end end vx,vy,vz = vx*6,vy*6,vz*6 makeNPCShootAtPos(npc,x+vx,y+vy,z+vz) end function makeNPCDriveToPos(npc,x,y,z) local car = getPedOccupiedVehicle(npc) local m = getElementMatrix(car) x,y,z = x-m[4][1],y-m[4][2],z-m[4][3] local rx,ry,rz = x*m[1][1]+y*m[1][2]+z*m[1][3], x*m[2][1]+y*m[2][2]+z*m[2][3], x*m[3][1]+y*m[3][2]+z*m[3][3] if ry <= 0 then setPedControlState(npc,"vehicle_left",rx < 0) setPedControlState(npc,"vehicle_right",rx >= 0) else local secondpart = getTickCount()%100 setPedControlState(npc,"vehicle_left",rx*500/ry < -secondpart) setPedControlState(npc,"vehicle_right",rx*500/ry > secondpart) end local vx,vy,vz = getElementVelocity(car) local vrx,vry,vrz = vx*m[1][1]+vy*m[1][2]+vz*m[1][3], vx*m[2][1]+vy*m[2][2]+vz*m[2][3], vx*m[3][1]+vy*m[3][2]+vz*m[3][3] local speed do local x1,y1,z1,x2,y2,z2 = getElementBoundingBox(car) z1 = z1+1 local vx,vy,vz = m[4][1]+m[3][1]*z1,m[4][2]+m[3][2]*z1,m[4][3]+m[3][3]*z1 local mult = (y2+6)/math.sqrt(x*x+y*y+z*z) local dx,dy,dz = x*mult,y*mult,z*mult if not isLineOfSightClear(vx,vy,vz,vx+dx,vy+dy,vz+dz,false,true,true,false,true,false,false,car) then speed = 0 else speed = getNPCDriveSpeed(npc)*math.sin(math.pi*0.5-math.atan(math.abs(rx/ry))*0.75) end end setPedControlState(npc,"accelerate",vry < speed) setPedControlState(npc,"brake_reverse",vry > speed*1.1) end function makeNPCDriveAlongLine(npc,x1,y1,z1,x2,y2,z2,off) local car = getPedOccupiedVehicle(npc) local x,y,z = getElementPosition(car) local p2 = getPercentageInLine(x,y,x1,y1,x2,y2) local len = getDistanceBetweenPoints3D(x1,y1,z1,x2,y2,z2) p2 = p2+off/len local p1 = 1-p2 local destx,desty,destz = p1*x1+p2*x2,p1*y1+p2*y2,p1*z1+p2*z2 makeNPCDriveToPos(npc,destx,desty,destz) end function makeNPCDriveAroundBend(npc,x0,y0,x1,y1,z1,x2,y2,z2,off) local car = getPedOccupiedVehicle(npc) local x,y,z = getElementPosition(car) local len = getDistanceBetweenPoints2D(x1,y1,x2,y2)*math.pi*0.5 local p2 = getAngleInBend(x,y,x0,y0,x1,y1,x2,y2)/math.pi*2 p2 = math.max(0,math.min(1,p2)) p2 = p2+off/len local destx,desty = getPosFromBend(p2*math.pi*0.5,x0,y0,x1,y1,x2,y2) local destz = (1-p2)*z1+p2*z2 makeNPCDriveToPos(npc,destx,desty,destz) end Where i can add it? I need jump for focused zombies on the player. Zombies jump when they can't see the player and are not focused on him.
  2. function zombieJump(ped) if (isElement(source)) then setPedControlState(source,"jump",true) setTimer(function(source) if (isElement(source)) then setPedControlState(source,"jump",true) end end,800,1,source) end end addEventHandler("bot_Jump",getRootElement(),zombieJump) addEvent("bot_Jump",true) function zombieJump(ped) if (isElement(source)) then setPedControlState(source,"jump",true) setTimer(function(source) if (isElement(source)) then setPedControlState(source,"jump",true) end end,800,1,source) end end addEventHandler("bot_Jump",getRootElement(),zombieJump) addEvent("bot_Jump",true) Why this function don't working...? How i can add jump for zombie? This is stat zombie 4: elseif ztype == 4 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", bear_blood) setElementData ( zomb, "bear", true ) setElementData(zomb, "damage", bear_damage) setElementData(zomb, "speed", "run") How i can add jump for it? I use npc_hlc.
  3. damageTable = { {"M4A1",11500}, {"M4A1 CCO SD",4250}, {"M4A1-S (Cyrex)",4250}, {"M136",300000}, {"RPK",4250}, {"M249 SAW",4250}, {"AKM",3850}, {"AK 74 GP-25",3850}, {"AKS Gold",3850}, {"KSVK",1000}, {"CZ550",1}, {"AS50",5000}, {"VSS",10000}, {"SVD Camo",100000}, {"M107",100000}, {"M1911",5500}, {"Rewolwer",7500}, {"Nóż myśliwski",15000}, {"Katana (Deadpool)",45000}, {"Siekiera",4500}, {"Łopata",1150}, {"Piła spalinowa",2150}, {"Maczeta",5500}, {"C4",18000}, {"M67",16000}, {"Butelka zapalająca",25}, {"GOOD NIGHT",45000}, {"Pistolet (Deadpool)",15000}, {"М134 Minigun",1000}, {"MP5A5",2500}, {"VZ 61 Scorpion",3000}, {"Winchester M1866",8500}, {"SPAZ-12 Combat Shotgun",9500}, } Each weapon assigned under ID takes as much blood as it is set at the first one. For example, KSVK takes 1000 blood because it is the first and all other sniper rifles also take 1000 blood. Please i need help. Where is problem?
  4. damageTable = { {"M4A1",3452}, {"M4A1 CCO SD",1000}, {"M4A1-S (Cyrex)",2000}, {"M136",300000}, {"RPK",11000}, {"M249 SAW",10000}, {"AKM",999999}, {"AK 74 GP-25",7000}, {"AKS Gold",4500}, {"CZ550",1}, {"AS50",1}, {"VSS",1}, {"SVD Camo",1}, {"M107",100000}, {"M1911",5500}, {"Rewolwer",7500}, {"Nóż myśliwski",15000}, {"Katana (Deadpool)",45000}, {"Siekiera",4500}, {"Łopata",1150}, {"Piła spalinowa",2000}, {"Maczeta",5500}, {"C4",18000}, {"M67",18000}, {"Butelka zapalająca",25}, {"GOOD NIGHT",45000}, {"Pistolet (Deadpool)",15000}, {"М134 Minigun",1000}, {"MP5A5",2500}, {"VZ 61 Scorpion",3000}, {"Winchester M1866",8500}, {"SPAZ-12 Combat Shotgun",9500}, } Why this not working? Weapon take other number damage..
  5. How i can add skill jump? if ztype == 3 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "soldier", true ) setElementData(zomb, "blood", sold_blood) setElementData(zomb, "damage", sold_damage) setElementData(zomb, "speed", "sprint")
  6. --By Fanbox fast_blood = 200000 -- ????? ? ??????? sold_blood = 20000 -- ????? ? ???????? zomb_blood = 5000 -- ????? ? ??????? ????? fast_damage = 12000 -- ???? ??????? sold_damage = 4112 -- ???? ??????? ????? zomb_damage = 1121 -- ???? ??????? ????? --??????? bear_blood = 20000 wolf_blood = 7000 fox_blood = 5000 bear_damage = 6111 wolf_damage = 3112 fox_damage = 1121 animal_blood = 2000 animal_damage = 100 boss_chucky_blood = 500000 boss_chucky_damage = 100000 boss_hulk_blood = 1500000 boss_hulk_damage = 100000 boss_octopus_blood = 2000000 boss_octopus_damage = 100000 boss_blood_blood = 3000000 boss_blood_damage = 100000 boss_leatherface_blood = 1000000 boss_leatherface_damage = 100000 boss_all_blood = 50000 boss_all_damage = 4212 function chasedStartAttack (zomb) if isElement ( zomb ) and not getElementData ( zomb, "target" ) then if getElementData ( zomb, "zHeared" ) then setElementData ( zomb, "zHeared", false ) end setElementSyncer ( zomb, source ) setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) exports.npc_hlc:addNPCTask ( zomb, {"killPed", source, 2, 2} ) setElementData ( zomb, "target", source ) setElementAlpha ( zomb, 255 ) end end addEvent( "chasedStartAttackC", true ) addEventHandler( "chasedStartAttackC", getRootElement(), chasedStartAttack ) local stats = { [ 69 ] = 500, [ 70 ] = 999, [ 71 ] = 999, [ 72 ] = 999, [ 73 ] = 500, [ 74 ] = 999, [ 75 ] = 500, [ 76 ] = 999, [ 77 ] = 999, [ 78 ] = 999, [ 79 ] = 999, [ 160 ] = 999, [ 229 ] = 999, [ 230 ] = 999 } function applyStats(player) for stat,value in pairs(stats) do setPedStat(player, stat, value) end end function spawnNewZombie(x, y, z, creator, ztype, skin) local zomb = createPed(skin,x,y,z+0.5,math.random(0,360),true) setElementData(zomb,"spawn_x",x) setElementData(zomb,"spawn_y",y) setElementData(zomb,"spawn_z",z) setElementData(zomb,"spawn_ztype",ztype) setElementData(zomb,"spawn_skin",skin) if isElement ( zomb ) then if not isElementInWater ( zomb ) then setTimer ( activateZombie, 1000, 1, zomb, x, y, z, ztype ) setElementData ( zomb, "creator", creator ) return true else destroyElement ( zomb ) return false end end return false end function activateZombie (zomb, x, y, z, ztype) if isElement ( zomb ) then local zSphere = createColSphere ( x, y, z, 50 ) local zSphereFar = createColSphere ( x, y, z, 150 ) local zSphereNear = createColSphere ( x, y, z, 3 ) attachElements ( zSphere, zomb ) attachElements ( zSphereFar, zomb ) attachElements ( zSphereNear, zomb ) setElementData ( zSphere, 'shapeZomb', true ) setElementData ( zSphereFar, 'shapeZomb', true ) setElementData ( zSphereNear, 'shapeZomb', true ) setElementData ( zomb, "zombieShape", zSphere ) setElementData ( zSphere, "zombieShape", true ) setElementData ( zSphere, "zombieElement", zomb ) setElementData ( zomb, "shapeFar", zSphereFar ) setElementData ( zomb, "shapeNear", zSphereNear ) setElementData ( zSphereNear, "zShapeNear", true ) --setElementData ( zomb, "zombie", true ) --??????? ?????? ?? ??????? (?????) --setElementData ( zomb, "animal", true ) --?????? ?????? ??????? (??????) --setElementData ( zomb, "killer", true ) --??????? ?????? ??????? (??????) --setElementData ( zomb, "boss", true ) --??????? ?????? ??????? (????) if ztype == 3 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "soldier", true ) setElementData(zomb, "blood", sold_blood) setElementData(zomb, "damage", sold_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 2 then setElementData ( zomb, "zombie", true ) setElementData(zomb, "blood", fast_blood) setElementData ( zomb, "fast", true ) setElementData(zomb, "damage", fast_damage) setElementData(zomb, "speed", "run") elseif ztype == 4 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", bear_blood) setElementData ( zomb, "bear", true ) setElementData(zomb, "damage", bear_damage) setElementData(zomb, "speed", "run") elseif ztype == 5 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", wolf_blood) setElementData ( zomb, "wolf", true ) setElementData(zomb, "damage", wolf_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 6 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", fox_blood) setElementData ( zomb, "fox", true ) setElementData(zomb, "damage", fox_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 7 then setElementData ( zomb, "animal", true ) setElementData(zomb, "blood", animal_blood) setElementData(zomb, "damage", animal_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 9 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_all", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "sprint") elseif ztype == 10 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "pila", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "run") applyStats(zomb) giveWeapon(zomb, 9, 9999, true) elseif ztype == 11 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_chucky", true ) setElementData(zomb, "blood", boss_chucky_blood) setElementData(zomb, "damage", boss_chucky_damage) setElementData(zomb, "speed", "sprint") setElementAlpha ( zomb, 5 ) elseif ztype == 14 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_hulk", true ) setElementData(zomb, "blood", boss_hulk_blood) setElementData(zomb, "damage", boss_hulk_damage) setElementData(zomb, "speed", "sprint") setElementAlpha ( zomb, 5 ) elseif ztype == 15 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_octopus", true ) setElementData(zomb, "blood", boss_octopus_blood) setElementData(zomb, "damage", boss_octopus_damage) setElementData(zomb, "speed", "run") setElementAlpha ( zomb, 5 ) elseif ztype == 12 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "pila", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "run") applyStats(zomb) giveWeapon(zomb, 29, 9999, true) elseif ztype == 16 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "pila", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "run") applyStats(zomb) giveWeapon(zomb, 27, 9999, true) elseif ztype == 17 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_leatherface", true ) setElementData(zomb, "blood", boss_leatherface_blood) setElementData(zomb, "damage", boss_leatherface_damage) setElementData(zomb, "speed", "run") elseif ztype == 13 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_blood", true ) setElementData(zomb, "blood", boss_blood_blood) setElementData(zomb, "damage", boss_blood_damage) setElementData(zomb, "speed", "sprint") applyStats(zomb) else setElementData ( zomb, "zombie", true ) setElementData(zomb, "blood", zomb_blood) setElementData(zomb, "damage", zomb_damage) setElementData(zomb, "speed", "run") end wentZombieToWalk ( zomb ) end end function wentZombieToWalk (zomb) if zomb then if isElement ( zomb ) then if not isPedDead ( zomb ) then if checkPlayersInView ( zomb ) then if not getElementData ( zomb, "target" ) and not getElementData ( zomb, 'rotating' ) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "WALK_fatold", -1, true, true, true) setTimer ( wentZombieToWalk, 10000, 1, zomb ) if getElementData ( zomb, "boss_blood" ) then setElementAlpha ( zomb, 5 ) end end else if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end if isElement ( getElementData ( zomb, "shapeNear" ) ) then destroyElement ( getElementData ( zomb, "shapeNear" ) ) end local attaches = getAttachedElements ( zomb ) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then if not getElementData ( ElementValue, "zRadZone" ) then destroyElement ( ElementValue ) end end end end local creator = getElementData ( zomb, "creator" ) if isElement ( creator ) then setElementData ( creator, "spawnedzombies", ( getElementData ( creator, "spawnedzombies" ) or 1 ) - 1 ) end setElementData ( zomb, "target", false ) setElementData ( zomb, "rotating", nil ) if not getElementData ( zomb, "target" ) and not getElementData ( zomb, 'rotating' ) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "WALK_fatold", -1, true, true, true) setTimer ( wentZombieToWalk, 10000, 1, zomb ) if getElementData ( zomb, "boss_blood" ) then setElementAlpha ( zomb, 5 ) end end end end end end end function checkPlayersInView ( zomb ) local shapeFar = getElementData ( zomb, "shapeFar" ) if isElement(shapeFar) then if #getElementsWithinColShape ( shapeFar, 'player' ) == 0 then return false else return true end end end function zombieKilledPlayer (task) if getElementData ( source, "zombie" ) then if task[1] == "walkToPos" then if getElementData ( source, "rotating" ) then setElementRotation ( source, 0, 0, task[6] ) setTimer ( function ( zomb ) if isElement ( zomb ) then setElementData ( zomb, "rotating", false ); wentZombieToWalk ( zomb ) end end, 3000, 1, source ) end end if getElementData ( source, "target" ) then local diedPlayer = task[2] setElementData ( source, "target", nil ) wentZombieToWalk ( source ) end end end addEventHandler ( "npc_hlc:onNPCTaskDone", root, zombieKilledPlayer ) function killPlayerOfSick() for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and target == source then setElementData ( v, "target", false ) exports.npc_hlc:clearNPCTasks(v) setTimer ( wentZombieToWalk, 3000, 1, v ) end end end end addEvent("killPlayerOfSick",true) addEventHandler("killPlayerOfSick",getRootElement(),killPlayerOfSick) function checkUnactiveZombies () for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and not isElement ( target ) then setElementData ( v, "target", false ) wentZombieToWalk ( v ) end end end end setTimer (checkUnactiveZombies,10000,0)--600000 function zombieWasAttackedS ( zomb ) if not isPedDead ( zomb ) and not getElementData ( source, "isPlayerZombie" ) then setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) exports.npc_hlc:addNPCTask ( zomb, {"killPed", source, 2, 2} ) setElementData ( zomb, "target", source ) setTimer ( wentZombieToWalk, 1000, 1, zomb ) end end addEvent( "zombieWasAttacked", true ) addEventHandler( "zombieWasAttacked", getRootElement(), zombieWasAttackedS ) function zombieHearedS ( zomb ) if isElement ( zomb ) then if not isPedDead ( zomb ) then if not getElementData ( zomb, "target" ) and not getElementData ( source, "zHeared" ) and not getElementData ( source, "isPlayerZombie" ) then setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) setElementData ( zomb, "zHeared", source ) local x,y,z = getElementPosition ( source ) exports.npc_hlc:addNPCTask ( zomb, {"walkToPos", x, y, z, 2}) end end end end addEvent( "zombieHeared", true ) addEventHandler( "zombieHeared", getRootElement(), zombieHearedS ) function rotateZombieToPlayer ( rotation, x, y, z ) if not isPedDead ( source ) then if not getElementData ( source, "target" ) then setPedAnimation ( source ) if not exports.npc_hlc:isHLCEnabled ( source ) then exports.npc_hlc:enableHLCForNPC( source, getElementData ( source,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (source) exports.npc_hlc:addNPCTask ( source, {"walkToPos", x, y, z, 1, rotation}) end end end addEvent( "rotateZombieToPlayer", true ) addEventHandler( "rotateZombieToPlayer", getRootElement(), rotateZombieToPlayer ) function zombieNearLeave ( thePlayer ) if getElementType ( thePlayer ) == "player" and getElementData ( source, "zombieShape" ) then local zomb = getElementData ( source, "zombieElement" ) if isElement ( zomb ) and exports.npc_hlc:isHLCEnabled ( zomb ) then if getElementData ( zomb, "fast" ) then return true end local thistask = getElementData(zomb,"npc_hlc:thistask") if thistask then local task = getElementData(zomb,"npc_hlc:task."..thistask) if task then if task[1] == "killPed" and isElement ( task[2] ) then if task[2] == thePlayer then exports.npc_hlc:clearNPCTasks (zomb) setElementData(zomb,"target",false) wentZombieToWalk(zomb) end end end end end end end addEventHandler ( "onColShapeLeave", root, zombieNearLeave ) --???? ??? ??????? ???? function PanicAnimals(zomb) if isElement(zomb) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "sprint_panic", -1, true, true, true) setTimer ( PanicAnimals, 20000, 1, zomb ) --??????? ?????? ? ???? ?????? end end function animalStopFollow(zomb) PanicAnimals(zomb) end addEvent("animalStopFollow",true) addEventHandler("animalStopFollow",getRootElement(),animalStopFollow) -- Co jest nie tak w tym kodzie po stronie servera? Zombie mimo ustalonych obrażeń wciąż zadają ich tyle ile jest ustawione domyślnie w gamemodzie. Podkreślam, że to działało tylko po dodaniu jakiegoś bossa coś musiałem zepsuć dokładnie w tym pliku, ponieważ gdy wrzucam starą z przed 2 lat wersję zakodowaną to wszystko działa, ze starej wersji podmieniłem tylko nz_s.Lua, więc w takim razie problem musi leżeć po stronie tego oto kodu. W DB3 nic nie ma.
  7. Please give me link to gamemode DayZ. Don't STOP gamemode etc.
  8. --By Fanbox fast_blood = 200000 -- ????? ? ??????? sold_blood = 20000 -- ????? ? ???????? zomb_blood = 5000 -- ????? ? ??????? ????? fast_damage = 12000 -- ???? ??????? sold_damage = 4112 -- ???? ??????? ????? zomb_damage = 1121 -- ???? ??????? ????? --??????? bear_blood = 20000 wolf_blood = 7000 fox_blood = 5000 bear_damage = 6111 wolf_damage = 3112 fox_damage = 1121 animal_blood = 2000 animal_damage = 100 boss_chucky_blood = 500000 boss_chucky_damage = 100000 boss_hulk_blood = 1500000 boss_hulk_damage = 100000 boss_octopus_blood = 2000000 boss_octopus_damage = 100000 boss_blood_blood = 3000000 boss_blood_damage = 100000 boss_leatherface_blood = 1000000 boss_leatherface_damage = 100000 boss_all_blood = 50000 boss_all_damage = 4212 function chasedStartAttack (zomb) if isElement ( zomb ) and not getElementData ( zomb, "target" ) then if getElementData ( zomb, "zHeared" ) then setElementData ( zomb, "zHeared", false ) end setElementSyncer ( zomb, source ) setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) exports.npc_hlc:addNPCTask ( zomb, {"killPed", source, 2, 2} ) setElementData ( zomb, "target", source ) setElementAlpha ( zomb, 255 ) end end addEvent( "chasedStartAttackC", true ) addEventHandler( "chasedStartAttackC", getRootElement(), chasedStartAttack ) local stats = { [ 69 ] = 500, [ 70 ] = 999, [ 71 ] = 999, [ 72 ] = 999, [ 73 ] = 500, [ 74 ] = 999, [ 75 ] = 500, [ 76 ] = 999, [ 77 ] = 999, [ 78 ] = 999, [ 79 ] = 999, [ 160 ] = 999, [ 229 ] = 999, [ 230 ] = 999 } function applyStats(player) for stat,value in pairs(stats) do setPedStat(player, stat, value) end end function spawnNewZombie(x, y, z, creator, ztype, skin) local zomb = createPed(skin,x,y,z+0.5,math.random(0,360),true) setElementData(zomb,"spawn_x",x) setElementData(zomb,"spawn_y",y) setElementData(zomb,"spawn_z",z) setElementData(zomb,"spawn_ztype",ztype) setElementData(zomb,"spawn_skin",skin) if isElement ( zomb ) then if not isElementInWater ( zomb ) then setTimer ( activateZombie, 1000, 1, zomb, x, y, z, ztype ) setElementData ( zomb, "creator", creator ) return true else destroyElement ( zomb ) return false end end return false end function activateZombie (zomb, x, y, z, ztype) if isElement ( zomb ) then local zSphere = createColSphere ( x, y, z, 50 ) local zSphereFar = createColSphere ( x, y, z, 150 ) local zSphereNear = createColSphere ( x, y, z, 3 ) attachElements ( zSphere, zomb ) attachElements ( zSphereFar, zomb ) attachElements ( zSphereNear, zomb ) setElementData ( zSphere, 'shapeZomb', true ) setElementData ( zSphereFar, 'shapeZomb', true ) setElementData ( zSphereNear, 'shapeZomb', true ) setElementData ( zomb, "zombieShape", zSphere ) setElementData ( zSphere, "zombieShape", true ) setElementData ( zSphere, "zombieElement", zomb ) setElementData ( zomb, "shapeFar", zSphereFar ) setElementData ( zomb, "shapeNear", zSphereNear ) setElementData ( zSphereNear, "zShapeNear", true ) --setElementData ( zomb, "zombie", true ) --??????? ?????? ?? ??????? (?????) --setElementData ( zomb, "animal", true ) --?????? ?????? ??????? (??????) --setElementData ( zomb, "killer", true ) --??????? ?????? ??????? (??????) --setElementData ( zomb, "boss", true ) --??????? ?????? ??????? (????) if ztype == 3 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "soldier", true ) setElementData(zomb, "blood", sold_blood) setElementData(zomb, "damage", sold_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 2 then setElementData ( zomb, "zombie", true ) setElementData(zomb, "blood", fast_blood) setElementData ( zomb, "fast", true ) setElementData(zomb, "damage", fast_damage) setElementData(zomb, "speed", "run") elseif ztype == 4 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", bear_blood) setElementData ( zomb, "bear", true ) setElementData(zomb, "damage", bear_damage) setElementData(zomb, "speed", "run") elseif ztype == 5 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", wolf_blood) setElementData ( zomb, "wolf", true ) setElementData(zomb, "damage", wolf_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 6 then setElementData ( zomb, "killer", true ) setElementData(zomb, "blood", fox_blood) setElementData ( zomb, "fox", true ) setElementData(zomb, "damage", fox_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 7 then setElementData ( zomb, "animal", true ) setElementData(zomb, "blood", animal_blood) setElementData(zomb, "damage", animal_damage) setElementData(zomb, "speed", "sprint") elseif ztype == 9 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_all", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "sprint") elseif ztype == 10 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "pila", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "run") applyStats(zomb) giveWeapon(zomb, 9, 9999, true) elseif ztype == 11 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_chucky", true ) setElementData(zomb, "blood", boss_chucky_blood) setElementData(zomb, "damage", boss_chucky_damage) setElementData(zomb, "speed", "sprint") setElementAlpha ( zomb, 5 ) elseif ztype == 14 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_hulk", true ) setElementData(zomb, "blood", boss_hulk_blood) setElementData(zomb, "damage", boss_hulk_damage) setElementData(zomb, "speed", "sprint") setElementAlpha ( zomb, 5 ) elseif ztype == 15 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_octopus", true ) setElementData(zomb, "blood", boss_octopus_blood) setElementData(zomb, "damage", boss_octopus_damage) setElementData(zomb, "speed", "run") setElementAlpha ( zomb, 5 ) elseif ztype == 12 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "pila", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "run") applyStats(zomb) giveWeapon(zomb, 29, 9999, true) elseif ztype == 16 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "pila", true ) setElementData(zomb, "blood", boss_all_blood) setElementData(zomb, "damage", boss_all_blood) setElementData(zomb, "speed", "run") applyStats(zomb) giveWeapon(zomb, 27, 9999, true) elseif ztype == 17 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_leatherface", true ) setElementData(zomb, "blood", boss_leatherface_blood) setElementData(zomb, "damage", boss_leatherface_damage) setElementData(zomb, "speed", "run") elseif ztype == 13 then setElementData ( zomb, "zombie", true ) setElementData ( zomb, "boss_blood", true ) setElementData(zomb, "blood", boss_blood_blood) setElementData(zomb, "damage", boss_blood_damage) setElementData(zomb, "speed", "sprint") applyStats(zomb) else setElementData ( zomb, "zombie", true ) setElementData(zomb, "blood", zomb_blood) setElementData(zomb, "damage", zomb_damage) setElementData(zomb, "speed", "run") end wentZombieToWalk ( zomb ) end end function wentZombieToWalk (zomb) if zomb then if isElement ( zomb ) then if not isPedDead ( zomb ) then if checkPlayersInView ( zomb ) then if not getElementData ( zomb, "target" ) and not getElementData ( zomb, 'rotating' ) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "WALK_fatold", -1, true, true, true) setTimer ( wentZombieToWalk, 10000, 1, zomb ) if getElementData ( zomb, "boss_blood" ) then setElementAlpha ( zomb, 5 ) end end else if isElement ( getElementData ( zomb, "zombieShape" ) ) then destroyElement ( getElementData ( zomb, "zombieShape" ) ) end if isElement ( getElementData ( zomb, "shapeFar" ) ) then destroyElement ( getElementData ( zomb, "shapeFar" ) ) end if isElement ( getElementData ( zomb, "shapeNear" ) ) then destroyElement ( getElementData ( zomb, "shapeNear" ) ) end local attaches = getAttachedElements ( zomb ) if attaches then for ElementKey, ElementValue in ipairs ( attaches ) do if isElement ( ElementValue ) then if not getElementData ( ElementValue, "zRadZone" ) then destroyElement ( ElementValue ) end end end end local creator = getElementData ( zomb, "creator" ) if isElement ( creator ) then setElementData ( creator, "spawnedzombies", ( getElementData ( creator, "spawnedzombies" ) or 1 ) - 1 ) end setElementData ( zomb, "target", false ) setElementData ( zomb, "rotating", nil ) if not getElementData ( zomb, "target" ) and not getElementData ( zomb, 'rotating' ) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "WALK_fatold", -1, true, true, true) setTimer ( wentZombieToWalk, 10000, 1, zomb ) if getElementData ( zomb, "boss_blood" ) then setElementAlpha ( zomb, 5 ) end end end end end end end function checkPlayersInView ( zomb ) local shapeFar = getElementData ( zomb, "shapeFar" ) if isElement(shapeFar) then if #getElementsWithinColShape ( shapeFar, 'player' ) == 0 then return false else return true end end end function zombieKilledPlayer (task) if getElementData ( source, "zombie" ) then if task[1] == "walkToPos" then if getElementData ( source, "rotating" ) then setElementRotation ( source, 0, 0, task[6] ) setTimer ( function ( zomb ) if isElement ( zomb ) then setElementData ( zomb, "rotating", false ); wentZombieToWalk ( zomb ) end end, 3000, 1, source ) end end if getElementData ( source, "target" ) then local diedPlayer = task[2] setElementData ( source, "target", nil ) wentZombieToWalk ( source ) end end end addEventHandler ( "npc_hlc:onNPCTaskDone", root, zombieKilledPlayer ) function killPlayerOfSick() for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and target == source then setElementData ( v, "target", false ) exports.npc_hlc:clearNPCTasks(v) setTimer ( wentZombieToWalk, 3000, 1, v ) end end end end addEvent("killPlayerOfSick",true) addEventHandler("killPlayerOfSick",getRootElement(),killPlayerOfSick) function checkUnactiveZombies () for i, v in ipairs ( getElementsByType ("ped")) do if getElementData ( v, "zombie" ) then local target = getElementData ( v, "target" ) if target and not isElement ( target ) then setElementData ( v, "target", false ) wentZombieToWalk ( v ) end end end end setTimer (checkUnactiveZombies,10000,0)--600000 function zombieWasAttackedS ( zomb ) if not isPedDead ( zomb ) and not getElementData ( source, "isPlayerZombie" ) then setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) exports.npc_hlc:addNPCTask ( zomb, {"killPed", source, 2, 2} ) setElementData ( zomb, "target", source ) setTimer ( wentZombieToWalk, 1000, 1, zomb ) end end addEvent( "zombieWasAttacked", true ) addEventHandler( "zombieWasAttacked", getRootElement(), zombieWasAttackedS ) function zombieHearedS ( zomb ) if isElement ( zomb ) then if not isPedDead ( zomb ) then if not getElementData ( zomb, "target" ) and not getElementData ( source, "zHeared" ) and not getElementData ( source, "isPlayerZombie" ) then setPedAnimation ( zomb ) if not exports.npc_hlc:isHLCEnabled ( zomb ) then exports.npc_hlc:enableHLCForNPC( zomb, getElementData ( zomb,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (zomb) setElementData ( zomb, "zHeared", source ) local x,y,z = getElementPosition ( source ) exports.npc_hlc:addNPCTask ( zomb, {"walkToPos", x, y, z, 2}) end end end end addEvent( "zombieHeared", true ) addEventHandler( "zombieHeared", getRootElement(), zombieHearedS ) function rotateZombieToPlayer ( rotation, x, y, z ) if not isPedDead ( source ) then if not getElementData ( source, "target" ) then setPedAnimation ( source ) if not exports.npc_hlc:isHLCEnabled ( source ) then exports.npc_hlc:enableHLCForNPC( source, getElementData ( source,"speed") or "sprint") end exports.npc_hlc:clearNPCTasks (source) exports.npc_hlc:addNPCTask ( source, {"walkToPos", x, y, z, 1, rotation}) end end end addEvent( "rotateZombieToPlayer", true ) addEventHandler( "rotateZombieToPlayer", getRootElement(), rotateZombieToPlayer ) function zombieNearLeave ( thePlayer ) if getElementType ( thePlayer ) == "player" and getElementData ( source, "zombieShape" ) then local zomb = getElementData ( source, "zombieElement" ) if isElement ( zomb ) and exports.npc_hlc:isHLCEnabled ( zomb ) then if getElementData ( zomb, "fast" ) then return true end local thistask = getElementData(zomb,"npc_hlc:thistask") if thistask then local task = getElementData(zomb,"npc_hlc:task."..thistask) if task then if task[1] == "killPed" and isElement ( task[2] ) then if task[2] == thePlayer then exports.npc_hlc:clearNPCTasks (zomb) setElementData(zomb,"target",false) wentZombieToWalk(zomb) end end end end end end end addEventHandler ( "onColShapeLeave", root, zombieNearLeave ) --???? ??? ??????? ???? function PanicAnimals(zomb) if isElement(zomb) then local rdmangle = math.random( 1, 359 ) setPedRotation( zomb, rdmangle ) setPedAnimation ( zomb, "PED", "sprint_panic", -1, true, true, true) setTimer ( PanicAnimals, 20000, 1, zomb ) --??????? ?????? ? ???? ?????? end end function animalStopFollow(zomb) PanicAnimals(zomb) end addEvent("animalStopFollow",true) addEventHandler("animalStopFollow",getRootElement(),animalStopFollow) -- checkZombies = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "zombie") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*1.2 + visibly*1.2 and scal <= 0 ) or ( distance > sound*1.4 + visibly*1.4 ) then -- Расстояние за которую он вас увидит и услышит (средне) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkZombies, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkAnimal = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "animal") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "animalStopFollow", getLocalPlayer(), ped ) end end end end setTimer(checkAnimal, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkKiller = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "killer") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkKiller, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkboss4aki = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "boss_chucky") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkboss4aki, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkbossleatherface = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "boss_leatherface") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(bossleatherface, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkbosshulk = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "boss_hulk") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkbosshulk, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkbossoctopus = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "boss_octopus") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 3 local visibly = getElementData(getLocalPlayer(), "visibly") / 3 local ready = true if ( distance > sound*1 + visibly*1 and scal <= 0 ) or ( distance > sound*1 + visibly*1 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkbossoctopus, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkblood = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "boss_blood") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 2 local visibly = getElementData(getLocalPlayer(), "visibly") / 2 local ready = true if ( distance > sound*3 + visibly*3 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkblood, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkBots = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "bots") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "botsStartAttack", getLocalPlayer(), ped ) end end end end setTimer(checkBots, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkbossBenz = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "bossBenz") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkbossBenz, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) checkbossCrais = function() for i,ped in ipairs(getElementsByType("ped",root,true)) do if getElementData(ped, "bossCrais") then local x,y,z = getElementPosition ( localPlayer ) local zx,zy,zz = getElementPosition (ped) local zfrontx, zfronty, zfrontz = getPositionInfrontOfElement(ped, 3) local vect1X, vect1Y = zx-x, zy-z local vect2X, vect2Y = zfrontx-zx, zfronty - zy local scal = vect2X*vect1X+vect2Y*vect1Y local distance = getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) local sound = getElementData(getLocalPlayer(), "volume") / 5 local visibly = getElementData(getLocalPlayer(), "visibly") / 5 local ready = true if ( distance > sound*3 + visibly*5 and scal <= 0 ) or ( distance > sound*3 + visibly*3 ) then -- Расстояние за которую он вас увидит и услышит (ДАЛЕКО) ready = false end if ready then triggerServerEvent ( "chasedStartAttackC", getLocalPlayer(), ped ) end end end end setTimer(checkbossCrais, 2000, 0) setElementData ( localPlayer, "spawnedzombies", 0 ) function zombieJump(ped) if (isElement(source)) then setPedControlState(source,"jump",true) setTimer(function(source) if (isElement(source)) then setPedControlState(source,"jump",false) end end,800,1,source) end end addEventHandler("bot_Jump",getRootElement(),zombieJump) addEvent("bot_Jump",true) function getPositionInfrontOfElement(element, meters) if not element or not isElement(element) then return false end if not meters then meters = 3 end local posX, posY, posZ = getElementPosition(element) local _, _, rotation = getElementRotation(element) posX = posX - math.sin(math.rad(rotation)) * meters posY = posY + math.cos(math.rad(rotation)) * meters return posX, posY, posZ end local fires = 0 local shotCheckAvailable = true function onClientPlayerWeaponFireFunc(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) if getElementData ( localPlayer, "isPlayerZombie" ) then return true end if shotCheckAvailable then if weapon > 9 and weapon ~= 23 then shotCheckAvailable = false setTimer ( function () shotCheckAvailable = true end, 4000, 1 ) local zombs = getElementsByType ( "ped", getRootElement(), true ) local x,y,z = getElementPosition ( localPlayer ) for i,zomb in ipairs(zombs) do if not getElementData ( zomb, "target" ) and not getElementData ( zomb, "zHeared" ) then local zx,zy,zz = getElementPosition (zomb) if getDistanceBetweenPoints3D ( x,y,z, zx,zy,zz ) < 50 then triggerServerEvent ("zombieHeared", localPlayer, zomb ) end end end end end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc ) 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 Hi, i need help :( Bots don't take as much blood as is set... Server gives them parameters from editor_client.Lua. gameplayVariables = {} gameplayVariables["ping"] = 300 gameplayVariables["zombiedamage"] = math.random(800,2000) gameplayVariables["enablenight"] = false gameplayVariables["hourxp"] = 125 There is also such a reference to this script in survivorSystem_client.Lua elseif getElementData ( attacker, "bots" ) or getElementData ( attacker, "snegovik" ) or getElementData ( attacker, "santa" ) or getElementData ( attacker, "boss4aki" ) or getElementData ( attacker, "bossBenz" ) or getElementData ( attacker, "bossCrais" ) then local damageded = Damage_ToCloth (bodypart) local reduce = getClothDamageReduce (pl_model, bodypart) setElementData(getLocalPlayer(),"blood",getElementData(getLocalPlayer(),"blood")-getElementData(attacker,"BOSSdamage")*damageded*reduce) local number = math.random(1,7) if number == 4 then setElementData(getLocalPlayer(),"bleeding",getElementData(getLocalPlayer(),"bleeding") + math.floor(loss*5)) end end end Please help me. What can cause all bots to hit with the same force?