Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, juanex), 1,247 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: 3rd Person Cam(gauging Interest) [Re: laethyn] #61844
01/15/06 00:32
01/15/06 00:32
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Post your work, not your words, how great it will be
If you want to talk about it, place post in other thread, not in contrib...

Re: 3rd Person Cam(gauging Interest) [Re: Lion_Ts] #61845
01/15/06 06:29
01/15/06 06:29
Joined: Feb 2005
Posts: 324
laethyn Offline OP
Senior Member
laethyn  Offline OP
Senior Member

Joined: Feb 2005
Posts: 324
I will be posting it. Just cleaning up the code, and, as I said, dealing with some family issues. Should be online in a day or two. I don't want to post code that works, sometimes. Besides, why should I post my work if there is no interest in people wanting it?


Read the manual, it's a good place to start learning ~ ulillillia
Re: 3rd Person Cam(gauging Interest) [Re: laethyn] #61846
01/17/06 01:49
01/17/06 01:49
Joined: Feb 2005
Posts: 324
laethyn Offline OP
Senior Member
laethyn  Offline OP
Senior Member

Joined: Feb 2005
Posts: 324
As promised...

My test level included a small area, one player mdl, and two different NPC models. But you can mess around with it as you see fit. I don't claim to have pretty code, but it works! lol This is provided as is, and is working on my system. So if it doesn't work, I have NO idea why. And I won't be updating to it, adding to it, whatever. As I continue, the rest of my code will be my own. So, here is a basic starter for a 3d cam, with rotate, zoom, mouse clicking to move, and mouse clicking to talk to NPCs

Code:
//////////////////////
// Set includes

include <vars.wdl>;
include <interface.wdl>;
include <camera.wdl>;
include <movement.wdl>;

/////////////////////
// Set mouse cursor bitmap

bmap arrow = <arrow.pcx>;

/////////////////////
// Set video mode

var video_mode = 8;

/////////////////////
// Turn mouse on

function mouse_on()
{
mouse_map = arrow; // set mouse to bitmap
mouse_mode += 1;
if (mouse_mode > 1) // if it's anything but 0, set it to 0
{
mouse_mode=0;
}
while (mouse_mode > 0) // while mouse_mode is 0, have the mouse bitmap follow the pointer
{
mouse_pos.x = pointer.x;
mouse_pos.y = pointer.y;
wait(1);
}
}

function main()
{
level_load("build.wmb"); // load the level
wait(1);

init_cameras(); // initialize camera
}



Code:
//////////////////////////
// <vars.wdl>

//////////////////////////
// entities
entity* player;
entity* NPC;

//////////////////////////
// defines
define convo, skill100;

//////////////////////////
// movement variables

var vecFrom[3];
var vecTo[3];
var my_target[3];
var move_position[3];
var move_position_2[3];
var move_pos[5];
var vecFrom[3];
var vecTo[3];
var move_dist[3];
var gravity_scan_height[3];
var gravity_scan_height_result;
var start_game = 0;

///////////////////////////
// camera variables

var eye_height = 25;
var tilt_1st = 0;
var cam_turnspeed = 2;
var max_tilt_1st = 40;
var dist_planar = 250;
var cam_angle = 25;
var dist_total = 250;
var tilt_3rd = 45;
var dist_traced;

///////////////////////////
// dialog variables

var noWalk;
var tempTalk = 0;
var maxConvo;



Code:
//////////////////////////////////////
// <interface.wdl>

///////////////////////////////
// main interface image - 1024 x 768
bmap main_panel = <main_interface.bmp>;

////////////////////////////////
// Dialog panel - 792 x 122
bmap dlg_panel = <dialog_panel.bmp>;

////////////////////////////////
// Arrows to handle dialog navigation
// all images are 20x17
bmap previous_bmp = <prev_bmp.bmp>;
bmap next_bmp = <next_bmp.bmp>;
bmap prev_over_bmp = <prev_ovr_bmp.bmp>;
bmap next_over_bmp = <nxt_ovr_bmp.bmp>;

/////////////////////////////////////////
// font used - change to whatever you wish
FONT dialog_fnt = <dialog_font.bmp>, 21, 17;

/////////////////////////////////////////
// Some simple test strings
string test = "want 50 gold?";
string test1 = "This is number 1";
string test2 = "This is number 2";
string test3 = "this is number 3";
string woman1 = "I'm a woman";
string woman2 = "see my boobs?";

/////////////////////////////////////////
// Create main interface panel
panel main_interface
{
bmap = main_panel;
layer = 7;
pos_x = 0;
pos_y = 0;
flags = refresh, visible, overlay;
}

/////////////////////////////////////////
// dialog panel
panel dialog
{
bmap = dlg_panel;
layer = 8;
pos_x = 100;
pos_y = 646;
BUTTON = 675, 103, next_bmp, next_bmp, next_over_bmp, next_text, off_scroll, over_scroll;
BUTTON = 65, 103, previous_bmp, previous_bmp, prev_over_bmp, scrll_txt_down, off_scroll, over_scroll;
flags = refresh, d3d, overlay;
}

/////////////////////////////////////////
// text for NPC dialog
text display_dlg_panel
{
pos_x = 120;
pos_y = 690;
font = dialog_fnt;
layer = 6;
flags = d3d, narrow;
}

function display_dlg()
{
dialog.visible = on; // Turn dialog panel on
display_dlg_panel.visible = on; // Turn text on
}

function talk_to_NPC()
{
display_dlg(); // Display the dialog
tempTalk = 1; // sets temptalk - temptalk handles stopping the players animation when near the NPC
}

function NPC_Coll()
{
// Was the NPC clicked?
if(event_type == event_click)
{
// if the distance between the NPC and the player is greater than 50
while(c_trace(me.x, player.x, IGNORE_ME) > 50)
{
// don't do anything yet. Distance is still to great
wait(1);
}
NPC = me; // Sets NPC entity - seems redundant, but won't work without
me.pan = player.pan - 180; // Rotate the NPC to look at the player
talk_to_NPC(); // Run the function
}
}

function clicked_NPC()
{
// enable the click event, and run the player/NPC collision
me.enable_click = on;
me.event = NPC_Coll;
}

///////////////////////////////////////////////////
// Create actions for NPCs
// *** TODO: Create system to allow for random strings to be shown

action click_me_Woman
{
NPC = me; // Set the NPC entity
while(1)
{
// player to NPC distance greater than 50?
if(c_trace(me.x, player.x, IGNORE_ME) > 50)
{
// Don't do anything yet. Distance is to great
wait(1);
}
else
{
// Set maximum number of conversations This should be number of strings to display + 1
maxConvo = 3;

// If the NPC skill is 1, set the first string
if(me.convo == 1)
{
display_dlg_panel.string = woman1;
}
// if 2, second string (others are the same, I shouldn't need to go into detail)
if(me.convo == 2)
{
display_dlg_panel.string = woman2;
}
// If the skill is the max, or 0, just wait
if(me.convo == 3 || me.convo == 0)
{
wait(1);
}

// Begin dialog display system
clicked_NPC();
}
wait(1);
}
}

action click_me_Warlock // Same actions as woman, just move conversation
{
NPC = me;
while(1)
{
if(c_trace(me.x, player.x, IGNORE_ME) > 50)
{
wait(1);
}
else
{
maxConvo = 5;
if(me.convo == 1)
{
display_dlg_panel.string = test;
}
if(me.convo == 2)
{
display_dlg_panel.string = test1;
}
if(me.convo == 3)
{
display_dlg_panel.string = test2;
}
if(me.convo == 4)
{
display_dlg_panel.string = test3;
}
if(me.convo == 5 || me.convo == 0)
{
wait(1);
}
clicked_NPC();
}
wait(1);
}
}

function hide_dialog()
{
// make player able to animate again
tempTalk = 0;
// turn off dialog and dialog panel
display_dlg_panel.visible = off;
dialog.visible = off;
// reset NPC convo skill
NPC.convo = 1;
}

////////////////////////////////////
// The following two functions set a flag to prevent walking when clicking on the
// next and previous buttons in the panel - if not set, when the player clicks the next
// button, the dialog dissappears, and the player walks to where the mouse was
function over_scroll()
{
while(1)
{
noWalk = 1;
wait(1);
}

}

function off_scroll()
{
while(1)
{
noWalk = 0;
wait(1);
}
}

//////////////////////////////////
// The following two functions handle moving forward and back through
// the NPC dialog

function next_text()
{
NPC.convo += 1;
if(NPC.convo == maxConvo)
{
NPC.convo = maxConvo - 1;
}
}

function scrll_txt_down()
{
NPC.convo -= 1;
if(NPC.convo == 0)
{
NPC.convo = 1;
}
}



Code:
/////////////////////////////////////////
// <camera.wdl>

////////////////////////////////////
// define 3rd person camera view

view 3rd_person
{
layer = 1;
pos_x = 0;
pos_y = 0;
}

function update_views()
{
dist_planar = cos(tilt_3rd) * dist_total;
3rd_person.x = player.x - cos(cam_angle) * dist_planar;
3rd_person.y = player.y - sin(cam_angle) * dist_planar;
3rd_person.z = player.z + sin(tilt_3rd) * dist_total;
3rd_person.pan = cam_angle;
3rd_person.roll = 0;
3rd_person.tilt = -tilt_3rd;
validate_view();
}

/////////////////////////////////////
// Camera collision
// **** Needs Improvement ****

function validate_view()
{
my = player;
trace_mode = ignore_me + ignore_passable;
dist_traced = trace(player.x, 3rd_person.x);
if(dist_traced == 0)
{
return;
}
if(dist_traced < dist_total)
{
dist_traced -= 6; // 5? 6? Run some tests
dist_planar = cos(tilt_3rd) * dist_traced;
3rd_person.x = player.x - cos(cam_angle) * dist_planar;
3rd_person.y = player.y - sin(cam_angle) * dist_planar;
3rd_person.z = player.z + sin(tilt_3rd) * dist_traced;
}
}

function orbit_camera()
{
while(mouse_right == 1) // while holding down the right mouse button
{
// set the camera angle to the mouse force
cam_angle += mouse_force.x/50; // lower/raise the "50" to speed up/slow down the camera
if(cam_angle > 360)
{
cam_angle = cam_angle - 360;
}
if(cam_angle < 0)
{
cam_angle = cam_angle + 360;
}
wait(1);
}
}

function tilt_cam()
{
while(mouse_right == 1) // while holding down the right mouse button
{
// set the tilt of the camera to the mouse movement
tilt_3rd += mouse_force.y/50; // lower/raise the "50" to change the speed of the camera movement

// limit the lowest camera tilt to -6
// change both -6 to whatever to limit the tilt
if(tilt_3rd < -6)
{
tilt_3rd = -6;
}
// set the upper limit of the tilt
// 90 is looking straight down
// change both "65" to change the camera tilt limit
if(tilt_3rd > 65)
{
tilt_3rd = 65;
}
wait(1);
}
}

function zoom_camera()
{
while(mouse_middle == 1) // while holding down the middle mouse button
{
// change the camera arc based on the mouse movement
3rd_person.arc -= mouse_force.y/10; // lower the "10" to speed up or slow down cam movement

// clamp the cameras arc to the limit
3rd_person.arc = clamp(3rd_person.arc, 25, 65);
wait(1);
}
}

function init_cameras()
{
camera.visible = off; // disable default camera

// set the camera size to the screen size
3rd_person.size_x = screen_size.x;
3rd_person.size_y = screen_size.y;

// turn on the 3rd person camera
3rd_person.visible = on;
}



Code:
//////////////////////////////////
// <movement.wdl>

action get_target
{
// This is to prevent the player from walking when the game starts up
// Couldn't get it to stop for some reason
if(start_game == 0)
{
start_game = 1;
}

// Stop walking while mouse is over next/previous buttons
while(noWalk == 1)
{
wait(1);
}

mouse_to_level();
vec_set(my_target,target);
vec_set(move_position,target);
vec_set(move_position_2,move_position);
vec_sub(move_position_2,player.x);

hide_dialog();
}

// convert the mouse click to coordinates where to move player
function mouse_to_level()
{
vecFrom.x = mouse_pos.x;
vecFrom.y = mouse_pos.y;
vecFrom.z = 5;
vec_set(vecTo,vecFrom);
vec_for_screen(vecFrom,3rd_person);
vecTo.z = 5000;
vec_for_screen(vecTo,3rd_person);
return(trace(vecFrom,vecTo));
}

////////////////////////////////////////////////////
// Assign this action to the player!!!
// ***Gravity is screwed up, player is standing a quant above the ground it seems***

action move_player
{
player = me;
mouse_on();
while(1)
{
vec_set(gravity_scan_height,my.x);
gravity_scan_height.z -= 4000;
trace_mode = ignore_me + ignore_sprites + ignore_models + use_box;
gravity_scan_height_result = trace(my.x,gravity_scan_height);
if(gravity_scan_height_result > 3)
{
move_dist.z = -5 * time;
}
else
{
if(gravity_scan_height_result > 1)
{
move_dist.z = 0;
}
else
{
move_dist.z = 5*time;
}
}
move_pos[1] = move_position.x - 5;
move_pos[2] = move_position.x + 5;
move_pos[3] = move_position.y - 5;
move_pos[4] = move_position.y + 5;
if(move_pos[1] < player.x && move_pos[2] > player.x && move_pos[3] < player.y && move_pos[4] > player.y || start_game == 0)
{
move_dist.x = 0;
ent_cycle("stand", my.skill20);
my.skill20 += 2 * time;
my.skill20 %= 100;
}
else
{
vec_to_angle(player.pan,move_position_2);
player.tilt = 0;
move_dist.x = 15*time;
ent_cycle("walk", my.skill20);
my.skill20 += 4 * time;
my.skill20 %= 100;
if(tempTalk == 1)
{
if(c_trace(me.x, NPC.x, IGNORE_ME) < 45)
{
move_dist.x = 0;
ent_cycle("stand", my.skill20);
my.skill20 += 2 * time;
my.skill20 %= 100;
wait(1);
}
}
}
move_mode = ignore_passable;
ent_move(move_dist.x,nullvector);
wait(1);

// fun camera functions
orbit_camera();
zoom_camera();
tilt_cam();
update_views();
}
}

// run function when mouse is clicked
on_mouse_left = get_target;




But, whatever, lemme know what you think

Cheers!


Read the manual, it's a good place to start learning ~ ulillillia
Re: 3rd Person Cam(gauging Interest) [Re: laethyn] #61847
01/17/06 03:50
01/17/06 03:50
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
thank you, laethyn!
have to try what is this...

Re: 3rd Person Cam(gauging Interest) [Re: Lion_Ts] #61848
01/17/06 04:24
01/17/06 04:24
Joined: Feb 2005
Posts: 324
laethyn Offline OP
Senior Member
laethyn  Offline OP
Senior Member

Joined: Feb 2005
Posts: 324
by the way, each code snippet here is a different wdl. As named in the comment section at the top of each code area.


Read the manual, it's a good place to start learning ~ ulillillia
Re: 3rd Person Cam(gauging Interest) [Re: laethyn] #61849
02/14/06 06:09
02/14/06 06:09
Joined: May 2005
Posts: 138
jamrud khatulistiwa
Kotakide Offline
Member
Kotakide  Offline
Member

Joined: May 2005
Posts: 138
jamrud khatulistiwa
it doesn't work !!
I dont understand how to implement this?
give me an enlightenmnet..
I'm a newbie

Page 2 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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