[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Self? Other? Owner?

Self? Other? Owner?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Self? Other? Owner?

Postby toneddu2000 » Sat Jul 21, 2012 8:33 am

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Self? Other? Owner?

Postby taniwha » Sat Jul 21, 2012 8:45 am

To be asking questions like this, you actually do get the concepts of quakec :).

Anyway:
self: the currently active entity. for think functions, it's the entity doing the thinking. in touch functions, it's the entity being touched (eg, doors). Set by the engine.
other: the other entity in touch functions. ie, the entity doing the touching (eg, the player). Set by the engine.
owner: the entity that "owns" the entity in question. Used mostly for missiles so grenades/rockets won't explode on the firing player, but also for paired doors (doorent.owner is the "master" door). Set by QC.

For self and other, there are times where QC sets the field, but these are rare, and the field is usually restored to its previous contents after doing something fancy.
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Self? Other? Owner?

Postby Seven » Sat Jul 21, 2012 6:15 pm

Hello toneddu2000,

For me, it helped a lot to read and understand the items.qc.
It helped me to proper understand what is "self" and "other".

Items.qc handles the powerups and keys and stuff.
So, all the models, that do nothing, but are touchable (!).
The players or monsters, who walk around and touch these models are always: "other" in the viewpoint of the powerups.

Example:
The health boxes functions have a lot of "other." in them, because they give the others health points, right ?
They do not give the health points them'selves'.
The "other" is the player who touch them.

One more important thing:
Look into Throwgib function (in player.qc) for example.
You can spawn new local entities and give them ANY 'name.' you want.
Example in throwgib: 'new.'
So all declarations start with 'new.' then.
But as soon as you jump into the next function that handles these entities,
you must use 'self.' for them (if it is not a global).
If you make these entities touchable, the player/monster that touches these passive ents are the 'other.' again (like described above).

I put my mind "into" the entities view to better understand who is self and who is the other.
That helps me to understand it better.
All powerups/keys and stuff in items.qc will help you to get a "feeling" for it.

Or another example are the projectiles (like rocket, grenade, ...) :
They give the 'other.' the damage (they do not give it them'self' (!)).
The other is the monster/player who gets touched...
In their function, they use:
if (other.health)
{
.....
}
So only 'others' with health (like players, monsters) get the damage.


... I guess what I just wrote is kind of a mess (grammar-wise and context-wise), but maybe this helps you bit.

Best wishes,
Seven
Seven
 
Posts: 301
Joined: Sat Oct 06, 2007 8:49 pm
Location: Germany

Re: Self? Other? Owner?

Postby toneddu2000 » Sat Jul 21, 2012 10:35 pm

- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Self? Other? Owner?

Postby Spike » Sat Jul 21, 2012 10:58 pm

'self' is to qc as 'this' is to c++
it is merely the 'active' entity that your code is currently talking about.

saving self into oldself (and restoring later) is a way to refer to a different entity in various function calls, without breaking things in the function that called you (which still expects self to be what it was when the current function was called).
thus you'll find functions that notify other entities of events on that entity switching self to the entity that's being notified then calling whatever notification function required, whether thats one of the th_foo functions or a direct function call.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Self? Other? Owner?

Postby Baker » Sat Jul 21, 2012 11:35 pm

This was always on my list of things I didn't know. Good question. I kept forgetting to ask.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Self? Other? Owner?

Postby mh » Sun Jul 22, 2012 3:37 pm

If you know some C it's helpful to look at the engine source here. Search for calls to PR_ExecuteProgram and you'll find that it's always preceded by pr_global_struct->self = whatever, and the same for other. Have a look at which entity is being set to self, have a think about what's happening there, and it starts to come together.
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Self? Other? Owner?

Postby toneddu2000 » Sun Jul 22, 2012 5:19 pm

@Spike, thanks a lot, now it's more clear.

@mh, yeah I'd like to learn more "serious" programming but I'm bit stuck with pointers! :) I'll try to search what you post it, thanks!

It would be great if it was available a "complete quakec guide for beginners"! :lol:
- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Self? Other? Owner?

Postby taniwha » Sun Jul 22, 2012 10:56 pm

toneddu2000: think of pointers as "entity" and the fields as (eg) ".float health", and ignore the difference between -> and . (even the designers of C regret that one). Pointers are really quite easy once you realize they're just a way to have one variable refer (point) to another. No different than asking one friend for another friend's phone number :).
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am

Re: Self? Other? Owner?

Postby toneddu2000 » Mon Jul 23, 2012 8:12 pm

wow taniwha! I never seen pointer in this way! It's more clear, like this, thanks!
- my first commercial game, made with FTEQW game engine
toneddu2000
 
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: Self? Other? Owner?

Postby taniwha » Mon Jul 23, 2012 11:06 pm

I'm glad I could help :)
Leave others their otherness.
http://quakeforge.net/
taniwha
 
Posts: 399
Joined: Thu Jan 14, 2010 7:11 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest