Steve_Yorkshire Posted February 14, 2015 Share Posted February 14, 2015 Okay, here's a question which I could do with some help...I have duplicated a new energy system for shapebase/player. Works just like the original but I wanted more than one. Do I have to add a new "enum PublicConstants" for this? It seems to work fine whether I do or do not.shapeBase.hclass ShapeBase : public GameBase, public ISceneLight { /... public: typedef GameBase Parent; enum PublicConstants { ThreadSequenceBits = 6, MaxSequenceIndex = (1 << ThreadSequenceBits) - 1, EnergyLevelBits = 5, //Energy2LevelBits = 5,//yorks - is it okay to use EnergyLevelBits again? Or give this new value and make ThreadSequenceBits 7? Seems to work either way DamageLevelBits = 6, DamageStateBits = 2, // The thread and image limits should not be changed without // also changing the ShapeBaseMasks enum values declared // further down. MaxSoundThreads = 4, ///< Should be a power of 2 MaxScriptThreads = 4, ///< Should be a power of 2 MaxMountedImages = 4, ///< Should be a power of 2 MaxImageEmitters = 3, NumImageBits = 3, CollisionTimeoutValue = 250 ///< Timeout in ms. }; //...Any explanation welcomed, preferably expressed in an idiot proof manner. ;) Quote Link to comment Share on other sites More sharing options...
Azaezel Posted February 14, 2015 Share Posted February 14, 2015 ok. so the way that works is https://github.com/GarageGames/Torque3D/blob/014b5660146e86a7dab677047c99a7cd10fbbf36/Engine/source/T3D/player.cpp#L6162-L6164 +https://github.com/GarageGames/Torque3D/blob/014b5660146e86a7dab677047c99a7cd10fbbf36/Engine/source/T3D/player.cpp#L6334specify how many bits to pack into the network stream for acceptable precision in terms of notifying the client. If for some reason you needed one energy system to have better fidelity, then they'd need two separate definitions. If not, then no. Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted February 14, 2015 Author Share Posted February 14, 2015 Thanks for the explanation. :) Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted February 14, 2015 Author Share Posted February 14, 2015 @Azaezel Just to check, I take it I needed a new bit so my new Energy2 takes position 7 and the total ThreadSequenceBits also updates to 7?That's what I've done it seems to work fine. enum PublicConstants { ThreadSequenceBits = 7,//yorks was 6 is now 7 MaxSequenceIndex = (1 << ThreadSequenceBits) - 1, EnergyLevelBits = 5, Energy2LevelBits = 7,//yorks - added and given the next available bit which is 7 DamageLevelBits = 6, DamageStateBits = 2, //... Quote Link to comment Share on other sites More sharing options...
Azaezel Posted February 15, 2015 Share Posted February 15, 2015 Not quite sure... If you're using the same general setup as the other energy system, say... stream->writeFloat(getEnergy2Level() / mDataBlock->maxEnergy2, Energy2LevelBits); what you've written there will send 7 bits instead of 5. same with the threadsequence end. was 6 bits, now 7. Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted February 15, 2015 Author Share Posted February 15, 2015 Yeah that's I did.I wasn't sure if it was sending the bits as the amount of bits or whether the bits were numbered in order (like an array) with energy being number 5, health numer 6 etc, --- so I did it like the later.I think it doesn't do that though does it? :oops: Quote Link to comment Share on other sites More sharing options...
Azaezel Posted February 15, 2015 Share Posted February 15, 2015 nah, it's size. Quote Link to comment Share on other sites More sharing options...
Atomic Walrus Posted February 23, 2015 Share Posted February 23, 2015 Just a heads up on the existing energy system: It's part of the client-predictive networking and was intended to be used mainly for energy related to movement (or other client-predictable events).Since it's part of writePacketData it will:-Only be updated to controlling clients (during a correction) and-Trigger correction packets if modified by a server-initiated event (as opposed to a client-predictable event initiated by a "move").+Allow movement to be energy-dependent without worrying about being out of sync with the server. For example it would be network-safe to scale player movement speed by current energy level.It's not the best choice if you're doing script-based abilities that drain energy, want a pool for weapons (not client predicted in stock), shield energy that drains when you take damage, etc. It will work but the correction packets will cause movement stuttering and waste bandwidth (sending the whole correction packet when all the client needed was 5 bits). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.