SendOnFootSyncData: Difference between revisions

From NPC for VCMP 0.4 Servers
Jump to navigation Jump to search
No edit summary
No edit summary
Line 30: Line 30:
local aimPos=Vector(tPos.x,tPos.y,tPos.z);
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, false ); /* See note */
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, -angle, false, false ); /* See note */


}
}
Line 38: Line 38:
npcid<-myplayerid;
npcid<-myplayerid;
}
}
</source>
</source>|
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 ).|
note=This was added in v1.4 and will not work in previous builds.|
note=This was added in v1.4 and will not work in previous builds.|
relfuncs=*[[SendOnFootSyncDataLV]]|
relfuncs=*[[SendOnFootSyncDataLV]]|
}}
}}

Revision as of 17:35, 7 December 2022


Description:
This will send a packet to server which is filled by the following parameters.


Parameters:

( keys, posx, posy, posz, angle, health, armour, weapon, ammo, speedx, speedy, speedz, aimposx, aimposy, aimposz, aimdirx, aimdiry, aimdirz, isCrouching, isReloading )

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.
ammo : The amount of ammo the npc has for weapon.
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'.)
isReloading: true, if the player has stopped shooting and is reloading his weapon. false, otherwise. The keys while reloading when 'Bitwise AND' with 512 must be zero while reloading. If the keys given are otherwise, the corresponding bit will be set off to match this requirement.


Return Values:
This function does not return any specific values.

Important Note:
This was added in v1.4 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, -angle, false, false ); /* See note */

}

function OnNPCConnect(myplayerid)
{
	npcid<-myplayerid;
}

Related Functions

The following functions may be helpful as they relate to this function in one way or another.