Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- #include mapandreas
- main()
- {
- printf("Gamemode KoIntelligence powered by Kuddy carregado");
- printf("Todos os direitos reservados a KomanZ");
- }
- new KoB;
- public OnGameModeInit()
- {
- printf("Iniciando KoIntelligence...");
- SetGameModeText("KoIntelligence");
- AddPlayerClass(0,2034.9125,1336.2625,10.8203,349.3566,0,0,0,0,0,0);
- KoB = CreateObject(1243, 2043.06, 1354.30, 7.37, 0.00, 0.00, 0.00);
- SetTimer("UpdateNPC", 500, true);
- MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
- /*new time = GetTickCount();
- new Float:loopar;
- for(new i; i < 1000000; i++)
- {
- loopar = loopar + random(10);
- MapAndreas_FindZ_For2DCoord(loopar,loopar,pz);
- }
- time = GetTickCount() - time;
- printf("%d MS", time);
- Resultado: 118 MS
- */
- return 1;
- }
- forward UpdateNPC();
- public UpdateNPC()
- {
- new Float:x, Float:y, Float:z, Float:px, Float:py, Float:pz;
- GetPlayerPos(0, px, py, pz);
- //MoveObject(KoB, px, py, pz, 2);
- GetObjectPos(KoB, x,y,z);
- MapAndreas_FindZ_For2DCoord(x,y,z);
- //MapAndreas_FindZ_For2DCoord(px,py,pz);
- AtualizarPos(x,y,z,px,py,pz);
- return 1;
- }
- stock AtualizarPos(Float:x, Float:y, Float:z, Float:fx, Float:fy, Float:fz)
- {
- // Getar direção que o objeto está em relação ao player:
- new Float:valorx = x - fx, Float:valory = y - fy, Float:outX,Float:outY, Float:outZ;
- outX = x; outY = y; outZ = z;
- if(valorx < 0)
- {
- //SendClientMessageToAll(-1, "valorx > x");
- new Float:preview = x + 1, Float:zprev;
- MapAndreas_FindZ_For2DCoord(preview, y, zprev);
- if(zprev < z + 2 && zprev > z - 2)
- {
- outX = x + 1;
- }
- }
- if(valorx > 0)
- {
- //SendClientMessageToAll(-1, "valorx < x");
- new Float:preview = x - 1, Float:zprev;
- MapAndreas_FindZ_For2DCoord(preview, y, zprev);
- if(zprev < z + 2 && zprev > z - 2)
- {
- outX = x - 1;
- }
- }
- if(valory < 0)
- {
- //SendClientMessageToAll(-1, "valorx > y");
- new Float:preview = y + 1, Float:zprev;
- MapAndreas_FindZ_For2DCoord(x, preview, zprev);
- if(zprev < z + 2 && zprev > z - 2)
- {
- outY = y + 1;
- outZ = zprev;
- }
- }
- if(valory > 0)
- {
- //SendClientMessageToAll(-1, "valorx < y");
- new Float:preview = y - 1, Float:zprev;
- MapAndreas_FindZ_For2DCoord(x, preview, zprev);
- if(zprev < z + 2 && zprev > z - 2)
- {
- outY = y - 1;
- outZ = zprev;
- }
- }
- MapAndreas_FindZ_For2DCoord(outX, outY, outZ);
- // debug
- new str[128];
- format(str,128,"Movendo para: {0000FF}%f, {FF0000}%f, {00FF00}%f",outX, outY, outZ);
- SendClientMessageToAll(-1, str);
- MoveObject(KoB, outX, outY, outZ, 2);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement