Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
NPC's ?? #203212
04/20/08 13:15
04/20/08 13:15
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Hey guys

I didn't even solved my Gravity Problem so far.. but I decided to ignore that for now and started a little with MED and WED. Now Im back on scripting and I got another Problem.
I want to make a NPC talk to me, when I am in a certain range to him.
You know like in every commercial RPG Game. You go to a NPC, hit a certain button on the keyboard (f.e. "E" or "Space") and a text box appears on the bottom of the screen and a text begins to scroll down. and when you hit the Action Key for this again, the next text should appear or the box should disappear.

well the thing with the text and textbox isn't the great problem.. but starting the conversation is..
I tried it with c_scan so far. but my problem is, that the npc starts his text at once. or he doesn't do anything.

Now Im wondering how to code that oO could someone please give me an understandable example for a NPC code?

 Code:
/////////////////////////////
// Bitmaps and Panels
BMAP* textbox = ("textbox.pcx");

PANEL* box =
{
  pos_x = 0;
  pos_y = 0;
  layer = 1;
  bmap = textbox;
  flags = OVERLAY;
}

/////////////////////////////
// Texts & Fonts

//FONTS
FONT* arial = "Arial#20b"; 

//STRINGS
STRING* npcgreeting= "Welcome to the Dark Room!";

//TXTS
TEXT* box_txt =
{
	pos_x = 83;
	pos_y = 478;
	layer = 2;
	font = arial;
	string (npcgreeting);
}

function scan_npcs()
{
	me = charakter;
	c_scan(vector(charakter.x, charakter.y, charakter.z), vector(charakter.pan,charakter.tilt, charakter.roll), vector(90,90,200), IGNORE_ME | SCAN_ENTS | SCAN_LIMIT);

}


function npctalks()
{
	if(event_type = EVENT_SCAN)
	{
		box.flags = OVERLAY | VISIBLE;
		box_txt.flags = VISIBLE;
		
	}
	
}

action npc()
{
	ENABLE_SCAN = ON;
	my.event = npctalks();
}


that's what i made up so far q_q..
there's a "on_e = scan_npcs();" command in my Playeraction in a while loop, too. for talking to a npc..

Sorry for my bad english..

Hope you could help me with that..

Greetings Roxas ~

Re: NPC's ?? [Re: Roxas] #203224
04/20/08 15:05
04/20/08 15:05
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
 Originally Posted By: Roxas
there's a "on_e = scan_npcs();" command in my Playeraction in a while loop, too.


Then delete it immediately. Either you want to assign a functin to a certain key, then its "on_e = scan_npcs;" without the brackets. With the brackets you'd assign on_e the result of scan_npcs, what you for sure don't intend to do. And don't put it in a loop. Once assigned it will work until you assign something new to on_e. The other possibility is, that you want to call the function every frame. Then you can use a loop and write "scan_npcs();" inside the loop.


Always learn from history, to be sure you make the same mistakes again...
Re: NPC's ?? [Re: Roxas] #203261
04/20/08 19:10
04/20/08 19:10
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Thanks uhrwerk for this, that was one of the major problems.
I think I got it to work now..

But there're so many things I don't get.. and I barely find help or tutorials or something.

well I don't even know what to code..
First I wanted to make a Mariolike Coin gathering game, but without gravity and jumping that's a little ~
well I got linear gravitation with c_trace to the ground. He's falling. but i don't get jumping to work.


at least I got the NPC code to work now..
I would be glad for every help I could get for this gravitation thing with c_trace so feel free to pm me please Q__Q.

I tried the phyiscs engine aswell but that's more for cars and stuff isnt it? not for humanoid charakters ôo?

Re: NPC's ?? [Re: Roxas] #203287
04/20/08 23:03
04/20/08 23:03
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Fine, you solved the problem. That's a success.

There really should be a lot of tutorials. What about Christian Behrenbergs Game Workshop Rudi? That's a really good workshop that introduces almost all parts of game development. A good example for a simple player movement can be found in the templates. The templates are based on c-script at the moment, but I guess it shouldn't be too hard to convert them to Lite-C.

I can try to help you on your gravitiational problem. Did you already post the code in a separate thread?

The A7 physics engine is not intended for use with characters. To be honest it is hardly usable for anything serious - that's at least my personal opinion. Others might of course find it suitable for a variety of tasks.


Always learn from history, to be sure you make the same mistakes again...
Re: NPC's ?? [Re: Roxas] #203322
04/21/08 07:49
04/21/08 07:49
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Yeah you're right, that's a success. I even got it to work that the NPC can talk more than just one sentence. Next I'll try to write a code for giving several answers to questions from NPC's. Maybe I'll get that to work too.

I posted some code in another Thread so far, but Im not sure if there was any of my physics code.

well basicly I tried it with c_trace.

I let c_trace trace down from the charakters origin 4000 quants down to the ground with use_box and ignore_me and ignore_passable. (written in capitals for lite-c) ehrm...
I save the result of this in a variable called "char_height"
and then I've got some weird if-things which are checking if char_height is less than the char's origin. if this is the case, the following code runs:
charakters.z += 2* time_step; (for me it's charakters.z because i defined charakter = me) I made this, because when he sinks into the ground he should be pulled out until he is on the floor again.

I did the same thing If char_height is bigger than his origins hight. so he is pulled down to the ground like charakters.z -= 2* time_step;

but that's just a linear gravity isnt it?. so how do I solve the problem that he shoud fall faster the deeper he fells? and the thing with the jumping is a riddle to me. he won't jump no matter what i try.. i tried several things like adding a certain value to his z-axis until he reached a certain height, and than tried to let my physic do the rest..but it does not work.

maybe you can help me with that.. i hope so.
thanks for responding to this uhrwerk.

i'll also look at the templates maybe i can learn something from it

Re: NPC's ?? [Re: Roxas] #203380
04/21/08 18:15
04/21/08 18:15
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You basic idea of using c_trace asbsolutely right. But with directly modifying the characters x, y and z parameters you do something that can lead to a lot of hard to find errors. The usual way to do this is the follwing:
  • Defining a vector that represents a force, that is working on the character.
  • Doing a c_trace as you already described it. If the character is in the air then you apply normal gravity, e.g. 9.81 nm converted to your game worlds scaling. With applying I mean setting the forces z component to -gravity. If the character is "inside" or very close to the ground you don't apply this gravity, but instead set a force pulling the character towards the surface of the ground. (A positive value if he is "inside", the ground, a negative one if slightly above.) If the player is not flying at the moment you might even make him jump by adding a positive value to the forces z component.
  • Now you should convert the force vector you got to a velocity. Have a loook in the manual under "poor mans physics engine" and vec_accelerate.
  • Once you calculated the resulting speed you move your character with the use of the c_move instruction. If you really want to you can even directly set the entities position, but be aware that this might let your character run into geometry.


I hope that list is of value for you. If you run into certain problems do't hesitate to post the code.


Always learn from history, to be sure you make the same mistakes again...
Re: NPC's ?? [Re: Roxas] #203564
04/22/08 19:41
04/22/08 19:41
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Allright Uhrwerk. Thank you for your tipps so far, but.. how do i manage it, to make a force, that's working on the charakter \:o

#define force_x skill40
#define force_y skill41
#define force_z skill42
#define velocity_x skill43
#define velocity_y skill44
#define velocity_z skill45

this is what i defined so far just for the movement.

how do i solve the problem now to get the force working on the charakter?
well I press a key and the charakter moves. thats what i mean.
my old function looked like this

 Code:
		

#define speed_x skill30

if(state == run){charakter.speed_x = 12;}
if(state == walk){charakter.speed_x = 7;}
state = stand;

if(key_w == 1 && key_s == 0 && key_a == 0 && key_d == 0)
		{
			if(key_shift == 1){state = walk;} else {state = run;}		
			charakter.pan = camera.pan;
			c_move(charakter, vector(charakter.speed_x * time_step, 0, 0), nullvector, IGNORE_PASSABLE | GLIDE);
		} 
/* here are 7 almost similar functions that handle the move directions */
		



I did this for every case of pressing the buttons. which means 8 of those if-functions. thats just the first

so speed_x is the force that works on the charakter, isnt it? \:o

Re: NPC's ?? [Re: Roxas] #203582
04/22/08 20:58
04/22/08 20:58
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I guess you move your character by changing its angle and then moving it forward, is that correct? Then you can define one force for the rotation and one force for the movement. You can determine the force by the keys. For example:
 Code:
/* Your defines and functions here... */
my.force_x = key_w - key_s;
my.force_y = key_d - key_a;
The same for the angular force and the keys you want to use for your movement. Maybe you have to exchange key_d and key_a, I am not sure about that. If your movement works the opposite direction than you want then just exchange them. You learn all the stuff piece by piece, all on your own and completely self coded. I like that. \:\)


Always learn from history, to be sure you make the same mistakes again...
Re: NPC's ?? [Re: Roxas] #203585
04/22/08 21:10
04/22/08 21:10
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
thank you^^.
well i guess I just want to become a good coder.

at the moment im motivated enough, cause i get some successes. and I got ambition.
at the moment I'm trying to get the physic to work. I coded the movement complete from the beginning and now it looks like this:

 Code:
function movement()
{
	charakter.force_x = 0;
	state = stand;
	if(key_w == 1 && key_s == 0 && key_a == 0 && key_d == 0)
	{
		charakter._angle = camera.pan;
		charakter.force_x = 1;
	}
	if(key_w == 0 && key_s == 1 && key_a == 0 && key_d == 0)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan - 180;
	}
	if(key_w == 0 && key_s == 0 && key_a == 1 && key_d == 0)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan + 90;
	}
	if(key_w == 0 && key_s == 0 && key_a == 0 && key_d == 1)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan - 90;
	}
	if(key_w == 1 && key_s == 0 && key_a == 1 && key_d == 0)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan + 45;
	}
	if(key_w == 1 && key_s == 0 && key_a == 0 && key_d == 1)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan - 45;
	}
	if(key_w == 0 && key_s == 1 && key_a == 0 && key_d == 1)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan - 135;
	}
	if(key_w == 0 && key_s == 1 && key_a == 1 && key_d == 0)
	{
		charakter.force_x = 1;
		charakter._angle = camera.pan + 135;
	}
	
	
	if(charakter.force_x > 0 && key_shift == 0)
	{
		state = run;
	}
	if(charakter.force_x > 0 && key_shift == 1)
	{
		state = walk;
	}
	
	if(state == run){charakter.velocity_x = 18 * time_step;}
	if(state == walk){charakter.velocity_x = 10 * time_step;}

	c_move(charakter,vector(charakter.force_x * charakter.velocity_x , charakter.force_y, charakter.force_z),nullvector, IGNORE_PASSABLE | GLIDE);
}


with the ._angle thing I let the entity turn towards the position i want him to run, I took the function from the khmovement tutorial for the rotation and adjusted it for my purposes etc.. looks quite good until now, in my opinion oO. better than the code before.

I'll post my gravity code later on. at the moment I try it the way you suggested ^^. hope ill get it to work.

greetz and thanks

Re: NPC's ?? [Re: Roxas] #203661
04/23/08 10:03
04/23/08 10:03
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Well as I said, here's my Gravity Handling so far
you may be disappointed when you see that I wasn't able to get the jumping into it. Same as ever. poor results. But this physics function works better than my old one.

I tried it with this vec_accelerate too ,but I couldn't get it to work. spit out some errors \:\(

well I got some jumping to work. but after jumping once he was stuck on the ground when I pressed the space_key again.

maybe you got some ideas how to put a Jumping code into it ? I would be glad
Because I think I am going to make the same mistakes again and again with the jumping..

 Code:
function gravity_handle()
{
	charakter.force_z = 0;
	char_height = c_trace(vector(charakter.x, charakter.y, charakter.z - charakter.z_offset), vector(charakter.x, charakter.y, charakter.z -4000), IGNORE_ME | IGNORE_PASSABLE | USE_BOX);
	
	
	if(char_height > charakter.z_offset)
	{
		state = falling;
	} 

	if(char_height < charakter.z_offset-2)
	{
		fall_time = 0;
		charakter.force_z += 8 * time_step;
		state = stand;	
	}
	
	if(state == falling)
	{
		charakter.force_z -=  8 * fall_time * time_step;
		wait(1);
		fall_time += 0.5 * time_step;
	}
	c_move(charakter, vector(0, 0, charakter.force_z), nullvector, IGNORE_PASSABLE | GLIDE);
}


thanks for your help so far.

greets

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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