Jump to content

[Release] Partial Firstperson


ToejaM

Recommended Posts

Based on this thread here: 
 
Created this thread to keep it up to date in the OP and so that I'm not spamming someone elses thread.
 
Current Script Function / Features
When you meet certain requirments it will force you into first person, each individual requirement below is annotated with what it does.
 
"If's" - Enabled by default
// If player is within 50m of any objects in the array, force player into first person.
// If player is not in a vehicle and is in combat, player forced into first person.
// If player is in a vehicle and near objects within _countCPC, player forced into third person.
// If player is not in a vehicle and is near objects within _countCPC, player forced into first person only if they use their camera view changer (numpad enter by default)
// Allow third person while building. Player once in third person will have their view distance set to the value in the config at the top of this file.
"If's" - Disabled by default - uncomment the /* and */ around the block of code to enable in the script below.
// If player is in a vehicle and the vehicle is moving faster than 30 KPH, player forced into first person.
// If player is near another player, player forced into first person.

// If player is in a vehicle and is in combat, force first person.
 
Changelog

Version 1.0.4
[ADDED] If in vehicle and in combat, force first person. - Off by default.

Version 1.0.3

[FIXED] First/third person loop bug while building.

Version 1.0.2
[ADDED] Full config support at the top of the script to stop the need for hunting around.
[MERGED] Previously there were two separate scripts, with a simple config setting at the top "_viewDCPCStatic" it doesn't matter if you use a view distance changer or not. This makes it easier for those without view distance changer scripts to install and use this script.
 
Version 1.0.1
[FIXED] Fog is removed after performing any actions

Version 1.0 - Initial working release, no errors.
[ADDED] Support for action menus and view distance changers. See Step 2a
[ADDED] Standalone version for servers who do not have a view distance changer for clients. See Step 2b)
 
 
Install
 
Step 1)
Create new .sqf file called "PFP.sqf" and place into your mission folder/pbo.
 
Step 2)
Copy the following code into your new PFP.sqf file:

/*
Original thread: http://epochmod.com/forum/index.php?/topic/10973-release-limited-3rd-person-view-script/
Credits: Halvhjearne / saintanthony / ToejaM
Purpose: In certain scenarios force player into first person.

Config: To allow extra restrictions detailed below, remove the commenting done via the slash and star around each block of code.
*/
private ["_countCPC","_viewDCPC","_viewDActionCPC","_viewDCPCStatic","_nearPCPC","_viewDCCPC","_objectACPC","_objectDCPC","_playerDCPC","_viewVSCPC","_viewVVSCPC"];
waitUntil {!isNil "dayz_animalCheck"};
//Initial Config that must be set early

// Set Default view distance - This setting should mirror the setViewDistance in your init.sqf in the root mission directory.
_viewDCPCStatic = 750;

// Maximum view distance in meters while in third person and building. If you have a script that allows you to change your own view distance, please see my thread on how to use both this script and your view distance changer script.
_viewDCCPC = 10;

// Object Array
_objectACPC = "Plastic_Pole_EP1_DZ","CinderWallDoorSmallLocked_DZ","Land_DZE_WoodDoorLocked","CinderWallDoorLocked_DZ","Land_DZE_GarageWoodDoorLocked","WoodFloorHalf_DZ","WoodFloor_DZ","WoodFloorQuarter_DZ","MetalFloor_DZ";

//Player distance from object array before being forced into first person.
_objectDCPC = 50;

// Player distance from other players before being forced into first person. This scenario is disabled, please uncomment it in the code below.
_playerDCPC = 50;

// Vehicle speed before being forced into first person. This scenario is disabled, please uncomment it in the code below.
_viewVVSCPC = 30;

// Config is now done. script Starts below this line, all config settings are above.


// Setting up the default value for the variable if no value set.
    waitUntil {!alive player ; !isNull (findDisplay 46)};
		if (isNil {player getVariable "VARviewDActionCPC"}) then { 
		player setVariable ["VARviewDActionCPC",_viewDCPCStatic];
		};

//Waiting for initial loop to start
        if (!isDedicated) then { //preventing start on server
    waitUntil {!isNull (findDisplay 46)}; //making sure player is spawned 
	    if (difficultyEnabled "3rdPersonView") then {
		    while {true} do {
    waitUntil {cameraView == "EXTERNAL" || cameraView == "GROUP"};
		
		
// Config - Config that needs to be refreshed each cycle for script to function.

// Objects Array
_countCPC = count nearestObjects [player, [_objectACPC], _objectDCPC];

// Maximum view distance in meters while in third person and building.
_viewDCPC = _viewDCCPC;

// Vehicle speed
_viewVSCPC = _viewVVSCPC;

// Players near
_nearPCPC = {isPlayer _x} count (player nearEntities ["CAManBase", _playerDCPC]) > 1;
						
			
			// Mandatory to set view distance variable, no need to change. Config setting is above under _viewDCPCStatic
            _viewDActionCPC = player getVariable "VARviewDActionCPC";
			
			// If player is not in a vehicle and is in combat, player forced into first person.
			if  (((vehicle player) == player) && (dayz_combat == 1)) then {
				player switchCamera "INTERNAL";
				setViewDistance _viewDActionCPC;
			};
			
			// If player is in a vehicle and near objects within _countCPC, player forced into third person.
			if (((vehicle player) != player) && (_countCPC > 0)) then {
				(vehicle player) switchCamera "EXTERNAL";
				setViewDistance _viewDActionCPC;
			}; 
			
			// If player is not in a vehicle and is near objects within _countCPC, player forced into first person.
			if (((vehicle player) == player) && (_countCPC > 0) && (!DZE_ActionInProgress)) then {
			player switchCamera "INTERNAL";
			setViewDistance _viewDActionCPC;
			};
			
			// Allow third person while building. In current state can be exploited to use third person while no intention to build, not recommended.
			if (((vehicle player) == player) && (DZE_ActionInProgress)) then {
			player switchCamera "EXTERNAL";
			setViewDistance _viewDCPC;
			};
			
			//Mandatory to restore vision after refuelling and performing other actions.
			if (!DZE_ActionInProgress) then {
			setViewDistance _viewDActionCPC;
			};
						
			// If player is in a vehicle and the vehicle is moving faster than 30 KPH, player forced into first person.
			/*
			if (((vehicle player) != player) && (speed (vehicle player)) >= _viewVSCPC) then {
				(vehicle player) switchCamera "Internal";
				setViewDistance _viewDActionCPC;
			};
			*/
			
                        // If player is in a vehicle and is in combat, force first person.
			/*
			if  (((vehicle player) != player) && (dayz_combat == 1)) then {
				player switchCamera "INTERNAL";
				setViewDistance _viewDActionCPC;
			};
			/*
			
			// If player is near another player then force player into first person. - Untested, should work.
			/*
			if(_nearPCPC) then {
			        player switchCamera "INTERNAL";
			        setViewDistance _viewDActionCPC;
			};
			*/
			
			sleep 0.1;
		};
	};
};

Step 3)
Edit the config at the top of the PFP.sqf to your liking. If you don't have a view distance changer, make sure to set "_viewDCPCStatic =" to the default that is in the init.sqf.
 
Step 4) - Only required if you have an optional view distance changer for your clients.
If you are using an action menu that allows the client changes their view distance, you will need to add the following command into each file that changes the view distance:


player setVariable ["VARviewDActionCPC",VALUEHERE];

I use:


I have modified the files to remove the weather changes and simply all that happens is the viewdistance changes and it sets a variable which allows the player to remember their last view distance, if you don't do this and you use the base building portion of the script it will leave people in permanent fog until they manually change their view distance.
 
Example of my full file: \ActionMenu\fog\1500.sqf

setviewdistance 1500;
player setVariable ["VARviewDActionCPC",1500];

I had a lot of fun working out and learning about simple variables and a small change like this adds a huge convenience to players, especially players not so keen on 1st person.
 
Step 5)
At the very bottom of your init.sqf add:

// Partial Firstperson
[] execVM "PFP.sqf";

Step 6)
Save all files and re-pbo if necessary, you are done.
 
Additional
Some people really don't like first person but I think there are a few things people can do to improve their experience.
 
Firstly watch this video:
It says it better than I can explain why 3rd person is bad, I get that people like it when running around but while in your bases and in combat, you should be first person imo or you're just cheating yourself out of some immersive, fun gameplay aswell as against other people.. you're cheating them to! 3rd person is a crutch that I hope one day people won't need.
https://www.youtube.com/watch?v=v7zoVIsIT2A
 
Secondly checkout this thread:
Some tips on improving your first person expierence not only in DayZ but any game that has the features mentioned.
http://www.cpc-gaming.eu/forum/m/12670048/viewthread/15312371-first-person-tweaks

Link to comment
Share on other sites

Updated.

I use a custom view distance changer for clients, its a bit annoying constantly resetting view distance with the third person base building addition so now I have added to the script the ability for it to remember your previous view distance and it should be automatic.

If you use a different script, post it here and I'll show you where to add the variable.

Link to comment
Share on other sites

when in a vehicle It doesnt place me in 1st person when I enter combat...

Added to the script, its off by default now - remove the surrounding comments /* *\

 

nice to see something posted from shacktactical particularly dsylecxsi

Yeah, he posts some good stuff. That video in the OP is particularly good!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...