how to code .....

Posted By: Aaron

how to code ..... - 02/17/07 17:48

I need to know how to code sounds in footsteps of different sounds depending on texture, and also how to put music in main menu??
Posted By: xXxGuitar511

Re: how to code ..... - 02/17/07 18:32

Main menu:
use media_loop()

Code:

//Volume for media
define MenuVol, 100;
//Sound File
string sndMMBG = "Menu.mp3";
//
var BGSound;
Function StartMenu()
{
BGSound = media_loop(sndMMBG, null, MenuVol);
}
Function EndMenu()
{
media_stop(BGSound);
}




Texture for footsteps:
Use a trace from the player to the ground. You can either name your textures starting with a x digit code such as dirtblabla.tga or graswhatever.bmp. Then in your trace include the flag scan_texture.

then you'd use string comparisons to get the tex name, copy and clip it to 4 (or so) digits, then use IF statements to figure out which sound to use...

Code:

//volume for footsteps
define StepVol, 100;
//
string tstr;
function PlayFootstep(Texname)
{
str_cpy(tstr, Texname);
var i;
i = str_len(tstr);
if (i < 5)
{return(0);}
i -= 4;
str_trunc(tstr, i);
//
if (str_cmpi(tstr, "dirt"))
{ent_playsound(my, sndStepDirt, StepVol); return(1);}
if (str_cmpi(tstr, "gras"))
{ent_playsound(my, sndStepGrass, StepVol); return(1);}
if (str_cmpi(tstr, "metl"))
{ent_playsound(my, sndStepMetal, StepVol); return(1);}
return(2);
}



Use:
call PlayFootstep(tex_name); after using a trace with the scan_texture flag.

returns:
0: the input string had less than enough characters
1: function ran successfully
2: No matching sound could be found

Code:

Function Footstep()
{
vec_set(temp, my.x);
temp.z -= 500;
c_trace(my.x, temp, scan_texture);
PlayFootstep(tex_name);
}


Posted By: Aaron

Re: how to code ..... - 02/17/07 22:30

Also How do you in the script use animation controls like I am making a window first I want if any ojbect with any speed more than 5 mph if it hits the window a spirit appers on the glass that makes it look as the window is about to smash into peices then if another object hits it again it then will play my glass shatter animation with sound of smashing glass. I don't fully under stand how you guy's know how to do certain things lol, I do understand programming but I can't understand programming in video games I dont' fully know commands that the engine provides ect and how it can be used.

if you know a place where their is a whole list of the commands and what they do please do tell.
Posted By: Ottawa

Re: how to code ..... - 02/18/07 00:56

HI Aaron!

Have you read all or part of the AUMS. That's where I found out how many things work.

Hope this helps

Ottawa
Posted By: Aaron

Re: how to code ..... - 02/18/07 03:32

I went through them and also I could understand what their doing but can't seem to get how you guy's out of the air write code, I mean if I know what bmap is fully is I am guess it's a code in the engine that loads a pic file which after that's used then after would be some kind of code on how you want it to function like as a button or a panel or as skin on a model ect that's if I am correct, but I don't know the codes for any physic's and 3d animation control, I know how to animate skin meaning if I wanted the person model to talk I could use a cheap way by making multiple skins and then using bmap load them in and then make a function, but like I want to do is make a code for a gate and a broken lock for a door so like when your player model walks into the door the door swings when then object is kinda pushing it well running into it the door opens more same type of thing that was used in manhunt the video game by rockstar games.

but the thing is I don't know what codes do what the building blocks I understand programming it's not the basic's I am not getting it's the commands used in this game engine, I want to know or have a list of all commands used in script for the engine that runs it and what it does meaning what job it does.

But I am right now mostly interested in learning all animation related controls code for the game engine, becuse I want to make a window that when a object hits it a 3mph or greater with at least weaight of 20 pounds a spirit pop's up and attaches itself to the glass kinda like the bullet hole concept, but this should make the glass look as if it was hit and about to break then when another object hit's it which the same criteria then the glass shatters but the shatter is a 3d animatied model of the window glass, I would need to know commands to control when the shattering takes place and I need to know phycis commands.

But I am getting closer and closer understanding this commands but still more to cover.

Thanks for your time.
Posted By: xXxGuitar511

Re: how to code ..... - 02/18/07 06:12

1st) It's called the MANUAL... You will hear this very often, lol. It contains (almost) everything you need to know.

2nd) It's SPRITE (like the soda), not SPIRIT (like a ghost). sprites are simply images. The problem is, what you are trying to do (shattering on the window) requires decals, and A6 currently does NOT support this. However, it is an upcomming feature. However, you may also position a sprite along the window, but you'd have to carefully place your window so that the sprite does not show up anywhere past the window.

3rd) Writing code "from the air". Well, I wish it were simply in the air to grab, but it's not . In truth, I still use the manual, but rarely. After you've been writing it for >3 years, you start to remember basic concepts of how things work. However, sometimes you have to look up the syntax of a function (which parameters to use), like i do.


finally) I've seem to be helpin you out alot lately, so why stop now . First off, the gate code. Now, physics gates (like in Manhunt) are a little harder to make, so I'm just gonna give you one that opens when the player is close to it. You will need to put the origin of the model on one of the sides of the gate (where the hinges would be).

Code:

ACTION GATE
{
// Distance from center...
my.skill1 = 500;
//
// Gate Speed...
my.skill2 = 5;
//
// Gate Angle to swing to
my.skill3 = 130;
//
// Set center of gate...
var MCenter[3];
vec_set(MCenter, my.x);
vec_add(MCenter, my.max_x);
MCenter.x -= ((my.max_x - my.min_x) / 2);
MCenter.y -= ((my.max_y - my.min_y) / 2);
MCenter.z -= ((my.max_z - my.min_z) / 2);
//
// Wait until close enough...
while(vec_dist(MCenter, player.x) < my.skill1)
{wait(1);}
//
// Remember original pan angle...
my.skill11 = my.pan;
//
// contains angle to add to original angle
my.skill10 = 0;
//
// Wait until gate reaches angle
while(my.skill10 < my.skill3)
{
// increase gates angle by speed, but don't go too far!
my.skill10 = min(my.skill10 + (my.skill2 * time), my.skill3);
//
// Set pan to original pan + new angle
my.pan = my.skill11 + my.skill10;
wait(1);
}
//
// Done!
}



This is the most work I've ever put into a post, so I hope it's helpful. You're lucky you caught me in a good mood . As for animating, here's a short example...

Code:

// The name of the scene in MED (default: Frame)
string SceneGlassBreak = "Break";
//
// Speed to animate
var AnimSpeed = 10;
//
...
// variable for holding animate position (in percent)
var i = 0;
//
// cycle until animation is done
while(i < 100)
{
// increase i by AnimSpeed, but not past 100%
i = min(i + (AnimSpeed * time), 100);
//
// Animate entity (non cycling animation)...
ent_animate(my, SceneGlassBreak, i, null);
//
wait(1);
}
// Done!
...




Good luck!
Posted By: Nidhogg

Re: how to code ..... - 02/18/07 12:17

Hey Guitar, Sorry to correct you, But isn't time succeded by time_step now.
Forget from what version though, 6.3 I think..

Also not a correction but info:- You must have a wait() in a while loop otherwise the engine crashes...
Posted By: Aaron

Re: how to code ..... - 02/18/07 15:06

thanks I am going to take a look at my manual but I check their one time in the beginning and I never found a list of commands used in the game engine, and I do know programming c++ and python, and I do know c coding, but it's the syntex for every project that's diffenent but I know programming basics.
the code is helpfull I am going to read it again when read to script I might now use your script becuse I feel cheap lol and plus I got to learn to code myself.
Posted By: xXxGuitar511

Re: how to code ..... - 02/18/07 17:06

@Nidhogg: I didn't forget any wait(); statements... & time/time_step are the same. time hasn't been removed yet. But you are correct, I should start using time_step more... time is just a habit...
Posted By: Aaron

Re: how to code ..... - 02/18/07 19:08

by the way I have A6 Pro v 6.1 and I don't use a6 temp's I use a5 temps becuse I try using a6 temps and I get script errors and the engine locks up, like I have to add scripts right?? and when I add pre-made scripts that come with the engine like plbip01 somthing likethat I the build of the level is ok but then I run it I get the a6 splash screen then a beep and then nothing happens after a while it then takes me back to wed. I would like to use the a6 temps someday, any ideas??? and is the latest v 6.50?? lol I am way out of date lol.
Posted By: Nidhogg

Re: how to code ..... - 02/19/07 00:00

Quote:

@Nidhogg: I didn't forget any wait(); statements... & time/time_step are the same. time hasn't been removed yet. But you are correct, I should start using time_step more... time is just a habit...




Hehhe, Ol habits are hard to break.. I wasn't correcting you on the while - wait statement, Sorry if it seemed that way. I was just letting the orginal poster know that it has to be used to avoid engine crash..
Posted By: xXxGuitar511

Re: how to code ..... - 02/19/07 03:55

I never use the templates...

I hate them... They're good for beginners, but I refuse to use them...
Posted By: Nidhogg

Re: how to code ..... - 02/19/07 09:02

Amen to that, I wish I knew enough to do it that way as well.

I like to use more meaningfull var etc easy to track code then if you need
to change something.
Posted By: Aaron

Re: how to code ..... - 02/20/07 22:52

is Their any place where I could find a list of commands used in 3dgs a6 v6.1.
for script's meaning for like animation and physic's handeling in game and controls.
Posted By: D3D

Re: how to code ..... - 02/20/07 22:57

Maybe in the manual? I don't know about A6.1, but there is a 6.22 manual below on the download page.
Posted By: xXxGuitar511

Re: how to code ..... - 02/21/07 01:35

A6.1?

I don't remember a 6.1, I think you mean A6.50.1? or A6.31?


The manual... (ANY 3DGS Program) (MENU) Help -> Contents
(OR) [start menu] Programs -> 3D Gamestudio -> Manual
Posted By: Aaron

Re: how to code ..... - 02/21/07 15:07

The manul say's 3dgs A6 v6.1 it say's that I don't know but it's a pro-version it could be v6.22 becuse it say's that in my properties but the manul say's v6.1 it's I think the second version of the A6 engine what ever version it is but it's the second version or update thing. To me looks every old I want to upgrade but don't have the money, I been looking on ebay lol that's how I bought this version someone sold it to me for 30 bucks the pro version, but so far don't find any newer versions.

ya I looked in the manual and it doesn't have a list of commands for the scripting, it is kinda choped up like it talks about panels and buttons and a little touch on animation like a few codes, but it dosen't talk about weather nor like sky it talks about the template sky00 or sky01 and talks about what that is used for but doesn't explain the codeing used in it or anything.
Posted By: Xarthor

Re: how to code ..... - 02/21/07 15:13

@Aaron: To make sure what Edition and Version of 3DGS you have, open WED and click on -> Help -> About WED
A small window will open where it states your edition and version.
Maybe you could just post that info here?
Thanks
Posted By: Aaron

Re: how to code ..... - 02/21/07 17:29

I done it and gave me gamestudios A6 pro V6.22 / web v6.22 and then states copyrights, that's what I get in that about window.
I got a question on my building stuff, I am building homes and offices in my city level and want them to be walk-inable so is it best to make 3d models and skin it, like for the walls I make one 3d model of a brick wall and a wall like for indoors like wallpaper, or just make a 3d model of the home ect, I am trying to use the phyics engine to make a realistic explosion so like if someone puts tnt in the home and it blows I want to show an effect where the wood or walls or door blows into peices depending where the explosion start so if it's right next to the door the door blows into millions of peicse were as if the tnt is on the other side of the house and a far distance away from the door I want the door to have little damage and have a sprite that goes on top of the door that shows black to make it look like an explosion occured, in the house I am shoot for interactivity meaning anything can break and blown up and throw abjects around acts with the envirement.

and that attach thing for the guns can I also use that for attach a player model enity to the player's hands and he could punch or throw the guy around which would put that 3d model player that thrown into stuff to be when thrown to be in the rag doll mode.
Posted By: Grafton

Re: how to code ..... - 04/01/07 04:08

Ahhh, another 6.22 Pro user....
© 2024 lite-C Forums