Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (EternallyCurious, howardR), 646 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[Contribution] Resident Evil Camera #438574
03/17/14 18:34
03/17/14 18:34
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Many years ago I found a resident evil script written in c-script (of coarse), and converted it over to lite-c last night.

I didn't write it. The authors names are in the code laugh

Code:
/*
'RESIDENT EVIL' STYLE CAMERA by <tesanders & Orange Brat>
HOW TO USE THIS CODE:
//
Each 'camera' has a 'camera entity' and its corresponding trigger entity. You assin the "set_cam" and "set_cam_trigger" actions and set each entities skill1 to an equal value. 
Both entities must have the same skill1 value and you can use up to 200 cameras, by default, but you can use any total you want by changing the array value. Do not assin "0"
as a skill1 value or it will return without switching cameras. You can also use more than one trigger entity for each camera. This is useful when you need to extend the influence 
of a specfic camera. You can insert an "island"of influence inside the zone of another camera's hotzone, too.

The 3rd object is a look at entity. It is used for an offset(if desired) based on the "cam_factor" variable. If you set it to 0, the camera will always look directly at the player. 
If you set it to 1 if will always look at the look at entity and will ever move... a perfectly still camera. If you set it to any value between 0 and 1, it will always match the "lerped" 
spot bewteen the player and the look at entity and will move when the player moves. The downside to this setup is, as is, you can only have one look at object per level. It can 
easily be adapted so that the camera has its own look at object, but if you don't require and offset, you can comment out the camera_move function and uncomment the other. Using the 
alternate function, you can still achieve a perfectly still camera by setting the camera entities flag1 to on. If you want it to follow the player set it to off.
*/

ENTITY* cam_look_at;//the look at object pointer
ENTITY* cam_ptr;// the camera object pointer
var cam_array[200]; // max 200 cameras
var cam_closest_distance;
var cam_active = 1;//0 = not active 1 = active
VECTOR temp, cam_target;

// 0 = always follows player 
// 1 = always look at cam_look_at
// between 0-1 looks at offset between player and cam_look_at
var cam_factor = 1;


function get_cam(cam_number){//retrieve fixed view
	proc_kill(4);
	if(cam_array[cam_number] == 0){return;}//no cameras available
	cam_ptr = ptr_for_handle(cam_array[cam_number]);//Store cam_number in cam_ptr, for next function
}

function init_cameras(){ //gets first camera
	get_cam(1);
}

function cam_poller(){ //controls the camera trigger array
	proc_kill(4);
	while(1){wait(1);
		cam_closest_distance = 100000;
	}
}

action set_cam(){//store fixed view - This is where the look at pointer is looking 
	set(me,INVISIBLE+PASSABLE);
	cam_array[my.skill1] = handle(me);	
}

action set_cam_trigger(){//trigger for fixed view
	while(player == NULL) {wait(1);}
	set(my,INVISIBLE + PASSABLE);
	while(1){wait(1);
		if(vec_dist(my.x,player.x) < cam_closest_distance){
			cam_closest_distance = vec_dist(my.x,player.x);
			get_cam(my.skill1);	
		}
	}
}

action set_cam_look_at(){//assign as look at object - This looks for the set_cam with equal skill1 value.
	set(my,PASSABLE+INVISIBLE);
	cam_look_at = me;	
}

function camera_move(){
	while(cam_ptr == NULL){wait(1);}
	while(cam_active == 1){wait(1);
		if(!cam_look_at){
			vec_set(camera.x,cam_ptr.x);
			vec_lerp(cam_target.x, player.x, cam_look_at.x, cam_factor);//Get the offset based on cam_factor
			vec_set(temp,cam_target.x);
			vec_sub(temp,camera.x);
			vec_to_angle(camera.pan,temp);//camera looks at cam_target	
		}
	}	
}

/*
function camera_move(){
	while(cam_ptr == NULL){wait(1);}
	while(cam_active == 1){wait(1);
		if(is(cam_ptr,FLAG1)){
			vec_set(camera.x, cam_ptr.x);
			vec_set(camera.pan,cam_ptr.pan);
		}
		else{
			vec_set(camera.x,cam_ptr.x);
			vec_set(temp,player.x);//assign to temp
			vec_sub(temp,camera.x);//get players sidtance from camera
			vec_to_angle(camera.pan,temp);//camera looks at player
		}
	}	
}
*/

action re_player(){
	
	player = me;	
	
	set(me,NARROW);//+FAT+SHADOW+CAST);
	//other functions here
	
	wait(2);
	
	cam_active = 1;
	camera_move();
	init_cameras();
	while(1){wait(1);
		
    c_move(me, vector((key_w - key_s)*time_step*8,0,0), nullvector, IGNORE_PASSABLE | GLIDE);
		
	}
}


Last edited by DevoN; 03/23/14 06:36.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: [Contribution] Resident Evil Camera [Re: DLively] #438581
03/17/14 21:25
03/17/14 21:25
Joined: Feb 2012
Posts: 371
Dico Offline
Senior Member
Dico  Offline
Senior Member

Joined: Feb 2012
Posts: 371
i think you just create a pointer , and play with distance like that :

Code:
ENTITY* cam_pointer;
var dist = 500;
VECTOR temp;
action camera_place ()
{
	set(me,INVISIBLE);

	while(1)
	{
		if(player)
		{
			var result_trace = c_trace(player.x,my.x,IGNORE_ME|IGNORE_PASSABLE);	
			if(!result_trace)
			{						
				if(vec_dist(my.x, player.x) < dist)
				{
					cam_pointer = me;					
				}
			}			
		}
		wait(1);
	}
}

function camera_fun() // in loop
{
	if (cam_pointer)	
	{
		vec_set(camera.x,cam_pointer.x);
		vec_set(temp,player.x); 
		vec_sub(temp,camera.x);
		vec_to_angle(camera.pan,temp); 
	}
}



test and source code : https://www.mediafire.com/?2xr433i5ijbrr1k

hope this work great for you laugh
Sorry i thought this a question laugh

Last edited by Dico; 06/07/17 12:16.
Re: [Contribution] Resident Evil Camera [Re: Dico] #438606
03/18/14 15:27
03/18/14 15:27
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
thank you for sharing laugh this is usefull and i will use it in the upcoming workshops laugh

Who needs TUSC when you have the forum and friendly people laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: [Contribution] Resident Evil Camera [Re: Realspawn] #438696
03/20/14 09:26
03/20/14 09:26
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
I remember this code... Orangebrat I think was the original author, not sure.


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: [Contribution] Resident Evil Camera [Re: Helghast] #438897
03/22/14 23:51
03/22/14 23:51
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Yep, I had a hand in it. Here's the old thread about it:

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Main=5133&Number=38230

EDIT: It's an old-school RE camera meaning pre-RE4. It handles both static and dynamic (RE: Code Veronica style) views.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: [Contribution] Resident Evil Camera [Re: Orange Brat] #438903
03/23/14 06:34
03/23/14 06:34
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline OP
Serious User
DLively  Offline OP
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
I've had that code printed off in a binder for many many years tongue

Thanks Orange Brat (and tesanders) for your wonderful Contribution. and it lives on laugh

Last edited by DevoN; 03/23/14 06:37.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: [Contribution] Resident Evil Camera [Re: DLively] #439009
03/25/14 12:21
03/25/14 12:21
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Originally Posted By: Orange Brat
Yep, I had a hand in it. Here's the old thread about it:

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Main=5133&Number=38230

EDIT: It's an old-school RE camera meaning pre-RE4. It handles both static and dynamic (RE: Code Veronica style) views.


I remember that coming out, and being completely happy with it (I think it came out as c-script first, right? I remember using that in early A6). Thanks for the awesome effort grin!

Originally Posted By: DevoN
I've had that code printed off in a binder for many many years tongue

Thanks Orange Brat (and tesanders) for your wonderful Contribution. and it lives on laugh


Same for me, I had this as a standard include for my projects tongue


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: [Contribution] Resident Evil Camera [Re: DLively] #439294
03/30/14 18:42
03/30/14 18:42
Joined: Aug 2000
Posts: 7,490
O
Orange Brat Offline

Senior Expert
Orange Brat  Offline

Senior Expert
O

Joined: Aug 2000
Posts: 7,490
Quote:
Many years ago I found a resident evil script written in c-script (of coarse), and converted it over to lite-c last night.


@DevoN: I forgot to say thank you for converting the script to LIte-C. I've been meaning to do it for years (that's right....years), but my day job, 2-year-old daughter, and life in general have kept me from doing this and working on my very long term project (11 years, now; 14 years if you go back to the very beginning). Anyway, I appreciate it, and I'm glad something I helped create has come in handy for so many people over the years.


My User Contributions master list - my initial post links are down but scroll down page to find list to active links
Re: [Contribution] Resident Evil Camera [Re: Orange Brat] #462043
09/05/16 15:58
09/05/16 15:58
Joined: Aug 2013
Posts: 78
Nottingham
DuaneDawson Offline
Junior Member
DuaneDawson  Offline
Junior Member

Joined: Aug 2013
Posts: 78
Nottingham
how do you get this code to work?


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1