Angled 2D camera section

Status
Not open for further replies.

WellDoneSnake

Yoko Shimomura
Hey guys,

So I learned while playing srb2 version 2.0.4 in past, that if you use camera scanner in a 2d section whilst analog mode is enabled, you would be able to angle the camera around the player:
Example

I'm not sure how long this has existed in srb2, but I decided to make some use of it.

EDIT: Hope this edit doesn't confuse things for you guys.

My aim is to make a lua script that changes the player's control to analog mode upon entering 2D mode. Without having to use a custom linedef or runsoc script.

The reason for this is because I want to apply the effects of the camera scanner to the player's camera in 2D mode as well as leave control setting default for analog control users.

I'm also not sure if this secondary flag "player.mo.flags2 & MF2_TWOD" is supposed to work with the enable/disable 2d effect or just 2d mode.
After all the wiki states this "This flag is given to Objects if they are in 2D mode or are supposed to behave as such", so I can only assume that the statement implies that this flags affects the enable/disable 2d effect.

One last thing, is there any difference in changing the player's control using "COM_BufInsertText" or "PF_ANALOGMODE"? Besides the obvious, which is one being a console command execution and the other being a player's internal flag.

New code:
Code:
addHook ("ThinkFrame", do
	for player in players.iterate
		if (player.analog2D == true) then
			COM_BufInsertText (player, "analog on") 
		end

		if (player.mo.flags2 & MF2_TWOD)
		and not (player.pflags & PF_ANALOGMODE) then
			player.analog2D = true
		else
			player.analog2D = false
		end
	end
end)
Just like with the old code, the switch to analog mode works but it isn't restricted to 2d mode, which is what I'm trying to make happen.

You would have two options:

a) If the player is in a 2d based mode and is already using analog mode then make no changes.

b) If the player is in a 2d based mode (which is also under the effects of the camera scanner linedef) and not using analog mode, then switch that players mode to analog mode until they leave 2d mode.
(When I say "2d based mode", I'm mainly referring to the lindef 432 "Enable/Disable 2d mode" and the sector that is affected this linedef action)

The two options above will be determined as variables under the name "player.scanneranalog2D". If this returns true then the changes that I stated in option B would take place, otherwise if false then no action is taken.

Here's what I've got so far:
Code:
[STRIKE]//Analog + Camera Scanner = Angled 2d Camera
//All that this script does is turn on analog mode when the camera scanner linedef is used
//in conjunction with the enable/disable2d.

addHook ("ThinkFrame", do
	for player in players.iterate
		if player.scanneranalog2D == nil then
			player.scanneranalog2D = false
		end

	for line in lines.iterate
		if line.special == 5
		and (player.scanneranalog2D == true) then
			player.pflags = PF_ANALOGMODE			
		end
	end

		if not (player.pflags & PF_ANALOGMODE)
		and not (player.mo.flags2 & MF2_TWOD)
			player.scanneranalog2D = true
		else
			player.scanneranalog2D = false
		end
	end
end)[/STRIKE]

The player.scanneranalog2D variable works however I am unable to use and restrict it to only working when the player is under the effect of 2D, and when the player's camera is under the effect of camera scanner.
 
Last edited:
Quick tip: Do not set pflags to PF_ANALOGMODE.
Instead, use the bitwise OR to turn on that flag (player.pflags = $ | PF_ANALOGMODE).
If you set this variable, you will also set to 0 all other bits.
 
Quick tip: Do not set pflags to PF_ANALOGMODE.
Instead, use the bitwise OR to turn on that flag (player.pflags = $ | PF_ANALOGMODE).
If you set this variable, you will also set to 0 all other bits.
Sorry for the delayed response, and thanks for the tip I'll try that.

BTW I think I might be overdoing it, I going to try and see if I can make it so that the player switches to analog mode when entering 2D mode. I feel that there's no need to bring the camera scanner into this script, I'll just leave it at applying it to the sectors that the player runs through.

I'll edit the first post to make things clearer.

EDIT: Oh wow, now it works with the code that I posted above for some reason.
Example
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top