[FilterScript] Deer Hunting !
#1




Is this picture bothering you ? Tired of Bambi ? Do you miss the hunting sessions in Red Dead Redemption ? Or maybe is it only hunger ?.. Anyway, you might enjoy what is following !
Quote:

Twenty deers are running through Los Santos woods... Your job there is to catch them ! Be careful and stay quiet ! Any engine noise, your own presence or any gunshot might make them flee !

Once shot (or ran over...), you'll have to take your knife (katana, or chainsaw ) to take the pieces of meat out of the deer. According to the deer, and how much you've "damaged" it (you would rather shoot Bambi with a hunting rifle than with a AK47...) you might get 30lbs of meat to ... nothing, if you ran over it, then shoot it, etc... You wouldn't eat it anyway.

I would like to emphasize the fact that this script doesn't use any NPC, and the deer object is actually included in SAMP since the 0.3c - I actually made this script because I thought it was unfair no one would use this object made with love by SAMP Teams...

Update ( 24/08 ) : From now on, instead of stabbing in the air, you'll have to press and hold LMB to get the meat, an anim being played (thanks to Virtual1ty for its suggestion about that ). Please have a look at the video following showing you this new system, but also what happens when you hit a deer with your car...

Update ( 25/08 ) :

A virus makes the deers be aggressive to the hunter ; if you get too close, it will attack you ! Also it won't be eatable. However this virus is still rare, only 3% of the deer population is hit by it (for the moment...).

This is how I originally introduced this original and unique script in SAMP, in this thread : https://sampforum.blast.hk/showthread.php?tid=371469


Download :
Pastebin v1.02(English - fixed)

v1.02 fixes :
  • Greatly increased the accuracy ; added a parameter to IsPlayerAimingPoint function (weapon)
  • Another orientation problem corrected
  • Added a condition in the OnPlayerUpdate (which you can actually replace by a callback called less frequently) so there won't be loops on every update
v1.01 fixes :
  • Use of GetPlayerCameraFrontVector instead of GetPlayerFacingAngle : checks the Z coord, you can't "cheat" only using your facing angle (thanks to Basssiiie for the idea)
  • IsPlayerAimingObject is now IsPlayerAimingPoint (see details in the first page).
  • Modified the FinDeer function because it had a bug when you picked the meat. If you clicked several times on LMB you could take more. -Fixed
  • Corrected a bug of the deer orientation during its movement
  • a few little bugs fixed
Features
  • Moving deers - they are like bots, will move in areas near LS. If you shoot near them they will flee.
  • Possibility to add areas where the animals can move.
  • Good for RP : can add a job ; you get meat from the deers you shoot.
  • Crazy deers system - totally up to you to set it or not...
  • Functions & stocks:
    pawn Code:
    stock IsPlayerAimingPoint(playerid, Float:X2,Float:Y2,Float:Z2, Float:range,Float:accuracy)
    stock CreateDeer(Float:X,Float:Y)
    public DestroyDeer(DeerID)
    public MovingDeer(DeerID)
    stock IsPosInDeerZone(Float:X,Float:Y)
    stock OnPlayerShoot(playerid,oldammo,newammo,weapon)
    public FinDeer(DeerID,playerid)

    stock IsPlayerAimingObject(playerid, aimid)//Out of date since 1.01, now IsPlayerAimingPoint
  • Commands :
    Code:
    /resetdeers - lets admins respawn the deers
  • Etc... See the videos below
Videos

Introduction
[ame]http://www.youtube.com/watch?v=3gkjqwgIJAg&feature=player_embedded[/ame]

1st update
[ame="http://www.youtube.com/watch?v=-g5gr2v6960&feature=plcp"]Video[/ame]

Crazy deers stuff (1st part of the video)
[ame="http://www.youtube.com/watch?v=vbjTqNTdCB4&feature=player_embedded"]Video[/ame]


Bugs still known :
  • Sometimes you might have to shoot several times to hit your target, since you can't get a really accurate result with the GetPlayerCameraFrontVector. You can change the "accuracy" field of the IsPlayerAimingPoint to make it easier to hit the target (increase accuracy) or harder (decrease it). -Fixed in 1.02
  • I apparently have some trouble using atan function because the deers won't always be orientated as they should when they move. However it is not a problem to have fun with this FS.
Important notes

Don't forget to read the informations in the comments in the Pastebin. Also there are some files you'll need :
  • Download the "SAfull.hmap" file here : https://sampforum.blast.hk/showthread.php?tid=273263 . Put it in your scriptfiles folder.
    /!\ Don't put MapAndreas include in your script, just the .hmap file ; or just remove the GetPointZPos stock in my script.
  • Download the OnPlayerVehicleDamage include here : https://sampforum.blast.hk/showthread.php?tid=276059
  • It is better to use the Incognito Streamer you can find on these forums. Although it is not needed, you can make the script work without it. Just replace the DynamicObject with simple Objects
  • Don't forget to replace with your own variables in the PlayerInfo ones.
You should not encounter any problem if you read carefully the informations in the pastebin. However, don't hesitate to report any mistake, untranslated stuff in the pastebin. Ask questions if needed.

Use and/or modify the script as you want, but if you share it, credits are always welcome !

Enjoy !
Reply
#2

i have put it in the scrpt and now when i shoot on the deers nothing hapend!
Reply
#3

Very nice work!
Reply
#4

Nice one dinno
Reply
#5

Nice idea, but translate the FS to english.
Reply
#6

Quote:
Originally Posted by Pasa
View Post
i have put it in the scrpt and now when i shoot on the deers nothing hapend!
Please post some screens or more info about this... I would be really surprised the code doesn't work since this is just copy/paste from my GM. Make sure you've put everything in the right callback. If other people report these kind of problems, I will check again if I didn't forget everything.

Quote:
Originally Posted by DiGiTaL_AnGeL
View Post
Nice idea, but translate the FS to english.
Here it is Check the new Pastebin, the texts should be fully translated and ready to put on English servers !
Reply
#7

I was creating something extremely similar for my server. This is loads better though, seems epic
Reply
#8

Oh, another exclusif system scripted by xXkevin69darkillerOO for his nooby server now
Btw, good job it's great idea, i've already done it on my server month ago with cow
Reply
#9

What if you shoot above or below the deer? Will it hit the deer too? I don't see a check in your script to prevent that.
Reply
#10

This is madness thanks dude rep+
Reply
#11

Quote:
Originally Posted by Dinnozor
Посмотреть сообщение
Indeed, the script actually checks if you shoot near the (0,0,0) point of the deer. So some times you might shoot it and it doesn't affect it, or you might shoot near and it kills it. But IG just blame the fact the deer wasn't killed in the shot (just wounded) or your rifle has some accuracy problem x)
I guess that's a possibility too, yeah. :P


Quote:
Originally Posted by Dinnozor
Посмотреть сообщение
However look at the videos, the script is pretty accurate and for a fun gameplay you don't always need to have something this perfect... But if you have a solution to this, feel free to improve the script and/or tell me how you would do !
I see, maybe an idea to calculate IsPlayerAimingAtObjct with GetPlayerCameraFrontVector and GetPlayerCameraPos? That might be a bit accurate than GetPlayerFacingAngle, as the facing angle can still point at the deer, if you shoot about 100 meters above it. Although the calculation might be a bit more difficult to do.
Reply
#12

Actually I tried with these functions but couldn't get a nice result... It has been a while I haven't changed the script but I remember having trouble with these, and not only with the deer hunting stuff...

So you can indeed shoot a deer aiming 100m above it (just blame gravity ? :P ), but once again this is for fun, so if people just want to "cheat" that way that's their problem..

For the moment I don't plan to modify it, but I note your suggestion and might be trying and pulling my hair off again to make it work with GetPlayerCameraFrontVector and GetPlayerCameraPos... Also I kind of have some trouble running SAMP with Wine (under Mac OS X Lion) ; it used to work but for a little while it just hasn't been working So I'll have to fix this before modifying the script...

Edit : adapted from another of my scripts, I will try this when my SAMP on Mac problem will be fixed :

pawn Код:
stock IsPlayerAimingObject(playerid, aimid)
{
    new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2,Float:xv,Float:yv,Float:zv,Float:xc,Float:yv,Float:zc,Float:xt,Float:yt,Float:zt;
    GetPlayerPos(playerid, X1, Y1, Z1);
    GetPlayerCameraPos(playerid,xc,yc,zc);
    GetPlayerCameraFrontVector(playerid,xv,yv,zv);
    GetDynamicObjectPos(aimid, X2, Y2, Z2);
    new Float:Dist = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
    if(Dist < 100)
    {
        for(new i=1;i<=100;i++)
        {
           
            xt=X1+i*xv;
            yt=Y1+yv*i;
            GetPointZPos(xt,yt,zt);
            Dist=floatsqroot(floatpower(floatabs(xt-X2), 2) + floatpower(floatabs(yt-Y2), 2)+floatpower(floatabs(zt-Z2),2));
            if (Dist<=0.5)
            {
                return true
            }
        }
    }
        return false;
}
It worked fine for another script. However it only had to check for a short distance (4), not like here, where it checks until 100. So maybe that would make a lot of calculation. I will make tests when I can, but tell me if you think something may be approved...
Reply
#13

v.1.01 is out !

v1.01 fixes :
-Use of GetPlayerCameraFrontVector instead of GetPlayerFacingAngle : checks the Z coord, you can't "cheat" only using your facing angle (thanks to Basssiiie for the idea)
-IsPlayerAimingObject is now IsPlayerAimingPoint (see details in the first page).
-Modified the FinDeer function because it had a bug when you picked the meat. If you clicked several times on LMB you could take more. -Fixed
-Corrected a bug of the deer orientation during its movement
-a few little bugs fixed

Bugs still known :
-Sometimes you might have to shoot several times to hit your target, since you can't get a really accurate result with the GetPlayerCameraFrontVector. You can change the "accuracy" field of the IsPlayerAimingPoint to make it easier to hit the target (increase accuracy) or harder (decrease it).
-I apparently have some trouble using atan function because the deers won't always be orientated as they should when they move. However it is not a problem to have fun with this FS.

Now, here is the release :
Pastebin v1.01(English)
Reply
#14

Nice work, but looping in OnPlayerUpdate ...
Reply
#15

Indeed, added some condition in 1.02 so loops in OnPlayerUpdate won't be so frequent. Also, you can create you own Update function, repeated less frequently - especially if you have a server with many people.

v.1.02

v1.02 fixes :
  • Greatly increased the accuracy ; added a parameter to IsPlayerAimingPoint function (weapon)
  • Another orientation problem corrected
  • Added a condition in the OnPlayerUpdate (which you can actually replace by a callback called less frequently) so there won't be loops on every update
Bugs still known :
-I apparently have some trouble using atan function because the deers won't always be orientated as they should when they move. However it is not a problem to have fun with this FS.

Download
Pastebin v1.02(English)
Reply
#16

A little suggestion

Put the
pawn Код:
new Float:xP,Float:yP,Float:zP;
        GetPlayerPos(playerid,xP,yP,zP);
after the condition cause is a bit more accurate
Reply
#17

Wut ? I take the Pos of the player and, I check whether he is in a deer zone and, if so, the script does the loop...
Reply
#18

Ops, my bad I didn't see the parameters in IsPosInDeerZone :/
Reply
#19

Eh eh no problem ^^
Reply
#20

This is EPIC, but.. It throws 21 errors :/ Why? lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)