trying to duplicate the player class. . .
by Anthony Rosenbaum · in General Discussion · 12/12/2001 (11:31 pm) · 6 replies
I was replacing the original player class with a duplicate... replacing "player" with "newplayer" anyway I wondering in the function of the player class there is this one
Anthony
function Armor::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
}my question do i replace it like thisfunction Armor::onRemove(%this, %obj)
{
if (%obj.client.newplayer == %obj)
%obj.client.newplayer = 0;
}or is player here something different . . . I'm still new to C++ and programming in general I just wanna keep things simple . . . .to me this looks like the same as calling player object . . . but then is this object one within the client class?. . . that would be hard coded right?!?!?! Anthony
About the author
#2
2. This is correct, same reason as above!
//hyzen
12/13/2001 (10:12 am)
1. No, you shouldn't replace this "player", because it's merely a variable in the "client" object.2. This is correct, same reason as above!
//hyzen
#4
I just made a copy of the player.cs, called newplayer.cs and changed all "Player" in it to "newPlayer".
Then in game.cs, createGame() I exec newplayer.cs instead of player.cs.
At last, I made the following changes in weapon.cs:
---old---
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
if (%shape.getClassName() $= "Player" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
---new---
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
if (%shape.getClassName() $= "newPlayer" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
---end---
Tell me if you find other things that should be altered!
//hyzen
12/14/2001 (1:44 am)
I don't know, but I didn't do anything with it and it works fine for me!I just made a copy of the player.cs, called newplayer.cs and changed all "Player" in it to "newPlayer".
Then in game.cs, createGame() I exec newplayer.cs instead of player.cs.
At last, I made the following changes in weapon.cs:
---old---
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
if (%shape.getClassName() $= "Player" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
---new---
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
if (%shape.getClassName() $= "newPlayer" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
---end---
Tell me if you find other things that should be altered!
//hyzen
#5
Anthony
12/14/2001 (1:59 pm)
i still wanna keep the exitsting class. . so I was wondering if actually ther weapon function should be function Weapon::onPickup(%this, %obj, %shape, %amount)
{
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
if (%shape.getClassName() $= "newPlayer" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
if (%shape.getClassName() $= "Player" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}basically adding the original if statment. . . this is still valid. rightAnthony
#6
12/14/2001 (2:03 pm)
Yepp, that is actually how I did it too. :)
Associate Anthony Rosenbaum
[code]
function GameConnection::createPlayer(%this, %spawnPoint)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
%player = new newPlayer() {
dataBlock = LightMaleHumanArmor;
client = %this;
};
[\code]
I changed the lower portion but what about the first if statment would that be changed too?