Back to the Vavoom Forum Archives


Forum

4 more questions on Vavoom C programming

Fri, 11 Nov 2005 19:46:56

Crimson Wizard

Well, first of all I want to say, that it would be great to have Vavoom C class hierarchy with brief explanaion of what they do. Then, I've got four questions on programming. 1) is the letter case is essential in Vavoom C's variable names? (i.e. is 'MyVar' is treated the same as 'myvar'?) 2) what Actor, Botplayer and PlayerPawn classes are doing? 3) what is the difference between LocalSound and Actor's PlaySound functions? 4) finally, how does StatusBar (client/statbar.vc) knows about player (or client?)? Where 'cl' pointer is defined? I ask this just for information, to be completely aware of what I am doing when modifying this file.
Sat, 12 Nov 2005 10:14:47

Janis Legzdinsh

Well, first of all I want to say, that it would be great to have Vavoom C class hierarchy with brief explanaion of what they do.
The main classes are: Object - base class for everything. Thinker - base class for all level objects (actors, doors, etc.) Actor - base class for all actors. Player - implements player specific things. Weapon - base class for weapons. Window - base class for user interface objects (currently not everything).
1) is the letter case is essential in Vavoom C's variable names? (i.e. is 'MyVar' is treated the same as 'myvar'?)
Yes it is, MyVar and myvar are different variables.
2) what Actor, Botplayer and PlayerPawn classes are doing?
Actor is base class for everything that is represented with sprites or models. BotPlayer implements bot AI. PlayerPawn is base class for player's actor, nothing special about his one.
3) what is the difference between LocalSound and Actor's PlaySound functions?
LocalSound is available only on client side, it's used by user interface - menus, intermissions, etc.
4) finally, how does StatusBar (client/statbar.vc) knows about player (or client?)? Where 'cl' pointer is defined? I ask this just for information, to be completely aware of what I am doing when modifying this file.
cl variable is only thing available for status bar. It's defined in common/clvars.vc, type is defined in common/types.vc, additional fields in hexndefs.vc.
Sat, 12 Nov 2005 11:58:31

Crimson Wizard

Thanks alot. Oh, phew... that was a *real* pain to learn how this addfield feature works, until I occasionally detected 'NUM_STATS' macro there... <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: -->
BotPlayer implements bot AI. PlayerPawn is base class for player's actor, nothing special about his one.
Well, as I understand this, class Actor deals with thing states and animation, class Pawn - is monster AI, and monster classes (Bishop, Ettin etc) just add specific AI to monsters. Am I right? Then, what is need of PlayerPawn anyway? What is it for? And about PlayerBot - you mean it can be used to create computer-controlled players (with full player functionality)? (By the way, I just wonder, aren't you planning to add Botmatch mode to Vavoom <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) --> )
Sat, 12 Nov 2005 12:09:38

Firebrand

Really nice explanation here! It's useful to know it <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->.
Sat, 12 Nov 2005 12:13:28

Crimson Wizard

[quote="Firebrand":bk3x14ar]Really nice explanation here! It's useful to know it <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->. It would be much more useful if put to Vavoom Wiki in form as all programming languages have in their reference. <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: --> Y'know, just like that: class Actor. - derived from... parameters methods description... <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> Hey, I just thought. I saw that some other guys wrote their tutorials to Wiki. May be I'll try to create such hierarchy and show you, and if you like it you may use it. <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: --> (If you need it at all, ofcourse) EDIT: Oops, I've got another one q.: Why player's health on the statusbar cannot go above 255? I set new player attribute - 'MaxHealth', that raises with experience level, but when it becomes more than 255 current health value shown on statusbar drops down (it looks like it has only 1 byte for value storage). (REAL health value - that's in BasePlayer class - change normally) And, anyway, where client_state_t take current health value from?
Sat, 12 Nov 2005 17:45:54

Firebrand

The wiki it's there so anyone can contribute, I also think it's necessary to have such tutorials, sadly, I don't have enough knowledge yet to complete the task myself <!-- s:( --><img src="{SMILIES_PATH}/icon_sad.gif" alt=":(" title="Sad" /><!-- s:( -->, but feel free to add anything you want to it, that's the use it has <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->.
Sat, 12 Nov 2005 18:08:15

Crimson Wizard

Err... I can add it just so simple? <!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: -->
Sat, 12 Nov 2005 20:09:34

Firebrand

Yep, just register on the Wiki and add a new page on the editing section under the Vavoom C category, it's that simple <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->, be welcome to add anything else you want, it's a community oriented way of creating documentation for Vavoom, which is cool I think <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->.
Sat, 12 Nov 2005 20:11:27

Crimson Wizard

Ok, I created my account there. I'll try to post some entries on class hierarchy topic as soon I study Wiki editorial documentation.
Sat, 12 Nov 2005 20:13:32

Firebrand

It's really easy to do most of the basic stuff, it's all in a toolbar when you edit or create topics there <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->, but it's useful to inform how to work with it, heh! <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->.
Sun, 13 Nov 2005 10:10:14

Janis Legzdinsh

Well, as I understand this, class Actor deals with thing states and animation, class Pawn - is monster AI, and monster classes (Bishop, Ettin etc) just add specific AI to monsters. Am I right?
Right.
Then, what is need of PlayerPawn anyway? What is it for?
It's basicly a base class for PlayerFighter, PlayerCleric, PlayerMage and PlayerPig. And MO property in Player class is expected to be a PlayerPawn.
And about PlayerBot - you mean it can be used to create computer-controlled players (with full player functionality)? (By the way, I just wonder, aren't you planning to add Botmatch mode to Vavoom)
Yes, that's what it does. And you already can have a botmatch.
Why player's health on the statusbar cannot go above 255? I set new player attribute - 'MaxHealth', that raises with experience level, but when it becomes more than 255 current health value shown on statusbar drops down (it looks like it has only 1 byte for value storage). (REAL health value - that's in BasePlayer class - change normally) And, anyway, where client_state_t take current health value from?
It's sent over network as byte, so on client you get only last byte.
Sun, 13 Nov 2005 12:57:27

Crimson Wizard

Yes, that's what it does. And you already can have a botmatch.
<!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: --> But how???!! I've suspected that I can, but I haven't found the way I can launch a botmatch.
It's sent over network as byte, so on client you get only last byte.
Hmm... but mana value CAN go over 255 limit. May be I should try to add another one param to Player class that would represent his health. <!-- s:?: --><img src="{SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question" /><!-- s:?: --> EDIT: Yes! That worked. I set new variable in Player class (named it Health2) and replaced Health variable everywhere in Player.vc, and also in statbar.vc (used cl->health2 field). Although, I had to add following block in all places where health is changed:
if(Health2 > 255) Health = 255; else Health = Health2;
if I wouldn't do this player appears dead at startup since Entity->health = 0. However, he can play (!), but his view is rotated 90 degree right.. this lookes like player is a zombie with broken neck... <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->
Sun, 13 Nov 2005 14:42:18

Janis Legzdinsh

<!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: --> But how???!! I've suspected that I can, but I haven't found the way I can launch a botmatch.
Start a multiplayer game, then go to console and use command addbot to spawn a bot.
Mon, 14 Nov 2005 09:39:57

Crimson Wizard

Heh, I never knew Doom-based games have such a weird-looking deathmatch. <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> By the way, why fragged players do not leave their weapons? (or it is Doom dm rules?) And, well, I've added something to Wiki. Everyone is invited to check&correct: <!-- m --><a class="postlink" href="http://www.vavoom-engine.com/wiki/index.php?title=VavoomC">http://www.vavoom-engine.com/wiki/index ... le=VavoomC</a><!-- m --> it is Classes List entry.
Mon, 14 Nov 2005 17:52:21

Janis Legzdinsh

By the way, why fragged players do not leave their weapons? (or it is Doom dm rules?)
Doom engine games didn't have such a feature.
Mon, 14 Nov 2005 19:09:38

Firebrand

[quote="Janis Legzdinsh":3990k0v9]
By the way, why fragged players do not leave their weapons? (or it is Doom dm rules?)
Doom engine games didn't have such a feature. But it can be implemented with some prog tweakings, heh! <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->.
Tue, 15 Nov 2005 10:56:51

Crimson Wizard

At first I just mention:
if(Health2 > 255) Health = 255; else Health = Health2;
Well, this actually was wrong and not needed at all. Then, I'd wish to ask: 1) What is bFloatBob flag in Actor (in which thing types it it used) and why there is such a strange string:
Health = P_Random();
under condition "if(bFloatBob)" in OnMapSpawn() function?
Tue, 15 Nov 2005 12:48:44

Janis Legzdinsh

bFloatBob is used by floating items, artifacts, etc. It uses Health to store current floating position (I'll replace this with dedicated variable for this).
Wed, 16 Nov 2005 15:52:27

Crimson Wizard

And why not use Z position? Also, I want to be sure about class objects' copying, since i am not aware of how it is implemented in VavoomC. For example, if I write:
Actor a; Pawn p; p = a;
Does this mean, that 'a' contents are copied to 'p', or that 'p' is given a reference to 'a'?
Wed, 16 Nov 2005 19:25:44

Janis Legzdinsh

And why not use Z position?
Z is current position. Health holds floating time.
Also, I want to be sure about class objects' copying, since i am not aware of how it is implemented in VavoomC. For example, if I write:
Actor a; Pawn p; p = a;
Does this mean, that 'a' contents are copied to 'p', or that 'p' is given a reference to 'a'?
Assigning reference variable to reference variable changes the reference.
Thu, 17 Nov 2005 14:18:17

Crimson Wizard

Assigning reference variable to reference variable changes the reference.
Ah, it is reference variable... I just forgot. Sorry. <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarassed" /><!-- s:oops: --> Well, and then, how these class objects are created/destroyed? I mean - real objects, in memory. If I create a new variable of class Actor, for example, is the object already created? And then, if I give that variable a reference to other object, what happens with that, first, object, it just stays in memory unreferenced, or what? Excuse me for such a stupid question, but this thing confuses me much. It is not that transparent, as common dynamic memory in C++.
Fri, 18 Nov 2005 19:39:36

Janis Legzdinsh

Classes cannot be instanciated. I think that "Reference variables" section in wiki topic VavoomC variables describes them clear enough. Actor classes are created with function Spawn, other thinkers with NewSpecialThinker, other objects with SpawnObject. Actors should be freed by calling Actor's Remove method, other thinkers use RemoveSpecialThinker, the rest using Object's Destroy method.
Sat, 19 Nov 2005 14:38:12

Crimson Wizard

OK, now it is absolutely clear.
Fri, 25 Nov 2005 12:49:28

Crimson Wizard

Well, I've got more questions, and some of them are very specific. They are: 1) Do I need to add my new thing classes into mobjinfo.vc? 2) What are GLavaInflictor and LavaInflictor classes for? 3) What does bBlaster flag means in Actor class? 4) What the following code means in Actor::HitFloor() function? :
if (vdot < -0.1) { if (bIceDamage && vdot < -GRAVITY * 0.25) { StateTime = 0.1; Velocity = vector(0.0, 0.0, 0.0); return true; } .....
Thanks.
Fri, 25 Nov 2005 13:10:20

Janis Legzdinsh

1) Do I need to add my new thing classes into mobjinfo.vc?
No. Actually I should clean this file up. Thanks for reminding me.
2) What are GLavaInflictor and LavaInflictor classes for?
It's used as damage source for lava, just to tell that it's a fire damage and in a case of death a fire death animation should be played.
3) What does bBlaster flag means in Actor class?
It's used for very fast moving projectiles, such as mage's first weapon projectile.
4) What the following code means in Actor::HitFloor() function? :
if (vdot < -0.1)
{
	if (bIceDamage && vdot < -GRAVITY * 0.25)
	{
		StateTime = 0.1;
		Velocity = vector(0.0, 0.0, 0.0);
		return true;
	}
.....
Thanks.
It's for frozen monsters. When they falls on the floor, it makes them explode immediately.
Wed, 30 Nov 2005 18:54:25

Crimson Wizard

About menus programming. How I may make a menu screen know current game state - I mean whether game is started or not?
Wed, 30 Nov 2005 22:44:05

Janis Legzdinsh

Currently there's no direct way to check this. If no game is currently running, PageDrawer is called, otherwise status bar, intermission or finale drawer and ticker is called.

Back to the Vavoom Forum Archives