SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/06/2014, 11:39 AM   #1
kristo
Banned
 
Join Date: Jun 2012
Location: Estonia
Posts: 352
Reputation: 179
Default Deer moving backwards.

I started writing a deer hunting system today (Well, some of it is based on this: http://pastebin.com/T7AyH6sQ) but their movement is a bit buggy. Most of the time they're moving at the right direction but sometimes they're going backwards. How to fix that?

pawn Code:
func LiigutaKits(id)
{
    new Float:pos[3], Float:randpos[3], Float:speed = 3 + random(3);
    StopDynamicObject(kitseobjekt[id]);
    GetDynamicObjectPos(kitseobjekt[id], pos[0], pos[1], pos[2]);
    if (random(2)) randpos[0] = pos[0] + 10 + random(10);
    else randpos[0] = pos[0] - 10 - random(10);
    if (random(2)) randpos[1] = pos[1] + 10 + random(10);
    else randpos[1] = pos[1] - 10 - random(10);
    MapAndreas_FindAverageZ(randpos[0], randpos[1], randpos[2]);
    if (floatabs(randpos[2] - pos[2]) > 2) return SetTimerEx("LiigutaKits", 0, false, "i", id);
    new Float:angle = angle = atan2(randpos[0] - pos[0], randpos[1] - pos[1]);
    if ((randpos[0] - pos[0]) < 1 || (randpos[1] - pos[1]) < 1) angle += 180;
    SetDynamicObjectRot(kitseobjekt[id], 0, 0, angle);
    MoveDynamicObject(kitseobjekt[id], randpos[0], randpos[1], randpos[2] + 0.4, speed);
    return 1;
}
kristo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Deer Hunting ! Dinnozor Filterscripts 53 15/07/2016 11:01 AM
[FilterScript] Transformation Into A Deer LevPopov Filterscripts 8 13/12/2013 03:36 PM
I'm moving backwards all the time Starver Client Support 1 24/12/2012 11:55 PM
moving a camera backwards? rep RLGaming Scripting Help 2 10/10/2012 09:08 PM
Camera moving backwards ? +Rep ShawnMiller1337 Scripting Help 2 04/09/2012 11:47 PM


All times are GMT. The time now is 12:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.