Gamestudio Links
Zorro Links
Newest Posts
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (VoroneTZ), 9,291 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 1 of 2 1 2
Scripting from ground up #47414
06/11/05 10:47
06/11/05 10:47
Joined: Apr 2005
Posts: 39
Wiesbaden / Germany
gandhi Offline OP
Newbie
gandhi  Offline OP
Newbie

Joined: Apr 2005
Posts: 39
Wiesbaden / Germany
Hi friends,
Until now i have programmed only with templates thats why i do not understand much of it. I think thats the main problem for the beginners.

To learn scripting from ground up i must start from a small scripting code.

I have made a floor and placed "cbabe" model on it, now to understand walk-Script i need just walk script(without other functions) that makes my model walk CAN SOMEONE PLEASE WRITE A SIMPLE WALKING SCRIPT FOR THIS.

This way i can better learn basics of scripting......THANX


Man kann auch in DEUTSCH antworten.....Danke


Warum einfach einfach nicht einfach ist ??? My English is Alpha version. My German is Beta version. But anyhow my brain is trial version.
Re: Scripting from ground up [Re: gandhi] #47415
06/11/05 12:23
06/11/05 12:23
Joined: Jul 2002
Posts: 3,208
Germany
Error014 Offline
Expert
Error014  Offline
Expert

Joined: Jul 2002
Posts: 3,208
Germany
From ground up?

Ah, well, okay

You wan't your entity to move and you want gravity for it. The two instructions we need for that are c_move and c_trace (besides some others).
Let's do the "move-part" first and have a look at the instruction:

Code:

c_move(entity,relvec,absvec,move_mode);



Okay, so we have the instruction-name c_move and four things to pass, which are named "entity", "relvec", "absvec" and "move_mode" here. The name isn't really important, but in this case they give us an idea what exactly c_move needs.

The first thing is "entity". That's an easy one, isn't it? Of course the engine needs to know which entity shall be moved. So we need a pointer which points to said entity and moves it afterwards. We can use "player" when we want to move the player (at least when "player" points to the player ) or, which will be of more use now, "me" and "you". "me" is a special, predefined pointer. In our action, it points to the entity which uses the action, so we can use me here.

The second thing is "relvec". As the last part "vec" suggest, we need a vector for it. In case you don't know what a vector is, I'll explain the basics now. If you can speak german, you might want to take a look here.
A vector basically contains three values. What they represent depends on it's usage (there are "colorvectors", too, then it's three values represent red, green and blue), in math and in our example they are the values "X", "Y" and "Z". Now, chances are that you already heard that numbers in a mathematical context or in GStudio - They of course represent a special "position" in the world space. So, vectors in GStudio can represent a position - like (0|0|0) - the famous nullvector or (23|-24.4|9) or whatever. But vectors are not only positions, they are "arrows". "Arrows?", you ask, "I thought they were positions!" - You got a point there.
Let's pretend the top of the arrow is the position, like (5|5|5). Now, imagine that position and draw a line to the nullposition (0|0|0). What you get is an arrow:



Yes, I'm sure you are amazed by my drawing skills - Look at the arrow - it does have a length, right? So, in contrary to "simple" positions, you can calculate the length of an vector, too. You can prove the following with Pythagoras, but I am too lazy to do that now
The formula for length:

length = SQUAREROOT(x²+y²+z²)

Thank you very much

Now, when you want your entity to move, like 5 quants ni the direction it looks, then your arrow should be five quants long.
Now, imagine we would "move" that array to the position of your entity and then "rotate" it, so it matches the angles of your entity, then you get what we need for "relvec".



In fact, we would only pass the vector (5|0|0) (named original vector in the picture) to c_move, everything else would be done by the engine.

Okay, so that would be relvec. Do all the stuff again, but don't rotate the arrow to fit the entities angles and you get absvec.

Move_mode? That's an easy one. The engine can ignore certain things if you want to on your movement. That way, your model might walk through models or everything which is "passable" (most like thats what you want). Have a look at the manual, everything is explained there.

Questions remaining:
1) How do we script "relvec"?
2) How shall we calculate "absvec"?
3) How to rotate the entity?
4) How to place the camera at the entities' position?
5) How can we put all of that in an action?

Answers: ;D
1) It's easy. It shall move when we hit "W" or "S". We only need to change the x-value of our vector, like this (key_w is 1 when w is pressed on the keyboard and 0 otherwise, same for key_s (of course with the s-key then )
we use temp as a temporary vector:

temp.x = 15*(key_w-key_s)*time;
temp.y = 0; //you might want to put something in here to allow strafing

Now, why time? We will put that in a loop. Faster computers might compute that more often, so we need to make the value smaller as on a computer where this line gets executed only every second or so. It will then run as fast on every computer, regardless of it's speed.

2) We will use trace for that.
c_trace(vector from,vector to, trace_mode);

Now, think of these two vectors as positions again. Now, imagine to be at position "vector from" and fire a "laser" to "vector to". Something like that would be done by trace. It returns the distance the laser could travel, so this way you can check for obstacles along the way.

ASCII-Art:

Code:

A B
in this case, trace would return the full distance from A to B, because there is no obstacle:
A-------------->B

A C B
However, in THIS case, trace would only return the length to the obstacle "C". In other words, the length of the arrow here
A------>C B



Now, how can we use this for our example? We can move the entity down, when we need it - or, in other words, when the distance to the floor (as in "the next obstacle down") is greater than, say, 40. That value depends on the scale of your level and playermodel, so play with it. Have a look at the code down there to see how we used it.

trace_mode is similar to move_mode of c_move - look at the manual, will you?

3) Rotating the entity? In our example, we have a first-person-shooter movement, so we only care for the "pan"-value. There are three rotate-values:
pan
tilt
roll.
You can write them as vectors, too! However, they aren't arrows, keep that in mind.
(pan|tilt|roll)

Anyway, which is which? Pretend a coordinate-system in your body, the one you have in WED, too (which means: Z is up) - now if you would rotate around your Z-axis, you'd change your pan-value. In other words: When you rotate, you change your pan-value

We will change it on mouse_movement in this case, which translate to this code

my.pan -= mouse_force.x*35*time; //you might want to change 35

4) That's an easy one.
vec_set(vectora,vectorb);

after this instruction, vectora is equal to vectorb, so we just need to make the position of the camera (camera.x) equal to the position of the player (player.x)

vec_set(camera.x,player.x);

You might want to add a little to camera.z, the players eyes are most likely a little higher than it's origin.

5)

Code:

ACTION simple_movement {
WHILE(1) { //do forever
temp.x = 15*(key_w-key_s)*time;
temp.y = 0; //you might want to put something in here to allow strafing
//temp.z shall be used for absolutemovement only, so we can use
//vector(x,y,z) and use only temp.x and y there in our relative movement

//calculate temp.z with trace
//we "trace" from the position of the player to the position 5000 quants under him
temp.z = 0; //without any gravity
IF(c_trace(player.x,vector(player.x,player.y,player.z-5000),ignore_me+ignore_passable) > 40) {
temp.z -= 50*time; //add gravity
}

//now move
c_move(me,vector(temp.x,temp.y,0),vector(0,0,temp.z),ignore_passable);

//change rotation
my.pan -= mouse_force.x*35*time;

//last but not least, place the camera at my position
vec_set(camera.x,my.x);

//and make it face the same direction as me
vec_set(camera.pan,my.pan);


wait(1); //give time to render, no endless loop
}
}




Please note that this was a rather fast written overview. There might be mistakes. There might be plenty of them.

Nontheless, I tried to make the issue easy to understand and easy to follow. I hope it helped you. If there are any questions ask. Any feedback appreciated


PS: That questions is asked quite often. Anyone could move it to the Frequently-asked-questions forum?


Perhaps this post will get me points for originality at least.

Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
Re: Scripting from ground up [Re: Error014] #47416
06/12/05 10:40
06/12/05 10:40
Joined: Apr 2005
Posts: 39
Wiesbaden / Germany
gandhi Offline OP
Newbie
gandhi  Offline OP
Newbie

Joined: Apr 2005
Posts: 39
Wiesbaden / Germany
Thanx Error014,
i am trying to understand UR code-script. After that i will give it feed back...
Have a nice day :


Warum einfach einfach nicht einfach ist ??? My English is Alpha version. My German is Beta version. But anyhow my brain is trial version.
Re: Scripting from ground up [Re: gandhi] #47417
06/13/05 22:39
06/13/05 22:39
Joined: Oct 2003
Posts: 2,628
IL,US
FeiHongJr Offline
Expert
FeiHongJr  Offline
Expert

Joined: Oct 2003
Posts: 2,628
IL,US
Theres a ton of great tutorials around that deal with the basics like this... start on the resource page (resource link at bottom of this page) and work thru the tutorials available there... Then the magazine link... Also one of the best in my opinion. Are the workshops on the downloads page and last but deffinately not least grimbers website... not sure of the address but hes made plenty of post and the links in his signature


http://www.freewebs.com/otama_syndicate/index.htm - Each master to his own technique.

- Not me said the bee, Nor I said the fly.
Re: Scripting from ground up [Re: FeiHongJr] #47418
09/06/05 20:26
09/06/05 20:26
Joined: Sep 2005
Posts: 26
Capelle, The Netherlands
SNK_Kenpachi Offline
Newbie
SNK_Kenpachi  Offline
Newbie

Joined: Sep 2005
Posts: 26
Capelle, The Netherlands
well for beginners i think the best way to learn coding from ground up is by first starting something like a digital clock then a calculater till ur able to create a game like pong.. or isnt that the way to do this with 3dgamestudio?


--====Musician / Modeller / Programmer====-- ----======= SNK Kenpachi =======----
Re: Scripting from ground up [Re: SNK_Kenpachi] #47419
09/07/05 05:50
09/07/05 05:50
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
ulillillia Offline
Senior Expert
ulillillia  Offline
Senior Expert

Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
Keep this law of my Status System in mind, which has been strongly successful so far for me:

"You level up the fastest and easiest by doing things at your own level and no higher or lower".

In short, start with simple stuff if you're a beginner and do the more complicated stuff when you're more advanced.

Read through the manual and look for instructions that seem to interest you. Then try to use them and modify them. Then find another instruction in the manual you are interested in and look at that. Now try to add that and combine it with the first instruction in some way. Then do a third, a fourth, and so on.

After that, create a new script and try to make something related what you did before in a somewhat different way without referencing your old script as much as you can.

Then keep on adding new instructions to your "instruction vocabulary" and expanding on it.

Now try to create a simple game like pong which has just two blocks that move left and right and a small ball. After some number of hits without the ball going past them, the ball speeds up. If the ball goes past them, a score is made and a new ball appears. That's an example of a simple game.

Go learn some more instructions and try to expand on this game to make more out of it.

Now try for a more complex game, sort of like an NES-type game (which are also rather simple, but more complex). Pick a game you like/know well and try to mimic it the best you can. Now, after you've done that, try to improve your game by adding some new features, some that might not be present in your favorite NES game.

Now try to mimic a more complicated game or create a game on your own with your own rules and game mechanics.

After a while, you could begin making your "official project", the project you intend to sell. Along the way, keep doing things at your own level for learning the fastest and easiest. This law has never failed me yet (hence the "mostly confirmed" status).



If you do something that's too easy (like having tenth-grade skills in first grade), you won't like it and you will barely even learn anything. Think of a tenth-grader in a first-grade classroom doing a spelling test trying to spell the word "walk". To them, it's not even a challenge at all and the tenth-grader would get A's across the report card (102% even) with almost no effort and school would be only boring to them.

If you do something that's too hard (liking being in tenth grade with only first-grade skills), you'll be very frustrated and give up. Think of a first grader trying to solve the quadratic equation. To them, it seems like a random mess that makes no sense. To a first grader, they'll likely only get F's across the report card, they'd be frustrated with school and would just plain give up.

Now, if you're a tenth grader in the tenth grade, then you'll understand all that tenth-grade stuff with some difficulty and some ease. It's like Goldilocks (sp.?) and the three bears. Goldilocks will only find what's right for her. If the porridge is too cold (too easy in a similar sense), she might eat it, but likely won't like it. If the porridge was too hot, she'd likely immediately stop eating it (too hard as you'd give up). If the porridge was just right, she'd eat it and like it.


"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip My 2D game - release on Jun 13th; My tutorials
Re: Scripting from ground up [Re: ulillillia] #47420
09/12/05 00:21
09/12/05 00:21
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
Ullillilia is right, most not so advanced users or newbies, often don't realize how much information and examples can be gathered from the manual, just make sure to download the latest manual from the forum and you are good to go! I think I've probably learned most from the manual in the beginning and later on I've tried certain user based tutorials, especially Grimber's page was a great help, because he collected various tutorials around and hosts them all ; Grimber's page
Also tried figuring things out on your own helps a lot too, though might not make the learning progress go as fast as you would like, but copying and pasting code from others is useless without understanding it, just my 2 cents though,

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Re: Scripting from ground up [Re: ulillillia] #47421
09/14/05 07:00
09/14/05 07:00
Joined: Jul 2004
Posts: 1,205
Greece
LarryLaffer Offline
Serious User
LarryLaffer  Offline
Serious User

Joined: Jul 2004
Posts: 1,205
Greece
Quote:

"You level up the fastest and easiest by doing things at your own level and no higher or lower".




my law on that goes something like this: "there's never a flawless way of doing something. If you happen to get more experienced, go back and do the basics again."

You could start off in Gstudio by coding an RPG game.. I know lots of people who've done that, including myself. It's certainly more motivating than working on a stupid ping pong clone...

What's gonna happen is, you're gonna start typing some half a$$ code, borrowing parts from others, etc... But you'll get your sh*t done..

A year later, you'll be a much better coder and I guarantee that you'll be looking at your old code in disguss. Same for the year after that and the year after that.. My point is, you can become a proffesional programmer either by rewritting an rpg or a ping pong game. The whole point is to keep being motivated and never stop learning. So whatever game you wanna start first, the truth is you won't be able to program a descent complex game in the first couple of years, so it might as well be an RPG. It makes this first years more fun... or at least it did for me..


INTENSE AI: Use the Best AI around for your games!
Join our Forums now! | Get Intense Pathfinding 3 Free!
Re: Scripting from ground up [Re: LarryLaffer] #47422
09/14/05 07:51
09/14/05 07:51
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
Yeah, I started off with an RPG, it's still going on too, on the back burner right now as more important projects have taken over, but i learned so much working on that RPG.

Now here is the difference. If i'm going to teach a class on programing, i'm going to start with a mario clone. If i'm going to teach myself I'm going to start with a final fantasy clone. The reason is there is so much i can jump back and forth from to keep my interest in the game. The class however can hear more indept reasons from a teacher, I can't get that from myself if i'm just now learning.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!
Re: Scripting from ground up [Re: LarryLaffer] #47423
09/19/05 14:37
09/19/05 14:37
Joined: Sep 2002
Posts: 8,177
Netherlands
PHeMoX Offline
Senior Expert
PHeMoX  Offline
Senior Expert

Joined: Sep 2002
Posts: 8,177
Netherlands
@Larrylaffer, yes, that may be true indeed, but back when you just started, you probably instantly realised you wouldn't be making DOOM 3 to start with or Morrowind 2 just to name some... Some newbies have that wishful thought of being able to start with complicated things first and almost want to skip the very important basics... Just look at how many new people tend to post in the shader forum, eventhough they don't really know 3dgs yet...
Also, scripting pong, or scripting a rpg will make you learn stuff in different ways, or maybe even totally different things... Does pong need a arrow and bow code for example? For more skilled beginner-programmers this will be a healthy challenge, for real newbies a nightmare. A well, you know what I mean out of your own experience about that I'm sure. Also one thing why making a pong game might be favorable over a 'complex' RPG is the fact that newbies like to see results quickly and some tend to give up if they turn out to not be able to make Morrowind 2, eventhough chances are they 'could', after fully learning 3dgs...

Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software
Page 1 of 2 1 2

Gamestudio download | 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