SendOnFootSyncData: Difference between revisions
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
desc=This will send a packet to server which is filled by the following parameters.| | desc=This will send a packet to server which is filled by the following parameters.| | ||
params=<syntaxhighlight lang="lua">( keys, [float] posX, [float] posY, [float] posZ, [float] angle, health, armour, weapon, [float] speedX, [float] speedY, [float] speedZ, [float] aimPosX, [float] aimPosY, [float] aimPosZ, [float] aimDirX, [float] aimDirY, [float] aimDirZ, [bool] isCrouching )</syntaxhighlight> | params=<syntaxhighlight lang="lua">( keys, [float] posX, [float] posY, [float] posZ, [float] angle, health, armour, weapon, [float] speedX, [float] speedY, [float] speedZ, [float] aimPosX, [float] aimPosY, [float] aimPosZ, [float] aimDirX, [float] aimDirY, [float] aimDirZ, [bool] isCrouching )</syntaxhighlight> | ||
<poem> | <poem> keys : The npc's Game Keys to hold. | ||
:: | ::posX : The npc's position x co-ordinate. | ||
::posY : The npc's position y co-ordinate. | ::posY : The npc's position y co-ordinate. | ||
::posZ : The npc's position z co-ordinate. | ::posZ : The npc's position z co-ordinate. | ||
::angle | ::angle : The npc's facing angle in radians.(-PI to PI ). | ||
::health | ::health : Health of the npc. | ||
::armour | ::armour : Armour of the npc. | ||
::weapon | ::weapon : Weapon of the npc. | ||
::speedX | ::speedX : The npc's speed in x direction (supposed to be same as player.Speed.x on serverside ) | ||
::speedY | ::speedY : The npc's speed in y direction ( " ) | ||
::speedZ | ::speedZ : The npc's speed in z direction ( " ) | ||
::aimPosX | ::aimPosX : The x co-ordinate of aim position of NPC ( can be determined using server using player.AimPos or can be calculated artificially). | ||
::aimPosY | ::aimPosY : The y co-ordinate of aim position of NPC | ||
::aimPosZ | ::aimPosZ : The z co-ordinate of aim position of NPC | ||
::aimDirX | ::aimDirX : The x value given by player.AimDir. (It is mostly 0 or PI ) | ||
::aimDirY | ::aimDirY : The y value given by player.AimDir. | ||
::aimDirZ | ::aimDirZ : The z value given by player.AimDir. (usually ranges from -PI/2 to PI/2) | ||
::isCrouching | ::isCrouching : Whether the player is crouching. ( need not set to true even if aiming using weapons like ruger or sniper rifles. The logic is whether player has previously send 'Crouch Key'.) | ||
</poem>| | </poem>| | ||
example=<source lang="lua"> | example=<source lang="lua"> |
Revision as of 01:41, 15 November 2022
Description:
This will send a packet to server which is filled by the following parameters.
Parameters:
( keys, [float] posX, [float] posY, [float] posZ, [float] angle, health, armour, weapon, [float] speedX, [float] speedY, [float] speedZ, [float] aimPosX, [float] aimPosY, [float] aimPosZ, [float] aimDirX, [float] aimDirY, [float] aimDirZ, [bool] isCrouching )
keys : The npc's Game Keys to hold.
posX : The npc's position x co-ordinate.
posY : The npc's position y co-ordinate.
posZ : The npc's position z co-ordinate.
angle : The npc's facing angle in radians.(-PI to PI ).
health : Health of the npc.
armour : Armour of the npc.
weapon : Weapon of the npc.
speedX : The npc's speed in x direction (supposed to be same as player.Speed.x on serverside )
speedY : The npc's speed in y direction ( " )
speedZ : The npc's speed in z direction ( " )
aimPosX : The x co-ordinate of aim position of NPC ( can be determined using server using player.AimPos or can be calculated artificially).
aimPosY : The y co-ordinate of aim position of NPC
aimPosZ : The z co-ordinate of aim position of NPC
aimDirX : The x value given by player.AimDir. (It is mostly 0 or PI )
aimDirY : The y value given by player.AimDir.
aimDirZ : The z value given by player.AimDir. (usually ranges from -PI/2 to PI/2)
isCrouching : Whether the player is crouching. ( need not set to true even if aiming using weapons like ruger or sniper rifles. The logic is whether player has previously send 'Crouch Key'.)
Return Values:
This function does not return any specific values.
Important Note:
This was added in v1.3 and will not work in previous builds.
Example
function ShootAt(tPos) { local Pos=GetMyPos(); local angle= atan2(-(tPos.x-Pos.x), tPos.y-Pos.y); local aimPos=Vector(tPos.x,tPos.y,tPos.z); SendOnFootSyncData( 576,Pos.x,Pos.y, Pos.z, angle, GetPlayerHealth( npcid ), GetPlayerArmour( npcid ), 27, 0.0, 0.0, 0.0, aimPos.x, aimPos.y, aimPos.z, PI, PI, Pos.x<tPos.x?PI/2:-PI/2, false ); /* See note */ }
Since it is difficult to calculate the aiming position and aim direction by npc, it has been found that npc can shoot a target almost accurately (an exception when the player is in the almost north of npc 3.10~3.14 ) when the aiming position of npc is set exactly as the target position and aiming direction z co-ordinate set as -PI/2 if player is to the west ( of npc's position with N (north pole) taking into account. npc angle will be positive ) or PI/2 if player is to the east of npc ( the angle of bot will be negative ).
Related Functions
The following functions may be helpful as they relate to this function in one way or another.