SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 06-02-2017   #1
TSDude
Lack of tea
 
TSDude's Avatar
Default Angled 2D camera section

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.

Spoiler: Old info, you can ignore this
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:
Spoiler: Old code
Code:
//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)


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.
__________________
*snip*

Last edited by TSDude; 06-02-2017 at 07:52 AM. Reason: Clearing up info
TSDude is offline   Reply With Quote
Old 06-02-2017   #2
Rapidgame7
Rookie modder
 
Rapidgame7's Avatar
Default

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.
__________________
Ever tried to start a project until you find out it's too complicated then you abandon it
Rapidgame7 is offline   Reply With Quote
Old 06-02-2017   #3
TSDude
Lack of tea
 
TSDude's Avatar
Default

Quote:
Originally Posted by Rapidgame7 View Post
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
__________________
*snip*

Last edited by TSDude; 06-02-2017 at 08:04 AM.
TSDude is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Forum Jump


All times are GMT. The time now is 05:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.