This tutorial is created by Thomas Werth.
Thanks and Greetings to Cyberjeff & Nathalie Bourassa for their knowledge.
Here's the tutorial everyone is looking for.
I will show you how to see your weapon and how to integerate different enemy's and different
Models for your own player depending on your current weapon ! That's great , isn't it.So you
know you need several Models with the same numer of Motions and the same Name of those
Motions. If you don't have just copy Dema.Act and rename it until you come along with 3dSMax
... The Variable "b1stPerson" is a global one for the current view of your actor for more
information check out my Advanced Chase Cam Tut or just kill it in your code ;-)
Let us begin with the weapon
Here's the code :
In "CheckClientPlayerChanges" in Client.c
if (Client->ViewPlayer == PlayerIndex && !TempPlayer) // ALWAYS render viewplayer.
{
if(geWorld_AddActor(World, Player->Actor,
GE_ACTOR_RENDER_NORMAL|GE_ACTOR_COLLIDE, 0xffffffff) == GE_FALSE)
GenVS_Error("[CLIENT] CheckClientPlayerChanges: Could not add actor to world. ActorDef
Name: %s.\n", ActorIndex->FileName);
}
else
{
if(geWorld_AddActor(World, Player->Actor,
GE_ACTOR_RENDER_NORMAL|GE_ACTOR_COLLIDE, 0xffffffff) == GE_FALSE)
GenVS_Error("[CLIENT] CheckClientPlayerChanges: Could not add actor to world. ActorDef
Name: %s.\n", ActorIndex->FileName);
}
In BuildClientViewXForm in client.c
double x, z;
x = sin(Client->Angles.Y)*20;
z = cos(Client->Angles.Y)*20;
Client->ViewXForm.Translation.Y += 160.0f;
Client->ViewXForm.Translation.Z = Pos.Z-(float)z;
Client->ViewXForm.Translation.X = Pos.X-(float)x;
Thats it for the Weapon.
So now we go to the actor's
we start In client.c
SetPlayerDefaults
Player->ActorDef = NULL;
//added for ownActors
Player->Person = -1; //just for initialising
in GMain.c
in GAME_Spawn_CLient
// Set the view info
Player->ViewFlags = VIEW_TYPE_ACTOR | VIEW_TYPE_YAW_ONLY |
VIEW_TYPE_COLLIDEMODEL;
//added for ownActors
//Player->ViewIndex = ACTOR_INDEX_PLAYER;
Player->Person = 0;
Player->ViewIndex = ACTOR_INDEX_1PBL;
//end added
in Client_Control
// Make sure the xform is valid
SetupPlayerXForm(VSI, Player, Time);
Player->VPos = Player->XForm.Translation;
//added for ownactor
switch (iWeapon1)
{
case 0:
if (b1stPerson)
{
// ViewIndex = ACTOR_INDEX_1PBL;
Player->ViewIndex = ACTOR_INDEX_1PBL;
}
else
{
// ViewIndex = ACTOR_INDEX_3PBL;
Player->ViewIndex = ACTOR_INDEX_3PBL;
}
break;
case 1:
if (b1stPerson)
{
// ViewIndex = ACTOR_INDEX_1PGR;
Player->ViewIndex = ACTOR_INDEX_1PGR;
}
else
{
// ViewIndex = ACTOR_INDEX_3PGR;
Player->ViewIndex = ACTOR_INDEX_3PGR;
}
break;
case 2:
if (b1stPerson)
{
//ViewIndex = ACTOR_INDEX_1PRO;
Player->ViewIndex = ACTOR_INDEX_1PRO;
}
else
{
//ViewIndex = ACTOR_INDEX_3PRO;
Player->ViewIndex = ACTOR_INDEX_3PRO;
}
break;
case 3:
if (b1stPerson)
{
// ViewIndex = ACTOR_INDEX_1PSH;
Player->ViewIndex = ACTOR_INDEX_1PSH;
}
else
{
// ViewIndex = ACTOR_INDEX_3PSH;
Player->ViewIndex = ACTOR_INDEX_3PSH;
}
break;
}
return GE_TRUE;
}
in GMain.h
// Actor indexes
#define ACTOR_INDEX_PLAYER 0
#define ACTOR_INDEX_TURRET 1
#define ACTOR_INDEX_HEALTH 2
#define ACTOR_INDEX_ROCKET_AMMO 3
#define ACTOR_INDEX_ROCKET 4
#define ACTOR_INDEX_SHREDDER 5
#define ACTOR_INDEX_SHREDDER_AMMO 6
#define ACTOR_INDEX_GRENADE_AMMO 7
#define ACTOR_INDEX_GRENADE 8
#define ACTOR_INDEX_ARMOR 9
//added for ownActors
#define ACTOR_INDEX_1PBL 10
#define ACTOR_INDEX_1PGR 11
#define ACTOR_INDEX_1PRO 12
#define ACTOR_INDEX_1PSH 13
#define ACTOR_INDEX_3PBL 14
#define ACTOR_INDEX_3PGR 15
#define ACTOR_INDEX_3PRO 16
#define ACTOR_INDEX_3PSH 17
#define ACTOR_INDEX_ENEMY1 18
#define ACTOR_INDEX_ENEMY2 19
#define ACTOR_INDEX_ENEMY3 20
#define ACTOR_INDEX_ENEMY4 21
// Motion indexes
in Level.c
// Actor indexes
GenVSI_ActorIndex(VSI, ACTOR_INDEX_PLAYER, "PlayerClient", "Actors\\Dema.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_TURRET, "PlayerClient", "Actors\\Turret.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_HEALTH, "foo", "Actors\\MedKit.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ROCKET_AMMO, "foo", "Actors\\rocket.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ROCKET, "foo", "Actors\\rlaunch.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_SHREDDER, "foo", "Actors\\Shredder.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_SHREDDER_AMMO, "foo",
"Actors\\SAmmo.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_GRENADE_AMMO, "foo",
"Actors\\Grenade.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_GRENADE, "foo", "Actors\\GLaunch.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ARMOR, "foo", "Actors\\Armor.Act");
//added for ownActors
GenVSI_ActorIndex(VSI, ACTOR_INDEX_1PBL, "PlayerClient", "Actors\\1PBl.act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_1PGR, "PlayerClient", "Actors\\1PGR.act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_1PRO, "PlayerClient", "Actors\\1PRO.act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_1PSH, "PlayerClient", "Actors\\1PSH.act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_3PBL, "PlayerClient", "Actors\\3PBl.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_3PGR, "PlayerClient", "Actors\\3PGR.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_3PRO, "PlayerClient", "Actors\\3PRO.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_3PSH, "PlayerClient", "Actors\\3PSH.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ENEMY1, "PlayerClient",
"Actors\\ENEMY1.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ENEMY2, "PlayerClient",
"Actors\\ENEMY2.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ENEMY3, "PlayerClient",
"Actors\\ENEMY3.Act");
GenVSI_ActorIndex(VSI, ACTOR_INDEX_ENEMY4, "PlayerClient",
"Actors\\ENEMY4.Act");
// Motion indexes
in Weapon.c
in Player_Dying
//Player->Dead = GE_FALSE;
Player->State = PSTATE_Normal; // Back to normal now...
//added for ownactor
//Player->ViewIndex = 0;
bot.c
#include "botact.h"
//added for ownactor
#include <stdlib.h> // we need this for our random function
in Bot_Dying
Player->Roll = 0.0f; // Make him stand right side up again
Player->Control = Bot_Control;
//added for ownactor
//Player->ViewIndex = 0;
switch (Player->Person)
{
case 1:
Player->ViewIndex = ACTOR_INDEX_ENEMY1;
break;
case 2:
Player->ViewIndex = ACTOR_INDEX_ENEMY2;
break;
case 3 :
Player->ViewIndex = ACTOR_INDEX_ENEMY3;
break;
case 4 :
Player->ViewIndex = ACTOR_INDEX_ENEMY4;
break;
default :
Player->ViewIndex = ACTOR_INDEX_ENEMY1;
break;
}
in Bot_ACTOR_Dying
//added for ownactor
//Player->ViewIndex = 0;
switch (Player->CurrentWeapon)
{
case 0 :
Player->ViewIndex = ACTOR_INDEX_3PBL;
break;
case 1 :
Player->ViewIndex = ACTOR_INDEX_3PGR;
break;
case 2 :
Player->ViewIndex = ACTOR_INDEX_3PRO;
break;
case 3 :
Player->ViewIndex = ACTOR_INDEX_3PSH;
break;
default :
Player->ViewIndex = ACTOR_INDEX_3PBL;
break;
}
in geBoolean Game_SpawnBot(GenVSI *VSI, geWorld *World, void *PlayerData, void
*ClassData)
{
int32 i;
GPlayer *DMStart;
GPlayer *Player;
geVec3d Normal = {0.0f, 1.0f, 0.0f};
//added for ownactor
int iNumber;
// Set the view info
Player->ViewFlags = VIEW_TYPE_ACTOR | VIEW_TYPE_YAW_ONLY |
VIEW_TYPE_COLLIDEMODEL;
//added for ownActor
//Player->ViewIndex = ACTOR_INDEX_PLAYER;
iNumber = rand();
iNumber = (((iNumber/RAND_MAX) * 3)+1);
Player->Person = iNumber;
switch (Player->Person)
{
case 1 :
Player->ViewIndex = ACTOR_INDEX_ENEMY1;
break;
case 2 :
Player->ViewIndex = ACTOR_INDEX_ENEMY2;
break;
case 3 :
Player->ViewIndex = ACTOR_INDEX_ENEMY3;
break;
case 4 :
Player->ViewIndex = ACTOR_INDEX_ENEMY4;
break;
default :
Player->ViewIndex = ACTOR_INDEX_ENEMY1;
break;
}
in Bot_Actor_start
// Set the view info
Player->ViewFlags = VIEW_TYPE_ACTOR | VIEW_TYPE_YAW_ONLY |
VIEW_TYPE_COLLIDEMODEL;
//added for ownActor
//Player->ViewIndex = ACTOR_INDEX_PLAYER;
// iNumber = rand();
// iNumber = (((iNumber/RAND_MAX) * 3)+1);
Player->Person = 5;
//0 = Player / 1-4 = Enemy / 5 = Enemy Player über Netzwerk
switch (Player->CurrentWeapon)
{
case 0 :
Player->ViewIndex = ACTOR_INDEX_3PBL;
break;
case 1 :
Player->ViewIndex = ACTOR_INDEX_3PGR;
break;
case 2 :
Player->ViewIndex = ACTOR_INDEX_3PRO;
break;
case 3 :
Player->ViewIndex = ACTOR_INDEX_3PSH;
break;
default :
Player->ViewIndex = ACTOR_INDEX_3PBL;
break;
}
Puhh thats it . You still need Dema.Act for some internal shit (if someone figurers out why mail
me).
But no Matter your Actor's will look like your Models in the files Enemy1.Act to Enemy4.Act and
your Player looks like 1PBl.act and so on.
You can use this code for whatever you wanna do but plese tell me that you do :)
Magicsoft
Thomas Werth
Different Actors & View Weapon (c) 1999 Thomas Werth.