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
0 registered members (), 631 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
PLZ HELP... IM A BEGINNER #83459
07/27/06 07:50
07/27/06 07:50
Joined: Jul 2006
Posts: 4
Philippines
B
bhoy Offline OP
Guest
bhoy  Offline OP
Guest
B

Joined: Jul 2006
Posts: 4
Philippines
plz help me! im a newbie! im creating an RPG style game. but i cant move my character by using the mouse? how do i get the coordinates of my map? tnxz!

Re: PLZ HELP... IM A BEGINNER [Re: bhoy] #83460
07/27/06 08:45
07/27/06 08:45
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Is this what you're looking for?
Code:
	// First we get the mouse coordinates (2D)
temp.x = mouse_pos.x;
temp.y = mouse_pos.y;
temp.z = 0;

// Set "target" to the same coordinates
vec_set(target,temp);

// Add some depth/dist. from screen, to "target"
target.z = 10000;

// Convert from 2D screen coordinates, to 3D world coordinates
vec_for_screen(temp,camera);
vec_for_screen(target,camera);

// Trace from temp (mouse pos.) to target
c_trace(temp,target,ignore_passable + ignore_passents + ignore_you);

// Now "target" holds the position of the point, where we have clicked



You could also check out the RPG movement code in AUM34

Also check the "RPG Template" link in my sig., if you download it, you can find an RPG/Adventure player script in NHAC_player.wdl

Re: PLZ HELP... IM A BEGINNER [Re: Claus_N] #83461
07/27/06 11:36
07/27/06 11:36
Joined: Jul 2006
Posts: 4
Philippines
B
bhoy Offline OP
Guest
bhoy  Offline OP
Guest
B

Joined: Jul 2006
Posts: 4
Philippines
tnx for your reply! im sorry but i still dont get it! is there a tutorial for that..a step by step procedure? how to implement it in my main script? tnx a lot!

Re: PLZ HELP... IM A BEGINNER [Re: bhoy] #83462
07/27/06 11:44
07/27/06 11:44
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Have you checked AUM34? It's the closest to a tutorial on that, which I know of

Do you know C-Script? Otherwise you should check out my RPG Templates (link in my sig.), they contain the basic stuff for an RPG/Adventure

Re: PLZ HELP... IM A BEGINNER [Re: Claus_N] #83463
07/27/06 20:05
07/27/06 20:05
Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
anonymous_alcoho Offline
Senior Developer
anonymous_alcoho  Offline
Senior Developer

Joined: Jan 2003
Posts: 1,738
Nashua New Hampshire
First thing you need to do is find the coordinates of the object using the mouse. This involves sending a trace from the mouse's position on the screen to the 3d ground below. (note this also assumes a birds eye view camera and a mouse in the game [mouse_mode = 2])

Code:

var from;
var to;
function mouse_trace()
{
from.X = MOUSE_POS.X; //set from.x to mouse_pos.x
from.Y = MOUSE_POS.Y; //set from.y to mouse_pos.y
from.Z = 0; //set from.z to zero
vec_set(to,from); //copy from to to
vec_for_screen(from,camera); //convert from to 3d coords
to.Z = 3000; //set to.z to 3000
vec_for_screen(to,camera); //convert to to 3d coords
return(trace(from,To)); //return the distance between from and to
}



What this code does is fire a trace from the mouse to the 3d spot right below it, giving us the coordinates. Each time trace is used, a built in variable called "target" recieves the coordinates of the final destination of the trace, where the trace ends. Now target is a very nasty variable as it always changes every frame and every trace, so as soon as we get it, we need to set it in a new vector.

Code:

function set_target()
{
mouse_trace();
vec_set(plrTarg,target); //copy target to plrTarg
}

on_mouse_left = set_target;



Okay, now we need to get our entity to move to that target.

Code:

action move_object
{
while(1)
{
vec_set(my.turnDir,plrTarg);
vec_diff(my.turnDir,my.turnDir,my.x);
vec_to_angle(my.pan,my.turnDir); //turn to target
if((my.tilt < 0) || (my.tilt > 0)) { my.tilt = 0; }
if((my.roll < 0) || (my.roll > 0)) { my.roll = 0; }
if(vec_dist(plrTarg,my.x) >= 10)
{
my.skill22 = 10 * time; //10 q per tick
my.skill23 = 0;
my.skill24 = 0;
move_mode = ignore_passable + ignore_passents + glide;
ent_move(my.skill22,nullvector); //go to target
}
wait(1);
}




So what is happening here? The entity enters a loop. Then he updates his rotation to point to the target in the next three lines. The next two lines after reset tilt and roll to zero so the target doesn't rotate in those directions. Then, if the distance between the target and the object is greater or equal to ten, the object moves to the target.

This code is untested. It is a modified rocket code actually, but it should work for an object on the ground. It only moves straight though, no pathfinding. If you want pathfinding, you've come to the wrong guy. I don't have any tips on that.

Where would you put this in a script? Just put them in somewhere in order as they are right here. Move_object is an action that should be attached to an entity in wed or ent_created during runtime.

And I would like to thank whoever gave me the mouse_trace code. I've used it in every game since.


"Oh no, it's true! I'm a love magnet!" Calvin from Calvin and Hobbes My name's Anonymous_Alcoholic.
Re: PLZ HELP... IM A BEGINNER [Re: anonymous_alcoho] #83464
08/09/06 17:49
08/09/06 17:49
Joined: Jul 2006
Posts: 4
Philippines
B
bhoy Offline OP
Guest
bhoy  Offline OP
Guest
B

Joined: Jul 2006
Posts: 4
Philippines
tnx for ur help guyz!

does c script support database? coz im planning to use a database for my game. i looked at the NHA RPG template. i was having a hard time to understand it. i also downloaded the game. wow i wish i could make a game like that.

Re: PLZ HELP... IM A BEGINNER [Re: bhoy] #83465
08/09/06 19:22
08/09/06 19:22
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
No, you can't access a database from C-Script


Quote:

i looked at the NHA RPG template. i was having a hard time to understand it. i also downloaded the game. wow i wish i could make a game like that



You can easily make a game like that, using my RPG templates. Just ask if you got any problems/questions with 'em

Re: PLZ HELP... IM A BEGINNER [Re: Claus_N] #83466
08/10/06 09:04
08/10/06 09:04
Joined: Jul 2006
Posts: 4
Philippines
B
bhoy Offline OP
Guest
bhoy  Offline OP
Guest
B

Joined: Jul 2006
Posts: 4
Philippines
if c-script can't access a database, is there any other way? on how to save to a file and access it. besides on the NHA RPG (ILF and NSF file txt).

Re: PLZ HELP... IM A BEGINNER [Re: bhoy] #83467
08/10/06 22:06
08/10/06 22:06
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
There was a plugin (to use MySQL databases, if I remember correctly) in the User Contributions forum looong time ago... You could try to find it

To create files like the ILF or NSF, you'll simply just use file_str_read/write, file_var_read/write, etc.


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