Vice City: Multiplayer

Vice City General => Videos & Screenshots => Topic started by: habi on May 06, 2023, 05:12 AM

Title: Walking Cop with Nitestick ( npc )
Post by: habi on May 06, 2023, 05:12 AM
Hi i made a walking cop with nitestick. See video:

Ingredients:
1 cup of SetAnim served in a NewTimer dish which is 100ms.
Keep the fire burning at npc's kitchen by GetMyPos()+(target-GetMyPos()).Normalised()*0.14
i will post the full recipe sometimes later
Title: Re: Walking Cop with Nitestick ( npc )
Post by: Ridwan Rz on May 06, 2023, 03:04 PM
It's time to make some noise huh?  ;D  ;D
Title: Re: Walking Cop with Nitestick ( npc )
Post by: PSL on Sep 29, 2023, 02:40 AM
GetMyPos()+(target-GetMyPos()).Normalised()*0.14
What does this code mean and what is Normalised like?
Is the 0.14 behind walking every 100ms distance?
Title: Re: Walking Cop with Nitestick ( npc )
Post by: habi on Sep 29, 2023, 07:51 AM
Quote from: PSL on Sep 29, 2023, 02:40 AMWhat does this code mean and what is Normalised like?
Is the 0.14 behind walking every 100ms distance?
Yes, 0.14 is the reason why the cop will appear walking even to players who stream in later. It is syncing.

Here is a look at the code. The complete code is put somewhere in npc-wiki.
function step_forward()
{
local newpos=GetMyPos()+(target-GetMyPos()).Normalised()*0.14;
newpos.z=FindZFor2DCoord(newpos.x, newpos.y)+1.0425;
SetLocalValue(V_POS, newpos);
SetLocalValue(F_ANGLE, atan2(-(target.x-GetMyPosX()),target.y-GetMyPosY()));
...
        SendOnFootSyncDataLV();
       ...
}
This function is called every 100 msec.
Normalized convert it into unit vector.
So multiplying by 0.14 is distance of one walking step
So newpos = oldpos + one step forward