Where can I get information on how to make a Farcry 3-ish leaning script?

Tl;dr: Title.

In depth explanation:
I am currently working on a gamemode, but I’m feeling kind of stuck, as I’m unsure about how to go ahead with a leaning script.
I am trying to figure out how to make a script that lets you peek and shoot from cover, like you can do in Farcry 3, when you right click while facing cover.
The only problem is I don’t know where to find the information I need, and the wiki isn’t the most usefull place in this matter.
I should make it clear that I’m not asking for a template script, but rather an explanation of some functions that could be used. The main reason for me to make the gamemode is to become a better programmer, and that means figuring out how to put the script together myself :wink:
The information I need regards:

  1. Is there a function that lets you alter the shooting pos of weapons? I saw that there was a Player:GetShootPos class based at viewpos on the wiki, but I couldn’t find anything on how to set the view/shoot pos.
  2. Is there a function that lets you calculate the distance to an edge of a wall that the player looks at? This might need an example, so I will try to provide one: each frame the server checks a function, which turns the player green if he looks at a wall, while being less than 50 units away from it. The closer the player gets to the wall, the greener he gets.
  3. This might require making new animations, but I was wondering if it is posible to let a players worldmodel lean a certain distance based on how far he is from an edge.

If you can help in any way, or are unsure of wether you can help, but would like more specific information, please write a comment.
Sorry for the long text and bad english and my amateur formatting.

1: You can easily override this using metatables.
2: You’d want to use a trace from the original player head position, with the direction as the player’s eye angles converted to a vector.
3: Create a weapon base and override GetViewModelPosition.

Could you go into a bit more detail? Like, what would you surgest to read up on for a better understanding on how to do it?
I know how to override the view model position, but I want the playermodel to mirror the viewmodel. Ideally the playermodel should tilt with the viewmodel, if that is possible?

The playermodel can be tweaked using lua bone manipulation, just like any other object. To get more info, go to the wiki.

Those pages should tell you how to use what I mentioned. The best way to learn is to play with things and figure them out yourself.

Thank you very much!