Sycronisation in EntHumanPlayer between Server an Client

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
TheMatrix
Posts: 20
Joined: 2004-10-19, 10:06

Sycronisation in EntHumanPlayer between Server an Client

Post by TheMatrix » 2004-10-27, 21:57

I want to code a feature that when you hit, you are injured, and you will lost live continuely.

So i add a member variable to EntHumanPlayerT Injured, which is set to true in TakeDamage(), and if in PostDraw(), if true, should display the Text "Injured". But this doesnt work, "Injured" will never be displayed
I think its because, TakeDamage() is called ServerSide, so Injured is just true on ServerSide, and on PostDraw() which is called by ClientSide, its still false

So i add a Injured to EntityStateT, because EntityStateT State of EntHumanPlayer because i think this is send from Server to Client,
and change in TakeDamage State.Injured, and in PostDraw i display "Injured" when State.Injured is true

But Now, "Injured" is displayed when i run, and isnt displayed when I stand. I dont understand this :?: :?: :?:
TheMatrix
Posts: 20
Joined: 2004-10-19, 10:06

Post by TheMatrix » 2004-10-27, 22:08

Hmm, i think it was because i wrote Injured between to other Var in EntityStateT and not as last Var, so there were some complications with the Constructor and Copy Constructor

I put Injured as last Var in EntityStateT (after Events), but now, Ca3D returns a error.

So, it isnt possible to change EntityStateT, is it ??

So does anybody know a other solution to my problem with Injured ??
TheMatrix
Posts: 20
Joined: 2004-10-19, 10:06

Post by TheMatrix » 2004-10-27, 22:29

The error was not because the changed EntityStateT. He still occur after i replaced my GameDll.hpp with the original GameDll.hpp. I had to delete all .obj and recompile the code to get Ca3D starting

I will try again with EntityStateT tomorrow, this was a little shock for me. :shock:
User avatar
Shadow
Posts: 195
Joined: 2004-08-28, 06:00
Location: Minesota, USofA
Contact:

Post by Shadow » 2004-10-28, 13:54

good idea, i was thinking about doing this but with the damage varying depending on where u were hit and the damage decreasing over time. but i stoped toying with it cause now im doing a paintball game which is u get shot ur dead!!! muhahahahaha :twisted:
Image
PBX CONTINUES!!!
CLICK HERE!!
TheMatrix
Posts: 20
Joined: 2004-10-19, 10:06

Post by TheMatrix » 2004-10-28, 16:15

I tested it again: Ca3D returns a error when you change EntityStateT

So is there a other way to set vars that are syncronized between Server an Client ??
User avatar
Carsten
Site Admin
Posts: 2160
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Post by Carsten » 2004-10-28, 19:48

TheMatrix wrote:I tested it again: Ca3D returns a error when you change EntityStateT
Please don't. Here is the quote from GameDLL.hpp:

Code: Select all

/********************************************************************************/
/*** This is the single interface through which the engine accesses the game. ***/
/*** It must be implemented by the game dll  >> AND MUST NOT BE MODIFIED << ! ***/
/********************************************************************************/
:P
So is there a other way to set vars that are syncronized between Server an Client ??
Yes, this is actually pretty easy: Simply mis-use one of the existing, but unused vars in EntityState, like for example HaveAmmo[7] (see Constants_AmmoSlots.hpp), or HaveAmmoInWeapons[13] (see Constants_WeaponSlots.hpp).
For improved convenience, you may e.g. define a reference:

Code: Select all

unsigned short& MyState=HaveAmmo[7];
at the beginning of a function, just to get a better name for the variable.

Please do also read the big chuck of comment near the definition of EntHumanPlayerT::Think().
I had to delete all .obj and recompile the code to get Ca3D starting
Well, yes, if the dependency statements in the makefiles fail to update something properly, it is always a good idea to refer to an occasional
wmake -h clean
;)

Hope that helps.
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest