Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
click and go script #124604
04/17/07 13:31
04/17/07 13:31
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Attach my_player action to the player in WED and enjoy

http://www.youtube.com/watch?v=nWg2ltVMxwU

Code:
 
/////////////////////////////////////////////////////////////////////////////
// script for isometric view game //
// with using template model (f.e. warlock.mdl) //
// to moving player with mouse click //
// and changing camera zoom with mouse wheel //
/////////// free to use and free to enjoy :) ////////////////
// TomPo // sorry for terrible Englilsh;) // 16.04.2007 //
/////////////////////////////////////////////////////////////////////////////

entity* player;
var camera_dist[3] = -400,0,600; //distance from camera to player
var distance_to_target; //nothing to explain
var move_position[3]; //move vector
var my_target[3]; //target vertor
var vecTo[3]; var vecFrom[3];
define _speed, skill1; //moving spped
define _moving, skill2; //if the player should move
define anim_speed, skill3; //animating speed
bmap arrow ="arrow_blue.pcx";

IFNDEF MSG_DEFS;
FONT digit_font,<digfont.pcx>,12,16; //template digit .pcx
ENDIF;

panel helper //shows usefuls parameters
{
digits = 20, 20, 3, digit_font, 1,player._moving; //has the player the target to move or not
digits = 20, 40, 3, digit_font, 1,distance_to_target; // you know
digits = 20, 60, 3, digit_font, 1,camera_dist.z; // camera height
flags REFRESH,visible;
}

Function get_target()
{
while(mouse_left == 1)
{

vecFrom.X = MOUSE_POS.X;
vecFrom.Y = MOUSE_POS.Y;
vecFrom.Z = 1;//close point
vec_set(vecTo,vecFrom);
vec_for_screen(vecFrom,CAMERA);
vecTo.Z = 10000;
vec_for_screen(vecTo,CAMERA);//far point
trace(vecFrom,vecTo);//trace a line between the two points
vec_set(my_target,target); //put invisible point on the gorund where you clicked on
player._moving = 1;//I have to move
player.tilt = 0;//keep player straight
wait(1);
}
}

function player_move()
{
while(1)
{
if(player._moving == 1) //if I have to move...
{
distance_to_target = vec_dist(player.x,my_target.x);//calculate distance to target
if(distance_to_target > 45)//if target is far far far away...
{
vec_set(temp,my_target.x);//keep target
vec_sub(temp,player.x); //check my position
vec_to_angle(player.pan,temp);// turn to target
my._speed = 10; //how fast player goes
animate_walk(); //animate player
}
if(distance_to_target <= 45)//if target is close
{
player._moving = 0;//I have not to move
my._speed = 0;//stay
}
}
if(player._moving == 0) //if I have not to move...
{
my._speed = 0;//stay
animate_stand();//animate standing like breathing or something
}

my.tilt = 0;//always stay straight
vec_set(temp,my.X);//check my position
temp.Z -= 1000;//check where the floor is
trace_mode=IGNORE_ME+IGNORE_MODELS+ignore_passable + USE_BOX;
result = trace (my.x, temp);
my.z -= result; //keep me on the ground and move me
c_move(me,vector(my._speed *time_step,0,0),nullvector,GLIDE | ACTIVATE_TRIGGER | IGNORE_SPRITES | IGNORE_PASSENTS | use_box);
wait(1);
}
}

function animate_walk
{
my.anim_speed += 10 * time_step; //add frames
ent_animate(me,NULL,0,0); //reset bones
ent_animate(me,"walk",my.anim_speed,anm_cycle); //animate walk with cyclic
}

function animate_stand
{
my.anim_speed += 3 * time_step;
ent_animate(me,NULL,0,0);
ent_animate(me,"stand",my.anim_speed,anm_cycle);
}

function move_camera
{
while(player != 0)
{
MOUSE_POS.X = POINTER.X; MOUSE_POS.Y = POINTER.Y;
camera_dist.z -= mickey.z * time_step; //change camera height with mosue wheel
camera_dist.z = clamp(camera_dist.z,player.max_z,600); //not to height and not hit the ground
vec_set(temp,player.pos); //check player position
vec_add(TEMP,camera_dist); //add to player position camera distance
vec_set(camera.pos,temp); //place camera at the correct position
vec_set(temp,player.x); //again check player position
vec_sub(temp,camera.x); //check camera position
vec_to_angle(camera.pan,temp); //turn camera to the player
wait(1);
}
}

action my_player
{
player = me;
video_switch (0,0,1);//switch to fullscreen
MY.FAT = OFF;
MY.NARROW = ON;
mouse_mode = 2;//make cursor visible and moving
mouse_map = arrow;//mouse bmap
mouse_range = 10000;//mouse range from camera
player_move();
move_camera();
}

view camera
{
layer = 0;
arc = 60;
aspect = 1;
ambient = 80;
flags = visible;
}

On_mouse_left get_target;



Last edited by tompo; 04/18/07 12:13.

Never say never.
Re: click and go script [Re: tompo] #124605
04/17/07 18:49
04/17/07 18:49
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Nice contribution, these once are always welcome I say ^^
But maybe you could make a small video or some screenies to "sell" your "product" at a more potential value to all the users
A download file with a precomplied version would be nice too

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: click and go script [Re: frazzle] #124606
04/17/07 22:00
04/17/07 22:00
Joined: Jul 2004
Posts: 4,206
Innsbruck, Austria
sPlKe Offline
Expert
sPlKe  Offline
Expert

Joined: Jul 2004
Posts: 4,206
Innsbruck, Austria
hey, say, isnt that what i asked for a while ago???

THANX MAN!!!!

Re: click and go script [Re: sPlKe] #124607
04/18/07 11:18
04/18/07 11:18
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
Frazzle... Someone (THX for that) put video to uTube so I've add a link above to see how this script is working


Never say never.
Re: click and go script [Re: tompo] #124608
04/18/07 14:15
04/18/07 14:15
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline
Serious User
PrenceOfDarkness  Offline
Serious User

Joined: Aug 2004
Posts: 1,305
New York
for some reason when I use something like this in my multiplayer game, the camera or the player seem to twitch. I think the problem is present in single version also, any ideas?


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: click and go script [Re: PrenceOfDarkness] #124609
04/18/07 15:17
04/18/07 15:17
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
this looks cool ... good work. thx for contributing!


~"I never let school interfere with my education"~
-Mark Twain
Re: click and go script [Re: tompo] #124610
04/19/07 08:48
04/19/07 08:48
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline OP
User
tompo  Offline OP
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
I've add smooth player rotation (change pan) to target
You have to do three things...

1. Add this at the top
Code:
 
var my_angle[3];



2. In player_move function cut vec_set, vec_sub and vec_to_angle and replace with this:
Code:
 
vec_diff(temp,my_target,my.pos);
result = vec_to_angle(my_angle,temp);
actor_turnto(my_angle.PAN);



3. And add this function. You can change turning speed by editing red part of code.

Code:
 
function actor_turnto(angle)
{
angle = ang(angle - MY.PAN);
if (angle > 10) {temp = my._speed;}
else{
if(angle < -10){temp = -my._speed;}
else{temp = my._speed * angle *0.1;}
}
MY.PAN += temp * time_step *2;
}



Last edited by tompo; 04/19/07 09:40.
Re: click and go script [Re: tompo] #124611
04/19/07 15:50
04/19/07 15:50
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
cool. what I like most about this addition is that it's easy to implement... and the whole code's easy to put in your game. thanks!


~"I never let school interfere with my education"~
-Mark Twain
Re: click and go script [Re: Germanunkol] #205874
05/09/08 09:43
05/09/08 09:43
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Nice contribution, but it does only work as long as there is nothing in the players way to the target...


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