I'm studying game engine architecture as a subclass of a computer game development degree in college right now, having a sharp set of C++ skills is mandatory there. C++ is very strict about what you can and can't do with a type, so to easily remember what type a variable is and save yourself some headaches later, it's common to use some kind of naming convention on your variables. Giving a variable a name like m_pLstGameEntities might seem a bit unnecessary, but in a large system it's very convenient to know that that variable is a member of the current class(m_), is a pointer(p) to a List(Lst), the name itself(GameEntities) telling us that it's used to keep track of all the entities in the game. Keeping a similar syntax is handy to let you remember what GameBryo script variables can be used for, even though we only have 3 types. I myself use b on Booleans(though they are in fact integers), i on shorts and f on floats, mostly to avoid rubbing out my C++ "accent", which happens alarmingly fast, I've already developed a nasty habit of not parenthesing my ifs, forgetting semicolons, etc.
As for script performance, I believe that sacrificing a small bit of performance is in order if it makes debugging easier, and especially if it increases code flexibility. Scripts will never be fast anyway, but a couple of if's extra should not matter. Expensive functions like sqrt, pow, trigonometry stuff, getLOS, etc. should however be used with care. Let's say you want some objects to always be in front and back of the player, as part of a floating ring of stuff or something, etc. This can be made positively devastating with bad scripting, like this stupid and extreme example:
set fFrontOfPlayerX to player.getpos x + sqrt(fVectorX*fVectorX + fVectorY*fVectorY) * sin (player.getangle z)set fFrontOfPlayerY to player.getpos y + sqrt(fVectorX*fVectorX + fVectorY*fVectorY) * cos (player.getangle z)set fBackOfPlayerX to player.getpos x - sqrt(fVectorX*fVectorX + fVectorY*fVectorY) * sin (player.getangle z)set fBackOfPlayerY to player.getpos y - sqrt(fVectorX*fVectorX + fVectorY*fVectorY) * cos (player.getangle z)frontObject.setpos x fFrontOfPlayerXfrontObject.setpos y fFrontOfPlayerYbackObject.setpos x fBackOfPlayerXbackObject.setpos y fBackOfPlayerY
Instead, you should do the expensive functions only once and store their results, cut down on unneeded variables, and avoid multiplication or division wherever you can, like this:
set fDistance to sqrt(fVectorX*fVectorX + fVectorY*fVectorY)set fPlayerYawSine to sin (player.getangle z)set fPlayerYawCosine to cos (player.getangle z)set fStuffPositionX to fDistance*fPlayerYawSineset fStuffPositionY to fDistance*fPlayerYawCosineset fStuffPositionX to fStuffPositionX + player.getpos xset fStuffPositionY to fStuffPositionY + player.getpos yfrontObject.setpos x fStuffPositionXfrontObject.setpos y fStuffPositionYset fStuffPositionX to player.getpos x - fStuffPositionXset fStuffPositionY to player.getpos y - fStuffPositionYbackObject.setpos x fStuffPositionXbackObject.setpos y fStuffPositionY
Also, it's important to remember that when you have a hammer, everything looks like a face. The above result can be achieved without any expensive trigonometry, simply with:
set fStuffPositionX to player.getpos x + fVectorXset fStuffPositionY to player.getpos y + fVectorYfrontObject.setpos x fStuffPositionXfrontObject.setpos y fStuffPositionYset fStuffPositionX to player.getpos x - fStuffPositionXset fStuffPositionY to player.getpos y - fStuffPositionYbackObject.setpos x fStuffPositionXbackObject.setpos y fStuffPositionY