}
// clamp strength
- if (strength < 0)
+ if (strength < 0) {
strength = 0;
- if (strength > 1)
+ }
+ if (strength > 1) {
strength = 1;
+ }
length -= (length - relaxlength) * (1 - strength) * multiplier * 10000;
length -= (length - targetlength) * strength * multiplier * 10000;
- if (strength == 0)
+ if (strength == 0) {
length = relaxlength;
+ }
- if ((relaxlength - length > 0 && relaxlength - oldlength < 0) || (relaxlength - length < 0 && relaxlength - oldlength > 0))
+ if ((relaxlength - length > 0 && relaxlength - oldlength < 0) || (relaxlength - length < 0 && relaxlength - oldlength > 0)) {
length = relaxlength;
+ }
// clamp length
- if (length < minlength)
+ if (length < minlength) {
length = minlength;
- if (length > maxlength)
+ }
+ if (length > maxlength) {
length = maxlength;
+ }
- if (length == relaxlength)
+ if (length == relaxlength) {
return;
+ }
// relax muscle?
temp = jointPos(rightknee) - (jointPos(righthip) + jointPos(rightankle)) / 2;
while (normaldotproduct(temp, lowforward) > -.1 && !sphere_line_intersection(&jointPos(righthip), &jointPos(rightankle), &jointPos(rightknee), &r)) {
jointPos(rightknee) -= lowforward * .05;
- if (spinny)
+ if (spinny) {
jointVel(rightknee) -= lowforward * .05 / multiplier / 4;
- else
+ } else {
jointVel(rightknee) -= lowforward * .05;
+ }
jointPos(rightankle) += lowforward * .025;
- if (spinny)
+ if (spinny) {
jointVel(rightankle) += lowforward * .025 / multiplier / 4;
- else
+ } else {
jointVel(rightankle) += lowforward * .25;
+ }
jointPos(righthip) += lowforward * .025;
- if (spinny)
+ if (spinny) {
jointVel(righthip) += lowforward * .025 / multiplier / 4;
- else
+ } else {
jointVel(righthip) += lowforward * .025;
+ }
temp = jointPos(rightknee) - (jointPos(righthip) + jointPos(rightankle)) / 2;
}
}
temp = jointPos(leftknee) - (jointPos(lefthip) + jointPos(leftankle)) / 2;
while (normaldotproduct(temp, lowforward) > -.1 && !sphere_line_intersection(&jointPos(lefthip), &jointPos(leftankle), &jointPos(leftknee), &r)) {
jointPos(leftknee) -= lowforward * .05;
- if (spinny)
+ if (spinny) {
jointVel(leftknee) -= lowforward * .05 / multiplier / 4;
- else
+ } else {
jointVel(leftknee) -= lowforward * .05;
+ }
jointPos(leftankle) += lowforward * .025;
- if (spinny)
+ if (spinny) {
jointVel(leftankle) += lowforward * .025 / multiplier / 4;
- else
+ } else {
jointVel(leftankle) += lowforward * .25;
+ }
jointPos(lefthip) += lowforward * .025;
- if (spinny)
+ if (spinny) {
jointVel(lefthip) += lowforward * .025 / multiplier / 4;
- else
+ } else {
jointVel(lefthip) += lowforward * .025;
+ }
temp = jointPos(leftknee) - (jointPos(lefthip) + jointPos(leftankle)) / 2;
}
}
for (i = 0; i < joints.size(); i++) {
- if (joints[i].locked && !spinny && findLengthfast(&joints[i].velocity) > 320)
+ if (joints[i].locked && !spinny && findLengthfast(&joints[i].velocity) > 320) {
joints[i].locked = 0;
- if (spinny && findLengthfast(&joints[i].velocity) > 600)
+ }
+ if (spinny && findLengthfast(&joints[i].velocity) > 600) {
joints[i].locked = 0;
+ }
if (joints[i].delay > 0) {
bool freely = true;
for (unsigned j = 0; j < joints.size(); j++) {
- if (joints[j].locked)
+ if (joints[j].locked) {
freely = false;
+ }
}
- if (freely)
+ if (freely) {
joints[i].delay -= multiplier * 3;
+ }
}
}
terrainnormal = terrain.getNormal(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z);
ReflectVector(&joints[i].velocity, &terrainnormal);
bounceness = terrainnormal * findLength(&joints[i].velocity) * (abs(normaldotproduct(joints[i].velocity, terrainnormal)));
- if (!joints[i].locked)
+ if (!joints[i].locked) {
damage += findLengthfast(&bounceness) / 4000;
- if (findLengthfast(&joints[i].velocity) < findLengthfast(&bounceness))
+ }
+ if (findLengthfast(&joints[i].velocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(joints[i].velocity, terrainnormal));
joints[i].velocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
joints[i].velocity *= 1 - friction * frictionness;
- else
+ } else {
joints[i].velocity = 0;
+ }
- if (!Tutorial::active || id == 0)
+ if (!Tutorial::active || id == 0) {
if (findLengthfast(&bounceness) > 8000 && breaking) {
// FIXME: this crashes because k is not initialized!
// to reproduce, type 'wolfie' in console and play a while
addEnvSound(*coords, 64);
}
+ }
if (findLengthfast(&bounceness) > 2500) {
Normalise(&bounceness);
joints[i].velocity = joints[i].oldvelocity;
}
- if (joints[i].locked == 0)
- if (findLengthfast(&joints[i].velocity) < 1)
+ if (joints[i].locked == 0) {
+ if (findLengthfast(&joints[i].velocity) < 1) {
joints[i].locked = 1;
+ }
+ }
if (environment == snowyenvironment && findLengthfast(&bounceness) > 500 && terrain.getOpacity(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z) < .2) {
terrainlight = terrain.getLighting(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z);
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7);
- if (detail == 2)
+ if (detail == 2) {
terrain.MakeDecal(bodyprintdecal, joints[i].position * (*scale) + *coords, .4, .4, 0);
+ }
} else if (environment == desertenvironment && findLengthfast(&bounceness) > 500 && terrain.getOpacity(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z) < .2) {
terrainlight = terrain.getLighting(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z);
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7);
else if (environment == grassyenvironment && findLengthfast(&bounceness) > 500 && terrain.getOpacity(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z) < .2) {
terrainlight = terrain.getLighting(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z);
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5);
- } else if (findLengthfast(&bounceness) > 500)
+ } else if (findLengthfast(&bounceness) > 500) {
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, terrainlight.x, terrainlight.y, terrainlight.z, .5, .2);
+ }
joints[i].position.y = (terrain.getHeight(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z) + groundlevel - coords->y) / (*scale);
- if (longdead > 100)
+ if (longdead > 100) {
broken = 1;
+ }
}
for (unsigned int m = 0; m < terrain.patchobjects[whichpatchx][whichpatchz].size(); m++) {
unsigned int k = terrain.patchobjects[whichpatchx][whichpatchz][m];
}
terrainnormal = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0) * -1;
- if (terrainnormal.y > .8)
+ if (terrainnormal.y > .8) {
freefall = 0;
+ }
bounceness = terrainnormal * findLength(&joints[i].velocity) * (abs(normaldotproduct(joints[i].velocity, terrainnormal)));
if (findLengthfast(&joints[i].velocity) > findLengthfast(&joints[i].oldvelocity)) {
bounceness = 0;
joints[i].velocity = joints[i].oldvelocity;
}
- if (!Tutorial::active || id == 0)
+ if (!Tutorial::active || id == 0) {
if (findLengthfast(&bounceness) > 4000 && breaking) {
Object::objects[k]->model.MakeDecal(breakdecal, DoRotation(temp - Object::objects[k]->position, 0, -Object::objects[k]->yaw, 0), .4, .5, Random() % 360);
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, 1, 1, 1, 4, .2);
addEnvSound(*coords, 64);
}
+ }
if (Object::objects[k]->type == treetrunktype) {
Object::objects[k]->rotx += joints[i].velocity.x * multiplier * .4;
Object::objects[k]->roty += joints[i].velocity.z * multiplier * .4;
Object::objects[k + 1]->rotx += joints[i].velocity.x * multiplier * .4;
Object::objects[k + 1]->roty += joints[i].velocity.z * multiplier * .4;
}
- if (!joints[i].locked)
+ if (!joints[i].locked) {
damage += findLengthfast(&bounceness) / 2500;
+ }
ReflectVector(&joints[i].velocity, &terrainnormal);
frictionness = abs(normaldotproduct(joints[i].velocity, terrainnormal));
joints[i].velocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
joints[i].velocity *= 1 - friction * frictionness;
- else
+ } else {
joints[i].velocity = 0;
+ }
if (findLengthfast(&bounceness) > 2500) {
Normalise(&bounceness);
bounceness = bounceness * 50;
}
joints[i].velocity += bounceness * elasticity;
- if (!joints[i].locked)
+ if (!joints[i].locked) {
if (findLengthfast(&joints[i].velocity) < 1) {
joints[i].locked = 1;
}
- if (findLengthfast(&bounceness) > 500)
+ }
+ if (findLengthfast(&bounceness) > 500) {
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, 1, 1, 1, .5, .2);
+ }
joints[i].position = (temp - *coords) / (*scale) + terrainnormal * .005;
- if (longdead > 100)
+ if (longdead > 100) {
broken = 1;
+ }
}
}
}
if (whichhit != -1) {
joints[jointlabels[whichjointendarray[i]]].position = (end - *coords) / (*scale);
for (unsigned j = 0; j < muscles.size(); j++) {
- if ((muscles[j].parent1->label == whichjointstartarray[i] && muscles[j].parent2->label == whichjointendarray[i]) || (muscles[j].parent2->label == whichjointstartarray[i] && muscles[j].parent1->label == whichjointendarray[i]))
+ if ((muscles[j].parent1->label == whichjointstartarray[i] && muscles[j].parent2->label == whichjointendarray[i]) || (muscles[j].parent2->label == whichjointstartarray[i] && muscles[j].parent1->label == whichjointendarray[i])) {
muscles[j].DoConstraint(spinny);
+ }
}
}
}
}
joints[i].position.y += groundlevel;
joints[i].mass = 1;
- if (joints[i].label == lefthip || joints[i].label == leftknee || joints[i].label == leftankle || joints[i].label == righthip || joints[i].label == rightknee || joints[i].label == rightankle)
+ if (joints[i].label == lefthip || joints[i].label == leftknee || joints[i].label == leftankle || joints[i].label == righthip || joints[i].label == rightknee || joints[i].label == rightankle) {
joints[i].mass = 2;
+ }
if (joints[i].locked) {
joints[i].mass = 4;
}
if (!free) {
for (i = 0; i < muscles.size(); i++) {
- if (muscles[i].type == boneconnect)
+ if (muscles[i].type == boneconnect) {
muscles[i].DoConstraint(0);
+ }
}
}
p1 = muscles[which].parent1->position;
p2 = muscles[which].parent2->position;
dist = findDistance(&p1, &p2);
- if (p1.y - p2.y <= dist)
+ if (p1.y - p2.y <= dist) {
muscles[which].rotate2 = asin((p1.y - p2.y) / dist);
- if (p1.y - p2.y > dist)
+ }
+ if (p1.y - p2.y > dist) {
muscles[which].rotate2 = asin(1.f);
+ }
muscles[which].rotate2 *= 360.0 / 6.2831853;
p1.y = 0;
p2.y = 0;
dist = findDistance(&p1, &p2);
- if (p1.z - p2.z <= dist)
+ if (p1.z - p2.z <= dist) {
muscles[which].rotate1 = acos((p1.z - p2.z) / dist);
- if (p1.z - p2.z > dist)
+ }
+ if (p1.z - p2.z > dist) {
muscles[which].rotate1 = acos(1.f);
+ }
muscles[which].rotate1 *= 360.0 / 6.2831853;
- if (p1.x > p2.x)
+ if (p1.x > p2.x) {
muscles[which].rotate1 = 360 - muscles[which].rotate1;
- if (!isnormal(muscles[which].rotate1))
+ }
+ if (!isnormal(muscles[which].rotate1)) {
muscles[which].rotate1 = 0;
- if (!isnormal(muscles[which].rotate2))
+ }
+ if (!isnormal(muscles[which].rotate2)) {
muscles[which].rotate2 = 0;
+ }
const int label1 = muscles[which].parent1->label;
const int label2 = muscles[which].parent2->label;
fwd = specialforward[4];
break;
default:
- if (muscles[which].parent1->lower)
+ if (muscles[which].parent1->lower) {
fwd = lowforward;
- else
+ } else {
fwd = forward;
+ }
break;
}
fwd = DoRotation(fwd, 0, 0, muscles[which].rotate2 - 90);
fwd.y = 0;
fwd /= findLength(&fwd);
- if (fwd.z <= 1 && fwd.z >= -1)
+ if (fwd.z <= 1 && fwd.z >= -1) {
muscles[which].rotate3 = acos(0 - fwd.z);
- else
+ } else {
muscles[which].rotate3 = acos(-1.f);
+ }
muscles[which].rotate3 *= 360.0 / 6.2831853;
- if (0 > fwd.x)
+ if (0 > fwd.x) {
muscles[which].rotate3 = 360 - muscles[which].rotate3;
- if (!isnormal(muscles[which].rotate3))
+ }
+ if (!isnormal(muscles[which].rotate3)) {
muscles[which].rotate3 = 0;
+ }
}
/* EFFECT
drawmodellow.Rotate(180, 0, 0);
drawmodellow.Scale(.04, .04, .04);
drawmodellow.FlipTexCoords();
- if (Tutorial::active && id != 0)
+ if (Tutorial::active && id != 0) {
drawmodellow.UniformTexCoords();
- if (Tutorial::active && id != 0)
+ }
+ if (Tutorial::active && id != 0) {
drawmodellow.ScaleTexCoords(0.1);
+ }
drawmodellow.CalculateNormals(0);
if (clothes) {
for (int i = 0; i < num_joints; i++) {
for (j = 0; j < num_joints; j++) {
- if (joints[i].label == j)
+ if (joints[i].label == j) {
jointlabels[j] = i;
+ }
}
}
footstepsound4 = footstepst2;
// Huh?
// OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL);
- for (int i = stream_firesound; i <= stream_menutheme; i++)
+ for (int i = stream_firesound; i <= stream_menutheme; i++) {
OPENAL_Stream_SetMode(samp[i], OPENAL_LOOP_NORMAL);
+ }
}
void addEnvSound(XYZ coords, float vol, float life)
chan->position[2] = z;
OPENAL_SAMPLE* sptr = chan->sample;
- if (sptr == NULL)
+ if (sptr == NULL) {
return;
+ }
const ALuint sid = chan->sid;
const bool no_attenuate = sptr->is2d;
AL_API void OPENAL_3D_Listener_SetAttributes(const float* pos, const float*, float fx, float fy, float fz, float tx, float ty, float tz)
{
- if (!initialized)
+ if (!initialized) {
return;
+ }
if (pos != NULL) {
alListener3f(AL_POSITION, pos[0], pos[1], -pos[2]);
listener_position[0] = pos[0];
AL_API signed char OPENAL_3D_SetAttributes(int channel, const float* pos)
{
- if (!initialized)
+ if (!initialized) {
return false;
- if ((channel < 0) || (channel >= (int)num_channels))
+ }
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
+ }
- if (pos != NULL)
+ if (pos != NULL) {
set_channel_position(channel, pos[0], pos[1], -pos[2]);
+ }
// we ignore velocity, since doppler's broken in the Linux AL at the moment...
AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ& pos)
{
- if (!initialized)
+ if (!initialized) {
return false;
- if ((channel < 0) || (channel >= (int)num_channels))
+ }
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
+ }
set_channel_position(channel, pos.x, pos.y, -pos.z);
AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags)
{
- if (initialized)
+ if (initialized) {
return false;
- if (maxsoftwarechannels == 0)
+ }
+ if (maxsoftwarechannels == 0) {
return false;
+ }
- if (flags != 0) // unsupported.
+ if (flags != 0) { // unsupported.
return false;
+ }
ALCdevice* dev = alcOpenDevice(NULL);
- if (!dev)
+ if (!dev) {
return false;
+ }
ALint caps[] = { ALC_FREQUENCY, mixrate, 0 };
ALCcontext* ctx = alcCreateContext(dev, caps);
num_channels = maxsoftwarechannels;
impl_channels = new OPENAL_Channels[maxsoftwarechannels];
memset(impl_channels, '\0', sizeof(OPENAL_Channels) * num_channels);
- for (unsigned i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++) {
alGenSources(1, &impl_channels[i].sid); // !!! FIXME: verify this didn't fail!
+ }
initialized = true;
return true;
AL_API void OPENAL_Close()
{
- if (!initialized)
+ if (!initialized) {
return;
+ }
ALCcontext* ctx = alcGetCurrentContext();
if (ctx) {
static OPENAL_SAMPLE* OPENAL_GetCurrentSample(int channel)
{
- if (!initialized)
+ if (!initialized) {
return NULL;
- if ((channel < 0) || (channel >= (int)num_channels))
+ }
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return NULL;
+ }
return impl_channels[channel].sample;
}
static signed char OPENAL_GetPaused(int channel)
{
- if (!initialized)
+ if (!initialized) {
return false;
- if ((channel < 0) || (channel >= (int)num_channels))
+ }
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
- if (impl_channels[channel].startpaused)
+ }
+ if (impl_channels[channel].startpaused) {
return (true);
+ }
ALint state = 0;
alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
static unsigned int OPENAL_GetLoopMode(int channel)
{
- if (!initialized)
+ if (!initialized) {
return 0;
- if ((channel < 0) || (channel >= (int)num_channels))
+ }
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return 0;
+ }
ALint loop = 0;
alGetSourceiv(impl_channels[channel].sid, AL_LOOPING, &loop);
- if (loop)
+ if (loop) {
return (OPENAL_LOOP_NORMAL);
+ }
return OPENAL_LOOP_OFF;
}
static signed char OPENAL_IsPlaying(int channel)
{
- if (!initialized)
+ if (!initialized) {
return false;
- if ((channel < 0) || (channel >= (int)num_channels))
+ }
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
+ }
ALint state = 0;
alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
return ((state == AL_PLAYING) ? true : false);
static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused)
{
- if (!initialized)
+ if (!initialized) {
return -1;
- if (sptr == NULL)
+ }
+ if (sptr == NULL) {
return -1;
- if (dsp != NULL)
+ }
+ if (dsp != NULL) {
return -1;
+ }
if (channel == OPENAL_FREE) {
for (unsigned i = 0; i < num_channels; i++) {
ALint state = 0;
}
}
- if ((channel < 0) || (channel >= (int)num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return -1;
+ }
alSourceStop(impl_channels[channel].sid);
impl_channels[channel].sample = sptr;
alSourcei(impl_channels[channel].sid, AL_BUFFER, sptr->bid);
set_channel_position(channel, 0.0f, 0.0f, 0.0f);
impl_channels[channel].startpaused = ((startpaused) ? true : false);
- if (!startpaused)
+ if (!startpaused) {
alSourcePlay(impl_channels[channel].sid);
+ }
return channel;
}
char* fname = (char*)alloca(strlen(_fname) + 16);
strcpy(fname, _fname);
char* ptr = strchr(fname, '.');
- if (ptr)
+ if (ptr) {
*ptr = '\0';
+ }
strcat(fname, ".ogg");
// just in case...
FILE* io = fopen(fname, "rb");
- if (io == NULL)
+ if (io == NULL) {
return NULL;
+ }
ALubyte* retval = NULL;
AL_API OPENAL_SAMPLE* OPENAL_Sample_Load(int index, const char* name_or_data, unsigned int mode, int offset, int length)
{
- if (!initialized)
+ if (!initialized) {
return NULL;
- if (index != OPENAL_FREE)
+ }
+ if (index != OPENAL_FREE) {
return NULL; // this is all the game does...
- if (offset != 0)
+ }
+ if (offset != 0) {
return NULL; // this is all the game does...
- if (length != 0)
+ }
+ if (length != 0) {
return NULL; // this is all the game does...
- if ((mode != OPENAL_HW3D) && (mode != OPENAL_2D))
+ }
+ if ((mode != OPENAL_HW3D) && (mode != OPENAL_2D)) {
return NULL; // this is all the game does...
+ }
OPENAL_SAMPLE* retval = NULL;
ALenum format = AL_NONE;
ALsizei size = 0;
ALuint frequency = 0;
void* data = decode_to_pcm(name_or_data, format, size, frequency);
- if (data == NULL)
+ if (data == NULL) {
return NULL;
+ }
ALuint bid = 0;
alGetError();
retval->mode = OPENAL_LOOP_OFF;
retval->is2d = (mode == OPENAL_2D);
retval->name = new char[strlen(name_or_data) + 1];
- if (retval->name)
+ if (retval->name) {
strcpy(retval->name, name_or_data);
+ }
}
free(data);
AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE* sptr)
{
- if (!initialized)
+ if (!initialized) {
return;
+ }
if (sptr) {
for (unsigned i = 0; i < num_channels; i++) {
if (impl_channels[i].sample == sptr) {
static signed char OPENAL_Sample_SetMode(OPENAL_SAMPLE* sptr, unsigned int mode)
{
- if (!initialized)
+ if (!initialized) {
return false;
- if ((mode != OPENAL_LOOP_NORMAL) && (mode != OPENAL_LOOP_OFF))
+ }
+ if ((mode != OPENAL_LOOP_NORMAL) && (mode != OPENAL_LOOP_OFF)) {
return false;
- if (!sptr)
+ }
+ if (!sptr) {
return false;
+ }
sptr->mode = mode;
return true;
}
AL_API signed char OPENAL_SetFrequency(int channel, bool slomo)
{
- if (!initialized)
+ if (!initialized) {
return false;
+ }
if (channel == OPENAL_ALL) {
- for (unsigned i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++) {
OPENAL_SetFrequency(i, slomo);
+ }
return true;
}
- if ((channel < 0) || (channel >= (int)num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
- if (slomo)
+ }
+ if (slomo) {
alSourcef(impl_channels[channel].sid, AL_PITCH, ((ALfloat)slomofreq) / 44100.0f);
- else
+ } else {
alSourcef(impl_channels[channel].sid, AL_PITCH, 1.0f);
+ }
return true;
}
AL_API signed char OPENAL_SetVolume(int channel, int vol)
{
- if (!initialized)
+ if (!initialized) {
return false;
+ }
if (channel == OPENAL_ALL) {
- for (unsigned i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++) {
OPENAL_SetVolume(i, vol);
+ }
return true;
}
- if ((channel < 0) || (channel >= (int)num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
+ }
- if (vol < 0)
+ if (vol < 0) {
vol = 0;
- else if (vol > 255)
+ } else if (vol > 255) {
vol = 255;
+ }
ALfloat gain = ((ALfloat)vol) / 255.0f;
alSourcef(impl_channels[channel].sid, AL_GAIN, gain);
return true;
AL_API signed char OPENAL_SetPaused(int channel, signed char paused)
{
- if (!initialized)
+ if (!initialized) {
return false;
+ }
if (channel == OPENAL_ALL) {
- for (unsigned i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++) {
OPENAL_SetPaused(i, paused);
+ }
return true;
}
- if ((channel < 0) || (channel >= (int)num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
+ }
ALint state = 0;
- if (impl_channels[channel].startpaused)
+ if (impl_channels[channel].startpaused) {
state = AL_PAUSED;
- else
+ } else {
alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
+ }
- if ((paused) && (state == AL_PLAYING))
+ if ((paused) && (state == AL_PLAYING)) {
alSourcePause(impl_channels[channel].sid);
- else if ((!paused) && (state == AL_PAUSED)) {
+ } else if ((!paused) && (state == AL_PAUSED)) {
alSourcePlay(impl_channels[channel].sid);
impl_channels[channel].startpaused = false;
}
AL_API void OPENAL_SetSFXMasterVolume(int volume)
{
- if (!initialized)
+ if (!initialized) {
return;
+ }
ALfloat gain = ((ALfloat)volume) / 255.0f;
alListenerf(AL_GAIN, gain);
}
AL_API signed char OPENAL_StopSound(int channel)
{
- if (!initialized)
+ if (!initialized) {
return false;
+ }
if (channel == OPENAL_ALL) {
- for (unsigned i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++) {
OPENAL_StopSound(i);
+ }
return true;
}
- if ((channel < 0) || (channel >= (int)num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels)) {
return false;
+ }
alSourceStop(impl_channels[channel].sid);
impl_channels[channel].startpaused = false;
return true;
static OPENAL_SAMPLE* OPENAL_Stream_GetSample(OPENAL_STREAM* stream)
{
- if (!initialized)
+ if (!initialized) {
return NULL;
+ }
return (OPENAL_SAMPLE*)stream;
}
static signed char OPENAL_Stream_Stop(OPENAL_STREAM* stream)
{
- if (!initialized)
+ if (!initialized) {
return false;
+ }
for (unsigned i = 0; i < num_channels; i++) {
if (impl_channels[i].sample == (OPENAL_SAMPLE*)stream) {
alSourceStop(impl_channels[i].sid);
AL_API void OPENAL_Update()
{
- if (!initialized)
+ if (!initialized) {
return;
+ }
alcProcessContext(alcGetCurrentContext());
}
Person::players[pnum]->clothestintb[id] = tintb;
Person::players[pnum]->numclothes++;
- if (!Person::players[pnum]->addClothes(id))
+ if (!Person::players[pnum]->addClothes(id)) {
return;
+ }
Person::players[pnum]->DoMipmaps();
}
fpackf(tfile, "Bf Bf Bf", skyboxlightr, skyboxlightg, skyboxlightb);
fpackf(tfile, "Bf Bf Bf Bf Bf Bi", Person::players[0]->coords.x, Person::players[0]->coords.y, Person::players[0]->coords.z,
Person::players[0]->yaw, Person::players[0]->targetyaw, Person::players[0]->num_weapons);
- if (Person::players[0]->num_weapons > 0 && Person::players[0]->num_weapons < 5)
- for (int j = 0; j < Person::players[0]->num_weapons; j++)
+ if (Person::players[0]->num_weapons > 0 && Person::players[0]->num_weapons < 5) {
+ for (int j = 0; j < Person::players[0]->num_weapons; j++) {
fpackf(tfile, "Bi", weapons[Person::players[0]->weaponids[j]].getType());
+ }
+ }
fpackf(tfile, "Bf Bf Bf", Person::players[0]->armorhead, Person::players[0]->armorhigh, Person::players[0]->armorlow);
fpackf(tfile, "Bf Bf Bf", Person::players[0]->protectionhead, Person::players[0]->protectionhigh, Person::players[0]->protectionlow);
for (int k = 0; k < Person::players[0]->numclothes; k++) {
int templength = strlen(Person::players[0]->clothes[k]);
fpackf(tfile, "Bi", templength);
- for (int l = 0; l < templength; l++)
+ for (int l = 0; l < templength; l++) {
fpackf(tfile, "Bb", Person::players[0]->clothes[k][l]);
+ }
fpackf(tfile, "Bf Bf Bf", Person::players[0]->clothestintr[k], Person::players[0]->clothestintg[k], Person::players[0]->clothestintb[k]);
}
fpackf(tfile, "Bi Bf Bf Bf Bf", Hotspot::hotspots[i].type, Hotspot::hotspots[i].size, Hotspot::hotspots[i].position.x, Hotspot::hotspots[i].position.y, Hotspot::hotspots[i].position.z);
int templength = strlen(Hotspot::hotspots[i].text);
fpackf(tfile, "Bi", templength);
- for (int l = 0; l < templength; l++)
+ for (int l = 0; l < templength; l++) {
fpackf(tfile, "Bb", Hotspot::hotspots[i].text[l]);
+ }
}
fpackf(tfile, "Bi", Person::players.size());
fpackf(tfile, "Bi Bi Bf Bf Bf Bi Bi Bf Bb Bf", Person::players[j]->whichskin, Person::players[j]->creature,
Person::players[j]->coords.x, Person::players[j]->coords.y, Person::players[j]->coords.z,
Person::players[j]->num_weapons, Person::players[j]->howactive, Person::players[j]->scale, Person::players[j]->immobile, Person::players[j]->yaw);
- if (Person::players[j]->num_weapons < 5)
- for (int k = 0; k < Person::players[j]->num_weapons; k++)
+ if (Person::players[j]->num_weapons < 5) {
+ for (int k = 0; k < Person::players[j]->num_weapons; k++) {
fpackf(tfile, "Bi", weapons[Person::players[j]->weaponids[k]].getType());
+ }
+ }
if (Person::players[j]->numwaypoints < 30) {
fpackf(tfile, "Bi", Person::players[j]->numwaypoints);
for (int k = 0; k < Person::players[j]->numwaypoints; k++) {
fpackf(tfile, "Bf Bf Bf Bf", headprop, bodyprop, armprop, legprop);
fpackf(tfile, "Bi", Person::players[j]->numclothes);
- if (Person::players[j]->numclothes)
+ if (Person::players[j]->numclothes) {
for (int k = 0; k < Person::players[j]->numclothes; k++) {
int templength;
templength = strlen(Person::players[j]->clothes[k]);
fpackf(tfile, "Bi", templength);
- for (int l = 0; l < templength; l++)
+ for (int l = 0; l < templength; l++) {
fpackf(tfile, "Bb", Person::players[j]->clothes[k][l]);
+ }
fpackf(tfile, "Bf Bf Bf", Person::players[j]->clothestintr[k], Person::players[j]->clothestintg[k], Person::players[j]->clothestintb[k]);
}
+ }
}
fpackf(tfile, "Bi", numpathpoints);
for (int j = 0; j < numpathpoints; j++) {
fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
- for (int k = 0; k < numpathpointconnect[j]; k++)
+ for (int k = 0; k < numpathpointconnect[j]; k++) {
fpackf(tfile, "Bi", pathpointconnect[j][k]);
+ }
}
fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
void ch_sizenear(const char* args)
{
int closest = findClosestPlayer();
- if (closest >= 0)
+ if (closest >= 0) {
Person::players[closest]->scale = atof(args) * .2;
+ }
}
void ch_proportion(const char* args)
void ch_proportionnear(const char* args)
{
int closest = findClosestPlayer();
- if (closest >= 0)
+ if (closest >= 0) {
set_proportion(closest, args);
+ }
}
void ch_protection(const char* args)
void ch_protectionnear(const char* args)
{
int closest = findClosestPlayer();
- if (closest >= 0)
+ if (closest >= 0) {
set_protection(closest, args);
+ }
}
void ch_armor(const char* args)
void ch_armornear(const char* args)
{
int closest = findClosestPlayer();
- if (closest >= 0)
+ if (closest >= 0) {
set_armor(closest, args);
+ }
}
void ch_protectionreset(const char*)
void ch_noclothesnear(const char* args)
{
int closest = findClosestPlayer();
- if (closest >= 0)
+ if (closest >= 0) {
set_noclothes(closest, args);
+ }
}
void ch_clothes(const char* args)
void ch_clothesnear(const char* args)
{
int closest = findClosestPlayer();
- if (closest >= 0)
+ if (closest >= 0) {
set_clothes(closest, args);
+ }
}
void ch_belt(const char*)
void ch_sizemin(const char*)
{
- for (unsigned i = 1; i < Person::players.size(); i++)
- if (Person::players[i]->scale < 0.8 * 0.2)
+ for (unsigned i = 1; i < Person::players.size(); i++) {
+ if (Person::players[i]->scale < 0.8 * 0.2) {
Person::players[i]->scale = 0.8 * 0.2;
+ }
+ }
}
void ch_tutorial(const char* args)
void ch_type(const char* args)
{
int n = sizeof(editortypenames) / sizeof(editortypenames[0]);
- for (int i = 0; i < n; i++)
+ for (int i = 0; i < n; i++) {
if (stripfx(args, editortypenames[i])) {
editoractive = i;
break;
}
+ }
}
void ch_path(const char* args)
{
unsigned int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
- for (unsigned int i = 0; i < n; i++)
+ for (unsigned int i = 0; i < n; i++) {
if (stripfx(args, pathtypenames[i])) {
editorpathtype = i;
break;
}
+ }
}
void ch_hs(const char* args)
void ch_allimmobile(const char*)
{
- for (unsigned i = 1; i < Person::players.size(); i++)
+ for (unsigned i = 1; i < Person::players.size(); i++) {
Person::players[i]->immobile = 1;
+ }
}
void ch_mobile(const char*)
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
- if (skyboxtexture)
+ if (skyboxtexture) {
glEnable(GL_TEXTURE_2D);
+ }
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
front.bind();
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
starty = i;
}
- if (startx < 0)
+ if (startx < 0) {
startx = 0;
- if (starty < 0)
+ }
+ if (starty < 0) {
starty = 0;
- if (endx > size - 1)
+ }
+ if (endx > size - 1) {
endx = size - 1;
- if (endy > size - 1)
+ }
+ if (endy > size - 1) {
endy = size - 1;
+ }
for (i = startx; i <= endx; i++) {
for (j = starty; j <= endy; j++) {
highest = -1000;
lowest = 1000;
for (k = 0; k < 2; k++) {
- if (heightmap[i + k][j] > highest)
+ if (heightmap[i + k][j] > highest) {
highest = heightmap[i + k][j];
- if (heightmap[i + k][j] < lowest)
+ }
+ if (heightmap[i + k][j] < lowest) {
lowest = heightmap[i + k][j];
- if (heightmap[i + k][j + 1] > highest)
+ }
+ if (heightmap[i + k][j + 1] > highest) {
highest = heightmap[i + k][j + 1];
- if (heightmap[i + k][j + 1] < lowest)
+ }
+ if (heightmap[i + k][j + 1] < lowest) {
lowest = heightmap[i + k][j + 1];
+ }
}
if ((p1.y <= highest || p2.y <= highest) && (p1.y >= lowest || p2.y >= lowest)) {
triangles[0].x = i;
vertex.z = j * scale;
vertex.y = heightmap[i][j] * scale;
distance = distsq(&viewer, &vertex);
- if (distance > viewdistsquared)
+ if (distance > viewdistsquared) {
distance = viewdistsquared;
+ }
colors[i][j][3] = (viewdistsquared - (distance - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
}
}
vertex.z = j * scale;
vertex.y = heightmap[i][j] * scale;
distance = distsq(&viewer, &vertex);
- if (distance > viewdistsquared)
+ if (distance > viewdistsquared) {
distance = viewdistsquared;
+ }
colors[i][j][3] = (viewdistsquared - (distance - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
}
}
minypatch[whichx][whichy] = 10000;
for (a = 0; a < size / subdivision; a++) {
for (b = 0; b < size / subdivision; b++) {
- if (heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale > maxypatch[whichx][whichy])
+ if (heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale > maxypatch[whichx][whichy]) {
maxypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
- if (heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale < minypatch[whichx][whichy])
+ }
+ if (heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale < minypatch[whichx][whichy]) {
minypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
+ }
}
}
heightypatch[whichx][whichy] = (maxypatch[whichx][whichy] - minypatch[whichx][whichy]);
- if (heightypatch[whichx][whichy] < size / subdivision * scale)
+ if (heightypatch[whichx][whichy] < size / subdivision * scale) {
heightypatch[whichx][whichy] = size / subdivision * scale;
+ }
avgypatch[whichx][whichy] = (minypatch[whichx][whichy] + maxypatch[whichx][whichy]) / 2;
for (i = whichx * size / subdivision; i < (whichx + 1) * size / subdivision - 1; i++) {
slopeness = heightmap[i][j] - heightmap[i][j - 1];
}
opacityother[i][j] = slopeness * slopeness * 2;
- if (opacityother[i][j] > 1)
+ if (opacityother[i][j] > 1) {
opacityother[i][j] = 1;
+ }
opacityother[i][j] -= (float)abs(Random() % 100) / 300;
}
if (environment == desertenvironment) {
slopeness = heightmap[i][j] - heightmap[i][j - 1];
}
opacityother[i][j] = slopeness * slopeness * 2;
- if (opacityother[i][j] > 1)
+ if (opacityother[i][j] > 1) {
opacityother[i][j] = 1;
+ }
opacityother[i][j] -= (float)abs(Random() % 100) / 300;
}
if (environment == grassyenvironment) {
slopeness = heightmap[i][j] - heightmap[i][j + 1];
}
opacityother[i][j] = slopeness * slopeness * 10;
- if (opacityother[i][j] > 1)
+ if (opacityother[i][j] > 1) {
opacityother[i][j] = 1;
+ }
opacityother[i][j] -= (float)abs(Random() % 100) / 100;
}
}
for (i = 0; i < size; i++) {
for (j = 0; j < size; j++) {
- if (opacityother[i][j] < .1)
+ if (opacityother[i][j] < .1) {
opacityother[i][j] = 0;
+ }
if (textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == -1) {
- if (!opacityother[i][j])
+ if (!opacityother[i][j]) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allfirst;
- if (opacityother[i][j] == 1)
+ }
+ if (opacityother[i][j] == 1) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allsecond;
+ }
}
- if (opacityother[i][j] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[i][j] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+ }
x = i;
y = j;
if (i > 0) {
i--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
if (j > 0) {
j--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
j++;
}
if (j < size - 1) {
j++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
j--;
}
i++;
if (i < size - 1) {
i++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
if (j > 0) {
j--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
j++;
}
if (j < size - 1) {
j++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
j--;
}
i--;
if (j > 0) {
j--;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
j++;
}
if (j < size - 1) {
j++;
- if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+ if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+ }
+ if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond) {
textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
- if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+ }
+ if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
- if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+ }
+ if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond) {
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+ }
j--;
}
}
void Terrain::drawpatch(int whichx, int whichy, float opacity)
{
- if (opacity >= 1)
+ if (opacity >= 1) {
glDisable(GL_BLEND);
+ }
if (opacity < 1) {
glEnable(GL_BLEND);
UpdateTransparency(whichx, whichy);
pointx /= scale;
pointz /= scale;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0) {
return 0;
+ }
startpoint.x = pointx;
startpoint.y = -1000;
pointx /= scale;
pointz /= scale;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0) {
return 0;
+ }
tilex = pointx;
tiley = pointz;
pointz /= scale;
height1 = 0;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0) {
return height1;
+ }
tilex = pointx;
tiley = pointz;
pointz /= scale;
height1 = 0;
- if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+ if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0) {
return height1;
+ }
tilex = pointx;
tiley = pointz;
//Only nearby blocks
beginx = ((viewer.x - viewdistance) / patch_size) - 1;
- if (beginx < 0)
+ if (beginx < 0) {
beginx = 0;
+ }
beginz = ((viewer.z - viewdistance) / patch_size) - 1;
- if (beginz < 0)
+ if (beginz < 0) {
beginz = 0;
+ }
endx = ((viewer.x + viewdistance) / patch_size) + 1;
- if (endx > subdivision)
+ if (endx > subdivision) {
endx = subdivision;
+ }
endz = ((viewer.z + viewdistance) / patch_size) + 1;
- if (endz > subdivision)
+ if (endz > subdivision) {
endz = subdivision;
+ }
if (!layer) {
for (i = beginx; i < endx; i++) {
for (j = beginz; j < endz; j++) {
if (distance[i][j] < (viewdistance + patch_size) * (viewdistance + patch_size)) {
opacity = 1;
- if (distance[i][j] > viewdistsquared * fadestart - viewdistsquared)
+ if (distance[i][j] > viewdistsquared * fadestart - viewdistsquared) {
opacity = 0;
- if (opacity == 1 && i != subdivision)
- if (distance[i + 1][j] > viewdistsquared * fadestart - viewdistsquared)
+ }
+ if (opacity == 1 && i != subdivision) {
+ if (distance[i + 1][j] > viewdistsquared * fadestart - viewdistsquared) {
opacity = 0;
- if (opacity == 1 && j != subdivision)
- if (distance[i][j + 1] > viewdistsquared * fadestart - viewdistsquared)
+ }
+ }
+ if (opacity == 1 && j != subdivision) {
+ if (distance[i][j + 1] > viewdistsquared * fadestart - viewdistsquared) {
opacity = 0;
- if (opacity == 1 && j != subdivision && i != subdivision)
- if (distance[i + 1][j + 1] > viewdistsquared * fadestart - viewdistsquared)
+ }
+ }
+ if (opacity == 1 && j != subdivision && i != subdivision) {
+ if (distance[i + 1][j + 1] > viewdistsquared * fadestart - viewdistsquared) {
opacity = 0;
+ }
+ }
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (frustum.CubeInFrustum(i * patch_size + patch_size * .5, avgypatch[i][j], j * patch_size + patch_size * .5, heightypatch[i][j] / 2)) {
- if (environment == desertenvironment && distance[i][j] > viewdistsquared / 4)
+ if (environment == desertenvironment && distance[i][j] > viewdistsquared / 4) {
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness);
- else if (environment == desertenvironment)
+ } else if (environment == desertenvironment) {
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
- if (!layer && textureness[i][j] != allsecond)
+ }
+ if (!layer && textureness[i][j] != allsecond) {
drawpatch(i, j, opacity);
- if (layer == 1 && textureness[i][j] != allfirst)
+ }
+ if (layer == 1 && textureness[i][j] != allfirst) {
drawpatchother(i, j, opacity);
- if (layer == 2 && textureness[i][j] != allfirst)
+ }
+ if (layer == 2 && textureness[i][j] != allfirst) {
drawpatchotherother(i, j);
+ }
}
glPopMatrix();
}
}
}
- if (environment == desertenvironment)
+ if (environment == desertenvironment) {
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
+ }
}
void Terrain::drawdecals()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(0);
for (unsigned int i = 0; i < decals.size(); i++) {
- if (decals[i].type == blooddecalfast && decals[i].alivetime < 2)
+ if (decals[i].type == blooddecalfast && decals[i].alivetime < 2) {
decals[i].alivetime = 2;
+ }
if (decals[i].type != lasttype) {
if (decals[i].type == shadowdecal || decals[i].type == shadowdecalpermanent) {
shadowtexture.bind();
}
if (decals[i].type == shadowdecal || decals[i].type == shadowdecalpermanent) {
distancemult = (viewdistsquared - (distsq(&viewer, &decals[i].position) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(1, 1, 1, decals[i].opacity);
- if (distancemult < 1)
+ }
+ if (distancemult < 1) {
glColor4f(1, 1, 1, decals[i].opacity * distancemult);
+ }
}
if (decals[i].type == footprintdecal || decals[i].type == bodyprintdecal) {
distancemult = (viewdistsquared - (distsq(&viewer, &decals[i].position) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
if (distancemult >= 1) {
glColor4f(1, 1, 1, decals[i].opacity);
- if (decals[i].alivetime > 3)
+ if (decals[i].alivetime > 3) {
glColor4f(1, 1, 1, decals[i].opacity * (5 - decals[i].alivetime) / 2);
+ }
}
if (distancemult < 1) {
glColor4f(1, 1, 1, decals[i].opacity * distancemult);
- if (decals[i].alivetime > 3)
+ if (decals[i].alivetime > 3) {
glColor4f(1, 1, 1, decals[i].opacity * (5 - decals[i].alivetime) / 2 * distancemult);
+ }
}
}
if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow)) {
distancemult = (viewdistsquared - (distsq(&viewer, &decals[i].position) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
if (distancemult >= 1) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity);
- if (decals[i].alivetime < 4)
+ if (decals[i].alivetime < 4) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * decals[i].alivetime * .25);
- if (decals[i].alivetime > 58)
+ }
+ if (decals[i].alivetime > 58) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * (60 - decals[i].alivetime) / 2);
+ }
}
if (distancemult < 1) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * distancemult);
- if (decals[i].alivetime < 4)
+ if (decals[i].alivetime < 4) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * decals[i].alivetime * distancemult * .25);
- if (decals[i].alivetime > 58)
+ }
+ if (decals[i].alivetime > 58) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * (60 - decals[i].alivetime) / 2 * distancemult);
+ }
}
}
lasttype = decals[i].type;
}
for (int i = decals.size() - 1; i >= 0; i--) {
decals[i].alivetime += multiplier;
- if (decals[i].type == blooddecalslow)
+ if (decals[i].type == blooddecalslow) {
decals[i].alivetime -= multiplier * 2 / 3;
- if (decals[i].type == blooddecalfast)
+ }
+ if (decals[i].type == blooddecalfast) {
decals[i].alivetime += multiplier * 4;
- if (decals[i].type == shadowdecal)
+ }
+ if (decals[i].type == shadowdecal) {
DeleteDecal(i);
- if (decals[i].type == footprintdecal && decals[i].alivetime >= 5)
+ }
+ if (decals[i].type == footprintdecal && decals[i].alivetime >= 5) {
DeleteDecal(i);
- if (decals[i].type == bodyprintdecal && decals[i].alivetime >= 5)
+ }
+ if (decals[i].type == bodyprintdecal && decals[i].alivetime >= 5) {
DeleteDecal(i);
- if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow) && decals[i].alivetime >= 60)
+ }
+ if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow) && decals[i].alivetime >= 60) {
DeleteDecal(i);
+ }
}
glAlphaFunc(GL_GREATER, 0.0001);
}
XYZ rot = getLighting(where.x, where.z);
float decalbright = (rot.x + rot.y + rot.z) / 3;
- if (decalbright < .4)
+ if (decalbright < .4) {
decalbright = .4;
+ }
if (environment == grassyenvironment) {
decalbright *= .6;
Decal decal(where, type, opacity, rotation, decalbright, whichx, whichy, size, *this, true);
- if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
- if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
- if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
- if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1))
- if (decals.size() < max_decals - 1)
+ if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+ if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+ if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
+ if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
+ if (decals.size() < max_decals - 1) {
decals.push_back(decal);
+ }
+ }
+ }
+ }
+ }
Decal decal2(where, type, opacity, rotation, decalbright, whichx, whichy, size, *this, false);
- if (!(decal2.texcoords[0][0] < 0 && decal2.texcoords[1][0] < 0 && decal2.texcoords[2][0] < 0))
- if (!(decal2.texcoords[0][1] < 0 && decal2.texcoords[1][1] < 0 && decal2.texcoords[2][1] < 0))
- if (!(decal2.texcoords[0][0] > 1 && decal2.texcoords[1][0] > 1 && decal2.texcoords[2][0] > 1))
- if (!(decal2.texcoords[0][1] > 1 && decal2.texcoords[1][1] > 1 && decal2.texcoords[2][1] > 1))
- if (decals.size() < max_decals - 1)
+ if (!(decal2.texcoords[0][0] < 0 && decal2.texcoords[1][0] < 0 && decal2.texcoords[2][0] < 0)) {
+ if (!(decal2.texcoords[0][1] < 0 && decal2.texcoords[1][1] < 0 && decal2.texcoords[2][1] < 0)) {
+ if (!(decal2.texcoords[0][0] > 1 && decal2.texcoords[1][0] > 1 && decal2.texcoords[2][0] > 1)) {
+ if (!(decal2.texcoords[0][1] > 1 && decal2.texcoords[1][1] > 1 && decal2.texcoords[2][1] > 1)) {
+ if (decals.size() < max_decals - 1) {
decals.push_back(decal2);
+ }
+ }
+ }
+ }
+ }
}
}
Game::LoadingScreen();
}
float brightness = dotproduct(&lightloc, &normals[i][j]);
- if (shadowed)
+ if (shadowed) {
brightness *= 1 - shadowed;
+ }
- if (brightness > 1)
+ if (brightness > 1) {
brightness = 1;
- if (brightness < 0)
+ }
+ if (brightness < 0) {
brightness = 0;
+ }
colors[i][j][0] = light.color[0] * brightness + light.ambient[0];
colors[i][j][1] = light.color[1] * brightness + light.ambient[1];
colors[i][j][2] = light.color[2] * brightness + light.ambient[2];
- if (colors[i][j][0] > 1)
+ if (colors[i][j][0] > 1) {
colors[i][j][0] = 1;
- if (colors[i][j][1] > 1)
+ }
+ if (colors[i][j][1] > 1) {
colors[i][j][1] = 1;
- if (colors[i][j][2] > 1)
+ }
+ if (colors[i][j][2] > 1) {
colors[i][j][2] = 1;
- if (colors[i][j][0] < 0)
+ }
+ if (colors[i][j][0] < 0) {
colors[i][j][0] = 0;
- if (colors[i][j][1] < 0)
+ }
+ if (colors[i][j][1] < 0) {
colors[i][j][1] = 0;
- if (colors[i][j][2] < 0)
+ }
+ if (colors[i][j][2] < 0) {
colors[i][j][2] = 0;
+ }
}
}
} else if (evenement.key.keysym.sym == SDLK_END) {
(*charselected) = str.size();
} else if (evenement.key.keysym.sym == SDLK_LEFT) {
- if ((*charselected) != 0)
+ if ((*charselected) != 0) {
(*charselected)--;
+ }
} else if (evenement.key.keysym.sym == SDLK_RIGHT) {
- if ((*charselected) < str.size())
+ if ((*charselected) < str.size()) {
(*charselected)++;
+ }
} else if (evenement.key.keysym.sym == SDLK_RETURN) {
waiting = false;
}
if (!mainmenu) {
if (editorenabled) {
numboundaries = mapradius * 2;
- if (numboundaries > 360)
+ if (numboundaries > 360) {
numboundaries = 360;
+ }
for (int i = 0; i < numboundaries; i++) {
boundary[i] = 0;
boundary[i].z = 1;
}
if (slomo && !loading) {
- if (ismotionblur)
+ if (ismotionblur) {
drawmode = motionblurmode;
+ }
motionbluramount = .2;
slomodelay -= multiplier;
- if (slomodelay < 0)
+ if (slomodelay < 0) {
slomo = 0;
+ }
camerashake = 0;
changed = 1;
}
if ((!changed && !slomo) || loading) {
drawmode = normalmode;
if (ismotionblur && (/*fps>100||*/ alwaysblur)) {
- if (olddrawmode != realmotionblurmode)
+ if (olddrawmode != realmotionblurmode) {
change = 1;
- else
+ } else {
change = 0;
+ }
drawmode = realmotionblurmode;
- } else if (olddrawmode == realmotionblurmode)
+ } else if (olddrawmode == realmotionblurmode) {
change = 2;
- else
+ } else {
change = 0;
+ }
}
- if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted))
+ if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
drawmode = normalmode;
- if ((freeze || winfreeze) && ismotionblur && !mainmenu)
+ }
+ if ((freeze || winfreeze) && ismotionblur && !mainmenu) {
drawmode = radialzoommode;
+ }
- if (winfreeze || mainmenu)
+ if (winfreeze || mainmenu) {
drawmode = normalmode;
+ }
- if (drawtoggle != 2)
+ if (drawtoggle != 2) {
drawtoggle = 1 - drawtoggle;
+ }
if (!texcoordwidth) {
texviewwidth = kTextureSize;
- if (texviewwidth > screenwidth)
+ if (texviewwidth > screenwidth) {
texviewwidth = screenwidth;
+ }
texviewheight = kTextureSize;
- if (texviewheight > screenheight)
+ if (texviewheight > screenheight) {
texviewheight = screenheight;
+ }
texcoordwidth = screenwidth / kTextureSize;
texcoordheight = screenheight / kTextureSize;
- if (texcoordwidth > 1)
+ if (texcoordwidth > 1) {
texcoordwidth = 1;
- if (texcoordheight > 1)
+ }
+ if (texcoordheight > 1) {
texcoordheight = 1;
+ }
}
glDrawBuffer(GL_BACK);
blurness = targetblurness;
targetblurness = (float)(abs(Random() % 100)) / 40;
}
- if (blurness < targetblurness)
+ if (blurness < targetblurness) {
blurness += multiplier * 5;
- else
+ } else {
blurness -= multiplier * 5;
+ }
if (environment == desertenvironment) {
if (detail == 2) {
static float size, opacity, rotation;
rotation = 0;
for (unsigned int k = 0; k < Person::players.size(); k++) {
- if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping)
- if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25)
+ if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping) {
+ if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25) {
for (unsigned int i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) {
point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
}
}
}
- if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail)
- if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25)
+ }
+ }
+ if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail) {
+ if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25) {
for (unsigned i = 0; i < Person::players[k]->skeleton.joints.size(); i++) {
if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) {
- if (Person::players[k]->skeleton.free)
+ if (Person::players[k]->skeleton.free) {
point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords;
- else
+ } else {
point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
+ }
size = .4f;
opacity = .4 - Person::players[k]->skeleton.joints[i].position.y * Person::players[k]->scale / 5 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5;
if (k != 0 && Tutorial::active) {
for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
unsigned int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
if (Object::objects[j]->position.y < Person::players[k]->coords.y || Object::objects[j]->type == tunneltype || Object::objects[j]->type == weirdtype) {
- if (Person::players[k]->skeleton.free)
+ if (Person::players[k]->skeleton.free) {
point = DoRotation(Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
- else
+ } else {
point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
+ }
size = .4f;
opacity = .4f;
if (k != 0 && Tutorial::active) {
}
}
}
+ }
+ }
- if (!Person::players[k]->playerdetail)
+ if (!Person::players[k]->playerdetail) {
if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5)) {
point = Person::players[k]->coords;
size = .7;
Object::objects[j]->model.MakeDecal(shadowdecal, &point, &size, &opacity, &rotation);
}
}
+ }
}
//Terrain
distance = distsq(&viewer, &Person::players[k]->coords);
distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
- if (distance >= 1)
+ if (distance >= 1) {
glDisable(GL_BLEND);
+ }
if (distance >= .5) {
checkpoint = DoRotation(Person::players[k]->skeleton.joints[fabs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
checkpoint.y += 1;
int i = -1;
- if (Person::players[k]->occluded != 0)
+ if (Person::players[k]->occluded != 0) {
i = Object::checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded);
- if (i == -1)
+ }
+ if (i == -1) {
i = Object::checkcollide(viewer, checkpoint);
+ }
if (i != -1) {
Person::players[k]->occluded += 1;
Person::players[k]->lastoccluded = i;
} else {
Person::players[k]->occluded = 0;
}
- if (Person::players[k]->occluded < 25)
+ if (Person::players[k]->occluded < 25) {
Person::players[k]->DrawSkeleton();
+ }
}
}
}
}
- if (!cameramode && musictype == stream_fighttheme)
+ if (!cameramode && musictype == stream_fighttheme) {
playerdist = distsqflat(&Person::players[0]->coords, &viewer);
- else
+ } else {
playerdist = -100;
+ }
glPushMatrix();
glCullFace(GL_BACK);
glEnable(GL_TEXTURE_2D);
glTranslatef(25, 0, 0);
distance = distsq(&viewer, &realhawkcoords) * 1.2;
glColor4f(light.color[0], light.color[1], light.color[2], (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance);
- if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1)
+ if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 1) {
glColor4f(light.color[0], light.color[1], light.color[2], 1);
- if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0)
+ }
+ if ((viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance > 0) {
hawk.drawdifftex(hawktexture);
+ }
}
glPopMatrix();
distance = distsq(&viewer, &Person::players[k]->coords);
distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
- if (distance >= 1)
+ if (distance >= 1) {
glDisable(GL_BLEND);
+ }
if (distance >= .5) {
checkpoint = DoRotation(Person::players[k]->skeleton.joints[fabs(Random() % Person::players[k]->skeleton.joints.size())].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords;
checkpoint.y += 1;
glEnable(GL_TEXTURE_2D);
glColor4f(.5, .5, .5, 1);
if (!console) {
- if (!Tutorial::active)
+ if (!Tutorial::active) {
if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
const char* bonus_name;
- if (bonus < bonus_count)
+ if (bonus < bonus_count) {
bonus_name = bonus_names[bonus];
- else
+ } else {
bonus_name = "Excellent!"; // When does this happen?
-
+ }
text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768);
string = to_string((int)bonusvalue);
glColor4f(.5, .5, .5, 1);
}
+ }
if (Tutorial::active) {
Tutorial::DrawTextInfo();
if (closest != -1) {
Hotspot::current = closest;
if (Hotspot::hotspots[closest].type <= 10) {
- if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size)
+ if (distsq(&Person::players[0]->coords, &Hotspot::hotspots[closest].position) < Hotspot::hotspots[closest].size) {
Tutorial::stagetime = 0;
+ }
Tutorial::maxtime = 1;
tutorialopac = Tutorial::maxtime - Tutorial::stagetime;
- if (tutorialopac > 1)
+ if (tutorialopac > 1) {
tutorialopac = 1;
- if (tutorialopac < 0)
+ }
+ if (tutorialopac < 0) {
tutorialopac = 0;
+ }
string = Hotspot::hotspots[closest].text;
text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * (i - lastline) * screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
lastline = i + 1;
line++;
- if (string[i] == '\0')
+ if (string[i] == '\0') {
done = 1;
+ }
}
- if (i >= 255)
+ if (i >= 255) {
done = 1;
+ }
i++;
}
} else if ((Hotspot::hotspots[closest].type >= 20) && (Dialog::dialogs[Hotspot::hotspots[closest].type - 20].gonethrough == 0)) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- if (Dialog::currentScene().location == 1)
+ if (Dialog::currentScene().location == 1) {
glTranslatef(0, screenheight * 3 / 4, 0);
+ }
glScalef(screenwidth, screenheight / 4, 1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) {
tempname[tempnum] = Dialog::currentScene().name[i];
- if (tempname[tempnum] == '#' || tempname[tempnum] == '\0')
+ if (tempname[tempnum] == '#' || tempname[tempnum] == '\0') {
tempname[tempnum] = '\0';
- else
+ } else {
tempnum++;
+ }
}
string = std::string(tempname) + ": ";
tempnum = 0;
for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) {
tempname[tempnum] = Dialog::currentScene().text[i];
- if (Dialog::currentScene().text[i] != '#')
+ if (Dialog::currentScene().text[i] != '#') {
tempnum++;
+ }
}
string = tempname;
}
lastline = i + 1;
line++;
- if (string[i] == '\0')
+ if (string[i] == '\0') {
done = 1;
+ }
}
- if (i >= 255)
+ if (i >= 255) {
done = 1;
+ }
i++;
}
}
glScalef(screenwidth, screenheight, 1);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
- if (Person::players[0]->dead)
+ if (Person::players[0]->dead) {
blackout += multiplier * 3;
- if (Person::players[0]->dead == 1)
+ }
+ if (Person::players[0]->dead == 1) {
blackout = .4f;
- if (Person::players[0]->dead == 2 && blackout > .6)
+ }
+ if (Person::players[0]->dead == 2 && blackout > .6) {
blackout = .6;
+ }
glColor4f(0, 0, 0, blackout);
if (!Person::players[0]->dead) {
if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)) * .3 < .3) {
blackout = Person::players[0]->blooddimamount * .3;
}
}
- if (console)
+ if (console) {
glColor4f(.7, 0, 0, .2);
+ }
glBegin(GL_QUADS);
glVertex3f(0, 0, 0.0f);
glVertex3f(256, 0, 0.0f);
}
if (flashamount > 0 && damageeffects) {
- if (flashamount > 1)
+ if (flashamount > 1) {
flashamount = 1;
- if (flashdelay <= 0)
+ }
+ if (flashdelay <= 0) {
flashamount -= multiplier;
+ }
flashdelay--;
- if (flashamount < 0)
+ if (flashamount < 0) {
flashamount = 0;
+ }
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
if (distcheck < mapviewdist) {
glPushMatrix();
Maparrowtexture.bind();
- if (i == 0)
+ if (i == 0) {
glColor4f(1, 1, 1, opac);
- else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping)
+ } else if (Person::players[i]->dead == 2 || Person::players[i]->howactive > typesleeping) {
glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
- else if (Person::players[i]->dead)
+ } else if (Person::players[i]->dead) {
glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
- else if (Person::players[i]->aitype == attacktypecutoff)
+ } else if (Person::players[i]->aitype == attacktypecutoff) {
glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
- else if (Person::players[i]->aitype == passivetype)
+ } else if (Person::players[i]->aitype == passivetype) {
glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
- else
+ } else {
glColor4f(1, 1, 0, 1);
+ }
glTranslatef(Person::players[i]->coords.x / terrain.scale / 256 * -2 + 1, Person::players[i]->coords.z / terrain.scale / 256 * 2 - 1, 0);
glRotatef(Person::players[i]->yaw + 180, 0, 0, 1);
glScalef(.005, .005, .005);
int awards[award_count];
int numawards = award_awards(awards);
- for (int i = 0; i < numawards && i < 6; i++)
+ for (int i = 0; i < numawards && i < 6; i++) {
text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768);
+ }
}
if (drawmode != normalmode) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
if (drawmode == motionblurmode) {
- if (motionbluramount < .2)
+ if (motionbluramount < .2) {
motionbluramount = .2;
+ }
glColor4f(1, 1, 1, motionbluramount);
glPushMatrix();
glBegin(GL_QUADS);
if (drawmode == doublevisionmode) {
static float crosseyedness;
crosseyedness = abs(Person::players[0]->damage - Person::players[0]->superpermanentdamage - (Person::players[0]->damagetolerance - Person::players[0]->superpermanentdamage) * 1 / 2) / 30;
- if (crosseyedness > 1)
+ if (crosseyedness > 1) {
crosseyedness = 1;
- if (crosseyedness < 0)
+ }
+ if (crosseyedness < 0) {
crosseyedness = 0;
+ }
glColor4f(1, 1, 1, 1);
glDisable(GL_BLEND);
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glColor4f(1, 1, 1, 1);
int offset = 0;
- if (consoleselected >= 60)
+ if (consoleselected >= 60) {
offset = consoleselected - 60;
+ }
textmono->glPrint(10, 30, " ]", 0, 1, 1024, 768);
if (consoleblink) {
textmono->glPrint(30 + (float)consoleselected * 10 - offset * 10, 30, "_", 0, 1, 1024, 768);
weapons.DoStuff();
- if (drawtoggle == 2)
+ if (drawtoggle == 2) {
drawtoggle = 0;
+ }
if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
multiplier = tempmult;
//draw screen flash
if (flashamount > 0) {
- if (flashamount > 1)
+ if (flashamount > 1) {
flashamount = 1;
- if (flashdelay <= 0)
+ }
+ if (flashdelay <= 0) {
flashamount -= multiplier;
+ }
flashdelay--;
- if (flashamount < 0)
+ if (flashamount < 0) {
flashamount = 0;
+ }
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
AbsoluteTime currTime = UpTime();
double deltaTime = (float)AbsoluteDeltaToDuration(currTime, frametime);
- if (0 > deltaTime) // if negative microseconds
+ if (0 > deltaTime) { // if negative microseconds
deltaTime /= -1000000.0;
- else // else milliseconds
+ } else { // else milliseconds
deltaTime /= 1000.0;
+ }
multiplier = deltaTime;
- if (multiplier < .001)
+ if (multiplier < .001) {
multiplier = .001;
- if (multiplier > 10)
+ }
+ if (multiplier > 10) {
multiplier = 10;
+ }
if (multiplier > .05) {
frametime = currTime; // reset for next time interval
loadtime += multiplier * 4;
loadprogress = loadtime;
- if (loadprogress > 100)
+ if (loadprogress > 100) {
loadprogress = 100;
+ }
//Background
//Text
if (flashamount > 0) {
- if (flashamount > 1)
+ if (flashamount > 1) {
flashamount = 1;
- if (flashdelay <= 0)
+ }
+ if (flashdelay <= 0) {
flashamount -= multiplier;
+ }
flashdelay--;
- if (flashamount < 0)
+ if (flashamount < 0) {
flashamount = 0;
+ }
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
OPENAL_SetSFXMasterVolume((int)(volume * 255));
loadAllSounds();
- if (musictoggle)
+ if (musictoggle) {
emit_stream_np(stream_menutheme);
+ }
cursortexture.load("Textures/Cursor.png", 0);
Maparrowtexture.load("Textures/MapArrow.png", 0);
temptexdetail = texdetail;
- if (texdetail > 2)
+ if (texdetail > 2) {
texdetail = 2;
+ }
Mainmenuitems[0].load("Textures/Lugaru.png", 0);
Mainmenuitems[1].load("Textures/NewGame.png", 0);
Mainmenuitems[2].load("Textures/Options.png", 0);
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- if (!Game::screentexture)
+ if (!Game::screentexture) {
glGenTextures(1, &Game::screentexture);
+ }
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
{
Normalise(&vec);
float angle = -asin(-vec.x) * 180 / M_PI;
- if (vec.z < 0)
+ if (vec.z < 0) {
angle = 180 - angle;
+ }
return angle;
}
float roughDirectionTo(XYZ start, XYZ end)
}
inline float stepTowardf(float from, float to, float by)
{
- if (fabs(from - to) < by)
+ if (fabs(from - to) < by) {
return to;
- else if (from > to)
+ } else if (from > to) {
return from - by;
- else
+ } else {
return from + by;
+ }
}
void Game::playdialoguescenesound()
default:
break;
}
- if (sound != -1)
+ if (sound != -1) {
emit_sound_at(sound, temppos);
+ }
}
// ================================================================
{
int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]);
- for (i = 0; i < n_cmds; i++)
+ for (i = 0; i < n_cmds; i++) {
if (cmd.substr(0, cmd.find(' ')) == string(cmd_names[i])) {
cout << "|" << cmd.substr(cmd.find(' ') + 1) << "|" << endl;
cmd_handlers[i](cmd.substr(cmd.find(' ') + 1).c_str());
break;
}
+ }
emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound);
}
void Game::SetUpLighting()
{
- if (environment == snowyenvironment)
+ if (environment == snowyenvironment) {
light.setColors(.65, .65, .7, .4, .4, .44);
- if (environment == desertenvironment)
+ }
+ if (environment == desertenvironment) {
light.setColors(.95, .95, .95, .4, .35, .3);
- if (environment == grassyenvironment)
+ }
+ if (environment == grassyenvironment) {
light.setColors(.95, .95, 1, .4, .4, .44);
- if (!skyboxtexture)
+ }
+ if (!skyboxtexture) {
light.setColors(1, 1, 1, .4, .4, .4);
+ }
float average;
average = (skyboxlightr + skyboxlightg + skyboxlightb) / 3;
light.color[0] *= (skyboxlightr + average) / 2;
if (environment == snowyenvironment) {
windvector = 0;
windvector.z = 3;
- if (ambientsound)
+ if (ambientsound) {
emit_stream_np(stream_wind);
+ }
Object::treetextureptr.load("Textures/SnowTree.png", 0);
Object::bushtextureptr.load("Textures/BushSnow.png", 0);
terraintexture2.load("Textures/Rock.jpg", 1);
temptexdetail = texdetail;
- if (texdetail > 1)
+ if (texdetail > 1) {
texdetail = 4;
+ }
skybox->load("Textures/Skybox(snow)/Front.jpg",
"Textures/Skybox(snow)/Left.jpg",
"Textures/Skybox(snow)/Back.jpg",
Object::rocktextureptr.load("Textures/BoulderDesert.jpg", 1);
Object::boxtextureptr.load("Textures/DesertBox.jpg", 1);
- if (ambientsound)
+ if (ambientsound) {
emit_stream_np(stream_desertambient);
+ }
footstepsound = footstepsn1;
footstepsound2 = footstepsn2;
terraintexture2.load("Textures/SandSlope.jpg", 1);
temptexdetail = texdetail;
- if (texdetail > 1)
+ if (texdetail > 1) {
texdetail = 4;
+ }
skybox->load("Textures/Skybox(sand)/Front.jpg",
"Textures/Skybox(sand)/Left.jpg",
"Textures/Skybox(sand)/Back.jpg",
Object::rocktextureptr.load("Textures/Boulder.jpg", 1);
Object::boxtextureptr.load("Textures/GrassBox.jpg", 1);
- if (ambientsound)
+ if (ambientsound) {
emit_stream_np(stream_wind, 100.);
+ }
footstepsound = footstepgr1;
footstepsound2 = footstepgr2;
terraintexture2.load("Textures/MossRock.jpg", 1);
temptexdetail = texdetail;
- if (texdetail > 1)
+ if (texdetail > 1) {
texdetail = 4;
+ }
skybox->load("Textures/Skybox(grass)/Front.jpg",
"Textures/Skybox(grass)/Left.jpg",
"Textures/Skybox(grass)/Back.jpg",
LOG(std::string("Loading level...") + name);
- if (!gameon)
+ if (!gameon) {
visibleloading = true;
- if (stealthloading)
+ }
+ if (stealthloading) {
visibleloading = false;
- if (!stillloading)
+ }
+ if (!stillloading) {
loadtime = 0;
+ }
gamestarted = 1;
numenvsounds = 0;
freeze = 0;
winfreeze = 0;
- for (unsigned char i = 0; i < 100; i++)
+ for (unsigned char i = 0; i < 100; i++) {
bonusnum[i] = 0;
+ }
numfalls = 0;
numflipfail = 0;
if (mapvers < 12) {
cerr << name << " has obsolete map version " << mapvers << endl;
}
- if (mapvers >= 15)
+ if (mapvers >= 15) {
funpackf(tfile, "Bi", &indemo);
- else
+ } else {
indemo = 0;
- if (mapvers >= 5)
+ }
+ if (mapvers >= 5) {
funpackf(tfile, "Bi", &maptype);
- else
+ } else {
maptype = mapkilleveryone;
- if (mapvers >= 6)
+ }
+ if (mapvers >= 6) {
funpackf(tfile, "Bi", &hostile);
- else
+ } else {
hostile = 1;
- if (mapvers >= 4)
+ }
+ if (mapvers >= 4) {
funpackf(tfile, "Bf Bf", &viewdistance, &fadestart);
- else {
+ } else {
viewdistance = 100;
fadestart = .6;
}
- if (mapvers >= 2)
+ if (mapvers >= 2) {
funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb);
- else {
+ } else {
skyboxtexture = 1;
skyboxr = 1;
skyboxg = 1;
skyboxb = 1;
}
- if (mapvers >= 10)
+ if (mapvers >= 10) {
funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb);
- else {
+ } else {
skyboxlightr = skyboxr;
skyboxlightg = skyboxg;
skyboxlightb = skyboxb;
} else {
funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &Person::players[0]->coords.x, &Person::players[0]->coords.y, &Person::players[0]->coords.z, &Person::players[0]->yaw, &Person::players[0]->targetyaw, &Person::players[0]->num_weapons);
}
- if (Person::players[0]->num_weapons > 0 && Person::players[0]->num_weapons < 5)
+ if (Person::players[0]->num_weapons > 0 && Person::players[0]->num_weapons < 5) {
for (int j = 0; j < Person::players[0]->num_weapons; j++) {
Person::players[0]->weaponids[j] = weapons.size();
int type;
funpackf(tfile, "Bi", &type);
weapons.push_back(Weapon(type, 0));
}
+ }
Game::LoadingScreen();
funpackf(tfile, "Bi", &Person::players[0]->numclothes);
- if (mapvers >= 9)
+ if (mapvers >= 9) {
funpackf(tfile, "Bi Bi", &Person::players[0]->whichskin, &Person::players[0]->creature);
- else {
+ } else {
Person::players[0]->whichskin = 0;
Person::players[0]->creature = rabbittype;
}
for (int k = 0; k < Person::players[0]->numclothes; k++) {
funpackf(tfile, "Bi", &templength);
- for (int l = 0; l < templength; l++)
+ for (int l = 0; l < templength; l++) {
funpackf(tfile, "Bb", &Person::players[0]->clothes[k][l]);
+ }
Person::players[0]->clothes[k][templength] = '\0';
funpackf(tfile, "Bf Bf Bf", &Person::players[0]->clothestintr[k], &Person::players[0]->clothestintg[k], &Person::players[0]->clothestintb[k]);
}
funpackf(tfile, "Bi", &environment);
- if (environment != oldenvironment)
+ if (environment != oldenvironment) {
Setenvironment(environment);
+ }
oldenvironment = environment;
Object::LoadObjectsFromFile(tfile, stealthloading);
for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
funpackf(tfile, "Bi Bf Bf Bf Bf", &Hotspot::hotspots[i].type, &Hotspot::hotspots[i].size, &Hotspot::hotspots[i].position.x, &Hotspot::hotspots[i].position.y, &Hotspot::hotspots[i].position.z);
funpackf(tfile, "Bi", &templength);
- if (templength)
- for (int l = 0; l < templength; l++)
+ if (templength) {
+ for (int l = 0; l < templength; l++) {
funpackf(tfile, "Bb", &Hotspot::hotspots[i].text[l]);
+ }
+ }
Hotspot::hotspots[i].text[templength] = '\0';
- if (Hotspot::hotspots[i].type == -111)
+ if (Hotspot::hotspots[i].type == -111) {
indemo = 1;
+ }
}
} else {
Hotspot::hotspots.clear();
Game::LoadingScreen();
funpackf(tfile, "Bi", &numpathpoints);
- if (numpathpoints > 30 || numpathpoints < 0)
+ if (numpathpoints > 30 || numpathpoints < 0) {
numpathpoints = 0;
+ }
for (int j = 0; j < numpathpoints; j++) {
funpackf(tfile, "Bf Bf Bf Bi", &pathpoint[j].x, &pathpoint[j].y, &pathpoint[j].z, &numpathpointconnect[j]);
for (int k = 0; k < numpathpointconnect[j]; k++) {
Person::players[i]->target = 0;
}
Person::players[i]->speed = 1 + (float)(Random() % 100) / 1000;
- if (difficulty == 0)
+ if (difficulty == 0) {
Person::players[i]->speed -= .2;
- if (difficulty == 1)
+ }
+ if (difficulty == 1) {
Person::players[i]->speed -= .1;
+ }
if (i == 0) {
Person::players[i]->velocity = 0;
/* Change environment */
if (Input::isKeyPressed(SDL_SCANCODE_J)) {
environment++;
- if (environment > 2)
+ if (environment > 2) {
environment = 0;
+ }
Setenvironment(environment);
}
if (closest >= 0) {
if (Person::players[closest]->num_weapons > 0) {
- if (weapons[Person::players[closest]->weaponids[0]].getType() == sword)
+ if (weapons[Person::players[closest]->weaponids[0]].getType() == sword) {
weapons[Person::players[closest]->weaponids[0]].setType(staff);
- else if (weapons[Person::players[closest]->weaponids[0]].getType() == staff)
+ } else if (weapons[Person::players[closest]->weaponids[0]].getType() == staff) {
weapons[Person::players[closest]->weaponids[0]].setType(knife);
- else
+ } else {
weapons[Person::players[closest]->weaponids[0]].setType(sword);
+ }
} else {
Person::players[closest]->weaponids[0] = weapons.size();
if (closest >= 0) {
Person::players[closest]->whichskin++;
- if (Person::players[closest]->whichskin > 9)
+ if (Person::players[closest]->whichskin > 9) {
Person::players[closest]->whichskin = 0;
- if (Person::players[closest]->whichskin > 2 && Person::players[closest]->creature == wolftype)
+ }
+ if (Person::players[closest]->whichskin > 2 && Person::players[closest]->creature == wolftype) {
Person::players[closest]->whichskin = 0;
+ }
Person::players[closest]->skeleton.drawmodel.textureptr.load(creatureskin[Person::players[closest]->creature][Person::players[closest]->whichskin], 1,
&Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
for (unsigned i = 1; i < Person::players.size(); i++) {
float distance = distsq(&Person::players[i]->coords, &Person::players[0]->coords);
- if (!Person::players[i]->headless)
+ if (!Person::players[i]->headless) {
if (distance < closestdist) {
closestdist = distance;
closest = i;
}
+ }
}
XYZ flatfacing2, flatvelocity2;
//int i = Person::players[closest]->skeleton.jointlabels[head];
Joint& headjoint = Person::players[closest]->joint(head);
for (unsigned k = 0; k < Person::players[closest]->skeleton.joints.size(); k++) {
- if (!Person::players[closest]->skeleton.free)
+ if (!Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->velocity;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatvelocity2 = headjoint.velocity;
- if (!Person::players[closest]->skeleton.free)
+ }
+ if (!Person::players[closest]->skeleton.free) {
flatfacing2 = DoRotation(DoRotation(DoRotation(headjoint.position, 0, 0, Person::players[closest]->tilt), Person::players[closest]->tilt2, 0, 0), 0, Person::players[closest]->yaw, 0) * Person::players[closest]->scale + Person::players[closest]->coords;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatfacing2 = headjoint.position * Person::players[closest]->scale + Person::players[closest]->coords;
+ }
flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
emit_sound_at(splattersound, blah);
emit_sound_at(breaksound2, blah, 100.);
- if (Person::players[closest]->skeleton.free == 2)
+ if (Person::players[closest]->skeleton.free == 2) {
Person::players[closest]->skeleton.free = 0;
+ }
Person::players[closest]->RagDoll(0);
Person::players[closest]->dead = 2;
Person::players[closest]->headless = 1;
emit_sound_at(breaksound2, blah);
for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
- if (!Person::players[closest]->skeleton.free)
+ if (!Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->velocity;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->skeleton.joints[i].velocity;
- if (!Person::players[closest]->skeleton.free)
+ }
+ if (!Person::players[closest]->skeleton.free) {
flatfacing2 = DoRotation(DoRotation(DoRotation(Person::players[closest]->skeleton.joints[i].position, 0, 0, Person::players[closest]->tilt), Person::players[closest]->tilt2, 0, 0), 0, Person::players[closest]->yaw, 0) * Person::players[closest]->scale + Person::players[closest]->coords;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatfacing2 = Person::players[closest]->skeleton.joints[i].position * Person::players[closest]->scale + Person::players[closest]->coords;
+ }
flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
}
for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
- if (!Person::players[closest]->skeleton.free)
+ if (!Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->velocity;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->skeleton.joints[i].velocity;
- if (!Person::players[closest]->skeleton.free)
+ }
+ if (!Person::players[closest]->skeleton.free) {
flatfacing2 = DoRotation(DoRotation(DoRotation(Person::players[closest]->skeleton.joints[i].position, 0, 0, Person::players[closest]->tilt), Person::players[closest]->tilt2, 0, 0), 0, Person::players[closest]->yaw, 0) * Person::players[closest]->scale + Person::players[closest]->coords;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatfacing2 = Person::players[closest]->skeleton.joints[i].position * Person::players[closest]->scale + Person::players[closest]->coords;
+ }
flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
}
for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
- if (!Person::players[closest]->skeleton.free)
+ if (!Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->velocity;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->skeleton.joints[i].velocity;
- if (!Person::players[closest]->skeleton.free)
+ }
+ if (!Person::players[closest]->skeleton.free) {
flatfacing2 = DoRotation(DoRotation(DoRotation(Person::players[closest]->skeleton.joints[i].position, 0, 0, Person::players[closest]->tilt), Person::players[closest]->tilt2, 0, 0), 0, Person::players[closest]->yaw, 0) * Person::players[closest]->scale + Person::players[closest]->coords;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatfacing2 = Person::players[closest]->skeleton.joints[i].position * Person::players[closest]->scale + Person::players[closest]->coords;
+ }
flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
}
for (unsigned i = 0; i < Person::players[closest]->skeleton.joints.size(); i++) {
- if (!Person::players[closest]->skeleton.free)
+ if (!Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->velocity;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatvelocity2 = Person::players[closest]->skeleton.joints[i].velocity;
- if (!Person::players[closest]->skeleton.free)
+ }
+ if (!Person::players[closest]->skeleton.free) {
flatfacing2 = DoRotation(DoRotation(DoRotation(Person::players[closest]->skeleton.joints[i].position, 0, 0, Person::players[closest]->tilt), Person::players[closest]->tilt2, 0, 0), 0, Person::players[closest]->yaw, 0) * Person::players[closest]->scale + Person::players[closest]->coords;
- if (Person::players[closest]->skeleton.free)
+ }
+ if (Person::players[closest]->skeleton.free) {
flatfacing2 = Person::players[closest]->skeleton.joints[i].position * Person::players[closest]->scale + Person::players[closest]->coords;
+ }
flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
if (int(j) != closest) {
if (distsq(&Person::players[j]->coords, &Person::players[closest]->coords) < 25) {
Person::players[j]->DoDamage((25 - distsq(&Person::players[j]->coords, &Person::players[closest]->coords)) * 60);
- if (Person::players[j]->skeleton.free == 2)
+ if (Person::players[j]->skeleton.free == 2) {
Person::players[j]->skeleton.free = 1;
+ }
Person::players[j]->skeleton.longdead = 0;
Person::players[j]->RagDoll(0);
for (unsigned i = 0; i < Person::players[j]->skeleton.joints.size(); i++) {
//skip level
if (whichlevel != -2 && Input::isKeyPressed(SDL_SCANCODE_K) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && !editorenabled) {
targetlevel++;
- if (targetlevel > numchallengelevels - 1)
+ if (targetlevel > numchallengelevels - 1) {
targetlevel = 0;
+ }
loading = 1;
leveltime = 5;
}
scenecoords.x = Person::players[0]->coords.x;
scenecoords.z = Person::players[0]->coords.z;
scenecoords.y = Person::players[0]->coords.y - 3;
- if (editortype == bushtype)
+ if (editortype == bushtype) {
scenecoords.y = Person::players[0]->coords.y - .5;
- if (editortype == firetype)
+ }
+ if (editortype == firetype) {
scenecoords.y = Person::players[0]->coords.y - .5;
+ }
float temprotat, temprotat2;
temprotat = editoryaw;
temprotat2 = editorpitch;
- if (temprotat < 0 || editortype == bushtype)
+ if (temprotat < 0 || editortype == bushtype) {
temprotat = Random() % 360;
- if (temprotat2 < 0)
+ }
+ if (temprotat2 < 0) {
temprotat2 = Random() % 360;
+ }
Object::MakeObject(editortype, scenecoords, (int)temprotat - ((int)temprotat) % 30, (int)temprotat2, editorsize);
- if (editortype == treetrunktype)
+ if (editortype == treetrunktype) {
Object::MakeObject(treeleavestype, scenecoords, Random() % 360 * (temprotat2 < 2) + (int)editoryaw - ((int)editoryaw) % 30, editorpitch, editorsize);
+ }
}
}
if (numpathpoints < 30) {
bool connected, alreadyconnected;
connected = 0;
- if (numpathpoints > 1)
+ if (numpathpoints > 1) {
for (int i = 0; i < numpathpoints; i++) {
if (distsq(&pathpoint[i], &Person::players[0]->coords) < .5 && i != pathpointselected && !connected) {
alreadyconnected = 0;
for (int j = 0; j < numpathpointconnect[pathpointselected]; j++) {
- if (pathpointconnect[pathpointselected][j] == i)
+ if (pathpointconnect[pathpointselected][j] == i) {
alreadyconnected = 1;
+ }
}
if (!alreadyconnected) {
numpathpointconnect[pathpointselected]++;
}
}
}
+ }
if (!connected) {
numpathpoints++;
pathpoint[numpathpoints - 1] = Person::players[0]->coords;
if (Input::isKeyPressed(SDL_SCANCODE_PERIOD)) {
pathpointselected++;
- if (pathpointselected >= numpathpoints)
+ if (pathpointselected >= numpathpoints) {
pathpointselected = -1;
+ }
}
if (Input::isKeyPressed(SDL_SCANCODE_COMMA) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
pathpointselected--;
- if (pathpointselected <= -2)
+ if (pathpointselected <= -2) {
pathpointselected = numpathpoints - 1;
+ }
}
if (Input::isKeyPressed(SDL_SCANCODE_COMMA) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
if (Input::isKeyPressed(SDL_SCANCODE_LEFT) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
editortype--;
- if (editortype == treeleavestype || editortype == 10)
+ if (editortype == treeleavestype || editortype == 10) {
editortype--;
- if (editortype < 0)
+ }
+ if (editortype < 0) {
editortype = firetype;
+ }
}
if (Input::isKeyPressed(SDL_SCANCODE_RIGHT) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
editortype++;
- if (editortype == treeleavestype || editortype == 10)
+ if (editortype == treeleavestype || editortype == 10) {
editortype++;
- if (editortype > firetype)
+ }
+ if (editortype > firetype) {
editortype = 0;
+ }
}
if (Input::isKeyDown(SDL_SCANCODE_LEFT) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
editoryaw -= multiplier * 100;
- if (editoryaw < -.01)
+ if (editoryaw < -.01) {
editoryaw = -.01;
+ }
}
if (Input::isKeyDown(SDL_SCANCODE_RIGHT) && !Input::isKeyDown(SDL_SCANCODE_LSHIFT) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
if (Input::isKeyDown(SDL_SCANCODE_DOWN) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
editorsize -= multiplier;
- if (editorsize < .1)
+ if (editorsize < .1) {
editorsize = .1;
+ }
}
if (Input::isKeyPressed(SDL_SCANCODE_LEFT) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
if (Input::isKeyDown(SDL_SCANCODE_DOWN) && Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
editorpitch -= multiplier * 100;
- if (editorpitch < -.01)
+ if (editorpitch < -.01) {
editorpitch = -.01;
+ }
}
if (Input::isKeyPressed(SDL_SCANCODE_DELETE) && Object::objects.size() && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
Person::players[i]->coords = Person::players[k]->coords;
Person::players[k]->targetyaw = Person::players[i]->targetyaw;
Person::players[k]->yaw = Person::players[i]->targetyaw;
- if (Person::players[k]->aitype == attacktypecutoff)
+ if (Person::players[k]->aitype == attacktypecutoff) {
Person::players[k]->stunned = .5;
+ }
}
if (Person::players[k]->animTarget == jumpupanim &&
Person::players[i]->animTarget != getupfrombackanim &&
Person::players[k]->coords = Person::players[i]->coords;
Person::players[i]->targetyaw = Person::players[k]->targetyaw;
Person::players[i]->yaw = Person::players[k]->targetyaw;
- if (Person::players[i]->aitype == attacktypecutoff)
+ if (Person::players[i]->aitype == attacktypecutoff) {
Person::players[i]->stunned = .5;
+ }
}
}
}
}
Person::players[k]->DoStuff();
- if (Person::players[k]->immobile && k != 0)
+ if (Person::players[k]->immobile && k != 0) {
Person::players[k]->coords = Person::players[k]->realoldcoords;
+ }
//if player's position has changed (?)
if (distsq(&Person::players[k]->coords, &Person::players[k]->realoldcoords) > 0 &&
int whichhit;
bool tempcollide = 0;
- if (Person::players[k]->collide < -.3)
+ if (Person::players[k]->collide < -.3) {
Person::players[k]->collide = -.3;
- if (Person::players[k]->collide > 1)
+ }
+ if (Person::players[k]->collide > 1) {
Person::players[k]->collide = 1;
+ }
Person::players[k]->collide -= multiplier * 30;
//clip to terrain
lowpoint = Person::players[k]->coords;
if (Person::players[k]->animTarget != jumpupanim &&
Person::players[k]->animTarget != jumpdownanim &&
- !Person::players[k]->isFlip())
+ !Person::players[k]->isFlip()) {
lowpoint.y += 1.25;
- else
+ } else {
lowpoint.y += 1.3;
+ }
if (Person::players[k]->coords.y < terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) &&
- Person::players[k]->coords.y > terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) - .1)
+ Person::players[k]->coords.y > terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) - .1) {
Person::players[k]->coords.y = terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z);
+ }
if (Person::players[k]->SphereCheck(&lowpoint, 1.3, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
flatfacing = lowpoint - Person::players[k]->coords;
Person::players[k]->coords = lowpoint;
if (whichhit != -1 && fabs(Object::objects[i]->model.Triangles[whichhit].facenormal.y) < .3) {
Person::players[k]->setTargetAnimation(walljumpleftanim);
emit_sound_at(movewhooshsound, Person::players[k]->coords);
- if (k == 0)
+ if (k == 0) {
pause_sound(whooshsound);
+ }
lowpointtarget = DoRotation(Object::objects[i]->model.Triangles[whichhit].facenormal, 0, Object::objects[i]->yaw, 0);
Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
- if (lowpointtarget.z < 0)
+ if (lowpointtarget.z < 0) {
Person::players[k]->yaw = 180 - Person::players[k]->yaw;
+ }
Person::players[k]->targetyaw = Person::players[k]->yaw;
Person::players[k]->lowyaw = Person::players[k]->yaw;
- if (k == 0)
+ if (k == 0) {
numwallflipped++;
+ }
} else {
lowpoint = tempcoords1;
lowpointtarget = lowpoint + DoRotation(Person::players[k]->facing, 0, 90, 0) * 1.5;
if (whichhit != -1 && fabs(Object::objects[i]->model.Triangles[whichhit].facenormal.y) < .3) {
Person::players[k]->setTargetAnimation(walljumprightanim);
emit_sound_at(movewhooshsound, Person::players[k]->coords);
- if (k == 0)
+ if (k == 0) {
pause_sound(whooshsound);
+ }
lowpointtarget = DoRotation(Object::objects[i]->model.Triangles[whichhit].facenormal, 0, Object::objects[i]->yaw, 0);
Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
- if (lowpointtarget.z < 0)
+ if (lowpointtarget.z < 0) {
Person::players[k]->yaw = 180 - Person::players[k]->yaw;
+ }
Person::players[k]->targetyaw = Person::players[k]->yaw;
Person::players[k]->lowyaw = Person::players[k]->yaw;
- if (k == 0)
+ if (k == 0) {
numwallflipped++;
+ }
} else {
lowpoint = tempcoords1;
lowpointtarget = lowpoint + Person::players[k]->facing * 2;
if (whichhit != -1 && fabs(Object::objects[i]->model.Triangles[whichhit].facenormal.y) < .3) {
Person::players[k]->setTargetAnimation(walljumpbackanim);
emit_sound_at(movewhooshsound, Person::players[k]->coords);
- if (k == 0)
+ if (k == 0) {
pause_sound(whooshsound);
+ }
lowpointtarget = DoRotation(Object::objects[i]->model.Triangles[whichhit].facenormal, 0, Object::objects[i]->yaw, 0);
Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
- if (lowpointtarget.z < 0)
+ if (lowpointtarget.z < 0) {
Person::players[k]->yaw = 180 - Person::players[k]->yaw;
+ }
Person::players[k]->targetyaw = Person::players[k]->yaw;
Person::players[k]->lowyaw = Person::players[k]->yaw;
- if (k == 0)
+ if (k == 0) {
numwallflipped++;
+ }
} else {
lowpoint = tempcoords1;
lowpointtarget = lowpoint - Person::players[k]->facing * 2;
if (whichhit != -1 && fabs(Object::objects[i]->model.Triangles[whichhit].facenormal.y) < .3) {
Person::players[k]->setTargetAnimation(walljumpfrontanim);
emit_sound_at(movewhooshsound, Person::players[k]->coords);
- if (k == 0)
+ if (k == 0) {
pause_sound(whooshsound);
+ }
lowpointtarget = DoRotation(Object::objects[i]->model.Triangles[whichhit].facenormal, 0, Object::objects[i]->yaw, 0);
Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
- if (lowpointtarget.z < 0)
+ if (lowpointtarget.z < 0) {
Person::players[k]->yaw = 180 - Person::players[k]->yaw;
+ }
Person::players[k]->yaw += 180;
Person::players[k]->targetyaw = Person::players[k]->yaw;
Person::players[k]->lowyaw = Person::players[k]->yaw;
- if (k == 0)
+ if (k == 0) {
numwallflipped++;
+ }
}
}
}
if (Person::players[k]->animTarget == jumpdownanim || Person::players[k]->isFlip()) {
//flipped into a rock
- if (Person::players[k]->isFlip() && Person::players[k]->targetFrame().label == 7)
+ if (Person::players[k]->isFlip() && Person::players[k]->targetFrame().label == 7) {
Person::players[k]->RagDoll(0);
+ }
if (Person::players[k]->animTarget == jumpupanim) {
Person::players[k]->jumppower = -4;
//landing
if ((Person::players[k]->animTarget == jumpdownanim || Person::players[k]->isFlip()) && !Person::players[k]->wasLanding()) {
- if (Person::players[k]->isFlip())
+ if (Person::players[k]->isFlip()) {
Person::players[k]->jumppower = -4;
+ }
Person::players[k]->animTarget = Person::players[k]->getLanding();
emit_sound_at(landsound, Person::players[k]->coords, 128.);
if (k == 0) {
}
}
- if (tempcollide)
+ if (tempcollide) {
for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
int i = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
lowpoint = Person::players[k]->coords;
lowpoint.y += 1.35;
- if (Object::objects[i]->type != rocktype)
+ if (Object::objects[i]->type != rocktype) {
if (Person::players[k]->SphereCheck(&lowpoint, 1.33, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
if (Person::players[k]->animTarget != jumpupanim &&
Person::players[k]->animTarget != jumpdownanim &&
- Person::players[k]->onterrain)
+ Person::players[k]->onterrain) {
Person::players[k]->avoidcollided = 1;
+ }
Person::players[k]->coords = lowpoint;
Person::players[k]->coords.y -= 1.35;
Person::players[k]->collide = 1;
lowpointtarget6 += facing * .6;
lowpointtarget7.y += 90 / 13;
whichhit = Object::objects[i]->model.LineCheckPossible(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
- if (Object::objects[i]->friction > .5)
+ if (Object::objects[i]->friction > .5) {
if (whichhit != -1) {
- if (Person::players[k]->animTarget != jumpupanim && Person::players[k]->animTarget != jumpdownanim)
+ if (Person::players[k]->animTarget != jumpupanim && Person::players[k]->animTarget != jumpdownanim) {
Person::players[k]->collided = 1;
- if (Object::checkcollide(lowpoint7, lowpointtarget7) == -1)
- if (Object::checkcollide(lowpoint6, lowpointtarget6) == -1)
+ }
+ if (Object::checkcollide(lowpoint7, lowpointtarget7) == -1) {
+ if (Object::checkcollide(lowpoint6, lowpointtarget6) == -1) {
if (Object::objects[i]->model.LineCheckPossible(&lowpoint2, &lowpointtarget2,
&colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
Object::objects[i]->model.LineCheckPossible(&lowpoint3, &lowpointtarget3,
Object::objects[i]->model.LineCheckPossible(&lowpoint4, &lowpointtarget4,
&colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
Object::objects[i]->model.LineCheckPossible(&lowpoint5, &lowpointtarget5,
- &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
+ &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1) {
for (int j = 0; j < 45; j++) {
lowpoint = Person::players[k]->coords;
lowpoint.y += (float)j / 13;
lowpointtarget = lowpoint + facing * 1.4;
if (Object::objects[i]->model.LineCheckPossible(&lowpoint, &lowpointtarget,
&colpoint2, &Object::objects[i]->position, &Object::objects[i]->yaw) == -1) {
- if (j <= 6 || j <= 25 && Person::players[k]->animTarget == jumpdownanim)
+ if (j <= 6 || j <= 25 && Person::players[k]->animTarget == jumpdownanim) {
break;
+ }
if (Person::players[k]->animTarget == jumpupanim || Person::players[k]->animTarget == jumpdownanim) {
lowpoint = Person::players[k]->coords;
lowpoint.y += (float)j / 13;
if (j > 10 || !Person::players[k]->isRun()) {
if (Person::players[k]->animTarget == jumpdownanim || Person::players[k]->animTarget == jumpupanim) {
- if (k == 0)
+ if (k == 0) {
pause_sound(whooshsound);
+ }
}
emit_sound_at(jumpsound, Person::players[k]->coords, 128.);
lowpointtarget = DoRotation(Object::objects[i]->model.Triangles[whichhit].facenormal, 0, Object::objects[i]->yaw, 0);
Person::players[k]->yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
- if (lowpointtarget.z < 0)
+ if (lowpointtarget.z < 0) {
Person::players[k]->yaw = 180 - Person::players[k]->yaw;
+ }
Person::players[k]->targetyaw = Person::players[k]->yaw;
Person::players[k]->lowyaw = Person::players[k]->yaw;
}
}
}
+ }
+ }
+ }
}
+ }
}
}
}
+ }
}
+ }
if (Person::players[k]->collide <= 0) {
//in the air
if (!Person::players[k]->onterrain &&
Person::players[k]->frameTarget < 2 ||
Person::players[k]->frameTarget > 6)) {
//stagger off ledge (?)
- if (Person::players[k]->animTarget == staggerbackhighanim || Person::players[k]->animTarget == staggerbackhardanim)
+ if (Person::players[k]->animTarget == staggerbackhighanim || Person::players[k]->animTarget == staggerbackhardanim) {
Person::players[k]->RagDoll(0);
+ }
Person::players[k]->setTargetAnimation(jumpdownanim);
- if (!k)
+ if (!k) {
emit_sound_at(whooshsound, Person::players[k]->coords, 128.);
+ }
}
//gravity
Person::players[k]->velocity.y += gravity;
static int randattack;
static bool playerrealattackkeydown = 0;
- if (!Input::isKeyDown(attackkey))
+ if (!Input::isKeyDown(attackkey)) {
oldattackkey = 0;
- if (oldattackkey)
+ }
+ if (oldattackkey) {
Person::players[0]->attackkeydown = 0;
- if (oldattackkey)
+ }
+ if (oldattackkey) {
playerrealattackkeydown = 0;
- if (!oldattackkey)
+ }
+ if (!oldattackkey) {
playerrealattackkeydown = Input::isKeyDown(attackkey);
+ }
if ((Person::players[0]->parriedrecently <= 0 ||
Person::players[0]->weaponactive == -1) &&
(!oldattackkey ||
Person::players[0]->lastattack != swordslashanim &&
Person::players[0]->lastattack != knifeslashstartanim &&
Person::players[0]->lastattack != staffhitanim &&
- Person::players[0]->lastattack != staffspinhitanim)))
+ Person::players[0]->lastattack != staffspinhitanim))) {
Person::players[0]->attackkeydown = Input::isKeyDown(attackkey);
+ }
if (Input::isKeyDown(attackkey) &&
!oldattackkey &&
!Person::players[0]->backkeydown) {
Person::players[k]->animTarget == staffhitanim ||
Person::players[k]->animTarget == staffspinhitanim) &&
Person::players[0]->animCurrent != dodgebackanim &&
- !Person::players[k]->skeleton.free)
+ !Person::players[k]->skeleton.free) {
Person::players[k]->Reverse();
+ }
}
}
- if (!hostile || Dialog::inDialog())
+ if (!hostile || Dialog::inDialog()) {
Person::players[0]->attackkeydown = 0;
+ }
for (unsigned k = 0; k < Person::players.size(); k++) {
- if (Dialog::inDialog())
+ if (Dialog::inDialog()) {
Person::players[k]->attackkeydown = 0;
+ }
if (Person::players[k]->animTarget != rabbitrunninganim && Person::players[k]->animTarget != wolfrunninganim) {
- if (Person::players[k]->aitype != playercontrolled)
+ if (Person::players[k]->aitype != playercontrolled) {
Person::players[k]->victim = Person::players[0];
+ }
//attack key pressed
if (Person::players[k]->attackkeydown) {
//dodge backward
Person::players[k]->jumppower -= 2;
} else {
for (unsigned i = 0; i < Person::players.size(); i++) {
- if (i == k)
+ if (i == k) {
continue;
+ }
if (Person::players[i]->animTarget == swordslashanim ||
Person::players[i]->animTarget == knifeslashstartanim ||
Person::players[i]->animTarget == staffhitanim ||
- Person::players[i]->animTarget == staffspinhitanim)
+ Person::players[i]->animTarget == staffspinhitanim) {
if (distsq(&Person::players[k]->coords, &Person::players[i]->coords) < 6.5 && !Person::players[i]->skeleton.free) {
Person::players[k]->setTargetAnimation(dodgebackanim);
Person::players[k]->targetyaw = roughDirectionTo(Person::players[k]->coords, Person::players[i]->coords);
Person::players[k]->targettilt2 = pitchTo(Person::players[k]->coords, Person::players[i]->coords);
}
+ }
}
if (Person::players[k]->animTarget != dodgebackanim) {
- if (k == 0)
+ if (k == 0) {
numflipped++;
+ }
Person::players[k]->setTargetAnimation(backhandspringanim);
Person::players[k]->targetyaw = -yaw + 180;
- if (Person::players[k]->leftkeydown)
+ if (Person::players[k]->leftkeydown) {
Person::players[k]->targetyaw -= 45;
- if (Person::players[k]->rightkeydown)
+ }
+ if (Person::players[k]->rightkeydown) {
Person::players[k]->targetyaw += 45;
+ }
Person::players[k]->yaw = Person::players[k]->targetyaw;
Person::players[k]->jumppower -= 2;
}
const int attackweapon = Person::players[k]->weaponactive == -1 ? 0 : weapons[Person::players[k]->weaponids[Person::players[k]->weaponactive]].getType();
//normal attacks (?)
Person::players[k]->hasvictim = 0;
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned i = 0; i < Person::players.size(); i++) {
- if (i == k || !(k == 0 || i == 0))
+ if (i == k || !(k == 0 || i == 0)) {
continue;
- if (!Person::players[k]->hasvictim)
+ }
+ if (!Person::players[k]->hasvictim) {
if (Animation::animations[Person::players[k]->animTarget].attack != reversal) {
//choose an attack
const float distance = distsq(&Person::players[k]->coords, &Person::players[i]->coords);
//sweep
if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
Person::players[k]->crouchkeydown &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ Animation::animations[Person::players[i]->animTarget].height != lowheight) {
Person::players[k]->animTarget = sweepanim;
- //winduppunch
- else if (distance < 1.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !Person::players[k]->forwardkeydown &&
- !Person::players[k]->leftkeydown &&
- !Person::players[k]->rightkeydown &&
- !Person::players[k]->crouchkeydown &&
- !attackweapon &&
- !reversaltrain)
+ //winduppunch
+ } else if (distance < 1.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !Person::players[k]->forwardkeydown &&
+ !Person::players[k]->leftkeydown &&
+ !Person::players[k]->rightkeydown &&
+ !Person::players[k]->crouchkeydown &&
+ !attackweapon &&
+ !reversaltrain) {
Person::players[k]->animTarget = winduppunchanim;
- //upunch
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !Person::players[k]->forwardkeydown &&
- !Person::players[k]->leftkeydown &&
- !Person::players[k]->rightkeydown &&
- !Person::players[k]->crouchkeydown &&
- !attackweapon)
+ //upunch
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !Person::players[k]->forwardkeydown &&
+ !Person::players[k]->leftkeydown &&
+ !Person::players[k]->rightkeydown &&
+ !Person::players[k]->crouchkeydown &&
+ !attackweapon) {
Person::players[k]->animTarget = upunchanim;
- //knifefollow
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Person::players[i]->staggerdelay > 0 &&
- attackweapon == knife &&
- Person::players[i]->bloodloss > Person::players[i]->damagetolerance / 2)
+ //knifefollow
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ Person::players[i]->staggerdelay > 0 &&
+ attackweapon == knife &&
+ Person::players[i]->bloodloss > Person::players[i]->damagetolerance / 2) {
Person::players[k]->animTarget = knifefollowanim;
- //knifeslashstart
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !Person::players[k]->forwardkeydown &&
- !Person::players[k]->leftkeydown &&
- !Person::players[k]->rightkeydown &&
- !Person::players[k]->crouchkeydown &&
- attackweapon == knife &&
- Person::players[k]->weaponmissdelay <= 0)
+ //knifeslashstart
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !Person::players[k]->forwardkeydown &&
+ !Person::players[k]->leftkeydown &&
+ !Person::players[k]->rightkeydown &&
+ !Person::players[k]->crouchkeydown &&
+ attackweapon == knife &&
+ Person::players[k]->weaponmissdelay <= 0) {
Person::players[k]->animTarget = knifeslashstartanim;
- //swordslash
- else if (distance < 4.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !Person::players[k]->crouchkeydown &&
- attackweapon == sword &&
- Person::players[k]->weaponmissdelay <= 0)
+ //swordslash
+ } else if (distance < 4.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !Person::players[k]->crouchkeydown &&
+ attackweapon == sword &&
+ Person::players[k]->weaponmissdelay <= 0) {
Person::players[k]->animTarget = swordslashanim;
- //staffhit
- else if (distance < 4.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !Person::players[k]->crouchkeydown &&
- attackweapon == staff &&
- Person::players[k]->weaponmissdelay <= 0 &&
- !Person::players[k]->leftkeydown &&
- !Person::players[k]->rightkeydown &&
- !Person::players[k]->forwardkeydown)
+ //staffhit
+ } else if (distance < 4.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !Person::players[k]->crouchkeydown &&
+ attackweapon == staff &&
+ Person::players[k]->weaponmissdelay <= 0 &&
+ !Person::players[k]->leftkeydown &&
+ !Person::players[k]->rightkeydown &&
+ !Person::players[k]->forwardkeydown) {
Person::players[k]->animTarget = staffhitanim;
- //staffspinhit
- else if (distance < 4.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !Person::players[k]->crouchkeydown &&
- attackweapon == staff &&
- Person::players[k]->weaponmissdelay <= 0)
+ //staffspinhit
+ } else if (distance < 4.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !Person::players[k]->crouchkeydown &&
+ attackweapon == staff &&
+ Person::players[k]->weaponmissdelay <= 0) {
Person::players[k]->animTarget = staffspinhitanim;
- //spinkick
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ //spinkick
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight) {
Person::players[k]->animTarget = spinkickanim;
- //lowkick
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height == lowheight &&
- Animation::animations[Person::players[k]->animTarget].attack != normalattack)
+ //lowkick
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height == lowheight &&
+ Animation::animations[Person::players[k]->animTarget].attack != normalattack) {
Person::players[k]->animTarget = lowkickanim;
+ }
} else { //AI player
if (distance < 4.5 * sq(Person::players[k]->scale * 5)) {
randattack = abs(Random() % 5);
if (!attackweapon && distance < 2.5 * sq(Person::players[k]->scale * 5)) {
//sweep
- if (randattack == 0 && Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ if (randattack == 0 && Animation::animations[Person::players[i]->animTarget].height != lowheight) {
Person::players[k]->animTarget = sweepanim;
- //upunch
- else if (randattack == 1 && Animation::animations[Person::players[i]->animTarget].height != lowheight &&
- !attackweapon)
+ //upunch
+ } else if (randattack == 1 && Animation::animations[Person::players[i]->animTarget].height != lowheight &&
+ !attackweapon) {
Person::players[k]->animTarget = upunchanim;
- //spinkick
- else if (randattack == 2 && Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ //spinkick
+ } else if (randattack == 2 && Animation::animations[Person::players[i]->animTarget].height != lowheight) {
Person::players[k]->animTarget = spinkickanim;
- //lowkick
- else if (Animation::animations[Person::players[i]->animTarget].height == lowheight)
+ //lowkick
+ } else if (Animation::animations[Person::players[i]->animTarget].height == lowheight) {
Person::players[k]->animTarget = lowkickanim;
+ }
}
if (attackweapon) {
//sweep
if ((!Tutorial::active || !attackweapon) &&
distance < 2.5 * sq(Person::players[k]->scale * 5) &&
randattack == 0 &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ Animation::animations[Person::players[i]->animTarget].height != lowheight) {
Person::players[k]->animTarget = sweepanim;
- //knifeslashstart
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- attackweapon == knife &&
- Person::players[k]->weaponmissdelay <= 0)
+ //knifeslashstart
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ attackweapon == knife &&
+ Person::players[k]->weaponmissdelay <= 0) {
Person::players[k]->animTarget = knifeslashstartanim;
- //swordslash
- else if (!(Person::players[0]->victim == Person::players[i] &&
- Person::players[0]->hasvictim &&
- Person::players[0]->animTarget == swordslashanim) &&
- attackweapon == sword &&
- Person::players[k]->weaponmissdelay <= 0)
+ //swordslash
+ } else if (!(Person::players[0]->victim == Person::players[i] &&
+ Person::players[0]->hasvictim &&
+ Person::players[0]->animTarget == swordslashanim) &&
+ attackweapon == sword &&
+ Person::players[k]->weaponmissdelay <= 0) {
Person::players[k]->animTarget = swordslashanim;
- //staffhit
- else if (!(Person::players[0]->victim == Person::players[i] &&
- Person::players[0]->hasvictim &&
- Person::players[0]->animTarget == swordslashanim) &&
- attackweapon == staff &&
- Person::players[k]->weaponmissdelay <= 0 &&
- randattack < 3)
+ //staffhit
+ } else if (!(Person::players[0]->victim == Person::players[i] &&
+ Person::players[0]->hasvictim &&
+ Person::players[0]->animTarget == swordslashanim) &&
+ attackweapon == staff &&
+ Person::players[k]->weaponmissdelay <= 0 &&
+ randattack < 3) {
Person::players[k]->animTarget = staffhitanim;
- //staffspinhit
- else if (!(Person::players[0]->victim == Person::players[i] &&
- Person::players[0]->hasvictim &&
- Person::players[0]->animTarget == swordslashanim) &&
- attackweapon == staff &&
- Person::players[k]->weaponmissdelay <= 0 &&
- randattack >= 3)
+ //staffspinhit
+ } else if (!(Person::players[0]->victim == Person::players[i] &&
+ Person::players[0]->hasvictim &&
+ Person::players[0]->animTarget == swordslashanim) &&
+ attackweapon == staff &&
+ Person::players[k]->weaponmissdelay <= 0 &&
+ randattack >= 3) {
Person::players[k]->animTarget = staffspinhitanim;
- //spinkick
- else if ((!Tutorial::active || !attackweapon) &&
- distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- randattack == 1 &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ //spinkick
+ } else if ((!Tutorial::active || !attackweapon) &&
+ distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ randattack == 1 &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight) {
Person::players[k]->animTarget = spinkickanim;
- //lowkick
- else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Animation::animations[Person::players[i]->animTarget].height == lowheight &&
- Animation::animations[Person::players[k]->animTarget].attack != normalattack)
+ //lowkick
+ } else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ Animation::animations[Person::players[i]->animTarget].height == lowheight &&
+ Animation::animations[Person::players[k]->animTarget].attack != normalattack) {
Person::players[k]->animTarget = lowkickanim;
+ }
}
}
}
//upunch becomes wolfslap
- if (Person::players[k]->animTarget == upunchanim && Person::players[k]->creature == wolftype)
+ if (Person::players[k]->animTarget == upunchanim && Person::players[k]->creature == wolftype) {
Person::players[k]->animTarget = wolfslapanim;
+ }
}
//sneak attacks
if ((k == 0) && (!Tutorial::active || Tutorial::stage == 22) &&
Person::players[i]->yaw = Person::players[k]->targetyaw;
}
}
+ }
}
+ }
const bool hasstaff = attackweapon == staff;
- if (k == 0 && Person::players.size() > 1)
+ if (k == 0 && Person::players.size() > 1) {
for (unsigned i = 0; i < Person::players.size(); i++) {
- if (i == k)
+ if (i == k) {
continue;
+ }
if ((playerrealattackkeydown || Person::players[i]->dead || !hasstaff) &&
Animation::animations[Person::players[k]->animTarget].attack == neutral) {
const float distance = distsq(&Person::players[k]->coords, &Person::players[i]->coords);
- if (!Person::players[i]->dead || !realthreat || (!attackweapon && Person::players[k]->crouchkeydown))
- if (Person::players[i]->skeleton.free)
+ if (!Person::players[i]->dead || !realthreat || (!attackweapon && Person::players[k]->crouchkeydown)) {
+ if (Person::players[i]->skeleton.free) {
if (distance < 3.5 * sq(Person::players[k]->scale * 5) &&
(Person::players[i]->dead ||
Person::players[i]->skeleton.longdead > 1000 ||
Person::players[k]->hasvictim = 1;
if (attackweapon && !Tutorial::active) {
//crouchstab
- if (Person::players[k]->crouchkeydown && attackweapon == knife && distance < 1.5 * sq(Person::players[k]->scale * 5))
+ if (Person::players[k]->crouchkeydown && attackweapon == knife && distance < 1.5 * sq(Person::players[k]->scale * 5)) {
Person::players[k]->animTarget = crouchstabanim;
+ }
//swordgroundstab
- if (Person::players[k]->crouchkeydown && distance < 1.5 * sq(Person::players[k]->scale * 5) && attackweapon == sword)
+ if (Person::players[k]->crouchkeydown && distance < 1.5 * sq(Person::players[k]->scale * 5) && attackweapon == sword) {
Person::players[k]->animTarget = swordgroundstabanim;
+ }
//staffgroundsmash
- if (distance < 3.5 * sq(Person::players[k]->scale * 5) && attackweapon == staff)
+ if (distance < 3.5 * sq(Person::players[k]->scale * 5) && attackweapon == staff) {
Person::players[k]->animTarget = staffgroundsmashanim;
+ }
}
if (distance < 2.5 &&
Person::players[k]->crouchkeydown &&
}
}
}
- if (!Person::players[i]->dead || musictype != 2)
+ if (!Person::players[i]->dead || musictype != 2) {
if (distance < 3.5 &&
(Person::players[k]->isRun() || Person::players[k]->isIdle() && Person::players[k]->attackkeydown) &&
Person::players[k]->staggerdelay <= 0 &&
}
}
}
+ }
}
+ }
+ }
if (Animation::animations[Person::players[k]->animTarget].attack == normalattack &&
Person::players[k]->victim == Person::players[i] &&
(!Person::players[i]->skeleton.free ||
Person::players[k]->targetyaw += (float)(abs(Random() % 100) - 50) / 4;
}
- if (Person::players[k]->animTarget == staffgroundsmashanim)
+ if (Person::players[k]->animTarget == staffgroundsmashanim) {
Person::players[k]->targettilt2 += 10;
+ }
Person::players[k]->lastattack3 = Person::players[k]->lastattack2;
Person::players[k]->lastattack2 = Person::players[k]->lastattack;
}
}
}
+ }
if (!Person::players[k]->hasvictim) {
//find victim
for (unsigned i = 0; i < Person::players.size(); i++) {
- if (i == k || !(i == 0 || k == 0))
+ if (i == k || !(i == 0 || k == 0)) {
continue;
+ }
if (!Person::players[i]->skeleton.free) {
if (Person::players[k]->hasvictim) {
if (distsq(&Person::players[k]->coords, &Person::players[i]->coords) <
- distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords))
+ distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords)) {
Person::players[k]->victim = Person::players[i];
+ }
} else {
Person::players[k]->victim = Person::players[i];
Person::players[k]->hasvictim = 1;
}
}
}
- if (Person::players[k]->aitype == playercontrolled)
+ if (Person::players[k]->aitype == playercontrolled) {
//rabbit kick
if (Person::players[k]->attackkeydown &&
Person::players[k]->isRun() &&
oldattackkey = 1;
Person::players[k]->setTargetAnimation(rabbitkickanim);
}
+ }
//update counts
if (Animation::animations[Person::players[k]->animTarget].attack && k == 0) {
numattacks++;
{
static XYZ rotatetarget;
static float collisionradius;
- if (Person::players.size() > 1)
- for (unsigned k = 0; k < Person::players.size(); k++)
+ if (Person::players.size() > 1) {
+ for (unsigned k = 0; k < Person::players.size(); k++) {
for (unsigned i = k + 1; i < Person::players.size(); i++) {
//neither player is part of a reversal
if ((Animation::animations[Person::players[i]->animTarget].attack != reversed &&
Animation::animations[Person::players[i]->animTarget].attack != reversal &&
Animation::animations[Person::players[k]->animTarget].attack != reversed &&
Animation::animations[Person::players[k]->animTarget].attack != reversal) ||
- (i != 0 && k != 0))
+ (i != 0 && k != 0)) {
if ((Animation::animations[Person::players[i]->animCurrent].attack != reversed &&
Animation::animations[Person::players[i]->animCurrent].attack != reversal &&
Animation::animations[Person::players[k]->animCurrent].attack != reversed &&
Animation::animations[Person::players[k]->animCurrent].attack != reversal) ||
- (i != 0 && k != 0))
+ (i != 0 && k != 0)) {
//neither is sleeping
- if (Person::players[i]->howactive <= typesleeping && Person::players[k]->howactive <= typesleeping)
- if (Person::players[i]->howactive != typesittingwall && Person::players[k]->howactive != typesittingwall)
+ if (Person::players[i]->howactive <= typesleeping && Person::players[k]->howactive <= typesleeping) {
+ if (Person::players[i]->howactive != typesittingwall && Person::players[k]->howactive != typesittingwall) {
//in same patch, neither is climbing
if (Person::players[i]->whichpatchx == Person::players[k]->whichpatchx &&
Person::players[i]->whichpatchz == Person::players[k]->whichpatchz &&
Person::players[i]->animTarget != climbanim &&
Person::players[i]->animTarget != hanganim &&
Person::players[k]->animTarget != climbanim &&
- Person::players[k]->animTarget != hanganim)
+ Person::players[k]->animTarget != hanganim) {
//players are close (bounding box test)
- if (Person::players[i]->coords.y > Person::players[k]->coords.y - 3)
- if (Person::players[i]->coords.y < Person::players[k]->coords.y + 3)
- if (Person::players[i]->coords.x > Person::players[k]->coords.x - 3)
- if (Person::players[i]->coords.x < Person::players[k]->coords.x + 3)
- if (Person::players[i]->coords.z > Person::players[k]->coords.z - 3)
+ if (Person::players[i]->coords.y > Person::players[k]->coords.y - 3) {
+ if (Person::players[i]->coords.y < Person::players[k]->coords.y + 3) {
+ if (Person::players[i]->coords.x > Person::players[k]->coords.x - 3) {
+ if (Person::players[i]->coords.x < Person::players[k]->coords.x + 3) {
+ if (Person::players[i]->coords.z > Person::players[k]->coords.z - 3) {
if (Person::players[i]->coords.z < Person::players[k]->coords.z + 3) {
//spread fire from player to player
if (distsq(&Person::players[i]->coords, &Person::players[k]->coords) < 3 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5)) {
if (Person::players[i]->onfire || Person::players[k]->onfire) {
- if (!Person::players[i]->onfire)
+ if (!Person::players[i]->onfire) {
Person::players[i]->CatchFire();
- if (!Person::players[k]->onfire)
+ }
+ if (!Person::players[k]->onfire) {
Person::players[k]->CatchFire();
+ }
}
}
XYZ tempcoords1 = Person::players[i]->coords;
XYZ tempcoords2 = Person::players[k]->coords;
- if (!Person::players[i]->skeleton.oldfree)
+ if (!Person::players[i]->skeleton.oldfree) {
tempcoords1.y += Person::players[i]->jointPos(abdomen).y * Person::players[i]->scale;
- if (!Person::players[k]->skeleton.oldfree)
+ }
+ if (!Person::players[k]->skeleton.oldfree) {
tempcoords2.y += Person::players[k]->jointPos(abdomen).y * Person::players[k]->scale;
+ }
collisionradius = 1.2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5);
- if (Person::players[0]->hasvictim)
- if (Person::players[0]->animTarget == rabbitkickanim && (k == 0 || i == 0) && !Person::players[0]->victim->skeleton.free)
+ if (Person::players[0]->hasvictim) {
+ if (Person::players[0]->animTarget == rabbitkickanim && (k == 0 || i == 0) && !Person::players[0]->victim->skeleton.free) {
collisionradius = 3;
+ }
+ }
if ((!Person::players[i]->skeleton.oldfree || !Person::players[k]->skeleton.oldfree) &&
(distsq(&tempcoords1, &tempcoords2) < collisionradius ||
distsq(&Person::players[i]->coords, &Person::players[k]->coords) < collisionradius)) {
if ((Person::players[i]->animTarget != getupfrombackanim && Person::players[i]->animTarget != getupfromfrontanim ||
Person::players[i]->skeleton.free) &&
(Person::players[k]->animTarget != getupfrombackanim && Person::players[k]->animTarget != getupfromfrontanim ||
- Person::players[k]->skeleton.free))
+ Person::players[k]->skeleton.free)) {
if ((((k != 0 && findLengthfast(&rotatetarget) > 150 ||
k == 0 && findLengthfast(&rotatetarget) > 50 && Person::players[0]->rabbitkickragdoll) &&
normaldotproduct(rotatetarget, Person::players[k]->coords - Person::players[i]->coords) > 0) &&
}
}
}
+ }
if ((Animation::animations[Person::players[i]->animTarget].attack == neutral ||
Animation::animations[Person::players[i]->animTarget].attack == normalattack) &&
(Animation::animations[Person::players[k]->animTarget].attack == neutral ||
Person::players[k]->coords = (Person::players[k]->coords + Person::players[i]->coords) / 2;
Person::players[i]->coords = Person::players[k]->coords - rotatetarget * fast_sqrt(.6) / 2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5);
Person::players[k]->coords += rotatetarget * fast_sqrt(.6) / 2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5);
- if (Person::players[k]->howactive == typeactive || hostile)
+ if (Person::players[k]->howactive == typeactive || hostile) {
if (Person::players[k]->isIdle()) {
- if (Person::players[k]->howactive < typesleeping)
+ if (Person::players[k]->howactive < typesleeping) {
Person::players[k]->setTargetAnimation(Person::players[k]->getStop());
- else if (Person::players[k]->howactive == typesleeping)
+ } else if (Person::players[k]->howactive == typesleeping) {
Person::players[k]->setTargetAnimation(getupfromfrontanim);
- if (!editorenabled)
+ }
+ if (!editorenabled) {
Person::players[k]->howactive = typeactive;
+ }
}
- if (Person::players[i]->howactive == typeactive || hostile)
+ }
+ if (Person::players[i]->howactive == typeactive || hostile) {
if (Person::players[i]->isIdle()) {
- if (Person::players[i]->howactive < typesleeping)
+ if (Person::players[i]->howactive < typesleeping) {
Person::players[i]->setTargetAnimation(Person::players[k]->getStop());
- else
+ } else {
Person::players[i]->setTargetAnimation(getupfromfrontanim);
- if (!editorenabled)
+ }
+ if (!editorenabled) {
Person::players[i]->howactive = typeactive;
+ }
}
+ }
}
//jump down on player
if (hostile) {
Person::players[k]->CheckKick();
}
}
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
+ }
+ }
}
void Game::Tick()
Input::Tick();
if (Input::isKeyPressed(SDL_SCANCODE_F6)) {
- if (Input::isKeyDown(SDL_SCANCODE_LSHIFT))
+ if (Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
stereoreverse = true;
- else
+ } else {
stereoreverse = false;
+ }
- if (stereoreverse)
+ if (stereoreverse) {
printf("Stereo reversed\n");
- else
+ } else {
printf("Stereo unreversed\n");
+ }
}
if (Input::isKeyDown(SDL_SCANCODE_F7)) {
- if (Input::isKeyDown(SDL_SCANCODE_LSHIFT))
+ if (Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
stereoseparation -= 0.001;
- else
+ } else {
stereoseparation -= 0.010;
+ }
printf("Stereo decreased increased to %f\n", stereoseparation);
}
if (Input::isKeyDown(SDL_SCANCODE_F8)) {
- if (Input::isKeyDown(SDL_SCANCODE_LSHIFT))
+ if (Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
stereoseparation += 0.001;
- else
+ } else {
stereoseparation += 0.010;
+ }
printf("Stereo separation increased to %f\n", stereoseparation);
}
if (!console) {
//campaign over?
- if (mainmenu && endgame == 1)
+ if (mainmenu && endgame == 1) {
mainmenu = 10;
+ }
//go to level select after completing a campaign level
if (campaign && winfreeze && mainmenu == 0 && campaignlevels[actuallevel].choosenext == 1) {
mainmenu = 5;
if (Input::isKeyPressed(SDL_SCANCODE_ESCAPE) &&
(gameon || mainmenu == 0)) {
selected = -1;
- if (mainmenu == 0 && !winfreeze)
+ if (mainmenu == 0 && !winfreeze) {
mainmenu = 2; //pause
- else if (mainmenu == 1 || mainmenu == 2) {
+ } else if (mainmenu == 1 || mainmenu == 2) {
mainmenu = 0; //unpause
}
//play menu theme
}
if (!mainmenu) {
- if (hostile == 1)
+ if (hostile == 1) {
hostiletime += multiplier;
- else
+ } else {
hostiletime = 0;
- if (!winfreeze)
+ }
+ if (!winfreeze) {
leveltime += multiplier;
+ }
//keys
if (Input::isKeyDown(SDL_SCANCODE_LALT) && Input::isKeyPressed(SDL_SCANCODE_V) && devtools) {
}
}
- if (console)
+ if (console) {
freeze = 1;
+ }
if (console && !Input::isKeyDown(SDL_SCANCODE_LGUI)) {
inputText(consoletext[0], &consoleselected);
if (!waiting) {
OPENAL_SetFrequency(OPENAL_ALL);
emit_sound_np(consolesuccesssound);
}
- if (winfreeze == 0)
+ if (winfreeze == 0) {
oldwinfreeze = winfreeze;
- else
+ } else {
oldwinfreeze++;
+ }
- if ((Input::isKeyPressed(jumpkey) || Input::isKeyPressed(SDL_SCANCODE_SPACE)) && !campaign)
- if (winfreeze)
+ if ((Input::isKeyPressed(jumpkey) || Input::isKeyPressed(SDL_SCANCODE_SPACE)) && !campaign) {
+ if (winfreeze) {
winfreeze = 0;
+ }
+ }
if ((Input::isKeyDown(SDL_SCANCODE_ESCAPE)) && !campaign && gameon) {
if (console) {
console = false;
//dialogues
static float talkdelay = 0;
- if (Dialog::inDialog())
+ if (Dialog::inDialog()) {
talkdelay = 1;
+ }
talkdelay -= multiplier;
if (talkdelay <= 0 && !Dialog::inDialog() && Animation::animations[Person::players[0]->animTarget].height != highheight) {
bonus != twoxcombo &&
bonus != threexcombo &&
bonus != fourxcombo &&
- bonus != megacombo)
+ bonus != megacombo) {
bonusnum[bonus]++;
- else
+ } else {
bonusnum[bonus] += 0.15;
- if (Tutorial::active)
+ }
+ if (Tutorial::active) {
bonusvalue = 0;
+ }
bonusvalue /= bonusnum[bonus];
bonustotal += bonusvalue;
}
precipdelay -= multiplier;
while (precipdelay < 0) {
precipdelay += .04;
- if (!detail)
+ if (!detail) {
precipdelay += .04;
+ }
XYZ footvel, footpoint;
footvel = 0;
Person::players[0]->throwkeydown = 0;
}
- if (!Person::players[0]->jumpkeydown)
+ if (!Person::players[0]->jumpkeydown) {
Person::players[0]->jumpclimb = 0;
+ }
if (Dialog::inDialog()) {
cameramode = 1;
flatfacing = DoRotation(flatfacing, 0, -yaw, 0);
- if (Input::isKeyDown(forwardkey))
+ if (Input::isKeyDown(forwardkey)) {
viewer += facing * multiplier * 4;
- if (Input::isKeyDown(backkey))
+ }
+ if (Input::isKeyDown(backkey)) {
viewer -= facing * multiplier * 4;
- if (Input::isKeyDown(leftkey))
+ }
+ if (Input::isKeyDown(leftkey)) {
viewer += DoRotation(flatfacing * multiplier, 0, 90, 0) * 4;
- if (Input::isKeyDown(rightkey))
+ }
+ if (Input::isKeyDown(rightkey)) {
viewer += DoRotation(flatfacing * multiplier, 0, -90, 0) * 4;
- if (Input::isKeyDown(jumpkey))
+ }
+ if (Input::isKeyDown(jumpkey)) {
viewer.y += multiplier * 4;
- if (Input::isKeyDown(crouchkey))
+ }
+ if (Input::isKeyDown(crouchkey)) {
viewer.y -= multiplier * 4;
+ }
if (Input::isKeyPressed(SDL_SCANCODE_1) ||
Input::isKeyPressed(SDL_SCANCODE_2) ||
Input::isKeyPressed(SDL_SCANCODE_3) ||
Input::isKeyPressed(SDL_SCANCODE_0) ||
Input::isKeyPressed(SDL_SCANCODE_MINUS)) {
int whichend;
- if (Input::isKeyPressed(SDL_SCANCODE_1))
+ if (Input::isKeyPressed(SDL_SCANCODE_1)) {
whichend = 1;
- if (Input::isKeyPressed(SDL_SCANCODE_2))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_2)) {
whichend = 2;
- if (Input::isKeyPressed(SDL_SCANCODE_3))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_3)) {
whichend = 3;
- if (Input::isKeyPressed(SDL_SCANCODE_4))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_4)) {
whichend = 4;
- if (Input::isKeyPressed(SDL_SCANCODE_5))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_5)) {
whichend = 5;
- if (Input::isKeyPressed(SDL_SCANCODE_6))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_6)) {
whichend = 6;
- if (Input::isKeyPressed(SDL_SCANCODE_7))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_7)) {
whichend = 7;
- if (Input::isKeyPressed(SDL_SCANCODE_8))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_8)) {
whichend = 8;
- if (Input::isKeyPressed(SDL_SCANCODE_9))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_9)) {
whichend = 9;
- if (Input::isKeyPressed(SDL_SCANCODE_0))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_0)) {
whichend = 0;
- if (Input::isKeyPressed(SDL_SCANCODE_MINUS))
+ }
+ if (Input::isKeyPressed(SDL_SCANCODE_MINUS)) {
whichend = -1;
+ }
if (whichend != -1) {
Dialog::currentScene().participantfocus = whichend;
Dialog::currentDialog().participantlocation[whichend] = Person::players[whichend]->coords;
Input::isKeyDown(SDL_SCANCODE_KP_9) ||
Input::isKeyDown(SDL_SCANCODE_KP_0)) {
int whichend;
- if (Input::isKeyDown(SDL_SCANCODE_KP_1))
+ if (Input::isKeyDown(SDL_SCANCODE_KP_1)) {
whichend = 1;
- if (Input::isKeyDown(SDL_SCANCODE_KP_2))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_2)) {
whichend = 2;
- if (Input::isKeyDown(SDL_SCANCODE_KP_3))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_3)) {
whichend = 3;
- if (Input::isKeyDown(SDL_SCANCODE_KP_4))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_4)) {
whichend = 4;
- if (Input::isKeyDown(SDL_SCANCODE_KP_5))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_5)) {
whichend = 5;
- if (Input::isKeyDown(SDL_SCANCODE_KP_6))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_6)) {
whichend = 6;
- if (Input::isKeyDown(SDL_SCANCODE_KP_7))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_7)) {
whichend = 7;
- if (Input::isKeyDown(SDL_SCANCODE_KP_8))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_8)) {
whichend = 8;
- if (Input::isKeyDown(SDL_SCANCODE_KP_9))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_9)) {
whichend = 9;
- if (Input::isKeyDown(SDL_SCANCODE_KP_0))
+ }
+ if (Input::isKeyDown(SDL_SCANCODE_KP_0)) {
whichend = 0;
+ }
Dialog::currentScene().participantfacing[whichend] = facing;
}
if (Dialog::indialogue >= int(Dialog::currentDialog().scenes.size())) {
if (Person::players[0]->jumpkeydown &&
Person::players[0]->animTarget != jumpupanim &&
Person::players[0]->animTarget != jumpdownanim &&
- !Person::players[0]->isFlip())
+ !Person::players[0]->isFlip()) {
Person::players[0]->jumptogglekeydown = 1;
+ }
Dialog::dialoguetime += multiplier;
hawkyaw += multiplier * 25;
doJumpReversals();
- for (unsigned k = 0; k < Person::players.size(); k++)
- if (k != 0 && Person::players[k]->immobile)
+ for (unsigned k = 0; k < Person::players.size(); k++) {
+ if (k != 0 && Person::players[k]->immobile) {
Person::players[k]->coords = Person::players[k]->realoldcoords;
+ }
+ }
for (unsigned k = 0; k < Person::players.size(); k++) {
if (!isnormal(Person::players[k]->coords.x) || !isnormal(Person::players[k]->coords.y) || !isnormal(Person::players[k]->coords.z)) {
Person::players[0]->animTarget != dodgebackanim &&
Person::players[0]->animTarget != walljumprightkickanim &&
Person::players[0]->animTarget != walljumpleftkickanim) {
- if (cameramode)
+ if (cameramode) {
Person::players[0]->targetyaw = 0;
- else
+ } else {
Person::players[0]->targetyaw = -yaw + 180;
+ }
}
facing = 0;
Person::players[i]->targetheadpitch = pitchOf(Dialog::currentScene().participantfacing[i]);
}
- if (leveltime < .5)
+ if (leveltime < .5) {
numenvsounds = 0;
+ }
Person::players[i]->avoidsomething = 0;
//avoid flaming things
- for (unsigned int j = 0; j < Object::objects.size(); j++)
- if (Object::objects[j]->onfire)
- if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) < sq(Object::objects[j]->scale) * 200)
+ for (unsigned int j = 0; j < Object::objects.size(); j++) {
+ if (Object::objects[j]->onfire) {
+ if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) < sq(Object::objects[j]->scale) * 200) {
if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
Person::players[i]->collided = 0;
Person::players[i]->avoidsomething = 1;
}
}
+ }
+ }
+ }
//avoid flaming players
- for (unsigned j = 0; j < Person::players.size(); j++)
- if (Person::players[j]->onfire)
- if (distsq(&Person::players[j]->coords, &Person::players[i]->coords) < sq(0.3) * 200)
+ for (unsigned j = 0; j < Person::players.size(); j++) {
+ if (Person::players[j]->onfire) {
+ if (distsq(&Person::players[j]->coords, &Person::players[i]->coords) < sq(0.3) * 200) {
if (distsq(&Person::players[i]->coords, &Person::players[j]->coords) <
distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
Person::players[i]->collided = 0;
Person::players[i]->avoidsomething = 1;
}
}
+ }
+ }
+ }
- if (Person::players[i]->collided > .8)
+ if (Person::players[i]->collided > .8) {
Person::players[i]->avoidcollided = 0;
+ }
Person::players[i]->doAI();
Person::players[i]->throwkeydown = 0;
}
- if (Person::players[i]->collided < -.3)
+ if (Person::players[i]->collided < -.3) {
Person::players[i]->collided = -.3;
- if (Person::players[i]->collided > 1)
+ }
+ if (Person::players[i]->collided > 1) {
Person::players[i]->collided = 1;
+ }
Person::players[i]->collided -= multiplier * 4;
Person::players[i]->whichdirectiondelay -= multiplier;
if (Person::players[i]->avoidcollided < -.3 || Person::players[i]->whichdirectiondelay <= 0) {
Person::players[i]->whichdirection = abs(Random() % 2);
Person::players[i]->whichdirectiondelay = .4;
}
- if (Person::players[i]->avoidcollided > 1)
+ if (Person::players[i]->avoidcollided > 1) {
Person::players[i]->avoidcollided = 1;
+ }
Person::players[i]->avoidcollided -= multiplier / 4;
if (!Person::players[i]->skeleton.free) {
Person::players[i]->stunned -= multiplier;
Person::players[i]->aitype == attacktypecutoff &&
!Person::players[i]->dead &&
!Person::players[i]->skeleton.free &&
- Animation::animations[Person::players[i]->animTarget].attack == neutral)
+ Animation::animations[Person::players[i]->animTarget].attack == neutral) {
numresponded = 1;
+ }
- if (!Person::players[i]->throwkeydown)
+ if (!Person::players[i]->throwkeydown) {
Person::players[i]->throwtogglekeydown = 0;
+ }
//pick up weapon
if (Person::players[i]->throwkeydown && !Person::players[i]->throwtogglekeydown) {
if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 ||
Person::players[i]->aitype == playercontrolled) &&
weapons[j].owner == -1 &&
- Person::players[i]->weaponactive == -1)
+ Person::players[i]->weaponactive == -1) {
if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2) {
if (distsq(&Person::players[i]->coords, &weapons[j].position) < 2) {
if (Person::players[i]->isCrouch() ||
Person::players[i]->aitype == playercontrolled) &&
weapons[j].owner == -1 ||
Person::players[i]->victim &&
- weapons[j].owner == int(Person::players[i]->victim->id))
- if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2 && Person::players[i]->weaponactive == -1)
+ weapons[j].owner == int(Person::players[i]->victim->id)) {
+ if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2 && Person::players[i]->weaponactive == -1) {
if (distsq(&Person::players[i]->coords, &weapons[j].position) < 1 || Person::players[i]->victim) {
- if (weapons[j].getType() != staff)
+ if (weapons[j].getType() != staff) {
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
+ }
Person::players[i]->takeWeapon(j);
}
+ }
+ }
}
} else if ((Person::players[i]->isIdle() ||
Person::players[i]->isFlip() ||
Person::players[i]->hasvictim = 0;
for (unsigned k = 0; k < weapons.size(); k++) {
- if (Person::players[i]->weaponactive == -1)
+ if (Person::players[i]->weaponactive == -1) {
if ((weapons[k].velocity.x == 0 && weapons[k].velocity.y == 0 && weapons[k].velocity.z == 0 ||
Person::players[i]->aitype == playercontrolled) &&
weapons[k].owner == -1 ||
Person::players[i]->victim &&
- weapons[k].owner == int(Person::players[i]->victim->id))
+ weapons[k].owner == int(Person::players[i]->victim->id)) {
if (distsqflat(&Person::players[i]->coords, &weapons[k].position) < 3 &&
Person::players[i]->weaponactive == -1) {
- if (weapons[k].getType() != staff)
+ if (weapons[k].getType() != staff) {
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
+ }
Person::players[i]->takeWeapon(k);
}
+ }
+ }
}
}
}
}
+ }
}
if (Person::players[i]->isCrouch() ||
Person::players[i]->animTarget == sneakanim ||
Person::players[i]->isRun() ||
Person::players[i]->isIdle() || Person::players[i]->animTarget == rollanim ||
Person::players[i]->animTarget == backhandspringanim) {
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned j = 0; j < Person::players.size(); j++) {
- if (Person::players[i]->weaponactive == -1)
- if (j != i)
+ if (Person::players[i]->weaponactive == -1) {
+ if (j != i) {
if (Person::players[j]->num_weapons &&
Person::players[j]->skeleton.free &&
distsq(&Person::players[i]->coords, &Person::players[j]->coords) < 2 /*&&Person::players[j]->dead*/ &&
}
}
if (!fleshstuck) {
- if (weapons[k].getType() != staff)
+ if (weapons[k].getType() != staff) {
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
+ }
}
- if (fleshstuck)
+ if (fleshstuck) {
emit_sound_at(fleshstabremovesound, Person::players[i]->coords, 128.);
+ }
if (weapons[k].owner != -1) {
- if (Person::players[i]->victim->num_weapons == 1)
+ if (Person::players[i]->victim->num_weapons == 1) {
Person::players[i]->victim->num_weapons = 0;
- else
+ } else {
Person::players[i]->victim->num_weapons = 1;
+ }
Person::players[i]->victim->skeleton.longdead = 0;
Person::players[i]->victim->skeleton.free = 1;
footpoint = weapons[k].position;
if (Person::players[i]->victim->weaponstuck != -1) {
if (Person::players[i]->victim->weaponids[Person::players[i]->victim->weaponstuck] == k) {
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
+ }
weapons[k].bloody = 2;
weapons[k].blooddrip = 5;
Person::players[i]->victim->weaponstuck = -1;
}
}
if (Person::players[i]->victim->num_weapons > 0) {
- if (Person::players[i]->victim->weaponstuck != 0 && Person::players[i]->victim->weaponstuck != -1)
+ if (Person::players[i]->victim->weaponstuck != 0 && Person::players[i]->victim->weaponstuck != -1) {
Person::players[i]->victim->weaponstuck = 0;
- if (Person::players[i]->victim->weaponids[0] == k)
+ }
+ if (Person::players[i]->victim->weaponids[0] == k) {
Person::players[i]->victim->weaponids[0] = Person::players[i]->victim->weaponids[Person::players[i]->victim->num_weapons];
+ }
}
Person::players[i]->victim->weaponactive = -1;
}
}
}
+ }
+ }
}
+ }
}
}
if (Person::players[i]->weaponactive != -1 && Person::players[i]->aitype == playercontrolled) {
Person::players[i]->isRun() ||
Person::players[i]->isCrouch() ||
Person::players[i]->animTarget == sneakanim ||
- Person::players[i]->isFlip())
- if (Person::players.size() > 1)
+ Person::players[i]->isFlip()) {
+ if (Person::players.size() > 1) {
for (unsigned j = 0; j < Person::players.size(); j++) {
- if (i != j)
- if (!Tutorial::active || Tutorial::stage == 49)
- if (hostile)
+ if (i != j) {
+ if (!Tutorial::active || Tutorial::stage == 49) {
+ if (hostile) {
if (normaldotproduct(Person::players[i]->facing, Person::players[i]->coords - Person::players[j]->coords) < 0 &&
distsq(&Person::players[i]->coords, &Person::players[j]->coords) < 100 &&
distsq(&Person::players[i]->coords, &Person::players[j]->coords) > 1.5 &&
}
}
}
+ }
+ }
+ }
}
+ }
+ }
}
}
if (Person::players[i]->weaponactive != -1 && Person::players[i]->aitype == playercontrolled) {
if (Person::players[i]->isCrouch() || Person::players[i]->animTarget == sneakanim) {
Person::players[i]->throwtogglekeydown = 1;
XYZ tempVelocity = Person::players[i]->velocity * .2;
- if (tempVelocity.x == 0)
+ if (tempVelocity.x == 0) {
tempVelocity.x = .1;
+ }
weapons[Person::players[i]->weaponids[0]].drop(tempVelocity, tempVelocity, false);
Person::players[i]->num_weapons--;
if (Person::players[i]->num_weapons) {
Person::players[i]->weaponids[0] = Person::players[i]->weaponids[Person::players[i]->num_weapons];
- if (Person::players[i]->weaponstuck == Person::players[i]->num_weapons)
+ if (Person::players[i]->weaponstuck == Person::players[i]->num_weapons) {
Person::players[i]->weaponstuck = 0;
+ }
}
Person::players[i]->weaponactive = -1;
(Person::players[i]->weaponactive != -1) &&
i != 0) {
bool isgood = true;
- if (Person::players[i]->weaponactive != -1)
- if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == staff)
+ if (Person::players[i]->weaponactive != -1) {
+ if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == staff) {
isgood = false;
+ }
+ }
if (isgood && Person::players[i]->creature != wolftype) {
if (Person::players[i]->isIdle() && Person::players[i]->num_weapons && weapons[Person::players[i]->weaponids[0]].getType() == knife) {
Person::players[i]->setTargetAnimation(drawrightanim);
Person::players[i]->num_weapons &&
Person::players[i]->attackkeydown &&
musictype != stream_fighttheme) {
- if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == knife)
+ if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == knife) {
Person::players[i]->setTargetAnimation(crouchstabanim);
- if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == sword)
+ }
+ if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == sword) {
Person::players[i]->setTargetAnimation(swordgroundstabanim);
+ }
Person::players[i]->hasvictim = 0;
}
}
- if (!Person::players[i]->drawkeydown)
+ if (!Person::players[i]->drawkeydown) {
Person::players[i]->drawtogglekeydown = 0;
+ }
XYZ absflatfacing;
if (i == 0) {
absflatfacing.z = -1;
absflatfacing = DoRotation(absflatfacing, 0, -yaw, 0);
- } else
+ } else {
absflatfacing = flatfacing;
+ }
if (Dialog::inDialog()) {
Person::players[i]->forwardkeydown = 0;
Person::players[i]->animTarget != staggerbackhardanim &&
Person::players[i]->animTarget != backhandspringanim &&
Person::players[i]->animTarget != dodgebackanim) {
- if (!Person::players[i]->forwardkeydown)
+ if (!Person::players[i]->forwardkeydown) {
Person::players[i]->forwardstogglekeydown = 0;
+ }
if (Person::players[i]->crouchkeydown) {
//Crouch
target = -2;
if (i == 0) {
Person::players[i]->superruntoggle = 1;
- if (Person::players.size() > 1)
- for (unsigned j = 0; j < Person::players.size(); j++)
- if (j != i && !Person::players[j]->skeleton.free && Person::players[j]->aitype == passivetype)
- if (distsq(&Person::players[j]->coords, &Person::players[i]->coords) < 16)
+ if (Person::players.size() > 1) {
+ for (unsigned j = 0; j < Person::players.size(); j++) {
+ if (j != i && !Person::players[j]->skeleton.free && Person::players[j]->aitype == passivetype) {
+ if (distsq(&Person::players[j]->coords, &Person::players[i]->coords) < 16) {
Person::players[i]->superruntoggle = 0;
+ }
+ }
+ }
+ }
}
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != i && !Person::players[j]->skeleton.free && Person::players[j]->victim && Person::players[i]->lowreversaldelay <= 0) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 3 &&
Person::players[j]->animTarget == staffhitanim ||
Person::players[j]->animTarget == staffspinhitanim) &&
distsq(&Person::players[j]->coords, &Person::players[i]->coords) < 2))) {
- if (target >= 0)
+ if (target >= 0) {
target = -1;
- else
+ } else {
target = j;
+ }
}
}
}
- if (target >= 0)
+ }
+ if (target >= 0) {
Person::players[target]->Reverse();
+ }
Person::players[i]->lowreversaldelay = .5;
if (Person::players[i]->isIdle()) {
}
if (!Person::players[i]->crouchkeydown) {
//Uncrouch
- if (!Person::players[i]->isRun() && Person::players[i]->animTarget != sneakanim && i == 0)
+ if (!Person::players[i]->isRun() && Person::players[i]->animTarget != sneakanim && i == 0) {
Person::players[i]->superruntoggle = 0;
+ }
target = -2;
if (Person::players[i]->isCrouch()) {
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != i &&
!Person::players[j]->skeleton.free &&
Person::players[j]->victim == Person::players[i] &&
(Person::players[j]->animTarget == spinkickanim) &&
Person::players[i]->isCrouch()) {
- if (target >= 0)
+ if (target >= 0) {
target = -1;
- else
+ } else {
target = j;
+ }
}
}
}
- if (target >= 0)
+ }
+ if (target >= 0) {
Person::players[target]->Reverse();
+ }
Person::players[i]->highreversaldelay = .5;
if (Person::players[i]->isCrouch()) {
Person::players[i]->frameTarget > 0 &&
!Person::players[i]->jumpkeydown &&
Person::players[i]->crouchkeydown)) {
- if (Person::players[i]->aitype == passivetype)
+ if (Person::players[i]->aitype == passivetype) {
Person::players[i]->setTargetAnimation(walkanim);
- else
+ } else {
Person::players[i]->setTargetAnimation(Person::players[i]->getRun());
+ }
}
if (Person::players[i]->isCrouch()) {
Person::players[i]->animTarget = sneakanim;
- if (Person::players[i]->wasCrouch())
+ if (Person::players[i]->wasCrouch()) {
Person::players[i]->target = 0;
+ }
Person::players[i]->frameTarget = 0;
}
if (Person::players[i]->animTarget == hanganim /*&&(!Person::players[i]->forwardstogglekeydown||Person::players[i]->aitype!=playercontrolled)*/) {
}
if (Person::players[i]->isCrouch()) {
Person::players[i]->animTarget = sneakanim;
- if (Person::players[i]->wasCrouch())
+ if (Person::players[i]->wasCrouch()) {
Person::players[i]->target = 0;
+ }
Person::players[i]->frameTarget = 0;
}
if (Person::players[i]->animTarget == jumpupanim || Person::players[i]->animTarget == jumpdownanim || Person::players[i]->isFlip()) {
Person::players[i]->velocity += DoRotation(absflatfacing * 5 * multiplier, 0, -90, 0);
}
Person::players[i]->targetyaw -= 90;
- if (Person::players[i]->forwardkeydown)
+ if (Person::players[i]->forwardkeydown) {
Person::players[i]->targetyaw += 45;
- if (Person::players[i]->backkeydown)
+ }
+ if (Person::players[i]->backkeydown) {
Person::players[i]->targetyaw -= 45;
+ }
movekey = 1;
}
if (Person::players[i]->leftkeydown) {
}
if (Person::players[i]->isCrouch()) {
Person::players[i]->animTarget = sneakanim;
- if (Person::players[i]->wasCrouch())
+ if (Person::players[i]->wasCrouch()) {
Person::players[i]->target = 0;
+ }
Person::players[i]->frameTarget = 0;
}
if (Person::players[i]->animTarget == jumpupanim || Person::players[i]->animTarget == jumpdownanim || Person::players[i]->isFlip()) {
Person::players[i]->velocity -= DoRotation(absflatfacing * 5 * multiplier, 0, -90, 0);
}
Person::players[i]->targetyaw += 90;
- if (Person::players[i]->forwardkeydown)
+ if (Person::players[i]->forwardkeydown) {
Person::players[i]->targetyaw -= 45;
- if (Person::players[i]->backkeydown)
+ }
+ if (Person::players[i]->backkeydown) {
Person::players[i]->targetyaw += 45;
+ }
movekey = 1;
}
if (Person::players[i]->backkeydown) {
}
if (Person::players[i]->isCrouch()) {
Person::players[i]->animTarget = sneakanim;
- if (Person::players[i]->wasCrouch())
+ if (Person::players[i]->wasCrouch()) {
Person::players[i]->target = 0;
+ }
Person::players[i]->frameTarget = 0;
}
if (Person::players[i]->animTarget == jumpupanim || Person::players[i]->animTarget == jumpdownanim || Person::players[i]->isFlip()) {
Person::players[i]->coords.y -= 1.4;
Person::players[i]->grabdelay = 1;
}
- if (!Person::players[i]->leftkeydown && !Person::players[i]->rightkeydown)
+ if (!Person::players[i]->leftkeydown && !Person::players[i]->rightkeydown) {
Person::players[i]->targetyaw += 180;
+ }
movekey = 1;
}
if ((Person::players[i]->jumpkeydown && !Person::players[i]->jumpclimb) || Person::players[i]->jumpstart) {
facing.z = -1;
flatfacing = DoRotation(facing, 0, Person::players[i]->targetyaw + 180, 0);
- if (movekey)
+ if (movekey) {
Person::players[i]->velocity = flatfacing * Person::players[i]->speed * 45 * Person::players[i]->scale;
- if (!movekey)
+ }
+ if (!movekey) {
Person::players[i]->velocity = 0;
+ }
//Dodge sweep?
target = -2;
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != i && !Person::players[j]->skeleton.free && Person::players[j]->victim) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 3 &&
(Person::players[j]->victim == Person::players[i]) &&
(Person::players[j]->animTarget == sweepanim)) {
- if (target >= 0)
+ if (target >= 0) {
target = -1;
- else
+ } else {
target = j;
+ }
}
}
}
- if (target >= 0)
+ }
+ if (target >= 0) {
Person::players[i]->velocity.y = 1;
- else if (Person::players[i]->crouchkeydown || Person::players[i]->aitype != playercontrolled) {
+ } else if (Person::players[i]->crouchkeydown || Person::players[i]->aitype != playercontrolled) {
Person::players[i]->velocity.y = 7;
Person::players[i]->crouchtogglekeydown = 1;
- } else
+ } else {
Person::players[i]->velocity.y = 5;
+ }
if (mousejump && i == 0 && devtools) {
- if (!Person::players[i]->isLanding())
+ if (!Person::players[i]->isLanding()) {
Person::players[i]->tempdeltav = deltav;
- if (Person::players[i]->tempdeltav < 0)
+ }
+ if (Person::players[i]->tempdeltav < 0) {
Person::players[i]->velocity.y -= (float)(Person::players[i]->tempdeltav) / multiplier / 1000;
+ }
}
Person::players[i]->coords.y += .2;
Person::players[i]->jumppower -= 1;
- if (!i)
+ if (!i) {
emit_sound_at(whooshsound, Person::players[i]->coords, 128.);
+ }
emit_sound_at(jumpsound, Person::players[i]->coords, 128.);
}
Person::players[i]->jumppower = 0;
}
}
- if (((floatjump || editorenabled) && devtools) && i == 0)
+ if (((floatjump || editorenabled) && devtools) && i == 0) {
Person::players[i]->velocity.y += multiplier * 30;
+ }
}
if (!movekey) {
(Person::players[i]->aitype == attacktypecutoff ||
Person::players[i]->aitype == searchtype ||
(Person::players[i]->aitype == passivetype &&
- Person::players[i]->numwaypoints <= 1)))
+ Person::players[i]->numwaypoints <= 1))) {
Person::players[i]->setTargetAnimation(Person::players[i]->getStop());
- if (Person::players[i]->isRun() && (Person::players[i]->aitype == passivetype))
+ }
+ if (Person::players[i]->isRun() && (Person::players[i]->aitype == passivetype)) {
Person::players[i]->setTargetAnimation(Person::players[i]->getStop());
+ }
}
}
- if (Person::players[i]->animTarget == rollanim)
+ if (Person::players[i]->animTarget == rollanim) {
Person::players[i]->targetyaw = oldtargetyaw;
+ }
}
//Rotation
for (unsigned k = 0; k < Person::players.size(); k++) {
if (fabs(Person::players[k]->yaw - Person::players[k]->targetyaw) > 180) {
- if (Person::players[k]->yaw > Person::players[k]->targetyaw)
+ if (Person::players[k]->yaw > Person::players[k]->targetyaw) {
Person::players[k]->yaw -= 360;
- else
+ } else {
Person::players[k]->yaw += 360;
+ }
}
//stop to turn in right direction
- if (fabs(Person::players[k]->yaw - Person::players[k]->targetyaw) > 90 && (Person::players[k]->isRun() || Person::players[k]->animTarget == walkanim))
+ if (fabs(Person::players[k]->yaw - Person::players[k]->targetyaw) > 90 && (Person::players[k]->isRun() || Person::players[k]->animTarget == walkanim)) {
Person::players[k]->setTargetAnimation(Person::players[k]->getStop());
+ }
- if (Person::players[k]->animTarget == backhandspringanim || Person::players[k]->animTarget == dodgebackanim)
+ if (Person::players[k]->animTarget == backhandspringanim || Person::players[k]->animTarget == dodgebackanim) {
Person::players[k]->targettilt = 0;
+ }
if (Person::players[k]->animTarget != jumpupanim &&
Person::players[k]->animTarget != backhandspringanim &&
Person::players[k]->animTarget != jumpdownanim &&
!Person::players[k]->isFlip()) {
Person::players[k]->targettilt = 0;
- if (Person::players[k]->jumppower < 0 && !Person::players[k]->jumpkeydown)
+ if (Person::players[k]->jumppower < 0 && !Person::players[k]->jumpkeydown) {
Person::players[k]->jumppower = 0;
+ }
Person::players[k]->jumppower += multiplier * 7;
- if (Person::players[k]->isCrouch())
+ if (Person::players[k]->isCrouch()) {
Person::players[k]->jumppower += multiplier * 7;
- if (Person::players[k]->jumppower > 5)
+ }
+ if (Person::players[k]->jumppower > 5) {
Person::players[k]->jumppower = 5;
+ }
}
- if (Person::players[k]->isRun())
+ if (Person::players[k]->isRun()) {
Person::players[k]->targettilt = (Person::players[k]->yaw - Person::players[k]->targetyaw) / 4;
+ }
Person::players[k]->tilt = stepTowardf(Person::players[k]->tilt, Person::players[k]->targettilt, multiplier * 150);
Person::players[k]->grabdelay -= multiplier;
}
}
- if (Input::isKeyPressed(SDL_SCANCODE_F1))
+ if (Input::isKeyPressed(SDL_SCANCODE_F1)) {
Screenshot();
+ }
}
void Game::TickOnce()
} else {
pitch += deltav * .7;
}
- if (pitch > 90)
+ if (pitch > 90) {
pitch = 90;
- if (pitch < -70)
+ }
+ if (pitch < -70) {
pitch = -70;
+ }
}
}
if (!mainmenu) {
static int oldmusictype = musictype;
- if (environment == snowyenvironment)
+ if (environment == snowyenvironment) {
leveltheme = stream_snowtheme;
- if (environment == grassyenvironment)
+ }
+ if (environment == grassyenvironment) {
leveltheme = stream_grasstheme;
- if (environment == desertenvironment)
+ }
+ if (environment == desertenvironment) {
leveltheme = stream_deserttheme;
+ }
realthreat = 0;
realthreat = 1;
}
}
- if (Person::players[0]->dead)
+ if (Person::players[0]->dead) {
musictype = stream_menutheme;
+ }
- if (musictype == stream_fighttheme)
+ if (musictype == stream_fighttheme) {
unseendelay = 1;
+ }
if (oldmusictype == stream_fighttheme && musictype != stream_fighttheme) {
unseendelay -= multiplier;
- if (unseendelay > 0)
+ if (unseendelay > 0) {
musictype = stream_fighttheme;
+ }
}
if (loading == 2) {
musicvolume[3] = 0;
}
- if (musictoggle)
- if (musictype != oldmusictype && musictype == stream_fighttheme)
+ if (musictoggle) {
+ if (musictype != oldmusictype && musictype == stream_fighttheme) {
emit_sound_np(alarmsound);
+ }
+ }
musicselected = musictype;
- if (musicselected == leveltheme)
+ if (musicselected == leveltheme) {
musicvolume[0] += multiplier * 450;
- else
+ } else {
musicvolume[0] -= multiplier * 450;
- if (musicselected == stream_fighttheme)
+ }
+ if (musicselected == stream_fighttheme) {
musicvolume[1] += multiplier * 450;
- else
+ } else {
musicvolume[1] -= multiplier * 450;
- if (musicselected == stream_menutheme)
+ }
+ if (musicselected == stream_menutheme) {
musicvolume[2] += multiplier * 450;
- else
+ } else {
musicvolume[2] -= multiplier * 450;
+ }
for (int i = 0; i < 3; i++) {
- if (musicvolume[i] < 0)
+ if (musicvolume[i] < 0) {
musicvolume[i] = 0;
- if (musicvolume[i] > 512)
+ }
+ if (musicvolume[i] > 512) {
musicvolume[i] = 512;
+ }
}
- if (musicvolume[2] > 128 && !loading && !mainmenu)
+ if (musicvolume[2] > 128 && !loading && !mainmenu) {
musicvolume[2] = 128;
+ }
if (musictoggle) {
- if (musicvolume[0] > 0 && oldmusicvolume[0] <= 0)
+ if (musicvolume[0] > 0 && oldmusicvolume[0] <= 0) {
emit_stream_np(leveltheme, musicvolume[0]);
- if (musicvolume[1] > 0 && oldmusicvolume[1] <= 0)
+ }
+ if (musicvolume[1] > 0 && oldmusicvolume[1] <= 0) {
emit_stream_np(stream_fighttheme, musicvolume[1]);
- if (musicvolume[2] > 0 && oldmusicvolume[2] <= 0)
+ }
+ if (musicvolume[2] > 0 && oldmusicvolume[2] <= 0) {
emit_stream_np(stream_menutheme, musicvolume[2]);
- if (musicvolume[0] <= 0 && oldmusicvolume[0] > 0)
+ }
+ if (musicvolume[0] <= 0 && oldmusicvolume[0] > 0) {
pause_sound(leveltheme);
- if (musicvolume[1] <= 0 && oldmusicvolume[1] > 0)
+ }
+ if (musicvolume[1] <= 0 && oldmusicvolume[1] > 0) {
pause_sound(stream_fighttheme);
- if (musicvolume[2] <= 0 && oldmusicvolume[2] > 0)
+ }
+ if (musicvolume[2] <= 0 && oldmusicvolume[2] > 0) {
pause_sound(stream_menutheme);
+ }
- if (musicvolume[0] != oldmusicvolume[0])
+ if (musicvolume[0] != oldmusicvolume[0]) {
OPENAL_SetVolume(channels[leveltheme], musicvolume[0]);
- if (musicvolume[1] != oldmusicvolume[1])
+ }
+ if (musicvolume[1] != oldmusicvolume[1]) {
OPENAL_SetVolume(channels[stream_fighttheme], musicvolume[1]);
- if (musicvolume[2] != oldmusicvolume[2])
+ }
+ if (musicvolume[2] != oldmusicvolume[2]) {
OPENAL_SetVolume(channels[stream_menutheme], musicvolume[2]);
+ }
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
oldmusicvolume[i] = musicvolume[i];
+ }
} else {
pause_sound(leveltheme);
pause_sound(stream_fighttheme);
Hotspot::killhotspot = 2;
for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
if (Hotspot::hotspots[i].type > 10 && Hotspot::hotspots[i].type < 20) {
- if (Person::players[Hotspot::hotspots[i].type - 10]->dead == 0)
+ if (Person::players[Hotspot::hotspots[i].type - 10]->dead == 0) {
Hotspot::killhotspot = 0;
- else if (Hotspot::killhotspot == 2)
+ } else if (Hotspot::killhotspot == 2) {
Hotspot::killhotspot = 1;
+ }
}
}
- if (Hotspot::killhotspot == 2)
+ if (Hotspot::killhotspot == 2) {
Hotspot::killhotspot = 0;
+ }
winhotspot = false;
for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
if (alldead && !Person::players[0]->dead && maptype == mapkilleveryone) {
changedelay = 1;
targetlevel = whichlevel + 1;
- if (targetlevel > numchallengelevels - 1)
+ if (targetlevel > numchallengelevels - 1) {
targetlevel = 0;
+ }
}
if (winhotspot || windialogue) {
changedelay = 0.1;
targetlevel = whichlevel + 1;
- if (targetlevel > numchallengelevels - 1)
+ if (targetlevel > numchallengelevels - 1) {
targetlevel = 0;
+ }
}
if (Hotspot::killhotspot) {
changedelay = 1;
targetlevel = whichlevel + 1;
- if (targetlevel > numchallengelevels - 1)
+ if (targetlevel > numchallengelevels - 1) {
targetlevel = 0;
+ }
}
if (changedelay > 0 && !Person::players[0]->dead && !won) {
}
if (!editorenabled && gameon && !mainmenu) {
- if (changedelay != -999)
+ if (changedelay != -999) {
changedelay -= multiplier / 7;
- if (Person::players[0]->dead)
+ }
+ if (Person::players[0]->dead) {
targetlevel = whichlevel;
+ }
if (loading == 2 && !campaign) {
flash();
fireSound(firestartsound);
- if (!Person::players[0]->dead && targetlevel != whichlevel)
+ if (!Person::players[0]->dead && targetlevel != whichlevel) {
startbonustotal = bonustotal;
+ }
LoadLevel(targetlevel);
fireSound();
(Person::players[0]->dead ||
(alldead && maptype == mapkilleveryone) ||
(winhotspot) ||
- (Hotspot::killhotspot)))
+ (Hotspot::killhotspot))) {
loading = 1;
+ }
if ((Person::players[0]->dead ||
(alldead && maptype == mapkilleveryone) ||
(winhotspot) ||
winfreeze = true;
changedelay = -999;
}
- if (Person::players[0]->dead)
+ if (Person::players[0]->dead) {
loading = 1;
+ }
}
}
// 1 = go back to level select screen
// 2 = stealthload next level
if (mainmenu == 0 && winfreeze && (campaignlevels[actuallevel].choosenext) == 1) {
- if (campaignlevels[actuallevel].nextlevel.empty())
+ if (campaignlevels[actuallevel].nextlevel.empty()) {
endgame = 1;
+ }
} else if (mainmenu == 0 && winfreeze) {
stealthloading = (campaignlevels[actuallevel].choosenext == 2);
}
}
- if (loading == 3)
+ if (loading == 3) {
loading = 0;
+ }
}
oldmusictype = musictype;
viewerfacing = facing;
if (!cameramode) {
- if ((Animation::animations[Person::players[0]->animTarget].attack != 3 && Animation::animations[Person::players[0]->animCurrent].attack != 3) || Person::players[0]->skeleton.free)
+ if ((Animation::animations[Person::players[0]->animTarget].attack != 3 && Animation::animations[Person::players[0]->animCurrent].attack != 3) || Person::players[0]->skeleton.free) {
target = Person::players[0]->coords + Person::players[0]->currentoffset * (1 - Person::players[0]->target) * Person::players[0]->scale + Person::players[0]->targetoffset * Person::players[0]->target * Person::players[0]->scale - Person::players[0]->facing * .05;
- else
+ } else {
target = Person::players[0]->oldcoords + Person::players[0]->currentoffset * (1 - Person::players[0]->target) * Person::players[0]->scale + Person::players[0]->targetoffset * Person::players[0]->target * Person::players[0]->scale - Person::players[0]->facing * .05;
+ }
target.y += .1;
if (Person::players[0]->skeleton.free) {
for (unsigned i = 0; i < Person::players[0]->skeleton.joints.size(); i++) {
- if (Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y > target.y)
+ if (Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y > target.y) {
target.y = Person::players[0]->skeleton.joints[i].position.y * Person::players[0]->scale + Person::players[0]->coords.y;
+ }
}
target.y += .1;
}
if (findLengthfast(&Person::players[0]->velocity) > 400) {
cameraspeed = 20 + (findLength(&Person::players[0]->velocity) - 20) * .96;
}
- if (Person::players[0]->skeleton.free == 0 && Person::players[0]->animTarget != hanganim && Person::players[0]->animTarget != climbanim)
+ if (Person::players[0]->skeleton.free == 0 && Person::players[0]->animTarget != hanganim && Person::players[0]->animTarget != climbanim) {
target.y += 1.4;
+ }
coltarget = target - cameraloc;
- if (findLengthfast(&coltarget) < multiplier * multiplier * 400)
+ if (findLengthfast(&coltarget) < multiplier * multiplier * 400) {
cameraloc = target;
- else {
+ } else {
Normalise(&coltarget);
- if (Person::players[0]->animTarget != hanganim && Person::players[0]->animTarget != climbanim && Person::players[0]->animCurrent != climbanim && Person::players[0]->currentoffset.x == 0)
+ if (Person::players[0]->animTarget != hanganim && Person::players[0]->animTarget != climbanim && Person::players[0]->animCurrent != climbanim && Person::players[0]->currentoffset.x == 0) {
cameraloc = cameraloc + coltarget * multiplier * cameraspeed;
- else
+ } else {
cameraloc = cameraloc + coltarget * multiplier * 8;
+ }
}
- if (editorenabled)
+ if (editorenabled) {
cameraloc = target;
+ }
cameradist += multiplier * 5;
- if (cameradist > 2.3)
+ if (cameradist > 2.3) {
cameradist = 2.3;
+ }
viewer = cameraloc - facing * cameradist;
colviewer = viewer;
coltarget = cameraloc;
cameraloc.y = terrain.getHeight(cameraloc.x, cameraloc.z);
}
}
- if (camerashake > .8)
+ if (camerashake > .8) {
camerashake = .8;
+ }
woozy += multiplier;
- if (Person::players[0]->dead)
+ if (Person::players[0]->dead) {
camerashake = 0;
- if (Person::players[0]->dead)
+ }
+ if (Person::players[0]->dead) {
woozy = 0;
+ }
camerashake -= multiplier * 2;
blackout -= multiplier * 2;
- if (camerashake < 0)
+ if (camerashake < 0) {
camerashake = 0;
- if (blackout < 0)
+ }
+ if (blackout < 0) {
blackout = 0;
+ }
if (camerashake) {
viewer.x += (float)(Random() % 100) * .0005 * camerashake;
viewer.y += (float)(Random() % 100) * .0005 * camerashake;
*p1 = *p1 - *move;
*p2 = *p2 - *move;
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, -*rotate, 0);
- if (*rotate)
+ }
+ if (*rotate) {
*p2 = DoRotation(*p2, 0, -*rotate, 0);
- if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+ }
+ if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) {
return -1;
+ }
firstintersecting = -1;
for (unsigned int j = 0; j < Triangles.size(); j++) {
}
}
- if (*rotate)
+ if (*rotate) {
*p = DoRotation(*p, 0, *rotate, 0);
+ }
*p = *p + *move;
return firstintersecting;
}
*p1 = *p1 - *move;
*p2 = *p2 - *move;
- if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+ if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) {
return -1;
+ }
firstintersecting = -1;
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, -*rotate, 0);
- if (*rotate)
+ }
+ if (*rotate) {
*p2 = DoRotation(*p2, 0, -*rotate, 0);
+ }
for (unsigned int j = 0; j < possible.size(); j++) {
if (possible[j] < Triangles.size()) {
}
}
- if (*rotate)
+ if (*rotate) {
*p = DoRotation(*p, 0, *rotate, 0);
+ }
*p = *p + *move;
return firstintersecting;
}
*p1 = *p1 - *move;
*p2 = *p2 - *move;
- if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+ if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius)) {
return -1;
+ }
firstintersecting = -1;
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, -*rotate, 0);
- if (*rotate)
+ }
+ if (*rotate) {
*p2 = DoRotation(*p2, 0, -*rotate, 0);
+ }
for (unsigned int j = 0; j < possible.size(); j++) {
if (possible[j] < Triangles.size()) {
*p2 -= Triangles[firstintersecting].facenormal * distance;
}
- if (*rotate)
+ if (*rotate) {
*p2 = DoRotation(*p2, 0, *rotate, 0);
+ }
*p2 = *p2 + *move;
return firstintersecting;
}
oldp1 = *p1;
*p1 = *p1 - *move;
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, -*rotate, 0);
- if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius)
+ }
+ if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius) {
return -1;
+ }
for (i = 0; i < 4; i++) {
for (unsigned int j = 0; j < Triangles.size(); j++) {
distance = abs((Triangles[j].facenormal.x * p1->x) + (Triangles[j].facenormal.y * p1->y) + (Triangles[j].facenormal.z * p1->z) - ((Triangles[j].facenormal.x * vertex[Triangles[j].vertex[0]].x) + (Triangles[j].facenormal.y * vertex[Triangles[j].vertex[0]].y) + (Triangles[j].facenormal.z * vertex[Triangles[j].vertex[0]].z)));
if (distance < radius) {
point = *p1 - Triangles[j].facenormal * distance;
- if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+ if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]])) {
intersecting = 1;
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], p1, &radius);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
+ }
if (intersecting) {
*p1 += Triangles[j].facenormal * (distance - radius);
}
}
}
}
- if (*rotate)
+ if (*rotate) {
*p = DoRotation(*p, 0, *rotate, 0);
+ }
*p = *p + *move;
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, *rotate, 0);
+ }
*p1 += *move;
return firstintersecting;
}
possible.clear();
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, -*rotate, 0);
+ }
if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius) {
*p1 = oldp1;
return -1;
distance = abs((Triangles[j].facenormal.x * p1->x) + (Triangles[j].facenormal.y * p1->y) + (Triangles[j].facenormal.z * p1->z) - ((Triangles[j].facenormal.x * vertex[Triangles[j].vertex[0]].x) + (Triangles[j].facenormal.y * vertex[Triangles[j].vertex[0]].y) + (Triangles[j].facenormal.z * vertex[Triangles[j].vertex[0]].z)));
if (distance < radius) {
point = *p1 - Triangles[j].facenormal * distance;
- if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+ if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]])) {
intersecting = 1;
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], p1, &radius);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
+ }
if (intersecting) {
possible.push_back(j);
}
firstintersecting = j;
}
}
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, *rotate, 0);
+ }
*p1 += *move;
return firstintersecting;
void Model::UpdateVertexArray()
{
- if (type != normaltype && type != decalstype)
+ if (type != normaltype && type != decalstype) {
return;
+ }
if (flat) {
for (unsigned int i = 0; i < Triangles.size(); i++) {
void Model::UpdateVertexArrayNoTex()
{
- if (type != normaltype && type != decalstype)
+ if (type != normaltype && type != decalstype) {
return;
+ }
if (flat) {
for (unsigned int i = 0; i < Triangles.size(); i++) {
void Model::UpdateVertexArrayNoTexNoNorm()
{
- if (type != normaltype && type != decalstype)
+ if (type != normaltype && type != decalstype) {
return;
+ }
for (unsigned int i = 0; i < Triangles.size(); i++) {
unsigned int j = i * 24;
void Model::ScaleNormals(float xscale, float yscale, float zscale)
{
- if (type != normaltype && type != decalstype)
+ if (type != normaltype && type != decalstype) {
return;
+ }
for (int i = 0; i < vertexNum; i++) {
normals[i].x *= xscale;
{
Game::LoadingScreen();
- if (type != normaltype && type != decalstype)
+ if (type != normaltype && type != decalstype) {
return;
+ }
for (int i = 0; i < vertexNum; i++) {
normals[i].x = 0;
normals[Triangles[i].vertex[2]].x += Triangles[i].facenormal.x;
normals[Triangles[i].vertex[2]].y += Triangles[i].facenormal.y;
normals[Triangles[i].vertex[2]].z += Triangles[i].facenormal.z;
- if (facenormalise)
+ if (facenormalise) {
Normalise(&Triangles[i].facenormal);
+ }
}
for (int i = 0; i < vertexNum; i++) {
Normalise(&normals[i]);
void Model::draw()
{
- if (type != normaltype && type != decalstype)
+ if (type != normaltype && type != decalstype) {
return;
+ }
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(0);
for (unsigned int i = 0; i < decals.size(); i++) {
- if (decals[i].type == blooddecalfast && decals[i].alivetime < 2)
+ if (decals[i].type == blooddecalfast && decals[i].alivetime < 2) {
decals[i].alivetime = 2;
+ }
if (decals[i].type != lasttype) {
if (decals[i].type == shadowdecal) {
}
if (decals[i].type == breakdecal) {
glColor4f(1, 1, 1, decals[i].opacity);
- if (decals[i].alivetime > 58)
+ if (decals[i].alivetime > 58) {
glColor4f(1, 1, 1, decals[i].opacity * (60 - decals[i].alivetime) / 2);
+ }
}
if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow)) {
glColor4f(1, 1, 1, decals[i].opacity);
- if (decals[i].alivetime < 4)
+ if (decals[i].alivetime < 4) {
glColor4f(1, 1, 1, decals[i].opacity * decals[i].alivetime * .25);
- if (decals[i].alivetime > 58)
+ }
+ if (decals[i].alivetime > 58) {
glColor4f(1, 1, 1, decals[i].opacity * (60 - decals[i].alivetime) / 2);
+ }
}
lasttype = decals[i].type;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
}
for (int i = decals.size() - 1; i >= 0; i--) {
decals[i].alivetime += multiplier;
- if (decals[i].type == blooddecalslow)
+ if (decals[i].type == blooddecalslow) {
decals[i].alivetime -= multiplier * 2 / 3;
- if (decals[i].type == blooddecalfast)
+ }
+ if (decals[i].type == blooddecalfast) {
decals[i].alivetime += multiplier * 4;
- if (decals[i].type == shadowdecal)
+ }
+ if (decals[i].type == shadowdecal) {
DeleteDecal(i);
- if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow) && decals[i].alivetime >= 60)
+ }
+ if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow) && decals[i].alivetime >= 60) {
DeleteDecal(i);
+ }
}
glAlphaFunc(GL_GREATER, 0.0001);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
void Model::DeleteDecal(int which)
{
if (decalstoggle) {
- if (type != decalstype)
+ if (type != decalstype) {
return;
+ }
decals.erase(decals.begin() + which);
}
}
void Model::MakeDecal(decal_type atype, XYZ* where, float* size, float* opacity, float* rotation)
{
if (decalstoggle) {
- if (type != decalstype)
+ if (type != decalstype) {
return;
+ }
static XYZ rot;
static float distance;
- if (*opacity > 0)
- if (distsq(where, &boundingspherecenter) < (boundingsphereradius + *size) * (boundingsphereradius + *size))
+ if (*opacity > 0) {
+ if (distsq(where, &boundingspherecenter) < (boundingsphereradius + *size) * (boundingsphereradius + *size)) {
for (unsigned int i = 0; i < Triangles.size(); i++) {
if (Triangles[i].facenormal.y < -.1 && (vertex[Triangles[i].vertex[0]].y < where->y || vertex[Triangles[i].vertex[1]].y < where->y || vertex[Triangles[i].vertex[2]].y < where->y)) {
distance = abs(((Triangles[i].facenormal.x * where->x) + (Triangles[i].facenormal.y * where->y) + (Triangles[i].facenormal.z * where->z) - ((Triangles[i].facenormal.x * vertex[Triangles[i].vertex[0]].x) + (Triangles[i].facenormal.y * vertex[Triangles[i].vertex[0]].y) + (Triangles[i].facenormal.z * vertex[Triangles[i].vertex[0]].z))) / Triangles[i].facenormal.y);
if ((*opacity - distance / 10) > 0) {
Decal decal(*where, atype, *opacity - distance / 10, *rotation, *size, *this, i, 0);
- if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
- if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
- if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+ if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+ if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+ if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
if (decal.rotation) {
for (int j = 0; j < 3; j++) {
decals.push_back(decal);
}
}
+ }
+ }
+ }
}
}
}
+ }
+ }
}
}
void Model::MakeDecal(decal_type atype, XYZ where, float size, float opacity, float rotation)
{
if (decalstoggle) {
- if (type != decalstype)
+ if (type != decalstype) {
return;
+ }
static XYZ rot;
static float distance;
- if (opacity > 0)
- if (distsq(&where, &boundingspherecenter) < (boundingsphereradius + size) * (boundingsphereradius + size))
+ if (opacity > 0) {
+ if (distsq(&where, &boundingspherecenter) < (boundingsphereradius + size) * (boundingsphereradius + size)) {
for (unsigned int i = 0; i < Triangles.size(); i++) {
distance = abs(((Triangles[i].facenormal.x * where.x) + (Triangles[i].facenormal.y * where.y) + (Triangles[i].facenormal.z * where.z) - ((Triangles[i].facenormal.x * vertex[Triangles[i].vertex[0]].x) + (Triangles[i].facenormal.y * vertex[Triangles[i].vertex[0]].y) + (Triangles[i].facenormal.z * vertex[Triangles[i].vertex[0]].z))));
if (distance < .02 && abs(Triangles[i].facenormal.y) > abs(Triangles[i].facenormal.x) && abs(Triangles[i].facenormal.y) > abs(Triangles[i].facenormal.z)) {
if ((opacity - distance / 10) > 0) {
Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 0);
- if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
- if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
- if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+ if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+ if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+ if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
if (decal.rotation) {
for (int j = 0; j < 3; j++) {
decals.push_back(decal);
}
}
+ }
+ }
+ }
}
} else if (distance < .02 && abs(Triangles[i].facenormal.x) > abs(Triangles[i].facenormal.y) && abs(Triangles[i].facenormal.x) > abs(Triangles[i].facenormal.z)) {
if ((opacity - distance / 10) > 0) {
Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 1);
- if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
- if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
- if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+ if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+ if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+ if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
if (decal.rotation) {
for (int j = 0; j < 3; j++) {
decals.push_back(decal);
}
}
+ }
+ }
+ }
}
} else if (distance < .02 && abs(Triangles[i].facenormal.z) > abs(Triangles[i].facenormal.y) && abs(Triangles[i].facenormal.z) > abs(Triangles[i].facenormal.x)) {
if ((opacity - distance / 10) > 0) {
Decal decal(where, atype, opacity - distance / 10, rotation, size, *this, i, 2);
- if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0))
- if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0))
- if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1))
+ if (!(decal.texcoords[0][0] < 0 && decal.texcoords[1][0] < 0 && decal.texcoords[2][0] < 0)) {
+ if (!(decal.texcoords[0][1] < 0 && decal.texcoords[1][1] < 0 && decal.texcoords[2][1] < 0)) {
+ if (!(decal.texcoords[0][0] > 1 && decal.texcoords[1][0] > 1 && decal.texcoords[2][0] > 1)) {
if (!(decal.texcoords[0][1] > 1 && decal.texcoords[1][1] > 1 && decal.texcoords[2][1] > 1)) {
if (decal.rotation) {
for (int j = 0; j < 3; j++) {
decals.push_back(decal);
}
}
+ }
+ }
+ }
}
}
}
+ }
+ }
}
}
void Model::deallocate()
{
- if (owner)
+ if (owner) {
free(owner);
+ }
owner = 0;
- if (vertex)
+ if (vertex) {
free(vertex);
+ }
vertex = 0;
- if (normals)
+ if (normals) {
free(normals);
+ }
normals = 0;
- if (vArray)
+ if (vArray) {
free(vArray);
+ }
vArray = 0;
decals.clear();
break;
case splintersprite:
if (lastspecial != sprites[i]->special) {
- if (sprites[i]->special == 0)
+ if (sprites[i]->special == 0) {
splintertexture.bind();
- if (sprites[i]->special == 1)
+ }
+ if (sprites[i]->special == 1) {
leaftexture.bind();
- if (sprites[i]->special == 2)
+ }
+ if (sprites[i]->special == 2) {
snowflaketexture.bind();
- if (sprites[i]->special == 3)
+ }
+ if (sprites[i]->special == 3) {
toothtexture.bind();
+ }
if (!blend) {
blend = 1;
glAlphaFunc(GL_GREATER, 0.0001);
break;
}
}
- if (sprites[i]->type == snowsprite)
+ if (sprites[i]->type == snowsprite) {
distancemult = (144 - (distsq(&tempviewer, &sprites[i]->position) - (144 * fadestart)) * (1 / (1 - fadestart))) / 144;
- else
+ } else {
distancemult = (viewdistsquared - (distsq(&viewer, &sprites[i]->position) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
+ }
if (sprites[i]->type == flamesprite) {
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity);
- else
+ } else {
glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity * distancemult);
+ }
} else {
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity);
- else
+ } else {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity * distancemult);
+ }
}
lasttype = sprites[i]->type;
lastspecial = sprites[i]->special;
glRotatef(sprites[i]->rotation, 0, 0, 1);
if ((sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite)) {
- if (sprites[i]->alivetime < .14)
+ if (sprites[i]->alivetime < .14) {
glScalef(sprites[i]->alivetime / .14, sprites[i]->alivetime / .14, sprites[i]->alivetime / .14);
+ }
}
if (sprites[i]->type == smoketype || sprites[i]->type == snowsprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == breathsprite) {
if (sprites[i]->alivetime < .3) {
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity * sprites[i]->alivetime / .3);
- if (distancemult < 1)
+ }
+ if (distancemult < 1) {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity * distancemult * sprites[i]->alivetime / .3);
+ }
}
}
if (sprites[i]->type == splintersprite && sprites[i]->special > 0 && sprites[i]->special != 3) {
if (sprites[i]->alivetime < .2) {
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->alivetime / .2);
- else
+ } else {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], distancemult * sprites[i]->alivetime / .2);
+ }
} else {
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], 1);
- else
+ } else {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], distancemult);
+ }
}
}
if (sprites[i]->type == splintersprite && (sprites[i]->special == 0 || sprites[i]->special == 3)) {
- if (distancemult >= 1)
+ if (distancemult >= 1) {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], 1);
- else
+ } else {
glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], distancemult);
+ }
}
glBegin(GL_TRIANGLES);
sprites[i]->position += sprites[i]->velocity * multiplier;
sprites[i]->velocity += windvector * multiplier;
}
- if (sprites[i]->type == flamesprite || sprites[i]->type == smoketype)
+ if (sprites[i]->type == flamesprite || sprites[i]->type == smoketype) {
sprites[i]->position += windvector * multiplier / 2;
- if ((sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite))
+ }
+ if ((sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite)) {
multiplier *= sprites[i]->speed * .7;
+ }
sprites[i]->alivetime += multiplier;
if (sprites[i]->type == cloudsprite || sprites[i]->type == cloudimpactsprite) {
sprites[i]->rotation += multiplier * 360;
sprites[i]->position.y -= multiplier;
sprites[i]->position += windvector * multiplier;
- if (sprites[i]->position.y < tempviewer.y - 6)
+ if (sprites[i]->position.y < tempviewer.y - 6) {
sprites[i]->position.y += 12;
- if (sprites[i]->position.y > tempviewer.y + 6)
+ }
+ if (sprites[i]->position.y > tempviewer.y + 6) {
sprites[i]->position.y -= 12;
- if (sprites[i]->position.z < tempviewer.z - 6)
+ }
+ if (sprites[i]->position.z < tempviewer.z - 6) {
sprites[i]->position.z += 12;
- if (sprites[i]->position.z > tempviewer.z + 6)
+ }
+ if (sprites[i]->position.z > tempviewer.z + 6) {
sprites[i]->position.z -= 12;
- if (sprites[i]->position.x < tempviewer.x - 6)
+ }
+ if (sprites[i]->position.x < tempviewer.x - 6) {
sprites[i]->position.x += 12;
- if (sprites[i]->position.x > tempviewer.x + 6)
+ }
+ if (sprites[i]->position.x > tempviewer.x + 6) {
sprites[i]->position.x -= 12;
+ }
}
if (sprites[i]->type == bloodsprite) {
bool spritehit = 0;
if (!spritehit && Person::players[j]->dead && sprites[i]->alivetime > .1) {
where = sprites[i]->oldposition;
where -= Person::players[j]->coords;
- if (!Person::players[j]->skeleton.free)
+ if (!Person::players[j]->skeleton.free) {
where = DoRotation(where, 0, -Person::players[j]->yaw, 0);
+ }
startpoint = where;
where = sprites[i]->position;
where -= Person::players[j]->coords;
- if (!Person::players[j]->skeleton.free)
+ if (!Person::players[j]->skeleton.free) {
where = DoRotation(where, 0, -Person::players[j]->yaw, 0);
+ }
endpoint = where;
movepoint = 0;
k = terrain.patchobjects[whichpatchx][whichpatchz][j];
start = sprites[i]->oldposition;
end = sprites[i]->position;
- if (!spritehit)
+ if (!spritehit) {
if (Object::objects[k]->model.LineCheck(&start, &end, &colpoint, &Object::objects[k]->position, &Object::objects[k]->yaw) != -1) {
- if (detail == 2 || (detail == 1 && abs(Random() % 4) == 0) || (detail == 0 && abs(Random() % 8) == 0))
+ if (detail == 2 || (detail == 1 && abs(Random() % 4) == 0) || (detail == 0 && abs(Random() % 8) == 0)) {
Object::objects[k]->model.MakeDecal(blooddecalfast, DoRotation(colpoint - Object::objects[k]->position, 0, -Object::objects[k]->yaw, 0), sprites[i]->size * 1.6, .5, Random() % 360);
+ }
DeleteSprite(i);
spritehit = 1;
}
+ }
}
}
}
if (sprites[i]->type == splintersprite) {
sprites[i]->rotation += sprites[i]->rotatespeed * multiplier;
sprites[i]->opacity -= multiplier / 2;
- if (sprites[i]->special == 0 || sprites[i]->special == 2 || sprites[i]->special == 3)
+ if (sprites[i]->special == 0 || sprites[i]->special == 2 || sprites[i]->special == 3) {
sprites[i]->velocity.y += gravity * multiplier;
- if (sprites[i]->special == 1)
+ }
+ if (sprites[i]->special == 1) {
sprites[i]->velocity.y += gravity * multiplier * .5;
+ }
}
if (sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite) {
sprites[i]->rotation += multiplier * sprites[i]->rotatespeed;
sprites[i]->opacity -= multiplier * 5 / 4;
- if (sprites[i]->type != weaponshinesprite && sprites[i]->type != bloodflamesprite)
- if (sprites[i]->opacity < .5 && sprites[i]->opacity + multiplier * 5 / 4 >= .5 && (abs(Random() % 4) == 0 || (sprites[i]->initialsize > 2 && Random() % 2 == 0)))
+ if (sprites[i]->type != weaponshinesprite && sprites[i]->type != bloodflamesprite) {
+ if (sprites[i]->opacity < .5 && sprites[i]->opacity + multiplier * 5 / 4 >= .5 && (abs(Random() % 4) == 0 || (sprites[i]->initialsize > 2 && Random() % 2 == 0))) {
MakeSprite(smoketype, sprites[i]->position, sprites[i]->velocity, .9, .9, .6, sprites[i]->size * 1.2, .4);
+ }
+ }
if (sprites[i]->alivetime > .14 && (sprites[i]->type == flamesprite)) {
sprites[i]->velocity = 0;
sprites[i]->velocity.y = 1.5;
sprites[i]->color[0] -= multiplier;
sprites[i]->color[1] -= multiplier;
sprites[i]->color[2] -= multiplier;
- if (sprites[i]->color[0] < .6)
+ if (sprites[i]->color[0] < .6) {
sprites[i]->color[0] = .6;
- if (sprites[i]->color[1] < .6)
+ }
+ if (sprites[i]->color[1] < .6) {
sprites[i]->color[1] = .6;
- if (sprites[i]->color[2] < .6)
+ }
+ if (sprites[i]->color[2] < .6) {
sprites[i]->color[2] = .6;
+ }
sprites[i]->size += multiplier;
sprites[i]->velocity = 0;
sprites[i]->velocity.y = 1.5;
sprites[i]->rotation += multiplier * sprites[i]->rotatespeed / 5;
}
- if (sprites[i]->opacity <= 0 || sprites[i]->size <= 0)
+ if (sprites[i]->opacity <= 0 || sprites[i]->size <= 0) {
DeleteSprite(i);
+ }
}
- if (check)
+ if (check) {
for (int i = sprites.size() - 1; i >= 0; i--) {
sprites[i]->oldposition = sprites[i]->position;
}
+ }
glAlphaFunc(GL_GREATER, 0.0001);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glTexCoord2f(cx, 1 - cy - +.001); // Texture Coord (Top Left)
glVertex2i(0, 16); // Vertex Coord (Top Left)
glEnd(); // Done Building Our Quad (Character)
- if (loop < 256)
+ if (loop < 256) {
glTranslated(10, 0, 0); // Move To The Right Of The Character
- else
+ } else {
glTranslated(8, 0, 0); // Move To The Right Of The Character
- glEndList(); // Done Building The Display List
- } // Loop Until All 256 Are Built
+ }
+ glEndList(); // Done Building The Display List
+ } // Loop Until All 256 Are Built
}
void Text::_glPrint(float x, float y, const std::string& string, int set, float size, float width, float height, int start, int end, int offset) // Where The Printing Happens
skinsize = texture.sizeX;
GLuint type = GL_RGBA;
- if (texture.bpp == 24)
+ if (texture.bpp == 24) {
type = GL_RGB;
+ }
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
const int nb = texture.sizeY * texture.sizeX * (texture.bpp / 8);
data = (GLubyte*)malloc(nb * sizeof(GLubyte));
datalen = 0;
- for (int i = 0; i < nb; i++)
- if ((i + 1) % 4 || type == GL_RGB)
+ for (int i = 0; i < nb; i++) {
+ if ((i + 1) % 4 || type == GL_RGB) {
data[datalen++] = texture.data[i];
+ }
+ }
glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
} else {
glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, type, GL_UNSIGNED_BYTE, texture.data);
void Texture::bind()
{
- if (tex)
+ if (tex) {
tex->bind();
- else
+ } else {
glBindTexture(GL_TEXTURE_2D, 0);
+ }
}
void award_bonus(int playerid, int bonusid, int alt_value)
{
- if (playerid != 0)
+ if (playerid != 0) {
return;
+ }
bonus = bonusid;
bonustime = 0;
bonusvalue = alt_value ? alt_value : bonus_values[bonusid];
}
bool alldead = true;
for (unsigned i = 1; i < Person::players.size(); i++) {
- if (Person::players[i]->dead != 2)
+ if (Person::players[i]->dead != 2) {
alldead = 0;
+ }
}
if (alldead) {
awards[numawards] = awardalldead;
}
alldead = 1;
for (unsigned i = 1; i < Person::players.size(); i++) {
- if (Person::players[i]->dead != 1)
+ if (Person::players[i]->dead != 1) {
alldead = 0;
+ }
}
if (alldead) {
awards[numawards] = awardnodead;
}
alldead = 1;
for (unsigned i = 1; i < Person::players.size(); i++) {
- if (Person::players[i]->dead != 2)
+ if (Person::players[i]->dead != 2) {
alldead = 0;
+ }
}
if (numafterkill > 0 && alldead) {
awards[numawards] = awardbrutal;
std::vector<std::string> campaignNames;
while ((campaign = readdir(campaigns)) != NULL) {
std::string name(campaign->d_name);
- if (name.length() < 5)
+ if (name.length() < 5) {
continue;
+ }
if (!name.compare(name.length() - 4, 4, ".txt")) {
campaignNames.push_back(name.substr(0, name.length() - 4));
}
char* text = new char[maxlength];
for (m = 0; m < templength; m++) {
funpackf(tfile, "Bb", &text[m]);
- if (text[m] == '\0')
+ if (text[m] == '\0') {
break;
+ }
}
text[m] = 0;
std::string result(text);
funpackf(tfile, "Bi", &participantfocus);
funpackf(tfile, "Bi", &participantaction);
- for (int m = 0; m < 10; m++)
+ for (int m = 0; m < 10; m++) {
funpackf(tfile, "Bf Bf Bf", &participantfacing[m].x, &participantfacing[m].y, &participantfacing[m].z);
+ }
funpackf(tfile, "Bf Bf", &camerayaw, &camerapitch);
}
ipstream.ignore(256, ' ');
getline(ipstream, text);
for (int j = 0; j < 128; j++) {
- if (text[j] == '\\')
+ if (text[j] == '\\') {
text[j] = '\n';
+ }
}
ipstream.ignore(256, ':');
ipstream >> sound;
fpackf(tfile, "Bi", participantfocus);
fpackf(tfile, "Bi", participantaction);
- for (int m = 0; m < 10; m++)
+ for (int m = 0; m < 10; m++) {
fpackf(tfile, "Bf Bf Bf", participantfacing[m].x, participantfacing[m].y, participantfacing[m].z);
+ }
fpackf(tfile, "Bf Bf", camerayaw, camerapitch);
}
value2 |= b.lo;
value -= value2;
- if (value <= 0)
+ if (value <= 0) {
return durationImmediate;
+ }
__int64 frac = value % g_appTime.counterRate;
value /= g_appTime.counterRate;
for (int i = 0; i < 6; i++) {
c = 0;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y - size) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y - size) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y - size) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y - size) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y + size) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y + size) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y + size) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y + size) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y - size) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y - size) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y - size) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y - size) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y + size) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y + size) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y + size) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y + size) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (c == 0)
+ }
+ if (c == 0) {
return 0;
- if (c == 8)
+ }
+ if (c == 8) {
c2++;
+ }
}
- if (c2 >= 6)
+ if (c2 >= 6) {
return 2;
- else
+ } else {
return 1;
+ }
}
int FRUSTUM::
for (int i = 0; i < 6; i++) {
c = 0;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y - height) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y - height) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y - height) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y - height) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y + height) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y + height) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y + height) + frustum[i][2] * (z - size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y + height) + frustum[i][2] * (z - size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y - height) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y - height) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y - height) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y - height) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x - size) + frustum[i][1] * (y + height) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x - size) + frustum[i][1] * (y + height) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (frustum[i][0] * (x + size) + frustum[i][1] * (y + height) + frustum[i][2] * (z + size) + frustum[i][3] > 0)
+ }
+ if (frustum[i][0] * (x + size) + frustum[i][1] * (y + height) + frustum[i][2] * (z + size) + frustum[i][3] > 0) {
c++;
- if (c == 0)
+ }
+ if (c == 0) {
return 0;
- if (c == 8)
+ }
+ if (c == 8) {
c2++;
+ }
}
- if (c2 >= 6)
+ if (c2 >= 6) {
return 2;
- else
+ } else {
return 1;
+ }
}
int FRUSTUM::
static int c2;
for (int i = 0; i < 6; i++) {
- if (frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] > -1 * radius)
+ if (frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] > -1 * radius) {
c2++;
- else
+ } else {
return 0;
+ }
}
- if (c2 >= 6)
+ if (c2 >= 6) {
return 2;
- else
+ } else {
return 1;
+ }
}
b = u0 / u2;
if (0.0f <= b && b <= 1.0f) {
a = (v0 - b * v2) / v1;
- if ((a >= 0.0f) && ((a + b) <= 1.0f))
+ if ((a >= 0.0f) && ((a + b) <= 1.0f)) {
bInter = 1;
+ }
}
} else {
b = (v0 * u1 - u0 * v1) / (v2 * u1 - u2 * v1);
if (0.0f <= b && b <= 1.0f) {
a = (u0 - b * u2) / u1;
- if ((a >= 0.0f) && ((a + b) <= 1.0f))
+ if ((a >= 0.0f) && ((a + b) <= 1.0f)) {
bInter = 1;
+ }
}
}
//Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) { // Line and plane don't intersect
return 0;
+ }
mu = -(d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
p->x = p1.x + mu * (p2.x - p1.x);
p->y = p1.y + mu * (p2.y - p1.y);
p->z = p1.z + mu * (p2.z - p1.z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) { // Intersection not along line segment
return 0;
+ }
if (!PointInTriangle(p, n, &pa, &pb, &pc)) {
return 0;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) { // Line and plane don't intersect
return 0;
+ }
mu = -(d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
p->x = p1.x + mu * (p2.x - p1.x);
p->y = p1.y + mu * (p2.y - p1.y);
p->z = p1.z + mu * (p2.z - p1.z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) { // Intersection not along line segment
return 0;
+ }
if (!PointInTriangle(p, n, &pa, &pb, &pc)) {
return 0;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) { // Line and plane don't intersect
return 0;
+ }
mu = -(d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
p->x = p1.x + mu * (p2.x - p1.x);
p->y = p1.y + mu * (p2.y - p1.y);
p->z = p1.z + mu * (p2.z - p1.z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) { // Intersection not along line segment
return 0;
+ }
if (!PointInTriangle(p, n, &pa, &pb, &pc)) {
return 0;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2->x - p1->x) + n.y * (p2->y - p1->y) + n.z * (p2->z - p1->z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) { // Line and plane don't intersect
return 0;
+ }
mu = -(d + n.x * p1->x + n.y * p1->y + n.z * p1->z) / denom;
p->x = p1->x + mu * (p2->x - p1->x);
p->y = p1->y + mu * (p2->y - p1->y);
p->z = p1->z + mu * (p2->z - p1->z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) { // Intersection not along line segment
return 0;
+ }
if (!PointInTriangle(p, n, pa, pb, pc)) {
return 0;
//Calculate the position on the line that intersects the plane
denom = n->x * (p2->x - p1->x) + n->y * (p2->y - p1->y) + n->z * (p2->z - p1->z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) { // Line and plane don't intersect
return 0;
+ }
mu = -(d + n->x * p1->x + n->y * p1->y + n->z * p1->z) / denom;
p->x = p1->x + mu * (p2->x - p1->x);
p->y = p1->y + mu * (p2->y - p1->y);
p->z = p1->z + mu * (p2->z - p1->z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) { // Intersection not along line segment
return 0;
+ }
if (!PointInTriangle(p, *n, pa, pb, pc)) {
return 0;
void Menu::setText(int id, const string& text)
{
- for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++)
+ for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
if (it->id == id) {
it->text = text;
it->w = it->text.length() * 10;
break;
}
+ }
}
void Menu::setText(int id, const string& text, int x, int y, int w, int h)
{
- for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++)
+ for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
if (it->id == id) {
it->text = text;
it->x = x;
it->y = y;
- if (w == -1)
+ if (w == -1) {
it->w = it->text.length() * 10;
- if (h == -1)
+ }
+ if (h == -1) {
it->h = 20;
+ }
break;
}
+ }
}
int Menu::getSelected(int mousex, int mousey)
{
- for (vector<MenuItem>::reverse_iterator it = items.rbegin(); it != items.rend(); it++)
+ for (vector<MenuItem>::reverse_iterator it = items.rbegin(); it != items.rend(); it++) {
if (it->type == MenuItem::BUTTON || it->type == MenuItem::IMAGEBUTTON || it->type == MenuItem::MAPMARKER) {
int mx = mousex;
int my = mousey;
mx -= 1;
my += 2;
}
- if (mx >= it->x && mx < it->x + it->w && my >= it->y && my < it->y + it->h)
+ if (mx >= it->x && mx < it->x + it->w && my >= it->y && my < it->y + it->h) {
return it->id;
+ }
}
+ }
return -1;
}
for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
if (it->id == Game::selected) {
it->effectfade += multiplier * 5;
- if (it->effectfade > 1)
+ if (it->effectfade > 1) {
it->effectfade = 1;
+ }
} else {
it->effectfade -= multiplier * 5;
- if (it->effectfade < 0)
+ if (it->effectfade < 0) {
it->effectfade = 0;
+ }
}
}
}
}
setText(0, sbuf);
setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off");
- if (newdetail == 0)
+ if (newdetail == 0) {
setText(1, "Detail: Low");
- if (newdetail == 1)
+ }
+ if (newdetail == 1) {
setText(1, "Detail: Medium");
- if (newdetail == 2)
+ }
+ if (newdetail == 2) {
setText(1, "Detail: High");
- if (bloodtoggle == 0)
+ }
+ if (bloodtoggle == 0) {
setText(2, "Blood: Off");
- if (bloodtoggle == 1)
+ }
+ if (bloodtoggle == 1) {
setText(2, "Blood: On, low detail");
- if (bloodtoggle == 2)
+ }
+ if (bloodtoggle == 2) {
setText(2, "Blood: On, high detail (slower)");
+ }
setText(4, ismotionblur ? "Blur Effects: Enabled (less compatible)" : "Blur Effects: Disabled (more compatible)");
setText(5, decalstoggle ? "Decals: Enabled (slower)" : "Decals: Disabled");
setText(6, musictoggle ? "Music: Enabled" : "Music: Disabled");
addButton(2, "No", 10, 320);
break;
case 7:
- if (Account::getNbAccounts() < 8)
+ if (Account::getNbAccounts() < 8) {
addButton(0, "New User", 10, 400);
- else
+ } else {
addLabel(0, "No More Users", 10, 400);
+ }
addLabel(-2, "", 20, 400);
addButton(Account::getNbAccounts() + 1, "Back", 10, 10);
for (int i = 0; i < Account::getNbAccounts(); i++) {
int fasttime = (int)round(Account::active().getFastTime(i));
name += to_string(int((fasttime - fasttime % 60) / 60));
name += ":";
- if (fasttime % 60 < 10)
+ if (fasttime % 60 < 10) {
name += "0";
+ }
name += to_string(fasttime % 60);
addButton(i, name, 10, 400 - i * 25, i > Account::active().getProgress() ? 0.5 : 1, 0, 0);
Account::active().endGame();
endgame = 0;
}
- if (mainmenu == 10)
+ if (mainmenu == 10) {
endgame = 2;
+ }
if (mainmenu == 18 && Input::isKeyPressed(MOUSEBUTTON_RIGHT) && selected == 1) {
stereoseparation -= 0.001;
updateStereoConfigMenu();
fireSound();
flash();
mainmenu = 3;
- if (newdetail > 2)
+ if (newdetail > 2) {
newdetail = detail;
- if (newdetail < 0)
+ }
+ if (newdetail < 0) {
newdetail = detail;
- if (newscreenwidth > 3000)
+ }
+ if (newscreenwidth > 3000) {
newscreenwidth = screenwidth;
- if (newscreenwidth < 0)
+ }
+ if (newscreenwidth < 0) {
newscreenwidth = screenwidth;
- if (newscreenheight > 3000)
+ }
+ if (newscreenheight > 3000) {
newscreenheight = screenheight;
- if (newscreenheight < 0)
+ }
+ if (newscreenheight < 0) {
newscreenheight = screenheight;
+ }
break;
case 3:
fireSound();
break;
case 1:
newdetail++;
- if (newdetail > 2)
+ if (newdetail > 2) {
newdetail = 0;
+ }
break;
case 2:
bloodtoggle++;
- if (bloodtoggle > 2)
+ if (bloodtoggle > 2) {
bloodtoggle = 0;
+ }
break;
case 4:
ismotionblur = !ismotionblur;
break;
case 10:
usermousesensitivity += .2;
- if (usermousesensitivity > 2)
+ if (usermousesensitivity > 2) {
usermousesensitivity = .2;
+ }
break;
case 11:
volume += .1f;
- if (volume > 1.0001f)
+ if (volume > 1.0001f) {
volume = 0;
+ }
OPENAL_SetSFXMasterVolume((int)(volume * 255));
break;
case 12:
case 4:
if (!waiting) {
fireSound();
- if (selected < (devtools ? 10 : 9) && keyselect == -1)
+ if (selected < (devtools ? 10 : 9) && keyselect == -1) {
keyselect = selected;
- if (keyselect != -1)
+ }
+ if (keyselect != -1) {
setKeySelected();
+ }
if (selected == (devtools ? 10 : 9)) {
flash();
mainmenu = 3;
vector<string> campaigns = ListCampaigns();
vector<string>::iterator c;
if ((c = find(campaigns.begin(), campaigns.end(), Account::active().getCurrentCampaign())) == campaigns.end()) {
- if (!campaigns.empty())
+ if (!campaigns.empty()) {
Account::active().setCurrentCampaign(campaigns.front());
+ }
} else {
c++;
- if (c == campaigns.end())
+ if (c == campaigns.end()) {
c = campaigns.begin();
+ }
Account::active().setCurrentCampaign(*c);
}
Load();
case 8:
fireSound();
flash();
- if (selected <= 2)
+ if (selected <= 2) {
Account::active().setDifficulty(selected);
+ }
mainmenu = 5;
break;
case 9:
}
break;
case 18:
- if (selected == 1)
+ if (selected == 1) {
stereoseparation += 0.001;
- else {
+ } else {
fireSound();
if (selected == 0) {
newstereomode = (StereoMode)(newstereomode + 1);
while (!CanInitStereo(newstereomode)) {
printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode).c_str(), newstereomode);
newstereomode = (StereoMode)(newstereomode + 1);
- if (newstereomode >= stereoCount)
+ if (newstereomode >= stereoCount) {
newstereomode = stereoNone;
+ }
}
} else if (selected == 2) {
stereoreverse = !stereoreverse;
setText(-2, newuserblink ? "_" : "", 20 + newuserselected * 10, 400, -1, -1);
}
- if (oldmainmenu != mainmenu)
+ if (oldmainmenu != mainmenu) {
Load();
+ }
oldmainmenu = mainmenu;
}
{
messedwith -= multiplier;
if (rotxvel || rotx) {
- if (rotx > 0)
+ if (rotx > 0) {
rotxvel -= multiplier * 8 * fabs(rotx);
- if (rotx < 0)
+ }
+ if (rotx < 0) {
rotxvel += multiplier * 8 * fabs(rotx);
- if (rotx > 0)
+ }
+ if (rotx > 0) {
rotxvel -= multiplier * 4;
- if (rotx < 0)
+ }
+ if (rotx < 0) {
rotxvel += multiplier * 4;
- if (rotxvel > 0)
+ }
+ if (rotxvel > 0) {
rotxvel -= multiplier * 4;
- if (rotxvel < 0)
+ }
+ if (rotxvel < 0) {
rotxvel += multiplier * 4;
- if (fabs(rotx) < multiplier * 4)
+ }
+ if (fabs(rotx) < multiplier * 4) {
rotx = 0;
- if (fabs(rotxvel) < multiplier * 4)
+ }
+ if (fabs(rotxvel) < multiplier * 4) {
rotxvel = 0;
+ }
rotx += rotxvel * multiplier * 4;
}
if (rotyvel || roty) {
- if (roty > 0)
+ if (roty > 0) {
rotyvel -= multiplier * 8 * fabs(roty);
- if (roty < 0)
+ }
+ if (roty < 0) {
rotyvel += multiplier * 8 * fabs(roty);
- if (roty > 0)
+ }
+ if (roty > 0) {
rotyvel -= multiplier * 4;
- if (roty < 0)
+ }
+ if (roty < 0) {
rotyvel += multiplier * 4;
- if (rotyvel > 0)
+ }
+ if (rotyvel > 0) {
rotyvel -= multiplier * 4;
- if (rotyvel < 0)
+ }
+ if (rotyvel < 0) {
rotyvel += multiplier * 4;
- if (fabs(roty) < multiplier * 4)
+ }
+ if (fabs(roty) < multiplier * 4) {
roty = 0;
- if (fabs(rotyvel) < multiplier * 4)
+ }
+ if (fabs(rotyvel) < multiplier * 4) {
rotyvel = 0;
+ }
roty += rotyvel * multiplier * 4;
}
if (rotx) {
glRotatef(-rotx / divide, 0, 0, 1);
}
- if (rotx > 10)
+ if (rotx > 10) {
rotx = 10;
- if (rotx < -10)
+ }
+ if (rotx < -10) {
rotx = -10;
- if (roty > 10)
+ }
+ if (roty > 10) {
roty = 10;
- if (roty < -10)
+ }
+ if (roty < -10) {
roty = -10;
+ }
}
void Object::draw()
hidden = !(distsqflat(&viewer, &position) > playerdist + 3 || (type != bushtype && type != treeleavestype));
if (!hidden) {
- if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment)
+ if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment) {
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness);
- else
+ } else {
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
+ }
distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
- if (distance > 1)
+ if (distance > 1) {
distance = 1;
+ }
if (distance > 0) {
if (occluded < 6) {
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (!model.color)
+ if (!model.color) {
glEnable(GL_LIGHTING);
- else
+ } else {
glDisable(GL_LIGHTING);
+ }
glDepthMask(1);
glTranslatef(position.x, position.y, position.z);
if (type == bushtype) {
{
XYZ lightloc;
lightloc = light.location;
- if (!skyboxtexture)
+ if (!skyboxtexture) {
lightloc = 0;
+ }
lightloc.y += 10;
Normalise(&lightloc);
for (int k = 0; k < numclothes; k++) {
int templength;
funpackf(tfile, "Bi", &templength);
- for (int l = 0; l < templength; l++)
+ for (int l = 0; l < templength; l++) {
funpackf(tfile, "Bb", &clothes[k][l]);
+ }
clothes[k][templength] = '\0';
funpackf(tfile, "Bf Bf Bf", &clothestintr[k], &clothestintg[k], &clothestintb[k]);
}
*/
void Person::CheckKick()
{
- if (!(hasvictim && (animTarget == rabbitkickanim && victim && victim != this->shared_from_this() && frameCurrent >= 2 && animCurrent == rabbitkickanim) && distsq(&coords, &victim->coords) < 1.2 && !victim->skeleton.free))
+ if (!(hasvictim && (animTarget == rabbitkickanim && victim && victim != this->shared_from_this() && frameCurrent >= 2 && animCurrent == rabbitkickanim) && distsq(&coords, &victim->coords) < 1.2 && !victim->skeleton.free)) {
return;
+ }
if (Animation::animations[victim->animTarget].height != lowheight) {
float damagemult = (creature == wolftype ? 2.5 : 1.) * power * power;
victim->spurt = 1;
DoBlood(.2, 250);
- if (!Tutorial::active)
+ if (!Tutorial::active) {
emit_sound_at(heavyimpactsound, victim->coords);
+ }
victim->RagDoll(0);
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * 120 * damagemult;
}
victim->Puff(neck);
victim->DoDamage(100 * damagemult / victim->protectionhigh);
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
target = 0;
frameCurrent = 3;
velocity = facing * -10;
velocity.y = 5;
skeleton.free = 0;
- if (id == 0)
+ if (id == 0) {
resume_stream(whooshsound);
+ }
award_bonus(id, cannon);
} else if (victim->isCrouch()) {
*/
int Person::getIdle()
{
- if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype))
+ if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype)) {
return talkidleanim;
+ }
if (hasvictim && (victim != this->shared_from_this())) {
if ((!victim->dead && victim->aitype != passivetype &&
victim->aitype != searchtype && aitype != passivetype && aitype != searchtype &&
victim->id < Person::players.size())) {
if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) {
- if (creature == rabbittype)
+ if (creature == rabbittype) {
return fightidleanim;
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
return wolfidle;
+ }
}
if (aitype == playercontrolled && stunned <= 0 && weaponactive != -1) {
- if (weapons[weaponids[weaponactive]].getType() == knife)
+ if (weapons[weaponids[weaponactive]].getType() == knife) {
return knifefightidleanim;
- if (weapons[weaponids[weaponactive]].getType() == sword && victim->weaponactive != -1)
+ }
+ if (weapons[weaponids[weaponactive]].getType() == sword && victim->weaponactive != -1) {
return swordfightidlebothanim;
- if (weapons[weaponids[weaponactive]].getType() == sword)
+ }
+ if (weapons[weaponids[weaponactive]].getType() == sword) {
return swordfightidleanim;
- if (weapons[weaponids[weaponactive]].getType() == staff)
+ }
+ if (weapons[weaponids[weaponactive]].getType() == staff) {
return swordfightidleanim;
+ }
}
- if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause)
+ if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause) {
return fightsidestep;
+ }
}
}
- if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype)
+ if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype) {
return hurtidleanim;
- if (howactive == typesitting)
+ }
+ if (howactive == typesitting) {
return sitanim;
- if (howactive == typesittingwall)
+ }
+ if (howactive == typesittingwall) {
return sitwallanim;
- if (howactive == typesleeping)
+ }
+ if (howactive == typesleeping) {
return sleepanim;
- if (howactive == typedead1)
+ }
+ if (howactive == typedead1) {
return dead1anim;
- if (howactive == typedead2)
+ }
+ if (howactive == typedead2) {
return dead2anim;
- if (howactive == typedead3)
+ }
+ if (howactive == typedead3) {
return dead3anim;
- if (howactive == typedead4)
+ }
+ if (howactive == typedead4) {
return dead4anim;
- if (creature == rabbittype)
+ }
+ if (creature == rabbittype) {
return bounceidleanim;
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
return wolfidle;
+ }
return 0;
}
*/
int Person::getCrouch()
{
- if (creature == rabbittype)
+ if (creature == rabbittype) {
return crouchanim;
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
return wolfcrouchanim;
+ }
return 0;
}
*/
int Person::getRun()
{
- if (creature == rabbittype && (!superruntoggle || weaponactive != -1))
+ if (creature == rabbittype && (!superruntoggle || weaponactive != -1)) {
return runanim;
- if (creature == wolftype && (!superruntoggle))
+ }
+ if (creature == wolftype && (!superruntoggle)) {
return wolfrunanim;
+ }
- if (creature == rabbittype && (superruntoggle && weaponactive == -1))
+ if (creature == rabbittype && (superruntoggle && weaponactive == -1)) {
return rabbitrunninganim;
- if (creature == wolftype && (superruntoggle))
+ }
+ if (creature == wolftype && (superruntoggle)) {
return wolfrunninganim;
+ }
return 0;
}
*/
int Person::getStop()
{
- if (creature == rabbittype)
+ if (creature == rabbittype) {
return stopanim;
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
return wolfstopanim;
+ }
return 0;
}
*/
int Person::getLanding()
{
- if (creature == rabbittype)
+ if (creature == rabbittype) {
return landanim;
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
return wolflandanim;
+ }
return 0;
}
*/
int Person::getLandhard()
{
- if (creature == rabbittype)
+ if (creature == rabbittype) {
return landhardanim;
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
return wolflandhardanim;
+ }
return 0;
}
static void
SolidHitBonus(int playerid)
{
- if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
+ if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo) {
award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
- else
+ } else {
award_bonus(playerid, solidhit);
+ }
}
/* EFFECT
Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
}
- if (Random() % 2 == 0) // 50% chance
+ if (Random() % 2 == 0) { // 50% chance
for (int i = 0; i < 3; i++) {
if (Random() % 2 != 0) {
// emit teeth particles
Sprite::setLastSpriteSpecial(3); // sets it to teeth
}
}
+ }
}
if (decalstoggle) {
// FIXME: manipulating attributes
bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
bleedxint = 0;
bleedyint = 0;
- if (creature == rabbittype)
+ if (creature == rabbittype) {
while (bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
bleedxint = abs(Random() % 512);
bleedyint = abs(Random() % 512);
}
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
while (wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
bleedxint = abs(Random() % 512);
bleedyint = abs(Random() % 512);
}
+ }
bleedy = bleedxint;
bleedx = bleedyint;
bleedy /= realtexdetail;
direction = abs(Random() % 2) * 2 - 1;
}
}
- if (bleeding > 2)
+ if (bleeding > 2) {
bleeding = 2;
+ }
}
/* EFFECT
{
static int bleedxint, bleedyint, i, j;
static XYZ bloodvel;
- if (howmuch && id == 0)
+ if (howmuch && id == 0) {
blooddimamount = 1;
+ }
- if (!Tutorial::active || id == 0)
+ if (!Tutorial::active || id == 0) {
if (aitype != playercontrolled && howmuch > 0) {
// play pain sounds
int whichsound = -1;
if (creature == wolftype) {
int i = abs(Random() % 2);
- if (i == 0)
+ if (i == 0) {
whichsound = snarlsound;
- if (i == 1)
+ }
+ if (i == 1) {
whichsound = snarl2sound;
+ }
}
if (creature == rabbittype) {
int i = abs(Random() % 2);
- if (i == 0)
+ if (i == 0) {
whichsound = rabbitpainsound;
- if (i == 1 && howmuch >= 2)
+ }
+ if (i == 1 && howmuch >= 2) {
whichsound = rabbitpain1sound;
+ }
}
if (whichsound != -1) {
addEnvSound(coords);
}
}
+ }
if (id == 0 && howmuch > 0) {
Game::flash(.5, 0);
int endx = 0;
int endy = 0;
GLubyte color;
- if (creature == rabbittype)
+ if (creature == rabbittype) {
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx)
+ if (i < startx) {
startx = i;
- if (j < starty)
+ }
+ if (j < starty) {
starty = j;
- if (i > endx)
+ }
+ if (i > endx) {
endx = i;
- if (j > endy)
+ }
+ if (j > endy) {
endy = j;
+ }
}
}
}
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx)
+ if (i < startx) {
startx = i;
- if (j < starty)
+ }
+ if (j < starty) {
starty = j;
- if (i > endx)
+ }
+ if (i > endx) {
endx = i;
- if (j > endy)
+ }
+ if (j > endy) {
endy = j;
+ }
}
}
}
+ }
startx += offsetx;
endx += offsetx;
starty += offsety;
endy += offsety;
- if (startx < 0)
+ if (startx < 0) {
startx = 0;
- if (starty < 0)
+ }
+ if (starty < 0) {
starty = 0;
- if (endx > 512 - 1)
+ }
+ if (endx > 512 - 1) {
endx = 512 - 1;
- if (endy > 512 - 1)
+ }
+ if (endy > 512 - 1) {
endy = 512 - 1;
- if (endx < startx)
+ }
+ if (endx < startx) {
endx = startx;
- if (endy < starty)
+ }
+ if (endy < starty) {
endy = starty;
+ }
startx /= realtexdetail;
starty /= realtexdetail;
int texdetailint = realtexdetail;
int where;
- if (creature == rabbittype)
+ if (creature == rabbittype) {
for (i = startx; i < endx; i++) {
for (j = starty; j < endy; j++) {
if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
color = Random() % 85 + 170;
where = i * skeleton.skinsize * 3 + j * 3;
- if (skeleton.skinText[where + 0] > color / 2)
+ if (skeleton.skinText[where + 0] > color / 2) {
skeleton.skinText[where + 0] = color / 2;
+ }
skeleton.skinText[where + 1] = 0;
skeleton.skinText[where + 2] = 0;
}
}
}
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
for (i = startx; i < endx; i++) {
for (j = starty; j < endy; j++) {
if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
color = Random() % 85 + 170;
where = i * skeleton.skinsize * 3 + j * 3;
- if (skeleton.skinText[where + 0] > color / 2)
+ if (skeleton.skinText[where + 0] > color / 2) {
skeleton.skinText[where + 0] = color / 2;
+ }
skeleton.skinText[where + 1] = 0;
skeleton.skinText[where + 2] = 0;
}
}
}
+ }
skeleton.drawmodel.textureptr.bind();
DoMipmaps();
bleedxint = 0;
bleedyint = 0;
- if (creature == rabbittype)
+ if (creature == rabbittype) {
while (bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || bloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
bleedxint = abs(Random() % 512);
bleedyint = abs(Random() % 512);
}
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
while (wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] > which + 4 || wolfbloodText[bleedxint * 512 * 3 + bleedyint * 3 + 0] < which - 4 || bleedxint < 10 || bleedyint < 10 || bleedxint > 500 || bleedyint > 500) {
bleedxint = abs(Random() % 512);
bleedyint = abs(Random() % 512);
}
+ }
bleedy = bleedxint + offsetx;
bleedx = bleedyint + offsety;
bleedy /= realtexdetail;
bleedx /= realtexdetail;
- if (bleedx < 0)
+ if (bleedx < 0) {
bleedx = 0;
- if (bleedy < 0)
+ }
+ if (bleedy < 0) {
bleedy = 0;
- if (bleedx > skeleton.skinsize - 1)
+ }
+ if (bleedx > skeleton.skinsize - 1) {
bleedx = skeleton.skinsize - 1;
- if (bleedy > skeleton.skinsize - 1)
+ }
+ if (bleedy > skeleton.skinsize - 1) {
bleedy = skeleton.skinsize - 1;
+ }
direction = abs(Random() % 2) * 2 - 1;
}
bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
if (abs(Random() % 2) == 0) {
aitype = gethelptype;
lastseentime = 12;
- } else
+ } else {
aitype = attacktypecutoff;
+ }
ally = 0;
}
- if (bleeding > 2)
+ if (bleeding > 2) {
bleeding = 2;
+ }
}
/* EFFECT
if (bloodtoggle && decalstoggle && !Tutorial::active) {
where -= coords;
- if (!skeleton.free)
+ if (!skeleton.free) {
where = DoRotation(where, 0, -yaw, 0);
+ }
//where=scale;
startpoint = where;
startpoint.y += 100;
int endx = 0;
int endy = 0;
GLubyte color;
- if (creature == rabbittype)
+ if (creature == rabbittype) {
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx)
+ if (i < startx) {
startx = i;
- if (j < starty)
+ }
+ if (j < starty) {
starty = j;
- if (i > endx)
+ }
+ if (i > endx) {
endx = i;
- if (j > endy)
+ }
+ if (j > endy) {
endy = j;
+ }
}
}
}
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx)
+ if (i < startx) {
startx = i;
- if (j < starty)
+ }
+ if (j < starty) {
starty = j;
- if (i > endx)
+ }
+ if (i > endx) {
endx = i;
- if (j > endy)
+ }
+ if (j > endy) {
endy = j;
+ }
}
}
}
+ }
startx += offsetx;
endx += offsetx;
starty += offsety;
endy += offsety;
- if (startx < 0)
+ if (startx < 0) {
startx = 0;
- if (starty < 0)
+ }
+ if (starty < 0) {
starty = 0;
- if (endx > 512 - 1)
+ }
+ if (endx > 512 - 1) {
endx = 512 - 1;
- if (endy > 512 - 1)
+ }
+ if (endy > 512 - 1) {
endy = 512 - 1;
- if (endx < startx)
+ }
+ if (endx < startx) {
endx = startx;
- if (endy < starty)
+ }
+ if (endy < starty) {
endy = starty;
+ }
startx /= realtexdetail;
starty /= realtexdetail;
int texdetailint = realtexdetail;
int where;
- if (creature == rabbittype)
+ if (creature == rabbittype) {
for (i = startx; i < endx; i++) {
for (j = starty; j < endy; j++) {
if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
color = Random() % 85 + 170;
where = i * skeleton.skinsize * 3 + j * 3;
- if (skeleton.skinText[where + 0] > color / 2)
+ if (skeleton.skinText[where + 0] > color / 2) {
skeleton.skinText[where + 0] = color / 2;
+ }
skeleton.skinText[where + 1] = 0;
skeleton.skinText[where + 2] = 0;
} else if (bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && bloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) {
color = Random() % 85 + 170;
where = i * skeleton.skinsize * 3 + j * 3;
- if (skeleton.skinText[where + 0] > color / 2)
+ if (skeleton.skinText[where + 0] > color / 2) {
skeleton.skinText[where + 0] = color / 2;
+ }
skeleton.skinText[where + 1] = 0;
skeleton.skinText[where + 2] = 0;
}
}
}
- if (creature == wolftype)
+ }
+ if (creature == wolftype) {
for (i = startx; i < endx; i++) {
for (j = starty; j < endy; j++) {
if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= which + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= which - 4) {
color = Random() % 85 + 170;
where = i * skeleton.skinsize * 3 + j * 3;
- if (skeleton.skinText[where + 0] > color / 2)
+ if (skeleton.skinText[where + 0] > color / 2) {
skeleton.skinText[where + 0] = color / 2;
+ }
skeleton.skinText[where + 1] = 0;
skeleton.skinText[where + 2] = 0;
} else if (wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] <= 160 + 4 && wolfbloodText[(i * texdetailint - offsetx) * 512 * 3 + (j * texdetailint - offsety) * 3 + 0] >= 160 - 4) {
color = Random() % 85 + 170;
where = i * skeleton.skinsize * 3 + j * 3;
- if (skeleton.skinText[where + 0] > color / 2)
+ if (skeleton.skinText[where + 0] > color / 2) {
skeleton.skinText[where + 0] = color / 2;
+ }
skeleton.skinText[where + 1] = 0;
skeleton.skinText[where + 2] = 0;
}
}
}
+ }
skeleton.drawmodel.textureptr.bind();
DoMipmaps();
bleedx = coordsx * 512;
bleedy /= realtexdetail;
bleedx /= realtexdetail;
- if (bleedx < 0)
+ if (bleedx < 0) {
bleedx = 0;
- if (bleedy < 0)
+ }
+ if (bleedy < 0) {
bleedy = 0;
- if (bleedx > skeleton.skinsize - 1)
+ }
+ if (bleedx > skeleton.skinsize - 1) {
bleedx = skeleton.skinsize - 1;
- if (bleedy > skeleton.skinsize - 1)
+ }
+ if (bleedy > skeleton.skinsize - 1) {
bleedy = skeleton.skinsize - 1;
+ }
direction = abs(Random() % 2) * 2 - 1;
}
- if (whichtri == -1)
+ if (whichtri == -1) {
return 0;
+ }
}
bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
deathbleeding += bleeding;
if (abs(Random() % 2) == 0) {
aitype = gethelptype;
lastseentime = 12;
- } else
+ } else {
aitype = attacktypecutoff;
+ }
ally = 0;
}
- if (bleeding > 2)
+ if (bleeding > 2) {
bleeding = 2;
+ }
return 1;
}
*/
void Person::Reverse()
{
- if (!((victim->aitype == playercontrolled || hostiletime > 1 || staggerdelay <= 0) && victim->animTarget != jumpupanim && victim->animTarget != jumpdownanim && (!Tutorial::active || cananger) && hostile))
+ if (!((victim->aitype == playercontrolled || hostiletime > 1 || staggerdelay <= 0) && victim->animTarget != jumpupanim && victim->animTarget != jumpdownanim && (!Tutorial::active || cananger) && hostile)) {
return;
+ }
- if (normaldotproduct(victim->facing, victim->coords - coords) > 0 && (victim->id != 0 || difficulty >= 2) && (creature != wolftype || victim->creature == wolftype))
+ if (normaldotproduct(victim->facing, victim->coords - coords) > 0 && (victim->id != 0 || difficulty >= 2) && (creature != wolftype || victim->creature == wolftype)) {
return;
+ }
if (animTarget == sweepanim) {
animTarget = sweepreversedanim;
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
- if (tempVelocity.x == 0)
+ if (tempVelocity.x == 0) {
tempVelocity.x = .1;
+ }
weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
- if (victim->weaponstuck == victim->num_weapons)
+ if (victim->weaponstuck == victim->num_weapons) {
victim->weaponstuck = 0;
+ }
}
victim->weaponactive = -1;
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
- if (tempVelocity.x == 0)
+ if (tempVelocity.x == 0) {
tempVelocity.x = .1;
+ }
weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
- if (victim->weaponstuck == victim->num_weapons)
+ if (victim->weaponstuck == victim->num_weapons) {
victim->weaponstuck = 0;
+ }
}
victim->weaponactive = -1;
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
- if (tempVelocity.x == 0)
+ if (tempVelocity.x == 0) {
tempVelocity.x = .1;
+ }
weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
- if (victim->weaponstuck == victim->num_weapons)
+ if (victim->weaponstuck == victim->num_weapons) {
victim->weaponstuck = 0;
+ }
}
victim->weaponactive = -1;
if (victim->weaponactive != -1) {
victim->throwtogglekeydown = 1;
XYZ tempVelocity = victim->velocity * .2;
- if (tempVelocity.x == 0)
+ if (tempVelocity.x == 0) {
tempVelocity.x = .1;
+ }
weapons[victim->weaponids[0]].drop(tempVelocity, tempVelocity, false);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
- if (victim->weaponstuck == victim->num_weapons)
+ if (victim->weaponstuck == victim->num_weapons) {
victim->weaponstuck = 0;
+ }
}
victim->weaponactive = -1;
if (abs(Random() % 20) == 0 || weapons[victim->weaponids[victim->weaponactive]].getType() == knife) {
if (victim->weaponactive != -1) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
- if (weapons[victim->weaponids[0]].getType() == staff)
+ if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (weapons[weaponids[0]].getType() == staff) {
weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+ }
emit_sound_at(swordstaffsound, victim->coords);
} else {
emit_sound_at(metalhitsound, victim->coords);
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[num_weapons];
- if (victim->weaponstuck == victim->num_weapons)
+ if (victim->weaponstuck == victim->num_weapons) {
victim->weaponstuck = 0;
+ }
}
victim->weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
if (abs(Random() % 20) == 0) {
if (weaponactive != -1) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
- if (weapons[victim->weaponids[0]].getType() == staff)
+ if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (weapons[weaponids[0]].getType() == staff) {
weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+ }
emit_sound_at(swordstaffsound, coords);
} else {
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
- if (weaponstuck == num_weapons)
+ if (weaponstuck == num_weapons) {
weaponstuck = 0;
+ }
}
weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
}
}
}
- if (hasvictim)
+ if (hasvictim) {
if (animTarget == knifeslashstartanim || animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim) {
if ((animTarget != staffhitanim && animTarget != staffspinhitanim) || distsq(&coords, &victim->coords) > .2) {
victim->animTarget = dodgebackanim;
Normalise(&rotatetarget);
victim->targetyaw = -asin(0 - rotatetarget.x);
victim->targetyaw *= 360 / 6.28;
- if (rotatetarget.z < 0)
+ if (rotatetarget.z < 0) {
victim->targetyaw = 180 - victim->targetyaw;
+ }
victim->targettilt2 = -asin(rotatetarget.y) * 360 / 6.28; //*-70;
Normalise(&rotatetarget);
victim->targetyaw = -asin(0 - rotatetarget.x);
victim->targetyaw *= 360 / 6.28;
- if (rotatetarget.z < 0)
+ if (rotatetarget.z < 0) {
victim->targetyaw = 180 - victim->targetyaw;
+ }
victim->targettilt2 = -asin(rotatetarget.y) * 360 / 6.28; //*-70;
victim->lastattack = victim->animTarget;
}
}
+ }
velocity = 0;
victim->velocity = 0;
}
}
- if (victim->id == 0 && Animation::animations[victim->animTarget].attack == reversal)
+ if (victim->id == 0 && Animation::animations[victim->animTarget].attack == reversal) {
numreversals++;
+ }
}
/* EFFECT
superpermanentdamage += howmuch / 4 / power;
}
// visual effects
- if (permanentdamage > damagetolerance / 2 && permanentdamage - howmuch < damagetolerance / 2 && Random() % 2)
+ if (permanentdamage > damagetolerance / 2 && permanentdamage - howmuch < damagetolerance / 2 && Random() % 2) {
DoBlood(1, 255);
- if ((permanentdamage > damagetolerance * .8 && Random() % 2 && !deathbleeding) || spurt)
+ }
+ if ((permanentdamage > damagetolerance * .8 && Random() % 2 && !deathbleeding) || spurt) {
DoBlood(1, 255);
+ }
spurt = 0;
if (id == 0) {
camerashake += howmuch / 100;
}
// cancel attack?
- if (aitype == passivetype && damage < damagetolerance && ((!Tutorial::active || cananger) && hostile))
+ if (aitype == passivetype && damage < damagetolerance && ((!Tutorial::active || cananger) && hostile)) {
aitype = attacktypecutoff;
+ }
if (!Tutorial::active && aitype != playercontrolled && damage < damagetolerance && damage > damagetolerance * 2 / 3 && creature == rabbittype) {
if (abs(Random() % 2) == 0) {
aitype = gethelptype;
lastseentime = 12;
- } else
+ } else {
aitype = attacktypecutoff;
+ }
ally = 0;
}
if (creature == wolftype) {
int i = abs(Random() % 2);
- if (i == 0)
+ if (i == 0) {
whichsound = snarlsound;
- if (i == 1)
+ }
+ if (i == 1) {
whichsound = snarl2sound;
+ }
}
if (creature == rabbittype) {
int i = abs(Random() % 2);
- if (i == 0)
+ if (i == 0) {
whichsound = rabbitpainsound;
- if (i == 1 && damage > damagetolerance)
+ }
+ if (i == 1 && damage > damagetolerance) {
whichsound = rabbitpain1sound;
+ }
}
if (whichsound != -1) {
targetheadyaw = (float)((int)((0 - yaw - targetheadyaw + 180) * 100) % 36000) / 100;
targetheadpitch = (float)((int)(targetheadpitch * 100) % 36000) / 100;
- while (targetheadyaw > 180)
+ while (targetheadyaw > 180) {
targetheadyaw -= 360;
- while (targetheadyaw < -180)
+ }
+ while (targetheadyaw < -180) {
targetheadyaw += 360;
+ }
- if (targetheadyaw > 160)
+ if (targetheadyaw > 160) {
targetheadpitch = targetheadpitch * -1;
- if (targetheadyaw < -160)
+ }
+ if (targetheadyaw < -160) {
targetheadpitch = targetheadpitch * -1;
- if (targetheadyaw > 160)
+ }
+ if (targetheadyaw > 160) {
targetheadyaw = targetheadyaw - 180;
- if (targetheadyaw < -160)
+ }
+ if (targetheadyaw < -160) {
targetheadyaw = targetheadyaw + 180;
+ }
- if (targetheadpitch > 120)
+ if (targetheadpitch > 120) {
targetheadpitch = 120;
- if (targetheadpitch < -120)
+ }
+ if (targetheadpitch < -120) {
targetheadpitch = -120;
- if (targetheadyaw > 120)
+ }
+ if (targetheadyaw > 120) {
targetheadyaw = 120;
- if (targetheadyaw < -120)
+ }
+ if (targetheadyaw < -120) {
targetheadyaw = -120;
+ }
- if (!isIdle())
+ if (!isIdle()) {
targetheadpitch = 0;
+ }
if (isIdle()) {
- if (targetheadyaw > 80)
+ if (targetheadyaw > 80) {
targetheadyaw = 80;
- if (targetheadyaw < -80)
+ }
+ if (targetheadyaw < -80) {
targetheadyaw = -80;
- if (targetheadpitch > 50)
+ }
+ if (targetheadpitch > 50) {
targetheadpitch = 50;
- if (targetheadpitch < -50)
+ }
+ if (targetheadpitch < -50) {
targetheadpitch = -50;
+ }
}
- if (abs(headyaw - targetheadyaw) < multiplier * lookspeed)
+ if (abs(headyaw - targetheadyaw) < multiplier * lookspeed) {
headyaw = targetheadyaw;
- else if (headyaw > targetheadyaw) {
+ } else if (headyaw > targetheadyaw) {
headyaw -= multiplier * lookspeed;
} else if (headyaw < targetheadyaw) {
headyaw += multiplier * lookspeed;
}
- if (abs(headpitch - targetheadpitch) < multiplier * lookspeed / 2)
+ if (abs(headpitch - targetheadpitch) < multiplier * lookspeed / 2) {
headpitch = targetheadpitch;
- else if (headpitch > targetheadpitch) {
+ } else if (headpitch > targetheadpitch) {
headpitch -= multiplier * lookspeed / 2;
} else if (headpitch < targetheadpitch) {
headpitch += multiplier * lookspeed / 2;
static int i;
static float speed;
if (!skeleton.free) {
- if (id == 0)
+ if (id == 0) {
numfalls++;
- if (id == 0 && isFlip())
+ }
+ if (id == 0 && isFlip()) {
numflipfail++;
+ }
escapednum = 0;
freefall = 1;
skeleton.freefall = 1;
- if (!isnormal(velocity.x))
+ if (!isnormal(velocity.x)) {
velocity.x = 0;
- if (!isnormal(velocity.y))
+ }
+ if (!isnormal(velocity.y)) {
velocity.y = 0;
- if (!isnormal(velocity.z))
+ }
+ if (!isnormal(velocity.z)) {
velocity.z = 0;
- if (!isnormal(yaw))
+ }
+ if (!isnormal(yaw)) {
yaw = 0;
- if (!isnormal(coords.x))
+ }
+ if (!isnormal(coords.x)) {
coords = 0;
- if (!isnormal(tilt))
+ }
+ if (!isnormal(tilt)) {
tilt = 0;
- if (!isnormal(tilt2))
+ }
+ if (!isnormal(tilt2)) {
tilt2 = 0;
+ }
for (unsigned i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].delay = 0;
skeleton.joints[i].locked = 0;
skeleton.joints[i].position = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
- if (!isnormal(skeleton.joints[i].position.x))
+ if (!isnormal(skeleton.joints[i].position.x)) {
skeleton.joints[i].position = DoRotation(skeleton.joints[i].position, 0, yaw, 0);
- if (!isnormal(skeleton.joints[i].position.x))
+ }
+ if (!isnormal(skeleton.joints[i].position.x)) {
skeleton.joints[i].position = coords;
+ }
skeleton.joints[i].position.y += .1;
skeleton.joints[i].oldposition = skeleton.joints[i].position;
skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords;
if (currentFrame().speed > targetFrame().speed) {
speed = currentFrame().speed * 2;
}
- if (transspeed)
+ if (transspeed) {
speed = transspeed * 2;
+ }
speed *= speedmult;
for (unsigned i = 0; i < skeleton.joints.size(); i++) {
- if ((Animation::animations[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && Animation::animations[animCurrent].height == Animation::animations[animTarget].height)
+ if ((Animation::animations[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && Animation::animations[animCurrent].height == Animation::animations[animTarget].height) {
skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((targetFrame().joints[i].position - currentFrame().joints[i].position) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
- else
+ } else {
skeleton.joints[i].velocity = velocity / scale + facing * 5;
+ }
change.x = (float)(Random() % 100) / 100;
change.y = (float)(Random() % 100) / 100;
change.z = (float)(Random() % 100) / 100;
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
- if (weaponstuck == num_weapons)
+ if (weaponstuck == num_weapons) {
weaponstuck = 0;
+ }
}
weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
if (opacity > 1) {
footvel = 0;
footpoint = DoRotation(jointPos(whichfoot), 0, yaw, 0) * scale + coords;
- if (distsq(&footpoint, &viewer))
+ if (distsq(&footpoint, &viewer)) {
Sprite::MakeSprite(cloudsprite, footpoint, footvel, 1, 1, 1, .5, .2 * opacity);
+ }
} else if (onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
footvel = velocity / 5;
- if (footvel.y < .8)
+ if (footvel.y < .8) {
footvel.y = .8;
+ }
footpoint = DoRotation(jointPos(whichfoot), 0, yaw, 0) * scale + coords;
footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
}
} else if (isLanding() || (animTarget == jumpupanim) || isLandhard()) {
footvel = velocity / 5;
- if (footvel.y < .8)
+ if (footvel.y < .8) {
footvel.y = .8;
+ }
footpoint = DoRotation(jointPos(whichfoot), 0, yaw, 0) * scale + coords;
if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, 1, 1, 1, .5, .2 * opacity);
if (!skeleton.free) {
static float oldtarget;
- if (isIdle() && animCurrent != getIdle())
+ if (isIdle() && animCurrent != getIdle()) {
normalsupdatedelay = 0;
+ }
if (animTarget == tempanim || animCurrent == tempanim) {
Animation::animations[tempanim] = tempanimation;
OPENAL_3D_SetAttributes(channels[whooshsound], gLoc);
OPENAL_SetVolume(channels[whooshsound], 64 * findLength(&velocity) / 5);
}
- if (((velocity.y < -15) || (crouchkeydown && velocity.y < -8)) && abs(velocity.y) * 4 > fast_sqrt(velocity.x * velocity.x * velocity.z * velocity.z))
+ if (((velocity.y < -15) || (crouchkeydown && velocity.y < -8)) && abs(velocity.y) * 4 > fast_sqrt(velocity.x * velocity.x * velocity.z * velocity.z)) {
landhard = 1;
- if (!crouchkeydown && velocity.y >= -15)
+ }
+ if (!crouchkeydown && velocity.y >= -15) {
landhard = 0;
+ }
}
if ((animCurrent == jumpupanim || animTarget == jumpdownanim) /*&&velocity.y<40*/ && !isFlip() && (!isLanding() && !isLandhard()) && ((crouchkeydown && !crouchtogglekeydown))) {
XYZ targfacing;
targfacing = DoRotation(targfacing, 0, targetyaw, 0);
- if (normaldotproduct(targfacing, velocity) >= -.3)
+ if (normaldotproduct(targfacing, velocity) >= -.3) {
animTarget = flipanim;
- else
+ } else {
animTarget = backflipanim;
+ }
crouchtogglekeydown = 1;
frameTarget = 0;
target = 0;
- if (id == 0)
+ if (id == 0) {
numflipped++;
+ }
}
- if (Animation::animations[animTarget].attack != reversed)
+ if (Animation::animations[animTarget].attack != reversed) {
feint = 0;
+ }
if (!crouchkeydown || (isLanding() || isLandhard()) || (wasLanding() || wasLandhard())) {
crouchtogglekeydown = 0;
- if (aitype == playercontrolled)
+ if (aitype == playercontrolled) {
feint = 0;
+ }
} else {
- if (!crouchtogglekeydown && Animation::animations[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain))
+ if (!crouchtogglekeydown && Animation::animations[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain)) {
feint = 1;
- if (!isFlip())
+ }
+ if (!isFlip()) {
crouchtogglekeydown = 1;
+ }
}
if (Animation::animations[animTarget].attack || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim) {
- if (detail)
+ if (detail) {
normalsupdatedelay = 0;
+ }
}
if (target >= 1) {
}
if (animTarget == rabbittacklinganim && frameTarget == 1) {
- if (victim->aitype == attacktypecutoff && victim->stunned <= 0 && victim->surprised <= 0 && victim->id != 0)
+ if (victim->aitype == attacktypecutoff && victim->stunned <= 0 && victim->surprised <= 0 && victim->id != 0) {
Reverse();
+ }
if (animTarget == rabbittacklinganim && frameTarget == 1 && !victim->isCrouch() && victim->animTarget != backhandspringanim) {
- if (normaldotproduct(victim->facing, facing) > 0)
+ if (normaldotproduct(victim->facing, facing) > 0) {
victim->animTarget = rabbittackledbackanim;
- else
+ } else {
victim->animTarget = rabbittackledfrontanim;
+ }
victim->frameTarget = 2;
victim->target = 0;
victim->yaw = yaw;
victim->targetyaw = yaw;
- if (victim->aitype == gethelptype)
+ if (victim->aitype == gethelptype) {
victim->DoDamage(victim->damagetolerance - victim->damage);
+ }
//victim->DoDamage(30);
if (creature == wolftype) {
DoBloodBig(0, 255);
if (!drawtogglekeydown && drawkeydown && (weaponactive == -1 || num_weapons == 1) && (targetFrame().label || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
if (weapons[weaponids[0]].getType() == knife) {
- if (weaponactive == -1)
+ if (weaponactive == -1) {
weaponactive = 0;
- else if (weaponactive == 0)
+ } else if (weaponactive == 0) {
weaponactive = -1;
+ }
if (weaponactive == -1) {
emit_sound_at(knifesheathesound, coords);
drawtogglekeydown = 1;
}
//Footstep sounds
- if (!Tutorial::active || id == 0)
+ if (!Tutorial::active || id == 0) {
if ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
int whichsound = -1;
if (onterrain) {
if (terrain.getOpacity(coords.x, coords.z) < .2) {
- if (targetFrame().label == 1)
+ if (targetFrame().label == 1) {
whichsound = footstepsound;
- else
+ } else {
whichsound = footstepsound2;
- if (targetFrame().label == 1)
+ }
+ if (targetFrame().label == 1) {
FootLand(leftfoot, 1);
- if (targetFrame().label == 2)
+ }
+ if (targetFrame().label == 2) {
FootLand(rightfoot, 1);
+ }
if (targetFrame().label == 3 && isRun()) {
FootLand(rightfoot, 1);
FootLand(leftfoot, 1);
}
}
if (terrain.getOpacity(coords.x, coords.z) >= .2) {
- if (targetFrame().label == 1)
+ if (targetFrame().label == 1) {
whichsound = footstepsound3;
- else
+ } else {
whichsound = footstepsound4;
+ }
}
}
if (!onterrain) {
- if (targetFrame().label == 1)
+ if (targetFrame().label == 1) {
whichsound = footstepsound3;
- else
+ } else {
whichsound = footstepsound4;
+ }
}
if (targetFrame().label == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 3);
- if (r == 0)
+ if (r == 0) {
whichsound = lowwhooshsound;
- if (r == 1)
+ }
+ if (r == 1) {
whichsound = midwhooshsound;
- if (r == 2)
+ }
+ if (r == 2) {
whichsound = highwhooshsound;
+ }
}
if (Animation::animations[animTarget].attack == neutral) {
whichsound = movewhooshsound;
}
}
}
+ }
//Combat sounds
- if (!Tutorial::active || id == 0)
- if (speechdelay <= 0)
- if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim)
+ if (!Tutorial::active || id == 0) {
+ if (speechdelay <= 0) {
+ if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim) {
if ((targetFrame().label && (targetFrame().label < 5 || targetFrame().label == 8))) {
int whichsound = -1;
if (targetFrame().label == 4 && aitype != playercontrolled) {
if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 4);
if (creature == rabbittype) {
- if (r == 0)
+ if (r == 0) {
whichsound = rabbitattacksound;
- if (r == 1)
+ }
+ if (r == 1) {
whichsound = rabbitattack2sound;
- if (r == 2)
+ }
+ if (r == 2) {
whichsound = rabbitattack3sound;
- if (r == 3)
+ }
+ if (r == 3) {
whichsound = rabbitattack4sound;
+ }
}
if (creature == wolftype) {
- if (r == 0)
+ if (r == 0) {
whichsound = barksound;
- if (r == 1)
+ }
+ if (r == 1) {
whichsound = bark2sound;
- if (r == 2)
+ }
+ if (r == 2) {
whichsound = bark3sound;
- if (r == 3)
+ }
+ if (r == 3) {
whichsound = barkgrowlsound;
+ }
}
speechdelay = .3;
}
emit_sound_at(whichsound, coords);
}
}
+ }
+ }
+ }
if ((!wasLanding() && !wasLandhard()) && animCurrent != getIdle() && (isLanding() || isLandhard())) {
FootLand(leftfoot, 1);
if (animTarget == removeknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
for (unsigned i = 0; i < weapons.size(); i++) {
- if (weapons[i].owner == -1)
+ if (weapons[i].owner == -1) {
if (distsqflat(&coords, &weapons[i].position) < 4 && weaponactive == -1) {
if (distsq(&coords, &weapons[i].position) >= 1) {
if (weapons[i].getType() != staff) {
takeWeapon(i);
}
}
+ }
}
}
if (animTarget == crouchremoveknifeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
for (unsigned i = 0; i < weapons.size(); i++) {
bool willwork = true;
- if (weapons[i].owner != -1)
- if (Person::players[weapons[i].owner]->weaponstuck != -1)
- if (Person::players[weapons[i].owner]->weaponids[Person::players[weapons[i].owner]->weaponstuck] == int(i))
- if (Person::players[weapons[i].owner]->num_weapons > 1)
+ if (weapons[i].owner != -1) {
+ if (Person::players[weapons[i].owner]->weaponstuck != -1) {
+ if (Person::players[weapons[i].owner]->weaponids[Person::players[weapons[i].owner]->weaponstuck] == int(i)) {
+ if (Person::players[weapons[i].owner]->num_weapons > 1) {
willwork = 0;
- if ((weapons[i].owner == -1) || (hasvictim && (weapons[i].owner == int(victim->id)) && victim->skeleton.free))
+ }
+ }
+ }
+ }
+ if ((weapons[i].owner == -1) || (hasvictim && (weapons[i].owner == int(victim->id)) && victim->skeleton.free)) {
if (willwork && distsqflat(&coords, &weapons[i].position) < 3 && weaponactive == -1) {
if (distsq(&coords, &weapons[i].position) < 1 || hasvictim) {
bool fleshstuck = false;
- if (weapons[i].owner != -1)
+ if (weapons[i].owner != -1) {
if (victim->weaponstuck != -1) {
if (victim->weaponids[victim->weaponstuck] == int(i)) {
fleshstuck = true;
}
}
+ }
if (fleshstuck) {
emit_sound_at(fleshstabremovesound, coords, 128.);
} else {
}
if (weapons[i].owner != -1) {
victim = Person::players[weapons[i].owner];
- if (victim->num_weapons == 1)
+ if (victim->num_weapons == 1) {
victim->num_weapons = 0;
- else
+ } else {
victim->num_weapons = 1;
+ }
//victim->weaponactive=-1;
victim->skeleton.longdead = 0;
footpoint = weapons[i].position;
if (victim->weaponstuck != -1) {
if (victim->weaponids[victim->weaponstuck] == int(i)) {
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
+ }
weapons[i].bloody = 2;
weapons[i].blooddrip = 5;
victim->weaponstuck = -1;
}
}
if (victim->num_weapons > 0) {
- if (victim->weaponstuck != 0 && victim->weaponstuck != -1)
+ if (victim->weaponstuck != 0 && victim->weaponstuck != -1) {
victim->weaponstuck = 0;
- if (victim->weaponids[0] == int(i))
+ }
+ if (victim->weaponids[0] == int(i)) {
victim->weaponids[0] = victim->weaponids[victim->num_weapons];
+ }
}
victim->jointVel(abdomen) += relative * 6;
takeWeapon(i);
}
}
+ }
}
}
if (animCurrent == drawleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
- if (weaponactive == -1)
+ if (weaponactive == -1) {
weaponactive = 0;
- else if (weaponactive == 0) {
+ } else if (weaponactive == 0) {
weaponactive = -1;
if (num_weapons == 2) {
int buffer;
Normalise(&rotatetarget);
targetyaw = -asin(0 - rotatetarget.x);
targetyaw *= 360 / 6.28;
- if (rotatetarget.z < 0)
+ if (rotatetarget.z < 0) {
targetyaw = 180 - targetyaw;
+ }
- if (animTarget == walljumprightkickanim)
+ if (animTarget == walljumprightkickanim) {
targetyaw += 40;
- if (animTarget == walljumpleftkickanim)
+ }
+ if (animTarget == walljumpleftkickanim) {
targetyaw -= 40;
+ }
}
bool dojumpattack;
dojumpattack = 0;
- if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && frameTarget == 3 && (jumpkeydown || attackkeydown || id != 0))
+ if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && frameTarget == 3 && (jumpkeydown || attackkeydown || id != 0)) {
dojumpattack = 1;
- if (hasvictim)
- if (distsq(&victim->coords, &/*Person::players[i]->*/ coords) < 5 && victim->aitype == gethelptype && (attackkeydown) && !victim->skeleton.free && victim->isRun() && victim->runninghowlong >= 1)
+ }
+ if (hasvictim) {
+ if (distsq(&victim->coords, &/*Person::players[i]->*/ coords) < 5 && victim->aitype == gethelptype && (attackkeydown) && !victim->skeleton.free && victim->isRun() && victim->runninghowlong >= 1) {
dojumpattack = 1;
- if (!hostile)
+ }
+ }
+ if (!hostile) {
dojumpattack = 0;
+ }
if (dojumpattack) {
if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && id == 0) {
animTarget = rabbittackleanim;
Normalise(&targetloc);
targetloc += coords;
for (unsigned i = 0; i < Person::players.size(); i++) {
- if (i != id)
+ if (i != id) {
if (distsq(&targetloc, &Person::players[i]->coords) < closestdist || closestdist == 0) {
closestdist = distsq(&targetloc, &Person::players[i]->coords);
closestid = i;
}
+ }
}
- if (closestid != -1)
+ if (closestid != -1) {
if (closestdist < 5 && !Person::players[closestid]->dead && Animation::animations[Person::players[closestid]->animTarget].height != lowheight && Person::players[closestid]->animTarget != backhandspringanim) {
hasvictim = 1;
victim = Person::players[closestid];
Normalise(&rotatetarget);
targetyaw = -asin(0 - rotatetarget.x);
targetyaw *= 360 / 6.28;
- if (rotatetarget.z < 0)
+ if (rotatetarget.z < 0) {
targetyaw = 180 - targetyaw;
+ }
}
if (animTarget != rabbitrunninganim) {
emit_sound_at(jumpsound, coords, 128.);
}
}
+ }
}
//Move impacts
float damagemult = 1 * power;
- if (creature == wolftype)
+ if (creature == wolftype) {
damagemult = 2.5 * power;
+ }
if (hasvictim) {
damagemult /= victim->damagetolerance / 200;
}
if (animTarget == spinkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2 || creature == wolftype) {
victim->spurt = 1;
DoBlood(.2, 250);
- if (creature == wolftype)
+ if (creature == wolftype) {
DoBloodBig(0, 250);
+ }
}
if (!Tutorial::active) {
emit_sound_at(heavyimpactsound, victim->coords, 128.);
if (animTarget == wolfslapanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2 || creature == wolftype) {
victim->spurt = 1;
- if (creature == wolftype)
+ if (creature == wolftype) {
DoBloodBig(0, 235);
+ }
}
emit_sound_at(whooshhitsound, victim->coords);
if (creature == wolftype) {
if (animTarget == walljumprightkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
victim->spurt = 1;
DoBlood(.2, 250);
if (!Tutorial::active) {
victim->Puff(head);
victim->DoDamage(damagemult * 150 / victim->protectionhead);
- if (victim->damage > victim->damagetolerance)
+ if (victim->damage > victim->damagetolerance) {
award_bonus(id, style);
- else
+ } else {
SolidHitBonus(id);
+ }
}
}
if (animTarget == walljumpleftkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
victim->spurt = 1;
DoBlood(.2, 250);
if (!Tutorial::active) {
victim->Puff(head);
victim->DoDamage(damagemult * 150 / victim->protectionhead);
- if (victim->damage > victim->damagetolerance)
+ if (victim->damage > victim->damagetolerance) {
award_bonus(id, style);
- else
+ } else {
SolidHitBonus(id);
+ }
}
}
if (animTarget == blockhighleftstrikeanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != lowheight) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 235);
if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 8) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim->dead) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .2;
+ }
emit_sound_at(whooshhitsound, victim->coords, 128.);
victim->skeleton.longdead = 0;
if (animTarget == killanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->dead) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (!Tutorial::active) {
emit_sound_at(heavyimpactsound, coords, 128.);
}
if (animTarget == dropkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->skeleton.free) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (!Tutorial::active) {
emit_sound_at(thudsound, coords);
}
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
- if (!victim->dead)
+ if (!victim->dead) {
SolidHitBonus(id);
+ }
victim->Puff(abdomen);
victim->DoDamage(damagemult * 20 / victim->protectionhigh);
victim->jointVel(abdomen) += relative * damagemult * 200;
staggerdelay = .5;
- if (!victim->dead)
+ if (!victim->dead) {
staggerdelay = 1.2;
+ }
}
}
if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
- if (hasvictim)
- if (!victim->skeleton.free)
+ if (hasvictim) {
+ if (!victim->skeleton.free) {
hasvictim = 0;
+ }
+ }
if (!hasvictim) {
terrain.MakeDecal(blooddecalfast, (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2), .08, .6, Random() % 360);
if (weapons[weaponids[weaponactive]].getType() == knife) {
where = (weapons[weaponids[weaponactive]].tippoint * .6 + weapons[weaponids[weaponactive]].position * .4);
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
//where=scale;
startpoint = where;
startpoint.y += 100;
if (weapons[weaponids[weaponactive]].getType() == sword) {
where = weapons[weaponids[weaponactive]].position;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
startpoint = where;
where = weapons[weaponids[weaponactive]].tippoint;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
endpoint = where;
}
if (weapons[weaponids[weaponactive]].getType() == staff) {
where = weapons[weaponids[weaponactive]].position;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
startpoint = where;
where = weapons[weaponids[weaponactive]].tippoint;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
endpoint = where;
}
movepoint = 0;
if (whichtri != -1) {
if (victim->dead != 2) {
victim->DoDamage(abs((victim->damagetolerance - victim->permanentdamage) * 2));
- if (!victim->dead)
+ if (!victim->dead) {
award_bonus(id, FinishedBonus);
+ }
}
- if (bloodtoggle)
+ if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
+ }
victim->skeleton.longdead = 0;
victim->skeleton.free = 1;
where = weapons[weaponids[weaponactive]].position;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
startpoint = where;
where = weapons[weaponids[weaponactive]].tippoint;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
endpoint = where;
movepoint = 0;
where = weapons[weaponids[weaponactive]].position;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
startpoint = where;
where = weapons[weaponids[weaponactive]].tippoint;
where -= victim->coords;
- if (!victim->skeleton.free)
+ if (!victim->skeleton.free) {
where = DoRotation(where, 0, -victim->yaw, 0);
+ }
endpoint = where;
movepoint = 0;
relative.y = 10;
Normalise(&relative);
//victim->Puff(abdomen);
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
+ }
if (victim->bloodloss < victim->damagetolerance) {
victim->bloodloss += 1000;
if (animTarget == upunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 235);
if (animTarget == winduppunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 2) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && Animation::animations[victim->animTarget].height != lowheight) {
if (!Tutorial::active) {
emit_sound_at(thudsound, victim->coords);
}
}
- if (victim->damage > victim->damagetolerance - 60 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || Animation::animations[victim->animTarget].height == lowheight)
+ if (victim->damage > victim->damagetolerance - 60 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || Animation::animations[victim->animTarget].height == lowheight) {
victim->RagDoll(0);
+ }
XYZ relative;
relative = victim->coords - coords;
relative.y = 0;
if (animTarget == blockhighleftanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
- if (victim->id == 0)
+ if (victim->id == 0) {
camerashake += .4;
+ }
emit_sound_at(landsound2, victim->coords);
Puff(righthand);
if (animTarget == swordslashparryanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
- if (victim->id == 0)
+ if (victim->id == 0) {
camerashake += .4;
+ }
if (weaponactive != -1) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
- if (weapons[victim->weaponids[0]].getType() == staff)
+ if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (weapons[weaponids[0]].getType() == staff) {
weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+ }
emit_sound_at(swordstaffsound, victim->coords);
} else {
}
if (animTarget == knifeslashstartanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
- if (hasvictim)
+ if (hasvictim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 && /*Animation::animations[victim->animTarget].height!=lowheight&&*/ victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
escapednum = 0;
if (!Tutorial::active) {
}
victim->lowreversaldelay = 0;
victim->highreversaldelay = 0;
- if (aitype != playercontrolled)
+ if (aitype != playercontrolled) {
weaponmissdelay = .6;
+ }
if (!Tutorial::active) {
if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) {
}
victim->DoDamage(damagemult * 0);
}
+ }
}
if (animTarget == swordslashanim && Animation::animations[animTarget].frames[frameCurrent].label == 5 && victim->animTarget != rollanim) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim) {
award_bonus(id, Slashbonus);
escapednum = 0;
if (!Tutorial::active) {
- if (normaldotproduct(victim->facing, victim->coords - coords) < 0)
+ if (normaldotproduct(victim->facing, victim->coords - coords) < 0) {
victim->DoBloodBig(2 / victim->armorhigh, 190);
- else
+ } else {
victim->DoBloodBig(2 / victim->armorhigh, 185);
+ }
victim->deathbleeding = 1;
emit_sound_at(swordslicesound, victim->coords);
victim->frameTarget = 0;
} else {
if (victim->weaponactive != -1) {
if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
- if (weapons[victim->weaponids[0]].getType() == staff)
+ if (weapons[victim->weaponids[0]].getType() == staff) {
weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (weapons[weaponids[0]].getType() == staff) {
weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
+ }
emit_sound_at(swordstaffsound, victim->coords);
} else {
victim->num_weapons--;
if (victim->num_weapons) {
victim->weaponids[0] = victim->weaponids[num_weapons];
- if (victim->weaponstuck == victim->num_weapons)
+ if (victim->weaponstuck == victim->num_weapons) {
victim->weaponstuck = 0;
+ }
}
victim->weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
if (!Tutorial::active) {
weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 250;
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2 || creature == wolftype) {
victim->spurt = 1;
}
if (!Tutorial::active) {
weapons[weaponids[0]].damage += .6 + float(abs(Random() % 100) - 50) / 250;
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2 || creature == wolftype) {
victim->spurt = 1;
}
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5) {
escapednum = 0;
if (!Tutorial::active) {
- if (!victim->dead)
+ if (!victim->dead) {
weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 500;
- if (id == 0)
+ }
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2 || creature == wolftype) {
victim->spurt = 1;
}
if (animTarget == lowkickanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && Animation::animations[victim->animTarget].height != highheight) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
XYZ relative;
relative = victim->coords - coords;
relative.y = 0;
}
victim->Puff(head);
victim->DoDamage(damagemult * 100 / victim->protectionhead);
- if (victim->howactive == typesleeping)
+ if (victim->howactive == typesleeping) {
victim->DoDamage(damagemult * 150 / victim->protectionhead);
+ }
if (creature == wolftype) {
emit_sound_at(clawslicesound, victim->coords, 128.);
victim->spurt = 1;
victim->DoBloodBig(2 / victim->armorhead, 175);
}
} else {
- if (victim->damage >= victim->damagetolerance)
+ if (victim->damage >= victim->damagetolerance) {
victim->RagDoll(0);
+ }
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 10;
}
(distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) &&
(victim != this->shared_from_this())) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .2;
+ }
if (!Tutorial::active) {
emit_sound_at(landsound2, victim->coords, 128.);
}
relative = DoRotation(relative, 0, -90, 0);
relative.y += .1;
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
- if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
+ if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle) {
victim->skeleton.joints[i].velocity = relative * 80;
+ }
}
victim->Puff(rightankle);
victim->Puff(leftankle);
victim->DoDamage(damagemult * 40 / victim->protectionlow);
} else {
- if (victim->damage >= victim->damagetolerance)
+ if (victim->damage >= victim->damagetolerance) {
victim->RagDoll(0);
+ }
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 10;
}
relative = DoRotation(relative, 0, -90, 0);
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
- if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle)
+ if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle) {
victim->skeleton.joints[i].velocity += relative * damagemult * 80;
+ }
}
victim->jointVel(abdomen) += relative * damagemult * 200;
victim->frameTarget = 0;
if (Animation::animations[animTarget].attack == reversal && (!victim->feint || (victim->lastattack == victim->lastattack2 && victim->lastattack2 == victim->lastattack3 && Random() % 2) || animTarget == knifefollowanim)) {
if (animTarget == spinkickreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 230);
if (animTarget == staffhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 230);
if (animTarget == staffspinhitreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 230);
bool doslice;
doslice = 0;
- if (weaponactive != -1 || creature == wolftype)
+ if (weaponactive != -1 || creature == wolftype) {
doslice = 1;
- if (creature == rabbittype && weaponactive != -1)
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (creature == rabbittype && weaponactive != -1) {
+ if (weapons[weaponids[0]].getType() == staff) {
doslice = 0;
+ }
+ }
if (doslice) {
if (weaponactive != -1) {
victim->DoBloodBig(2 / victim->armorhigh, 225);
emit_sound_at(knifeslicesound, victim->coords);
- if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
+ if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) {
weapons[weaponids[weaponactive]].bloody = 1;
+ }
weapons[weaponids[weaponactive]].blooddrip += 3;
}
if (weaponactive == -1 && creature == wolftype) {
if (hasvictim && animTarget == knifeslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 230);
relative = facing * -1;
relative.y = -3;
Normalise(&relative);
- if (victim->id == 0)
+ if (victim->id == 0) {
relative /= 30;
+ }
for (unsigned i = 0; i < victim->skeleton.joints.size(); i++) {
victim->skeleton.joints[i].velocity += relative * damagemult * 40;
}
victim->permanentdamage = victim->damagetolerance - 1;
bool doslice;
doslice = 0;
- if (weaponactive != -1 || creature == wolftype)
+ if (weaponactive != -1 || creature == wolftype) {
doslice = 1;
- if (creature == rabbittype && weaponactive != -1)
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (creature == rabbittype && weaponactive != -1) {
+ if (weapons[weaponids[0]].getType() == staff) {
doslice = 0;
+ }
+ }
if (doslice) {
if (weaponactive != -1) {
victim->DoBloodBig(200, 225);
emit_sound_at(knifeslicesound, victim->coords);
- if (bloodtoggle)
+ if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
+ }
weapons[weaponids[weaponactive]].blooddrip += 5;
}
if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
escapednum = 0;
- if (animTarget == knifefollowanim)
+ if (animTarget == knifefollowanim) {
victim->DoBloodBig(200, 210);
+ }
if (animTarget == knifesneakattackanim) {
XYZ footvel, footpoint;
footvel = 0;
footpoint = weapons[weaponids[0]].tippoint;
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ }
footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
XYZ footvel, footpoint;
footvel = 0;
footpoint = weapons[weaponids[0]].tippoint;
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ }
footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
victim->bloodloss += 10000;
victim->velocity = 0;
emit_sound_at(fleshstabsound, victim->coords);
- if (bloodtoggle)
+ if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
+ }
weapons[weaponids[weaponactive]].blooddrip += 5;
}
}
}
if (weaponactive != -1 && Animation::animations[victim->animTarget].attack != reversal) {
emit_sound_at(fleshstabremovesound, victim->coords);
- if (bloodtoggle)
+ if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
+ }
weapons[weaponids[weaponactive]].blooddrip += 5;
XYZ footvel, footpoint;
footvel = 0;
footpoint = weapons[weaponids[0]].tippoint;
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ }
footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
XYZ footvel, footpoint;
footvel = 0;
footpoint = (weapons[weaponids[0]].tippoint + weapons[weaponids[0]].position) / 2;
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ }
footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
victim->bloodloss += 10000;
victim->velocity = 0;
emit_sound_at(fleshstabsound, victim->coords);
- if (bloodtoggle)
+ if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
+ }
weapons[weaponids[weaponactive]].blooddrip += 5;
}
}
}
if (weaponactive != -1) {
emit_sound_at(fleshstabremovesound, victim->coords);
- if (bloodtoggle)
+ if (bloodtoggle) {
weapons[weaponids[weaponactive]].bloody = 2;
+ }
weapons[weaponids[weaponactive]].blooddrip += 5;
XYZ footvel, footpoint;
footvel = 0;
footpoint = weapons[weaponids[0]].tippoint;
- if (bloodtoggle)
+ if (bloodtoggle) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
+ }
footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
if (animTarget == sweepreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
if (Random() % 2) {
victim->spurt = 1;
DoBlood(.2, 240);
}
bool doslice;
doslice = 0;
- if (weaponactive != -1 || creature == wolftype)
+ if (weaponactive != -1 || creature == wolftype) {
doslice = 1;
- if (creature == rabbittype && weaponactive != -1)
- if (weapons[weaponids[0]].getType() == staff)
+ }
+ if (creature == rabbittype && weaponactive != -1) {
+ if (weapons[weaponids[0]].getType() == staff) {
doslice = 0;
+ }
+ }
if (doslice) {
if (weaponactive != -1) {
victim->DoBloodBig(2 / victim->armorhead, 225);
emit_sound_at(knifeslicesound, victim->coords);
- if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
+ if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody) {
weapons[weaponids[weaponactive]].bloody = 1;
+ }
weapons[weaponids[weaponactive]].blooddrip += 3;
}
if (weaponactive == -1 && creature == wolftype) {
victim->skeleton.joints[i].velocity += relative * damagemult * 20;
}
victim->jointVel(head) += relative * damagemult * 200;
- if (victim->damage < victim->damagetolerance - 100)
+ if (victim->damage < victim->damagetolerance - 100) {
victim->velocity = relative * 200;
+ }
victim->DoDamage(damagemult * 100 / victim->protectionhead);
victim->velocity = 0;
}
victim->jointVel(head) += relative * damagemult * 200;
}
- if (hasvictim && (animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == rabbitkickreversalanim || animTarget == upunchreversalanim || animTarget == jumpreversalanim || animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == rabbittacklereversal || animTarget == wolftacklereversal || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim))
+ if (hasvictim && (animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == rabbitkickreversalanim || animTarget == upunchreversalanim || animTarget == jumpreversalanim || animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == rabbittacklereversal || animTarget == wolftacklereversal || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim)) {
if (victim->damage > victim->damagetolerance && bonus != reverseko) {
award_bonus(id, reverseko);
}
+ }
}
//Animation end
if (animCurrent == crouchdrawrightanim) {
animTarget = getCrouch();
}
- if (weaponactive == -1)
+ if (weaponactive == -1) {
weaponactive = 0;
- else if (weaponactive == 0) {
+ } else if (weaponactive == 0) {
weaponactive = -1;
if (num_weapons == 2) {
int buffer;
animTarget = getCrouch();
frameTarget = 1;
coords += facing * .1;
- if (!isnormal(coords.x))
+ if (!isnormal(coords.x)) {
coords = oldcoords;
+ }
oldcoords = coords;
targetoffset = 0;
currentoffset = 0;
int closest = -1;
float closestdist = -1;
float distance;
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned i = 0; i < Person::players.size(); i++) {
if (id != i && Person::players[i]->coords.y < coords.y && !Person::players[i]->skeleton.free) {
distance = distsq(&Person::players[i]->coords, &coords);
}
}
}
+ }
if (closestdist > 0 && closest >= 0 && closestdist < 16) {
victim = Person::players[closest];
animTarget = walljumprightkickanim;
Normalise(&rotatetarget);
yaw = -asin(0 - rotatetarget.x);
yaw *= 360 / 6.28;
- if (rotatetarget.z < 0)
+ if (rotatetarget.z < 0) {
yaw = 180 - yaw;
+ }
targettilt2 = -asin(rotatetarget.y) * 360 / 6.28;
velocity = (victim->coords - coords) * 4;
velocity.y += 2;
frameTarget = 3;
velocity = facing * -8;
velocity.y = 4;
- if (id == 0)
+ if (id == 0) {
resume_stream(whooshsound);
+ }
}
if (animTarget == walljumprightanim) {
animTarget = rightflipanim;
velocity = facing * 8;
velocity.y = 4;
}
- if (id == 0)
+ if (id == 0) {
resume_stream(whooshsound);
+ }
}
if (animTarget == walljumpleftanim) {
if (attackkeydown) {
int closest = -1;
float closestdist = -1;
float distance;
- if (Person::players.size() > 1)
+ if (Person::players.size() > 1) {
for (unsigned i = 0; i < Person::players.size(); i++) {
if (id != i && Person::players[i]->coords.y < coords.y && !Person::players[i]->skeleton.free) {
distance = distsq(&Person::players[i]->coords, &coords);
}
}
}
+ }
if (closestdist > 0 && closest >= 0 && closestdist < 16) {
victim = Person::players[closest];
animTarget = walljumpleftkickanim;
Normalise(&rotatetarget);
yaw = -asin(0 - rotatetarget.x);
yaw *= 360 / 6.28;
- if (rotatetarget.z < 0)
+ if (rotatetarget.z < 0) {
yaw = 180 - yaw;
+ }
targettilt2 = -asin(rotatetarget.y) * 360 / 6.28;
velocity = (victim->coords - coords) * 4;
velocity.y += 2;
velocity = DoRotation(facing, 0, -30, 0) * -8;
velocity.y = 4;
}
- if (id == 0)
+ if (id == 0) {
resume_stream(whooshsound);
+ }
}
if (animTarget == sneakattackanim) {
animCurrent = getCrouch();
transspeed = 1000000;
targetheadyaw += 180;
coords -= facing * .7;
- if (onterrain)
+ if (onterrain) {
coords.y = terrain.getHeight(coords.x, coords.z);
+ }
lastfeint = 0;
}
if (animTarget == knifesneakattackanim || animTarget == swordsneakattackanim) {
animTarget = getIdle();
frameTarget = 0;
- if (onterrain)
+ if (onterrain) {
coords.y = terrain.getHeight(coords.x, coords.z);
+ }
lastfeint = 0;
}
tilt2 *= -1;
transspeed = 1000000;
targetheadyaw += 180;
- if (!isnormal(coords.x))
+ if (!isnormal(coords.x)) {
coords = oldcoords;
- if (animCurrent == spinkickreversalanim || animCurrent == swordslashreversalanim)
+ }
+ if (animCurrent == spinkickreversalanim || animCurrent == swordslashreversalanim) {
oldcoords = coords + facing * .5;
- else if (animCurrent == sweepreversalanim)
+ } else if (animCurrent == sweepreversalanim) {
oldcoords = coords + facing * 1.1;
- else if (animCurrent == upunchreversalanim) {
+ } else if (animCurrent == upunchreversalanim) {
oldcoords = coords + facing * 1.5;
targetyaw += 180;
yaw += 180;
targettilt2 = 0;
tilt2 = 0;
}
- if (onterrain)
+ if (onterrain) {
oldcoords.y = terrain.getHeight(oldcoords.x, oldcoords.z);
- else
+ } else {
oldcoords.y = ycoords;
+ }
currentoffset = coords - oldcoords;
targetoffset = 0;
coords = oldcoords;
}
if (Animation::animations[animTarget].attack == reversed) {
escapednum++;
- if (animTarget == sweepreversedanim)
+ if (animTarget == sweepreversedanim) {
targetyaw += 90;
+ }
animTarget = backhandspringanim;
frameTarget = 2;
emit_sound_at(landsound, coords, 128);
if (wasFlip()) {
animTarget = jumpdownanim;
}
- if (wasLanding())
+ if (wasLanding()) {
animTarget = getIdle();
- if (wasLandhard())
+ }
+ if (wasLandhard()) {
animTarget = getIdle();
+ }
if (animCurrent == spinkickanim || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim || animCurrent == lowkickanim) {
animTarget = getIdle();
oldcoords = coords;
coords.y = oldcoords.y;
//coords+=DoRotation(Animation::animations[animCurrent].offset,0,yaw,0)*scale;
targetoffset.y = coords.y;
- if (onterrain)
+ if (onterrain) {
targetoffset.y = terrain.getHeight(coords.x, coords.z);
+ }
currentoffset = DoRotation(Animation::animations[animCurrent].offset * -1, 0, yaw, 0) * scale;
currentoffset.y -= (coords.y - targetoffset.y);
coords.y = targetoffset.y;
targetyaw = yaw;
bool hasstaff;
hasstaff = 0;
- if (num_weapons > 0)
- if (weapons[0].getType() == staff)
+ if (num_weapons > 0) {
+ if (weapons[0].getType() == staff) {
hasstaff = 1;
- if (!hasstaff)
+ }
+ }
+ if (!hasstaff) {
DoDamage(35);
+ }
RagDoll(0);
lastfeint = 0;
rabbitkickragdoll = 1;
escapednum++;
animTarget = rollanim;
coords += facing;
- if (id == 0)
+ if (id == 0) {
pause_sound(whooshsound);
+ }
}
lastfeint = 0;
}
escapednum++;
animTarget = rollanim;
coords += facing * 2;
- if (id == 0)
+ if (id == 0) {
pause_sound(whooshsound);
+ }
}
lastfeint = 0;
}
lastfeint = 0;
}
if (animCurrent == spinkickanim && victim->skeleton.free) {
- if (creature == rabbittype)
+ if (creature == rabbittype) {
animTarget = fightidleanim;
+ }
}
}
target = 0;
- if (isIdle() && !wasIdle())
+ if (isIdle() && !wasIdle()) {
normalsupdatedelay = 0;
+ }
if (animCurrent == jumpupanim && velocity.y < 0 && !isFlip()) {
animTarget = jumpdownanim;
oldtarget = target;
if (!transspeed && Animation::animations[animTarget].attack != 2 && Animation::animations[animTarget].attack != 3) {
if (!isRun() || !wasRun()) {
- if (targetFrame().speed > currentFrame().speed)
+ if (targetFrame().speed > currentFrame().speed) {
target += multiplier * targetFrame().speed * speed * 2;
- if (targetFrame().speed <= currentFrame().speed)
+ }
+ if (targetFrame().speed <= currentFrame().speed) {
target += multiplier * currentFrame().speed * speed * 2;
+ }
}
if (isRun() && wasRun()) {
float tempspeed;
tempspeed = velspeed;
- if (tempspeed < 10 * speedmult)
+ if (tempspeed < 10 * speedmult) {
tempspeed = 10 * speedmult;
+ }
/* FIXME - mixed of target and current here, is that intended? */
target += multiplier * Animation::animations[animTarget].frames[frameCurrent].speed * speed * 1.7 * tempspeed / (speed * 45 * scale);
}
- } else if (transspeed)
+ } else if (transspeed) {
target += multiplier * transspeed * speed * 2;
- else {
+ } else {
if (!isRun() || !wasRun()) {
- if (targetFrame().speed > currentFrame().speed)
+ if (targetFrame().speed > currentFrame().speed) {
target += multiplier * targetFrame().speed * 2;
- if (targetFrame().speed <= currentFrame().speed)
+ }
+ if (targetFrame().speed <= currentFrame().speed) {
target += multiplier * currentFrame().speed * 2;
+ }
}
}
- if (animCurrent != animTarget)
+ if (animCurrent != animTarget) {
target = (target + oldtarget) / 2;
+ }
if (target > 1) {
frameCurrent = frameTarget;
}
for (unsigned i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
- if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100)) {
skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
- if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100))
+ }
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100)) {
skeleton.muscles[i].oldrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
- if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
+ }
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100)) {
skeleton.muscles[i].oldrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
+ }
}
}
}
for (unsigned i = 0; i < skeleton.muscles.size(); i++) {
if (skeleton.muscles[i].visible) {
- if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100)) {
skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
- if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100))
+ }
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100)) {
skeleton.muscles[i].newrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
- if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
+ }
+ if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100)) {
skeleton.muscles[i].newrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
- if (skeleton.muscles[i].newrotate3 > skeleton.muscles[i].oldrotate3 + 180)
+ }
+ if (skeleton.muscles[i].newrotate3 > skeleton.muscles[i].oldrotate3 + 180) {
skeleton.muscles[i].newrotate3 -= 360;
- if (skeleton.muscles[i].newrotate3 < skeleton.muscles[i].oldrotate3 - 180)
+ }
+ if (skeleton.muscles[i].newrotate3 < skeleton.muscles[i].oldrotate3 - 180) {
skeleton.muscles[i].newrotate3 += 360;
- if (skeleton.muscles[i].newrotate2 > skeleton.muscles[i].oldrotate2 + 180)
+ }
+ if (skeleton.muscles[i].newrotate2 > skeleton.muscles[i].oldrotate2 + 180) {
skeleton.muscles[i].newrotate2 -= 360;
- if (skeleton.muscles[i].newrotate2 < skeleton.muscles[i].oldrotate2 - 180)
+ }
+ if (skeleton.muscles[i].newrotate2 < skeleton.muscles[i].oldrotate2 - 180) {
skeleton.muscles[i].newrotate2 += 360;
- if (skeleton.muscles[i].newrotate1 > skeleton.muscles[i].oldrotate1 + 180)
+ }
+ if (skeleton.muscles[i].newrotate1 > skeleton.muscles[i].oldrotate1 + 180) {
skeleton.muscles[i].newrotate1 -= 360;
- if (skeleton.muscles[i].newrotate1 < skeleton.muscles[i].oldrotate1 - 180)
+ }
+ if (skeleton.muscles[i].newrotate1 < skeleton.muscles[i].oldrotate1 - 180) {
skeleton.muscles[i].newrotate1 += 360;
+ }
}
}
}
}
if (isLanding() && landhard) {
- if (id == 0)
+ if (id == 0) {
camerashake += .4;
+ }
animTarget = getLandhard();
frameTarget = 0;
target = 0;
}
crouchkeydowntime += multiplier;
- if (!crouchkeydown)
+ if (!crouchkeydown) {
crouchkeydowntime = 0;
+ }
jumpkeydowntime += multiplier;
- if (!jumpkeydown && skeleton.free)
+ if (!jumpkeydown && skeleton.free) {
jumpkeydowntime = 0;
+ }
- if (hostile || damage > 0 || bloodloss > 0)
+ if (hostile || damage > 0 || bloodloss > 0) {
immobile = 0;
+ }
- if (isIdle() || isRun())
+ if (isIdle() || isRun()) {
targetoffset = 0;
+ }
- if (num_weapons == 1 && weaponactive != -1)
+ if (num_weapons == 1 && weaponactive != -1) {
weaponstuck = -1;
+ }
- if (id == 0)
+ if (id == 0) {
blooddimamount -= multiplier * .3;
+ }
speechdelay -= multiplier;
texupdatedelay -= multiplier;
interestdelay -= multiplier;
hasvictim = 0;
}
- if (id == 0)
+ if (id == 0) {
speed = 1.1 * speedmult;
- else
+ } else {
speed = 1.0 * speedmult;
- if (!skeleton.free)
+ }
+ if (!skeleton.free) {
rabbitkickragdoll = 0;
+ }
speed *= speedmult;
- if (id != 0 && (creature == rabbittype || difficulty != 2))
+ if (id != 0 && (creature == rabbittype || difficulty != 2)) {
superruntoggle = 0;
+ }
if (id != 0 && creature == wolftype && difficulty == 2) {
superruntoggle = 0;
if (aitype != passivetype) {
superruntoggle = 0;
}
}
- if (scale < 0.2)
+ if (scale < 0.2) {
superruntoggle = 0;
+ }
if (animTarget == wolfrunninganim && !superruntoggle) {
animTarget = getRun();
frameTarget = 0;
if (onfire) {
burnt += multiplier;
deathbleeding = 1;
- if (burnt > .6)
+ if (burnt > .6) {
burnt = .6;
+ }
OPENAL_SetVolume(channels[stream_firesound], 256 + 256 * findLength(&velocity) / 3);
if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
bleeding -= multiplier * .3;
if (bloodtoggle == 2) {
skeleton.drawmodel.textureptr.bind();
- if ((bleeding <= 0) && (detail != 2))
+ if ((bleeding <= 0) && (detail != 2)) {
DoMipmaps();
+ }
}
}
}
if (deathbleeding > 0 && dead != 2) {
- if (deathbleeding < 5)
+ if (deathbleeding < 5) {
bleeddelay -= deathbleeding * multiplier / 4;
- else
+ } else {
bleeddelay -= 5 * multiplier / 4;
+ }
if (bleeddelay < 0 && bloodtoggle) {
bleeddelay = 1;
XYZ bloodvel;
}
bloodloss += deathbleeding * multiplier * 80;
deathbleeding -= multiplier * 1.6;
- if (deathbleeding < 0)
+ if (deathbleeding < 0) {
deathbleeding = 0;
+ }
if (bloodloss > damagetolerance && Animation::animations[animTarget].attack == neutral) {
if (weaponactive != -1) {
weapons[weaponids[0]].drop(velocity * scale * -.3, velocity * scale);
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
- if (weaponstuck == num_weapons)
+ if (weaponstuck == num_weapons) {
weaponstuck = 0;
+ }
}
weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
endy = skeleton.skinsize - 1;
bleeding = 0;
}
- if (endx < startx)
+ if (endx < startx) {
endx = startx;
- if (endy < starty)
+ }
+ if (endy < starty) {
endy = starty;
+ }
for (int i = startx; i < endx; i++) {
for (int j = starty; j < endy; j++) {
if (Random() % 2 == 0) {
color = Random() % 85 + 170;
- if (skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 0] > color / 2)
+ if (skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 0] > color / 2) {
skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 0] = color / 2;
+ }
skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 1] = 0;
skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 2] = 0;
}
if (skeleton.free) {
bleedx += 4 * direction / realtexdetail;
- if (detail == 2)
+ if (detail == 2) {
bleedy += (abs(Random() % 3) - 1) * 2 / realtexdetail;
- else
+ } else {
bleedy += (abs(Random() % 3) - 1) * 4 / realtexdetail;
+ }
} else {
bleedy -= 4 / realtexdetail;
- if (detail == 2)
+ if (detail == 2) {
bleedx += (abs(Random() % 3) - 1) * 2 / realtexdetail;
- else
+ } else {
bleedx += (abs(Random() % 3) - 1) * 4 / realtexdetail;
+ }
}
}
footvel = DoRotation(skeleton.specialforward[0], 0, yaw, 0) * -1;
footpoint = DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords;
}
- if (animTarget == sleepanim)
+ if (animTarget == sleepanim) {
footvel = DoRotation(footvel, 0, 90, 0);
+ }
Sprite::MakeSprite(breathsprite, footpoint + footvel * .2, footvel * .4, 1, 1, 1, .4, .3);
}
}
righthandmorphness = 0;
targetrighthandmorphness = 1;
righthandmorphend = 1;
- if (Random() % 2 == 0)
+ if (Random() % 2 == 0) {
twitchdelay3 = (float)(abs(Random() % 40)) / 5;
+ }
}
if (righthandmorphstart == 1 && righthandmorphend == 1) {
righthandmorphness = 0;
}
if (!dead) {
if (creature == rabbittype) {
- if (howactive < typesleeping)
+ if (howactive < typesleeping) {
twitchdelay2 -= multiplier * 1.5;
- else
+ } else {
twitchdelay2 -= multiplier * 0.5;
+ }
if (howactive <= typesleeping) {
if (tailmorphstart == 0 && tailmorphend == 0 && twitchdelay2 <= 0) {
tailmorphness = 0;
}
if (creature == wolftype) {
twitchdelay2 -= multiplier * 1.5;
- if (tailmorphend != 0)
+ if (tailmorphend != 0) {
if ((isRun() || animTarget == jumpupanim || animTarget == jumpdownanim || animTarget == backflipanim) && !skeleton.free) {
tailmorphness = 0;
targettailmorphness = 1;
tailmorphend = 0;
twitchdelay2 = .1;
}
- if (tailmorphend != 5)
+ }
+ if (tailmorphend != 5) {
if (animTarget == flipanim || animTarget == frontflipanim || animTarget == rollanim || skeleton.free) {
tailmorphness = 0;
targettailmorphness = 1;
tailmorphend = 5;
twitchdelay2 = .1;
}
+ }
if (twitchdelay2 <= 0) {
if (((tailmorphstart == 0 && tailmorphend == 0) || (tailmorphstart == 5 && tailmorphend == 5))) {
tailmorphness = 0;
if (dead == 1 || howactive == typesleeping) {
unconscioustime += multiplier;
//If unconscious, close eyes and mouth
- if (righthandmorphend != 0)
+ if (righthandmorphend != 0) {
righthandmorphness = 0;
+ }
righthandmorphend = 0;
targetrighthandmorphness = 1;
- if (lefthandmorphend != 0)
+ if (lefthandmorphend != 0) {
lefthandmorphness = 0;
+ }
lefthandmorphend = 0;
targetlefthandmorphness = 1;
- if (headmorphend != 3 && headmorphend != 5)
+ if (headmorphend != 3 && headmorphend != 5) {
headmorphness = 0;
+ }
headmorphend = 3;
targetheadmorphness = 1;
}
if (dead == 2 || howactive > typesleeping) {
//If dead, open mouth and hands
- if (righthandmorphend != 0)
+ if (righthandmorphend != 0) {
righthandmorphness = 0;
+ }
righthandmorphend = 0;
targetrighthandmorphness = 1;
- if (lefthandmorphend != 0)
+ if (lefthandmorphend != 0) {
lefthandmorphness = 0;
+ }
lefthandmorphend = 0;
targetlefthandmorphness = 1;
- if (headmorphend != 2)
+ if (headmorphend != 2) {
headmorphness = 0;
+ }
headmorphend = 2;
targetheadmorphness = 1;
}
if (stunned > 0 && !dead && headmorphend != 2) {
- if (headmorphend != 4)
+ if (headmorphend != 4) {
headmorphness = 0;
+ }
headmorphend = 4;
targetheadmorphness = 1;
}
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
- if (weaponstuck == num_weapons)
+ if (weaponstuck == num_weapons) {
weaponstuck = 0;
+ }
}
weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
permanentdamage -= multiplier * 4;
}
}
- if (damage < 0)
+ if (damage < 0) {
damage = 0;
- if (permanentdamage < 0)
+ }
+ if (permanentdamage < 0) {
permanentdamage = 0;
- if (superpermanentdamage < 0)
+ }
+ if (superpermanentdamage < 0) {
superpermanentdamage = 0;
+ }
if (permanentdamage < superpermanentdamage) {
permanentdamage = superpermanentdamage;
}
num_weapons--;
if (num_weapons) {
weaponids[0] = weaponids[num_weapons];
- if (weaponstuck == num_weapons)
+ if (weaponstuck == num_weapons) {
weaponstuck = 0;
+ }
}
weaponactive = -1;
for (unsigned i = 0; i < Person::players.size(); i++) {
award_bonus(0, Wolfbonus);
}
- if (unconscioustime < .1 && (bonus != spinecrusher || bonustime > 1) && (bonus != FinishedBonus || bonustime > 1) && bloodloss < damagetolerance)
+ if (unconscioustime < .1 && (bonus != spinecrusher || bonustime > 1) && (bonus != FinishedBonus || bonustime > 1) && bloodloss < damagetolerance) {
award_bonus(id, touchofdeath);
+ }
if (id != 0 && unconscioustime > .1) {
numafterkill++;
}
}
if (skeleton.free == 1) {
- if (id == 0)
+ if (id == 0) {
pause_sound(whooshsound);
+ }
if (!dead) {
//If knocked over, open hands and close mouth
- if (righthandmorphend != 0)
+ if (righthandmorphend != 0) {
righthandmorphness = 0;
+ }
righthandmorphend = 0;
targetrighthandmorphness = 1;
- if (lefthandmorphend != 0)
+ if (lefthandmorphend != 0) {
lefthandmorphness = 0;
+ }
lefthandmorphend = 0;
targetlefthandmorphness = 1;
if (headmorphend != 3 && headmorphend != 5 && headmorphstart != 3 && headmorphstart != 5) {
- if (headmorphend != 0)
+ if (headmorphend != 0) {
headmorphness = 0;
+ }
headmorphend = 0;
targetheadmorphness = 1;
}
skeleton.DoGravity(&scale);
float damageamount;
damageamount = skeleton.DoConstraints(&coords, &scale) * 5;
- if (damage > damagetolerance - damageamount && !dead && (bonus != spinecrusher || bonustime > 1) && (bonus != style || bonustime > 1) && (bonus != cannon || bonustime > 1))
+ if (damage > damagetolerance - damageamount && !dead && (bonus != spinecrusher || bonustime > 1) && (bonus != style || bonustime > 1) && (bonus != cannon || bonustime > 1)) {
award_bonus(id, deepimpact);
+ }
DoDamage(damageamount / ((protectionhigh + protectionhead + protectionlow) / 3));
XYZ average;
skeleton.longdead += (2000 - findLength(&average)) * multiplier + multiplier;
if (skeleton.longdead > 2000) {
if (skeleton.longdead > 6000) {
- if (id == 0)
+ if (id == 0) {
pause_sound(whooshsound);
+ }
skeleton.free = 3;
DrawSkeleton();
skeleton.free = 2;
if (dead == 2 && bloodloss >= damagetolerance) {
XYZ headpoint;
headpoint = (jointPos(abdomen) + jointPos(neck)) / 2 * scale + coords;
- if (bleeding <= 0)
+ if (bleeding <= 0) {
DoBlood(1, 255);
+ }
if (bloodtoggle && !bled) {
terrain.MakeDecal(blooddecalslow, headpoint, .8, .5, 0);
for (unsigned int l = 0; l < terrain.patchobjects[whichpatchx][whichpatchz].size(); l++) {
startpoint = coords;
endpoint = coords;
endpoint.y -= .7;
- if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1)
+ if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1) {
canrecover = 0;
- if (velocity.y < -30)
+ }
+ if (velocity.y < -30) {
canrecover = 0;
+ }
for (unsigned int i = 0; i < Object::objects.size(); i++) {
if (Object::objects[i]->type != treeleavestype && Object::objects[i]->type != bushtype && Object::objects[i]->type != firetype) {
colviewer = startpoint;
coltarget = endpoint;
- if (Object::objects[i]->model.LineCheck(&colviewer, &coltarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
+ if (Object::objects[i]->model.LineCheck(&colviewer, &coltarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1) {
canrecover = 0;
+ }
}
}
if (canrecover) {
targetyaw = -asin(0 - terrainnormal.x);
targetyaw *= 360 / 6.28;
- if (terrainnormal.z < 0)
+ if (terrainnormal.z < 0) {
targetyaw = 180 - targetyaw;
+ }
yaw = targetyaw;
frameTarget = 0;
if (findLength(&average) < 10 && !dead && skeleton.free) {
skeleton.longdead += (2000 - findLength(&average)) * multiplier + multiplier;
if (skeleton.longdead > (damage + 500) * 1.5) {
- if (id == 0)
+ if (id == 0) {
pause_sound(whooshsound);
+ }
skeleton.free = 0;
velocity = 0;
XYZ middle;
targetyaw = -asin(0 - terrainnormal.x);
targetyaw *= 360 / 6.28;
- if (terrainnormal.z < 0)
+ if (terrainnormal.z < 0) {
targetyaw = 180 - targetyaw;
+ }
yaw = targetyaw;
targettilt2 = asin(terrainnormal.y) * 180 / 3.14 * -1;
if (id == 0) {
if (rightkeydown) {
targetyaw -= 90;
- if (forwardkeydown)
+ if (forwardkeydown) {
targetyaw += 45;
- if (backkeydown)
+ }
+ if (backkeydown) {
targetyaw -= 45;
+ }
}
if (leftkeydown) {
targetyaw += 90;
- if (forwardkeydown)
+ if (forwardkeydown) {
targetyaw -= 45;
- if (backkeydown)
+ }
+ if (backkeydown) {
targetyaw += 45;
+ }
}
if (backkeydown) {
- if (!leftkeydown && !rightkeydown)
+ if (!leftkeydown && !rightkeydown) {
targetyaw += 180;
+ }
}
targetyaw += 180;
}
}
- if (abs(targettilt2) > 50)
+ if (abs(targettilt2) > 50) {
targettilt2 = 0;
+ }
animCurrent = tempanim;
frameCurrent = 0;
target = 0;
tilt2 = targettilt2;
- if (middle.y > 0 && animTarget != rollanim)
+ if (middle.y > 0 && animTarget != rollanim) {
targetoffset.y = middle.y + 1;
+ }
for (unsigned i = 0; i < skeleton.joints.size(); i++) {
tempanimation.frames[0].joints[i].position = skeleton.joints[i].position;
bool hasstaff;
hasstaff = 0;
- if (num_weapons > 0)
- if (weapons[0].getType() == staff)
+ if (num_weapons > 0) {
+ if (weapons[0].getType() == staff) {
hasstaff = 1;
+ }
+ }
if (!skeleton.freefall && freefall && ((jumpkeydown && jumpkeydowntime < .2) || (hasstaff && rabbitkickragdoll)) && !dead) {
if (velocity.y > -30) {
XYZ tempvelocity;
Normalise(&tempvelocity);
targetyaw = -asin(0 - tempvelocity.x);
targetyaw *= 360 / 6.28;
- if (velocity.z < 0)
+ if (velocity.z < 0) {
targetyaw = 180 - targetyaw;
+ }
//targetyaw+=180;
skeleton.free = 0;
targettilt2 = 0;
}
}
- if (skeleton.freefall == 0)
+ if (skeleton.freefall == 0) {
freefall = 0;
+ }
}
- if (aitype != passivetype || skeleton.free == 1)
- if (findLengthfast(&velocity) > .1)
+ if (aitype != passivetype || skeleton.free == 1) {
+ if (findLengthfast(&velocity) > .1) {
for (unsigned int i = 0; i < Object::objects.size(); i++) {
- if (Object::objects[i]->type == firetype)
+ if (Object::objects[i]->type == firetype) {
if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 49) {
if (onfire) {
if (!Object::objects[i]->onfire) {
}
}
}
- if (Object::objects[i]->type == bushtype)
+ }
+ if (Object::objects[i]->type == bushtype) {
if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 49) {
if (onfire) {
if (!Object::objects[i]->onfire) {
}
int howmany = 0;
- if (environment == grassyenvironment)
+ if (environment == grassyenvironment) {
howmany = findLength(&velocity) * 4;
- if (environment == snowyenvironment)
+ }
+ if (environment == snowyenvironment) {
howmany = findLength(&velocity) * 2;
- if (detail == 2)
- if (environment != desertenvironment)
+ }
+ if (detail == 2) {
+ if (environment != desertenvironment) {
for (int j = 0; j < howmany; j++) {
tempvel.x = float(abs(Random() % 100) - 50) / 20;
tempvel.y = float(abs(Random() % 100) - 50) / 20;
Sprite::MakeSprite(splintersprite, pos, tempvel * .5 + velocity * float(abs(Random() % 100)) / 100, 165 / 255 + float(abs(Random() % 100) - 50) / 400, 0, 0, .2 + float(abs(Random() % 100) - 50) / 1300, 1);
Sprite::setLastSpriteSpecial(1);
}
+ }
+ }
howmany = findLength(&velocity) * 4;
- if (detail == 2)
- if (environment == snowyenvironment)
+ if (detail == 2) {
+ if (environment == snowyenvironment) {
for (int j = 0; j < howmany; j++) {
tempvel.x = float(abs(Random() % 100) - 50) / 20;
tempvel.y = float(abs(Random() % 100) - 50) / 20;
Sprite::MakeSprite(splintersprite, pos, tempvel * .3 + velocity * float(abs(Random() % 100)) / 100 / 2, 1, 1, 1, .1, 1);
Sprite::setLastSpriteSpecial(2);
}
+ }
+ }
}
Object::objects[i]->rotx += velocity.x * multiplier * 6;
Object::objects[i]->roty += velocity.z * multiplier * 6;
Object::objects[i]->messedwith = .5;
}
+ }
XYZ tempcoord;
if (Object::objects[i]->type == treeleavestype && environment != desertenvironment) {
- if (Object::objects[i]->pitch == 0)
+ if (Object::objects[i]->pitch == 0) {
tempcoord = coords;
- else {
+ } else {
tempcoord = coords - Object::objects[i]->position;
tempcoord = DoRotation(tempcoord, 0, -Object::objects[i]->yaw, 0);
tempcoord = DoRotation(tempcoord, -Object::objects[i]->pitch, 0, 0);
}
int howmany = 0;
- if (environment == grassyenvironment)
+ if (environment == grassyenvironment) {
howmany = findLength(&velocity) * 4;
- if (environment == snowyenvironment)
+ }
+ if (environment == snowyenvironment) {
howmany = findLength(&velocity) * 2;
- if (detail == 2)
- if (environment != desertenvironment)
+ }
+ if (detail == 2) {
+ if (environment != desertenvironment) {
for (int j = 0; j < howmany; j++) {
tempvel.x = float(abs(Random() % 100) - 50) / 20;
tempvel.y = float(abs(Random() % 100) - 50) / 20;
Sprite::MakeSprite(splintersprite, pos, tempvel * .5 + velocity * float(abs(Random() % 100)) / 100, 165 / 255 + float(abs(Random() % 100) - 50) / 400, 0, 0, .2 + float(abs(Random() % 100) - 50) / 1300, 1);
Sprite::setLastSpriteSpecial(1);
}
+ }
+ }
howmany = findLength(&velocity) * 4;
- if (detail == 2)
- if (environment == snowyenvironment)
+ if (detail == 2) {
+ if (environment == snowyenvironment) {
for (int j = 0; j < howmany; j++) {
tempvel.x = float(abs(Random() % 100) - 50) / 20;
tempvel.y = float(abs(Random() % 100) - 50) / 20;
Sprite::MakeSprite(splintersprite, pos, tempvel * .3 + velocity * float(abs(Random() % 100)) / 100 / 2, 1, 1, 1, .1, 1);
Sprite::setLastSpriteSpecial(2);
}
+ }
+ }
}
Object::objects[i]->messedwith = .5;
}
}
}
+ }
+ }
if (!skeleton.free) {
bool play;
play = 0;
- if ((stunned > 0 || surprised > 0) && Person::players.size() > 2 && aitype != passivetype)
+ if ((stunned > 0 || surprised > 0) && Person::players.size() > 2 && aitype != passivetype) {
play = 1;
- if (hasvictim)
- if (aitype != passivetype && victim->skeleton.free && !victim->dead)
+ }
+ if (hasvictim) {
+ if (aitype != passivetype && victim->skeleton.free && !victim->dead) {
play = 1;
- if (Tutorial::active && id != 0)
+ }
+ }
+ if (Tutorial::active && id != 0) {
play = 0;
+ }
if (play && aitype != playercontrolled) {
int whichsound = -1;
if (speechdelay <= 0) {
unsigned int i = abs(Random() % 4);
if (creature == rabbittype) {
- if (i == 0)
+ if (i == 0) {
whichsound = rabbitchitter;
- if (i == 1)
+ }
+ if (i == 1) {
whichsound = rabbitchitter2;
+ }
}
if (creature == wolftype) {
- if (i == 0)
+ if (i == 0) {
whichsound = growlsound;
- if (i == 1)
+ }
+ if (i == 1) {
whichsound = growl2sound;
+ }
}
}
speechdelay = .3;
}
}
- if (animTarget == staggerbackhighanim)
+ if (animTarget == staggerbackhighanim) {
staggerdelay = 1;
- if (animTarget == staggerbackhardanim)
+ }
+ if (animTarget == staggerbackhardanim) {
staggerdelay = 1;
+ }
staggerdelay -= multiplier;
- if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim)
+ if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim) {
hasvictim = 1;
- if (velocity.y < -30 && animTarget == jumpdownanim)
+ }
+ if (velocity.y < -30 && animTarget == jumpdownanim) {
RagDoll(0);
+ }
if (animCurrent != getIdle() && wasIdle() && animTarget != getIdle() && isIdle()) {
animTarget = getIdle();
frameTarget = 0;
}
}
- if (!dead && animTarget != hurtidleanim)
+ if (!dead && animTarget != hurtidleanim) {
if (behind || animTarget == killanim || animTarget == knifethrowanim || animTarget == knifefollowanim || animTarget == spinkickreversalanim || animTarget == rabbitkickreversedanim || animTarget == jumpreversedanim) {
if (headmorphend != 4 || headmorphness == targetheadmorphness) {
headmorphend = 4;
targetheadmorphness = 1;
}
}
+ }
if (weaponactive != -1) {
if (weapons[weaponids[weaponactive]].getType() != staff) {
terrainnormal = terrain.getNormal(coords.x, coords.z);
if (Animation::animations[animTarget].attack != reversal) {
- if (!isnormal(coords.x))
+ if (!isnormal(coords.x)) {
coords = oldcoords;
+ }
oldcoords = coords;
}
if (isRun() ||
animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) {
- if (onterrain)
+ if (onterrain) {
targettilt2 = -facing.y * 20;
- else
+ } else {
targettilt2 = 0;
+ }
}
onterrain = 0;
- if (!isRun() && !Animation::animations[animTarget].attack && animTarget != getupfromfrontanim && animTarget != getupfrombackanim && animTarget != sneakanim)
+ if (!isRun() && !Animation::animations[animTarget].attack && animTarget != getupfromfrontanim && animTarget != getupfrombackanim && animTarget != sneakanim) {
targettilt2 = 0;
+ }
if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
flatvelocity = velocity;
flatvelocity.y = 0;
flatvelspeed = findLength(&flatvelocity);
targettilt = flatvelspeed * fast_sqrt(abs(velocity.y) * .7) * normaldotproduct(DoRotation(flatfacing, 0, -90, 0), flatvelocity);
targettilt2 = flatvelspeed * fast_sqrt(abs(velocity.y) * .7) * normaldotproduct(flatfacing, flatvelocity);
- if (velocity.y < 0)
+ if (velocity.y < 0) {
targettilt2 *= -1;
- if (velocity.y < 0)
+ }
+ if (velocity.y < 0) {
targettilt *= -1;
- if (targettilt > 25)
+ }
+ if (targettilt > 25) {
targettilt = 25;
- if (targettilt < -25)
+ }
+ if (targettilt < -25) {
targettilt = -25;
+ }
}
- if (targettilt2 > 45)
+ if (targettilt2 > 45) {
targettilt2 = 45;
- if (targettilt2 < -45)
+ }
+ if (targettilt2 < -45) {
targettilt2 = -45;
- if (abs(tilt2 - targettilt2) < multiplier * 400)
+ }
+ if (abs(tilt2 - targettilt2) < multiplier * 400) {
tilt2 = targettilt2;
- else if (tilt2 > targettilt2) {
+ } else if (tilt2 > targettilt2) {
tilt2 -= multiplier * 400;
} else if (tilt2 < targettilt2) {
tilt2 += multiplier * 400;
}
if (!Animation::animations[animTarget].attack && animTarget != getupfrombackanim && animTarget != getupfromfrontanim) {
- if (tilt2 > 25)
+ if (tilt2 > 25) {
tilt2 = 25;
- if (tilt2 < -25)
+ }
+ if (tilt2 < -25) {
tilt2 = -25;
+ }
}
if (!isnormal(targettilt) && targettilt) {
velocity.y += gravity * multiplier * 20;
ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
velspeed = findLength(&velocity);
- if (velspeed < speed * 30 * scale)
+ if (velspeed < speed * 30 * scale) {
velspeed = speed * 30 * scale;
+ }
velocity = flatfacing * velspeed;
}
} else if (isRun()) {
velocity.y += gravity * multiplier;
}
- if (animTarget != climbanim && animTarget != hanganim && !isWallJump())
+ if (animTarget != climbanim && animTarget != hanganim && !isWallJump()) {
coords += velocity * multiplier;
+ }
if (coords.y < terrain.getHeight(coords.x, coords.z) && (animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) {
- if (isFlip() && targetFrame().label == 7)
+ if (isFlip() && targetFrame().label == 7) {
RagDoll(0);
+ }
if (animTarget == jumpupanim) {
jumppower = -4;
}
if (animTarget == jumpdownanim || isFlip()) {
- if (isFlip())
+ if (isFlip()) {
jumppower = -4;
+ }
animTarget = getLanding();
emit_sound_at(landsound, coords, 128.);
}
}
- if (animTarget != jumpupanim && animTarget != jumpdownanim && !isFlip() && animTarget != climbanim && animTarget != hanganim && !isWallJump())
+ if (animTarget != jumpupanim && animTarget != jumpdownanim && !isFlip() && animTarget != climbanim && animTarget != hanganim && !isWallJump()) {
coords.y += gravity * multiplier * 2;
+ }
if (animTarget != jumpupanim && animTarget != jumpdownanim && !isFlip() && coords.y < terrain.getHeight(coords.x, coords.z)) {
coords.y = terrain.getHeight(coords.x, coords.z);
onterrain = 1;
}
}
- if (skiddingdelay < 0)
+ if (skiddingdelay < 0) {
skiddingdelay += multiplier;
+ }
if (skiddingdelay > .02 && !forwardkeydown && !backkeydown && !leftkeydown && !rightkeydown && !jumpkeydown && isLanding() && !landhard) {
skiddingdelay = -1;
if (!onterrain || environment == grassyenvironment) {
Normalise(&terrainnormal);
targetyaw = -asin(0 - terrainnormal.x);
targetyaw *= 360 / 6.28;
- if (terrainnormal.z < 0)
+ if (terrainnormal.z < 0) {
targetyaw = 180 - targetyaw;
+ }
targettilt2 = -asin(terrainnormal.y) * 360 / 6.28; //*-70;
}
XYZ terrainlight;
float terrainheight;
float distance;
- if (!isnormal(yaw))
+ if (!isnormal(yaw)) {
yaw = 0;
- if (!isnormal(tilt))
+ }
+ if (!isnormal(tilt)) {
tilt = 0;
- if (!isnormal(tilt2))
+ }
+ if (!isnormal(tilt2)) {
tilt2 = 0;
+ }
oldplayerdetail = playerdetail;
playerdetail = 0;
if (distsq(&viewer, &coords) < viewdistance * viewdistance / 32 && detail == 2) {
if (distsq(&viewer, &coords) < viewdistance * viewdistance / 256 && (detail != 1 && detail != 2)) {
playerdetail = 1;
}
- if (id == 0)
+ if (id == 0) {
playerdetail = 1;
+ }
if (playerdetail != oldplayerdetail) {
updatedelay = 0;
normalsupdatedelay = 0;
if (onterrain && (cond1 && cond2) && !skeleton.free) {
IKHelper(this, 1);
- if (creature == wolftype)
+ if (creature == wolftype) {
IKHelper(this, 1);
+ }
}
if (onterrain && (cond1 && !cond2) && !skeleton.free) {
IKHelper(this, target);
- if (creature == wolftype)
+ if (creature == wolftype) {
IKHelper(this, target);
+ }
}
if (onterrain && (!cond1 && cond2) && !skeleton.free) {
IKHelper(this, 1 - target);
- if (creature == wolftype)
+ if (creature == wolftype) {
IKHelper(this, 1 - target);
+ }
}
}
- if (!skeleton.free && (!Animation::animations[animTarget].attack && animTarget != getupfrombackanim && ((animTarget != rollanim && !isFlip()) || targetFrame().label == 6) && animTarget != getupfromfrontanim && animTarget != wolfrunninganim && animTarget != rabbitrunninganim && animTarget != backhandspringanim && animTarget != walljumpfrontanim && animTarget != hurtidleanim && !isLandhard() && !isSleeping()))
+ if (!skeleton.free && (!Animation::animations[animTarget].attack && animTarget != getupfrombackanim && ((animTarget != rollanim && !isFlip()) || targetFrame().label == 6) && animTarget != getupfromfrontanim && animTarget != wolfrunninganim && animTarget != rabbitrunninganim && animTarget != backhandspringanim && animTarget != walljumpfrontanim && animTarget != hurtidleanim && !isLandhard() && !isSleeping())) {
DoHead();
- else {
+ } else {
targetheadyaw = -targetyaw;
targetheadpitch = 0;
- if (Animation::animations[animTarget].attack == 3)
+ if (Animation::animations[animTarget].attack == 3) {
targetheadyaw += 180;
+ }
}
for (int i = 0; i < skeleton.drawmodel.vertexNum; i++) {
skeleton.drawmodel.vertex[i] = 0;
start = tailmorphstart;
endthing = tailmorphend;
}
- if (calcrot)
+ if (calcrot) {
skeleton.FindRotationMuscle(i, animTarget);
+ }
mid = (skeleton.muscles[i].parent1->position + skeleton.muscles[i].parent2->position) / 2;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- if (!skeleton.free)
+ if (!skeleton.free) {
glRotatef(tilt2, 1, 0, 0);
- if (!skeleton.free)
+ }
+ if (!skeleton.free) {
glRotatef(tilt, 0, 0, 1);
+ }
glTranslatef(mid.x, mid.y, mid.z);
XYZ& v1 = skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (p1 == abdomen || p2 == abdomen)
+ if (p1 == abdomen || p2 == abdomen) {
glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionbody.x,
(v0.y * (1 - morphness) + v1.y * morphness) * proportionbody.y,
(v0.z * (1 - morphness) + v1.z * morphness) * proportionbody.z);
- if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow)
+ }
+ if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow) {
glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionarms.x,
(v0.y * (1 - morphness) + v1.y * morphness) * proportionarms.y,
(v0.z * (1 - morphness) + v1.z * morphness) * proportionarms.z);
- if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee)
+ }
+ if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee) {
glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionlegs.x,
(v0.y * (1 - morphness) + v1.y * morphness) * proportionlegs.y,
(v0.z * (1 - morphness) + v1.z * morphness) * proportionlegs.z);
- if (p1 == head || p2 == head)
+ }
+ if (p1 == head || p2 == head) {
glTranslatef((v0.x * (1 - morphness) + v1.x * morphness) * proportionhead.x,
(v0.y * (1 - morphness) + v1.y * morphness) * proportionhead.y,
(v0.z * (1 - morphness) + v1.z * morphness) * proportionhead.z);
+ }
glGetFloatv(GL_MODELVIEW_MATRIX, M);
skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x = M[12] * scale;
skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y = M[13] * scale;
XYZ& v0 = skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (p1 == abdomen || p2 == abdomen)
+ if (p1 == abdomen || p2 == abdomen) {
glTranslatef(v0.x * proportionbody.x,
v0.y * proportionbody.y,
v0.z * proportionbody.z);
- if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow)
+ }
+ if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow) {
glTranslatef(v0.x * proportionarms.x,
v0.y * proportionarms.y,
v0.z * proportionarms.z);
- if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee)
+ }
+ if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee) {
glTranslatef(v0.x * proportionlegs.x,
v0.y * proportionlegs.y,
v0.z * proportionlegs.z);
- if (p1 == head || p2 == head)
+ }
+ if (p1 == head || p2 == head) {
glTranslatef(v0.x * proportionhead.x,
v0.y * proportionhead.y,
v0.z * proportionhead.z);
+ }
glGetFloatv(GL_MODELVIEW_MATRIX, M);
skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x = M[12] * scale;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- if (!skeleton.free)
+ if (!skeleton.free) {
glRotatef(tilt2, 1, 0, 0);
- if (!skeleton.free)
+ }
+ if (!skeleton.free) {
glRotatef(tilt, 0, 0, 1);
+ }
glTranslatef(mid.x, mid.y, mid.z);
skeleton.muscles[i].lastrotate1 = skeleton.muscles[i].rotate1;
glRotatef(-skeleton.muscles[i].lastrotate1 + 90, 0, 1, 0);
XYZ& v0 = skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (p1 == abdomen || p2 == abdomen)
+ if (p1 == abdomen || p2 == abdomen) {
glTranslatef(v0.x * proportionbody.x,
v0.y * proportionbody.y,
v0.z * proportionbody.z);
- if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow)
+ }
+ if (p1 == lefthand || p1 == righthand || p1 == leftwrist || p1 == rightwrist || p1 == leftelbow || p1 == rightelbow || p2 == leftelbow || p2 == rightelbow) {
glTranslatef(v0.x * proportionarms.x,
v0.y * proportionarms.y,
v0.z * proportionarms.z);
- if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee)
+ }
+ if (p1 == leftfoot || p1 == rightfoot || p1 == leftankle || p1 == rightankle || p1 == leftknee || p1 == rightknee || p2 == leftknee || p2 == rightknee) {
glTranslatef(v0.x * proportionlegs.x,
v0.y * proportionlegs.y,
v0.z * proportionlegs.z);
- if (p1 == head || p2 == head)
+ }
+ if (p1 == head || p2 == head) {
glTranslatef(v0.x * proportionhead.x,
v0.y * proportionhead.y,
v0.z * proportionhead.z);
+ }
glGetFloatv(GL_MODELVIEW_MATRIX, M);
skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x = M[12] * scale;
skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y = M[13] * scale;
}
if (skeleton.free != 2 && (skeleton.free == 1 || skeleton.free == 3 || id == 0 || (normalsupdatedelay <= 0) || animTarget == getupfromfrontanim || animTarget == getupfrombackanim || animCurrent == getupfromfrontanim || animCurrent == getupfrombackanim)) {
normalsupdatedelay = 1;
- if (playerdetail || skeleton.free == 3)
+ if (playerdetail || skeleton.free == 3) {
skeleton.drawmodel.CalculateNormals(0);
- if (!playerdetail || skeleton.free == 3)
+ }
+ if (!playerdetail || skeleton.free == 3) {
skeleton.drawmodellow.CalculateNormals(0);
- if (skeleton.clothes)
+ }
+ if (skeleton.clothes) {
skeleton.drawmodelclothes.CalculateNormals(0);
+ }
} else {
- if (playerdetail || skeleton.free == 3)
+ if (playerdetail || skeleton.free == 3) {
skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
- if (!playerdetail || skeleton.free == 3)
+ }
+ if (!playerdetail || skeleton.free == 3) {
skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
+ }
if (skeleton.clothes) {
skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
}
}
framemult = .01;
updatedelaychange = -framemult * 4 * (45 - findDistance(&viewer, &coords) * 1);
- if (updatedelaychange > -realmultiplier * 30)
+ if (updatedelaychange > -realmultiplier * 30) {
updatedelaychange = -realmultiplier * 30;
- if (updatedelaychange > -framemult * 4)
+ }
+ if (updatedelaychange > -framemult * 4) {
updatedelaychange = -framemult * 4;
- if (skeleton.free == 1)
+ }
+ if (skeleton.free == 1) {
updatedelaychange *= 6;
- if (id == 0)
+ }
+ if (id == 0) {
updatedelaychange *= 8;
+ }
updatedelay += updatedelaychange;
glMatrixMode(GL_MODELVIEW);
terrainlight = terrain.getLighting(coords.x, coords.z);
distance = distsq(&viewer, &coords);
distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
- if (distance > 1)
+ if (distance > 1) {
distance = 1;
+ }
if (distance > 0) {
terrainheight = (coords.y - terrain.getHeight(coords.x, coords.z)) / 3 + 1;
- if (terrainheight < 1)
+ if (terrainheight < 1) {
terrainheight = 1;
- if (terrainheight > 1.7)
+ }
+ if (terrainheight > 1.7) {
terrainheight = 1.7;
+ }
glColor4f((1 - (1 - terrainlight.x) / terrainheight) - burnt, (1 - (1 - terrainlight.y) / terrainheight) - burnt, (1 - (1 - terrainlight.z) / terrainheight) - burnt, distance);
glDisable(GL_BLEND);
glDepthMask(0);
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
- if (canattack && cananger)
+ if (canattack && cananger) {
if (Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed) {
glDisable(GL_TEXTURE_2D);
glColor4f(1, 0, 0, 0.8);
}
+ }
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glTranslatef(0, -smoketex, 0);
}
if (playerdetail) {
if (!showpoints) {
- if (Tutorial::active && (id != 0))
+ if (Tutorial::active && (id != 0)) {
skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
- else
+ } else {
skeleton.drawmodel.draw();
+ }
}
}
if (!playerdetail) {
- if (Tutorial::active && (id != 0))
+ if (Tutorial::active && (id != 0)) {
skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
- else
+ } else {
skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
+ }
}
- if (!(Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed))
+ if (!(Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed)) {
if (Tutorial::active && id != 0) {
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glDepthMask(0);
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
- if (canattack && cananger)
+ if (canattack && cananger) {
if (Animation::animations[animTarget].attack == normalattack || Animation::animations[animTarget].attack == reversed) {
glDisable(GL_TEXTURE_2D);
glColor4f(1, 0, 0, 0.8);
}
+ }
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glTranslatef(0, -smoketex * .6, 0);
glTranslatef(smoketex * .6, 0, 0);
if (playerdetail) {
if (!showpoints) {
- if (Tutorial::active && (id != 0))
+ if (Tutorial::active && (id != 0)) {
skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
- else
+ } else {
skeleton.drawmodel.draw();
+ }
}
}
if (!playerdetail) {
- if (Tutorial::active && (id != 0))
+ if (Tutorial::active && (id != 0)) {
skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
- else
+ } else {
skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
+ }
}
}
+ }
if (Tutorial::active && id != 0) {
glPopMatrix();
if (skeleton.clothes) {
glDepthMask(0);
glEnable(GL_BLEND);
- if (!immediate)
+ if (!immediate) {
skeleton.drawmodelclothes.draw();
- if (immediate)
+ }
+ if (immediate) {
skeleton.drawmodelclothes.drawimmediate();
+ }
glDepthMask(1);
}
}
}
}
weaponpoint = (skeleton.muscles[weaponattachmuscle].parent1->position + skeleton.muscles[weaponattachmuscle].parent2->position) / 2;
- if (creature == wolftype)
+ if (creature == wolftype) {
weaponpoint = (jointPos(rightwrist) * .7 + jointPos(righthand) * .3);
+ }
}
if (weapons[i].getType() == staff) {
for (unsigned j = 0; j < skeleton.muscles.size(); j++) {
vec2 = (jointPos(rightwrist) - jointPos(rightshoulder));
CrossProduct(&vec1, &vec2, &tempnormthing);
Normalise(&tempnormthing);
- if (animTarget != staffhitanim && animCurrent != staffhitanim && animTarget != staffgroundsmashanim && animCurrent != staffgroundsmashanim && animTarget != staffspinhitanim && animCurrent != staffspinhitanim)
+ if (animTarget != staffhitanim && animCurrent != staffhitanim && animTarget != staffgroundsmashanim && animCurrent != staffgroundsmashanim && animTarget != staffspinhitanim && animCurrent != staffspinhitanim) {
weaponpoint += tempnormthing * .1 - skeleton.specialforward[1] * .3 + (jointPos(rightwrist) - jointPos(rightelbow));
+ }
}
}
if (weaponactive != k && weaponstuck != k) {
- if (weapons[i].getType() == knife)
+ if (weapons[i].getType() == knife) {
weaponpoint = jointPos(abdomen) + (jointPos(righthip) - jointPos(lefthip)) * .1 + (jointPos(rightshoulder) - jointPos(leftshoulder)) * .35;
- if (weapons[i].getType() == sword)
+ }
+ if (weapons[i].getType() == sword) {
weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
- if (weapons[i].getType() == staff)
+ }
+ if (weapons[i].getType() == staff) {
weaponpoint = jointPos(abdomen) + (jointPos(lefthip) - jointPos(righthip)) * .09 + (jointPos(leftshoulder) - jointPos(rightshoulder)) * .33;
+ }
for (unsigned j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
}
}
if (weaponstuck == k) {
- if (weaponstuckwhere == 0)
+ if (weaponstuckwhere == 0) {
weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 - skeleton.forward * .8;
- else
+ } else {
weaponpoint = jointPos(abdomen) * .5 + jointPos(neck) * .5 + skeleton.forward * .8;
+ }
for (unsigned j = 0; j < skeleton.muscles.size(); j++) {
if ((skeleton.muscles[j].parent1->label == abdomen || skeleton.muscles[j].parent2->label == abdomen) && (skeleton.muscles[j].parent1->label == neck || skeleton.muscles[j].parent2->label == neck) && skeleton.muscles[j].vertices.size() > 0) {
weaponrotatemuscle = j;
weapons[i].rotation3 = 0;
weapons[i].smallrotation = -90;
weapons[i].smallrotation2 = 0;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
weapons[i].rotation1 = 360 - weapons[i].rotation1;
+ }
}
if ((animCurrent == knifeslashreversalanim && animTarget == knifeslashreversalanim) || (animCurrent == knifeslashreversedanim && animTarget == knifeslashreversedanim)) {
XYZ temppoint1, temppoint2;
weapons[i].rotation3 = 0;
weapons[i].smallrotation = 90;
weapons[i].smallrotation2 = 0;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
weapons[i].rotation1 = 360 - weapons[i].rotation1;
+ }
}
if (animTarget == knifethrowanim) {
weapons[i].smallrotation = 90;
weapons[i].rotation3 = 0;
weapons[i].smallrotation = 90;
weapons[i].smallrotation2 = 0;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
weapons[i].rotation1 = 360 - weapons[i].rotation1;
+ }
}
}
if (weapons[i].getType() == staff) {
weapons[i].rotation3 = 0;
weapons[i].smallrotation = 90;
weapons[i].smallrotation2 = 0;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
weapons[i].rotation1 = 360 - weapons[i].rotation1;
+ }
}
}
}
}
}
if (weaponstuck == k) {
- if (weaponstuckwhere == 0)
+ if (weaponstuckwhere == 0) {
weapons[i].smallrotation = 180;
- else
+ } else {
weapons[i].smallrotation = 0;
+ }
weapons[i].smallrotation2 = 10;
}
}
}
calcrot = 0;
- if (skeleton.free)
+ if (skeleton.free) {
calcrot = 1;
- if (Animation::animations[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isWallJump())
+ }
+ if (Animation::animations[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isWallJump()) {
calcrot = 1;
- if (animCurrent != animTarget)
+ }
+ if (animCurrent != animTarget) {
calcrot = 1;
- if (skeleton.free == 2)
+ }
+ if (skeleton.free == 2) {
calcrot = 0;
+ }
return 0;
}
oldp1 = *p1;
*p1 = *p1 - *move;
- if (distsq(p1, &model->boundingspherecenter) > radius * radius + model->boundingsphereradius * model->boundingsphereradius)
+ if (distsq(p1, &model->boundingspherecenter) > radius * radius + model->boundingsphereradius * model->boundingsphereradius) {
return -1;
- if (*rotate)
+ }
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, -*rotate, 0);
+ }
for (int i = 0; i < 4; i++) {
for (unsigned int j = 0; j < model->Triangles.size(); j++) {
if (model->Triangles[j].facenormal.y <= slopethreshold) {
distance = abs((model->Triangles[j].facenormal.x * p1->x) + (model->Triangles[j].facenormal.y * p1->y) + (model->Triangles[j].facenormal.z * p1->z) - ((model->Triangles[j].facenormal.x * model->vertex[model->Triangles[j].vertex[0]].x) + (model->Triangles[j].facenormal.y * model->vertex[model->Triangles[j].vertex[0]].y) + (model->Triangles[j].facenormal.z * model->vertex[model->Triangles[j].vertex[0]].z)));
if (distance < radius) {
point = *p1 - model->Triangles[j].facenormal * distance;
- if (PointInTriangle(&point, model->Triangles[j].facenormal, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]]))
+ if (PointInTriangle(&point, model->Triangles[j].facenormal, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]])) {
intersecting = 1;
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
&model->vertex[model->Triangles[j].vertex[1]],
p1, &radius);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
&model->vertex[model->Triangles[j].vertex[2]],
p1, &radius);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
&model->vertex[model->Triangles[j].vertex[2]],
p1, &radius);
+ }
end = *p1 - point;
if (dotproduct(&model->Triangles[j].facenormal, &end) > 0 && intersecting) {
start = *p1;
if (LineFacetd(&start, &end, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]], &model->Triangles[j].facenormal, &point)) {
p1->y = point.y + radius;
if ((animTarget == jumpdownanim || isFlip())) {
- if (isFlip() && (frameTarget < 5 || targetFrame().label == 7 || targetFrame().label == 4))
+ if (isFlip() && (frameTarget < 5 || targetFrame().label == 7 || targetFrame().label == 4)) {
RagDoll(0);
+ }
if (animTarget == jumpupanim) {
jumppower = -4;
}
if ((animTarget == jumpdownanim || isFlip()) && !wasLanding() && !wasLandhard()) {
- if (isFlip())
+ if (isFlip()) {
jumppower = -4;
+ }
animTarget = getLanding();
emit_sound_at(landsound, coords, 128.);
distance = abs((model->Triangles[j].facenormal.x * start.x) + (model->Triangles[j].facenormal.y * start.y) + (model->Triangles[j].facenormal.z * start.z) - ((model->Triangles[j].facenormal.x * v0.x) + (model->Triangles[j].facenormal.y * v0.y) + (model->Triangles[j].facenormal.z * v0.z)));
if (distance < radius * .5) {
point = start - model->Triangles[j].facenormal * distance;
- if (PointInTriangle(&point, model->Triangles[j].facenormal, &v0, &v1, &v2))
+ if (PointInTriangle(&point, model->Triangles[j].facenormal, &v0, &v1, &v2)) {
intersecting = 1;
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, p1->x, p1->y, p1->z, radius / 2);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, p1->x, p1->y, p1->z, radius / 2);
- if (!intersecting)
+ }
+ if (!intersecting) {
intersecting = sphere_line_intersection(v0.x, v0.y, v0.z, v2.x, v2.y, v2.z, p1->x, p1->y, p1->z, radius / 2);
+ }
end = *p1 - point;
if (dotproduct(&model->Triangles[j].facenormal, &end) > 0 && intersecting) {
if ((animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) {
start = velocity;
velocity -= DoRotation(model->Triangles[j].facenormal, 0, *rotate, 0) * findLength(&velocity) * abs(normaldotproduct(velocity, DoRotation(model->Triangles[j].facenormal, 0, *rotate, 0))); //(distance-radius*.5)/multiplier;
- if (findLengthfast(&start) < findLengthfast(&velocity))
+ if (findLengthfast(&start) < findLengthfast(&velocity)) {
velocity = start;
+ }
}
*p1 += model->Triangles[j].facenormal * (distance - radius * .5);
}
}
}
}
- if (*rotate)
+ if (*rotate) {
*p = DoRotation(*p, 0, *rotate, 0);
+ }
*p = *p + *move;
- if (*rotate)
+ if (*rotate) {
*p1 = DoRotation(*p1, 0, *rotate, 0);
+ }
*p1 += *move;
return firstintersecting;
}
for (int j = 0; j < Game::numpathpoints; j++) {
if (j != last && j != last2 && j != last3 && j != last4) {
connected = 0;
- if (Game::numpathpointconnect[j])
+ if (Game::numpathpointconnect[j]) {
for (int k = 0; k < Game::numpathpointconnect[j]; k++) {
- if (Game::pathpointconnect[j][k] == last)
+ if (Game::pathpointconnect[j][k] == last) {
connected = 1;
+ }
}
- if (!connected)
- if (Game::numpathpointconnect[last])
+ }
+ if (!connected) {
+ if (Game::numpathpointconnect[last]) {
for (int k = 0; k < Game::numpathpointconnect[last]; k++) {
- if (Game::pathpointconnect[last][k] == j)
+ if (Game::pathpointconnect[last][k] == j) {
connected = 1;
+ }
}
- if (connected)
+ }
+ }
+ if (connected) {
if (closest == -1 || Random() % 2 == 0) {
closest = j;
}
+ }
}
}
last4 = last3;
float tintg = clothestintg[clothesId];
float tintb = clothestintb[clothesId];
- if (tintr > 1)
+ if (tintr > 1) {
tintr = 1;
- if (tintg > 1)
+ }
+ if (tintg > 1) {
tintg = 1;
- if (tintb > 1)
+ }
+ if (tintb > 1) {
tintb = 1;
+ }
- if (tintr < 0)
+ if (tintr < 0) {
tintr = 0;
- if (tintg < 0)
+ }
+ if (tintg < 0) {
tintg = 0;
- if (tintb < 0)
+ }
+ if (tintb < 0) {
tintb = 0;
+ }
int bytesPerPixel = texture.bpp / 8;
int tempnum = 0;
alphanum = 255;
for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
- if (bytesPerPixel == 3)
+ if (bytesPerPixel == 3) {
alphanum = 255;
- else if ((i + 1) % 4 == 0)
+ } else if ((i + 1) % 4 == 0) {
alphanum = texture.data[i];
+ }
if ((i + 1) % 4 || bytesPerPixel == 3) {
- if ((i % 4) == 0)
+ if ((i % 4) == 0) {
texture.data[i] *= tintr;
- if ((i % 4) == 1)
+ }
+ if ((i % 4) == 1) {
texture.data[i] *= tintg;
- if ((i % 4) == 2)
+ }
+ if ((i % 4) == 2) {
texture.data[i] *= tintb;
+ }
array[tempnum] = (float)array[tempnum] * (1 - alphanum / 255) + (float)texture.data[i] * (alphanum / 255);
tempnum++;
}
if (aitype != playercontrolled && !Dialog::inDialog()) {
jumpclimb = 0;
//disable movement in editor
- if (Game::editorenabled)
+ if (Game::editorenabled) {
stunned = 1;
+ }
pause = 0;
if (distsqflat(&Person::players[0]->coords, &coords) < 30 &&
Person::players[0]->coords.y > coords.y + 2 &&
- !Person::players[0]->onterrain)
+ !Person::players[0]->onterrain) {
pause = 1;
+ }
//pathfinding
if (aitype == pathfindtype) {
for (int j = 0; j < Game::numpathpoints; j++) {
for (int k = 0; k < Game::numpathpointconnect[j]; k++) {
DistancePointLine(&finalfinaltarget, &Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]], &tempdist, &colpoint);
- if (sq(tempdist) < closestdistance)
+ if (sq(tempdist) < closestdistance) {
if (findDistance(&colpoint, &Game::pathpoint[j]) + findDistance(&colpoint, &Game::pathpoint[Game::pathpointconnect[j][k]]) <
findDistance(&Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]]) + .1) {
closestdistance = sq(tempdist);
closest = j;
finaltarget = colpoint;
}
+ }
}
}
finalpathfindpoint = closest;
closestdistance = -1;
if (lastpathfindpoint == -1) {
for (int j = 0; j < Game::numpathpoints; j++) {
- if (j != lastpathfindpoint)
+ if (j != lastpathfindpoint) {
if (closest == -1 || (distsq(&coords, &Game::pathpoint[j]) < closestdistance)) {
closestdistance = distsq(&coords, &Game::pathpoint[j]);
closest = j;
}
+ }
}
targetpathfindpoint = closest;
- for (int j = 0; j < Game::numpathpoints; j++)
- if (j != lastpathfindpoint)
+ for (int j = 0; j < Game::numpathpoints; j++) {
+ if (j != lastpathfindpoint) {
for (int k = 0; k < Game::numpathpointconnect[j]; k++) {
DistancePointLine(&coords, &Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]], &tempdist, &colpoint);
if (sq(tempdist) < closestdistance) {
}
}
}
+ }
+ }
targetpathfindpoint = closest;
} else {
- for (int j = 0; j < Game::numpathpoints; j++)
+ for (int j = 0; j < Game::numpathpoints; j++) {
if (j != lastpathfindpoint &&
j != lastpathfindpoint2 &&
j != lastpathfindpoint3 &&
j != lastpathfindpoint4) {
bool connected = 0;
- if (Game::numpathpointconnect[j])
- for (int k = 0; k < Game::numpathpointconnect[j]; k++)
- if (Game::pathpointconnect[j][k] == lastpathfindpoint)
+ if (Game::numpathpointconnect[j]) {
+ for (int k = 0; k < Game::numpathpointconnect[j]; k++) {
+ if (Game::pathpointconnect[j][k] == lastpathfindpoint) {
connected = 1;
- if (!connected)
- if (Game::numpathpointconnect[lastpathfindpoint])
- for (int k = 0; k < Game::numpathpointconnect[lastpathfindpoint]; k++)
- if (Game::pathpointconnect[lastpathfindpoint][k] == j)
+ }
+ }
+ }
+ if (!connected) {
+ if (Game::numpathpointconnect[lastpathfindpoint]) {
+ for (int k = 0; k < Game::numpathpointconnect[lastpathfindpoint]; k++) {
+ if (Game::pathpointconnect[lastpathfindpoint][k] == j) {
connected = 1;
+ }
+ }
+ }
+ }
if (connected) {
tempdist = findPathDist(j, finalpathfindpoint);
if (closest == -1 || tempdist < closestdistance) {
}
}
}
+ }
targetpathfindpoint = closest;
}
}
lastpathfindpoint3 = lastpathfindpoint2;
lastpathfindpoint2 = lastpathfindpoint;
lastpathfindpoint = targetpathfindpoint;
- if (lastpathfindpoint2 == -1)
+ if (lastpathfindpoint2 == -1) {
lastpathfindpoint2 = lastpathfindpoint;
- if (lastpathfindpoint3 == -1)
+ }
+ if (lastpathfindpoint3 == -1) {
lastpathfindpoint3 = lastpathfindpoint2;
- if (lastpathfindpoint4 == -1)
+ }
+ if (lastpathfindpoint4 == -1) {
lastpathfindpoint4 = lastpathfindpoint3;
+ }
targetpathfindpoint = -1;
}
if (distsqflat(&coords, &finalfinaltarget) <
attackkeydown = 0;
throwkeydown = 0;
- if (avoidcollided > .8 && !jumpkeydown && collided < .8)
+ if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
targetyaw += 90 * (whichdirection * 2 - 1);
+ }
- if (collided < 1 || animTarget != jumpupanim)
+ if (collided < 1 || animTarget != jumpupanim) {
jumpkeydown = 0;
- if ((collided > .8 && jumppower >= 5))
+ }
+ if ((collided > .8 && jumppower >= 5)) {
jumpkeydown = 1;
+ }
if ((!Tutorial::active || cananger) &&
hostile &&
if (distsq(&coords, &Person::players[0]->coords) < 12 &&
Animation::animations[Person::players[0]->animTarget].height != lowheight &&
!Game::editorenabled &&
- (Person::players[0]->coords.y < coords.y + 5 || Person::players[0]->onterrain))
+ (Person::players[0]->coords.y < coords.y + 5 || Person::players[0]->onterrain)) {
aitype = attacktypecutoff;
+ }
if (distsq(&coords, &Person::players[0]->coords) < 30 &&
Animation::animations[Person::players[0]->animTarget].height == highheight &&
- !Game::editorenabled)
+ !Game::editorenabled) {
aitype = attacktypecutoff;
+ }
if (losupdatedelay < 0 && !Game::editorenabled && occluded < 2) {
losupdatedelay = .2;
- for (unsigned j = 0; j < Person::players.size(); j++)
- if (j == 0 || Person::players[j]->skeleton.free || Person::players[j]->aitype != passivetype)
- if (abs(Random() % 2) || Animation::animations[Person::players[j]->animTarget].height != lowheight || j != 0)
- if (distsq(&coords, &Person::players[j]->coords) < 400)
- if (normaldotproduct(facing, Person::players[j]->coords - coords) > 0)
- if (Person::players[j]->coords.y < coords.y + 5 || Person::players[j]->onterrain)
+ for (unsigned j = 0; j < Person::players.size(); j++) {
+ if (j == 0 || Person::players[j]->skeleton.free || Person::players[j]->aitype != passivetype) {
+ if (abs(Random() % 2) || Animation::animations[Person::players[j]->animTarget].height != lowheight || j != 0) {
+ if (distsq(&coords, &Person::players[j]->coords) < 400) {
+ if (normaldotproduct(facing, Person::players[j]->coords - coords) > 0) {
+ if (Person::players[j]->coords.y < coords.y + 5 || Person::players[j]->onterrain) {
if (!Person::players[j]->isWallJump() && -1 == Object::checkcollide(DoRotation(jointPos(head), 0, yaw, 0) * scale + coords, DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0) * Person::players[j]->scale + Person::players[j]->coords) ||
(Person::players[j]->animTarget == hanganim &&
normaldotproduct(Person::players[j]->facing, coords - Person::players[j]->coords) < 0)) {
lastseen = Person::players[j]->coords;
lastseentime = 12;
}
+ }
+ }
+ }
+ }
+ }
+ }
}
}
- if (aitype == attacktypecutoff && Game::musictype != 2)
+ if (aitype == attacktypecutoff && Game::musictype != 2) {
if (creature != wolftype) {
stunned = .6;
surprised = .6;
}
+ }
}
- if (aitype != passivetype && Game::leveltime > .5)
+ if (aitype != passivetype && Game::leveltime > .5) {
howactive = typeactive;
+ }
if (aitype == passivetype) {
aiupdatedelay -= multiplier;
losupdatedelay -= multiplier;
lastseentime += multiplier;
pausetime -= multiplier;
- if (lastseentime > 1)
+ if (lastseentime > 1) {
lastseentime = 1;
+ }
if (aiupdatedelay < 0) {
if (numwaypoints > 1 && howactive == typeactive && pausetime <= 0) {
aiupdatedelay = .05;
if (distsqflat(&coords, &waypoints[waypoint]) < 1) {
- if (waypointtype[waypoint] == wppause)
+ if (waypointtype[waypoint] == wppause) {
pausetime = 4;
+ }
waypoint++;
- if (waypoint > numwaypoints - 1)
+ if (waypoint > numwaypoints - 1) {
waypoint = 0;
+ }
}
}
- if (numwaypoints > 1 && howactive == typeactive && pausetime <= 0)
+ if (numwaypoints > 1 && howactive == typeactive && pausetime <= 0) {
forwardkeydown = 1;
- else
+ } else {
forwardkeydown = 0;
+ }
leftkeydown = 0;
backkeydown = 0;
rightkeydown = 0;
throwkeydown = 0;
if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
- if (!avoidsomething)
+ if (!avoidsomething) {
targetyaw += 90 * (whichdirection * 2 - 1);
- else {
+ } else {
XYZ leftpos, rightpos;
float leftdist, rightdist;
leftpos = coords + DoRotation(facing, 0, 90, 0);
rightpos = coords - DoRotation(facing, 0, 90, 0);
leftdist = distsq(&leftpos, &avoidwhere);
rightdist = distsq(&rightpos, &avoidwhere);
- if (leftdist < rightdist)
+ if (leftdist < rightdist) {
targetyaw += 90;
- else
+ } else {
targetyaw -= 90;
+ }
}
}
}
- if (collided < 1 || animTarget != jumpupanim)
+ if (collided < 1 || animTarget != jumpupanim) {
jumpkeydown = 0;
- if ((collided > .8 && jumppower >= 5))
+ }
+ if ((collided > .8 && jumppower >= 5)) {
jumpkeydown = 1;
+ }
//hearing sounds
if (!Game::editorenabled) {
- if (howactive <= typesleeping)
- if (numenvsounds > 0 && (!Tutorial::active || cananger) && hostile)
+ if (howactive <= typesleeping) {
+ if (numenvsounds > 0 && (!Tutorial::active || cananger) && hostile) {
for (int j = 0; j < numenvsounds; j++) {
float vol = howactive == typesleeping ? envsoundvol[j] - 14 : envsoundvol[j];
- if (vol > 0 && distsq(&coords, &envsound[j]) < 2 * (vol + vol * (creature == rabbittype) * 3))
+ if (vol > 0 && distsq(&coords, &envsound[j]) < 2 * (vol + vol * (creature == rabbittype) * 3)) {
aitype = attacktypecutoff;
+ }
}
+ }
+ }
if (aitype != passivetype) {
- if (howactive == typesleeping)
+ if (howactive == typesleeping) {
setTargetAnimation(getupfromfrontanim);
+ }
howactive = typeactive;
}
}
distsq(&coords, &Person::players[0]->coords) < 400 &&
occluded < 25) {
if (distsq(&coords, &Person::players[0]->coords) < 12 &&
- Animation::animations[Person::players[0]->animTarget].height != lowheight && !Game::editorenabled)
+ Animation::animations[Person::players[0]->animTarget].height != lowheight && !Game::editorenabled) {
aitype = attacktypecutoff;
+ }
if (distsq(&coords, &Person::players[0]->coords) < 30 &&
- Animation::animations[Person::players[0]->animTarget].height == highheight && !Game::editorenabled)
+ Animation::animations[Person::players[0]->animTarget].height == highheight && !Game::editorenabled) {
aitype = attacktypecutoff;
+ }
//wolf smell
if (creature == wolftype) {
if (j == 0 || (Person::players[j]->dead && Person::players[j]->bloodloss > 0)) {
float smelldistance = 50;
if (j == 0 && Person::players[j]->num_weapons > 0) {
- if (weapons[Person::players[j]->weaponids[0]].bloody)
+ if (weapons[Person::players[j]->weaponids[0]].bloody) {
smelldistance = 100;
- if (Person::players[j]->num_weapons == 2)
- if (weapons[Person::players[j]->weaponids[1]].bloody)
+ }
+ if (Person::players[j]->num_weapons == 2) {
+ if (weapons[Person::players[j]->weaponids[1]].bloody) {
smelldistance = 100;
+ }
+ }
}
- if (j != 0)
+ if (j != 0) {
smelldistance = 100;
+ }
windsmell = windvector;
Normalise(&windsmell);
windsmell = windsmell * 2 + Person::players[j]->coords;
- if (distsq(&coords, &windsmell) < smelldistance && !Game::editorenabled)
+ if (distsq(&coords, &windsmell) < smelldistance && !Game::editorenabled) {
aitype = attacktypecutoff;
+ }
}
}
}
losupdatedelay = .2;
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j == 0 || Person::players[j]->skeleton.free || Person::players[j]->aitype != passivetype) {
- if (abs(Random() % 2) || Animation::animations[Person::players[j]->animTarget].height != lowheight || j != 0)
- if (distsq(&coords, &Person::players[j]->coords) < 400)
- if (normaldotproduct(facing, Person::players[j]->coords - coords) > 0)
+ if (abs(Random() % 2) || Animation::animations[Person::players[j]->animTarget].height != lowheight || j != 0) {
+ if (distsq(&coords, &Person::players[j]->coords) < 400) {
+ if (normaldotproduct(facing, Person::players[j]->coords - coords) > 0) {
if ((-1 == Object::checkcollide(
DoRotation(jointPos(head), 0, yaw, 0) *
scale +
(Person::players[j]->animTarget == hanganim &&
normaldotproduct(Person::players[j]->facing, coords - Person::players[j]->coords) < 0)) {
lastseentime -= .2;
- if (j == 0 && Animation::animations[Person::players[j]->animTarget].height == lowheight)
+ if (j == 0 && Animation::animations[Person::players[j]->animTarget].height == lowheight) {
lastseentime -= .4;
- else
+ } else {
lastseentime -= .6;
+ }
}
+ }
+ }
+ }
if (lastseentime <= 0) {
aitype = searchtype;
lastchecktime = 12;
if (aitype == searchtype) {
aiupdatedelay -= multiplier;
losupdatedelay -= multiplier;
- if (!pause)
+ if (!pause) {
lastseentime -= multiplier;
+ }
lastchecktime -= multiplier;
if (isRun() && !onground) {
XYZ test = coords + facing;
test.y -= 10;
j = Object::checkcollide(test2, test, laststanding);
- if (j == -1)
+ if (j == -1) {
j = Object::checkcollide(test2, test);
+ }
if (j == -1) {
velocity = 0;
setTargetAnimation(getStop());
lastpathfindpoint2 = -1;
lastpathfindpoint3 = -1;
lastpathfindpoint4 = -1;
- } else
+ } else {
laststanding = j;
+ }
}
}
//check out last seen location
throwkeydown = 0;
if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
- if (!avoidsomething)
+ if (!avoidsomething) {
targetyaw += 90 * (whichdirection * 2 - 1);
- else {
+ } else {
XYZ leftpos, rightpos;
float leftdist, rightdist;
leftpos = coords + DoRotation(facing, 0, 90, 0);
rightpos = coords - DoRotation(facing, 0, 90, 0);
leftdist = distsq(&leftpos, &avoidwhere);
rightdist = distsq(&rightpos, &avoidwhere);
- if (leftdist < rightdist)
+ if (leftdist < rightdist) {
targetyaw += 90;
- else
+ } else {
targetyaw -= 90;
+ }
}
}
}
- if (collided < 1 || animTarget != jumpupanim)
+ if (collided < 1 || animTarget != jumpupanim) {
jumpkeydown = 0;
- if ((collided > .8 && jumppower >= 5))
+ }
+ if ((collided > .8 && jumppower >= 5)) {
jumpkeydown = 1;
+ }
- if (numenvsounds > 0 && ((!Tutorial::active || cananger) && hostile))
+ if (numenvsounds > 0 && ((!Tutorial::active || cananger) && hostile)) {
for (int k = 0; k < numenvsounds; k++) {
if (distsq(&coords, &envsound[k]) < 2 * (envsoundvol[k] + envsoundvol[k] * (creature == rabbittype) * 3)) {
aitype = attacktypecutoff;
}
}
+ }
if (!Person::players[0]->dead &&
losupdatedelay < 0 &&
aitype = attacktypecutoff;
lastseentime = 1;
}
- if (abs(Random() % 2) || Animation::animations[animTarget].height != lowheight)
+ if (abs(Random() % 2) || Animation::animations[animTarget].height != lowheight) {
//TODO: factor out canSeePlayer()
- if (distsq(&coords, &Person::players[0]->coords) < 400)
- if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0)
+ if (distsq(&coords, &Person::players[0]->coords) < 400) {
+ if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0) {
if ((Object::checkcollide(
DoRotation(jointPos(head), 0, yaw, 0) *
scale +
aitype = attacktypecutoff;
lastseentime = 1;
}
+ }
+ }
+ }
}
//player escaped
if (lastseentime < 0) {
}
}
- if (aitype != gethelptype)
+ if (aitype != gethelptype) {
runninghowlong = 0;
+ }
//get help from buddies
if (aitype == gethelptype) {
XYZ flatfacing = Person::players[ally]->coords;
facing.y += jointPos(head).y * scale;
flatfacing.y += Person::players[ally]->jointPos(head).y * Person::players[ally]->scale;
- if (-1 != Object::checkcollide(facing, flatfacing))
+ if (-1 != Object::checkcollide(facing, flatfacing)) {
lastseentime -= .1;
+ }
//no available ally, run back to player
if (ally <= 0 ||
}
if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
- if (!avoidsomething)
+ if (!avoidsomething) {
targetyaw += 90 * (whichdirection * 2 - 1);
- else {
+ } else {
XYZ leftpos, rightpos;
float leftdist, rightdist;
leftpos = coords + DoRotation(facing, 0, 90, 0);
rightpos = coords - DoRotation(facing, 0, 90, 0);
leftdist = distsq(&leftpos, &avoidwhere);
rightdist = distsq(&rightpos, &avoidwhere);
- if (leftdist < rightdist)
+ if (leftdist < rightdist) {
targetyaw += 90;
- else
+ } else {
targetyaw -= 90;
+ }
}
}
}
crouchkeydown = 0;
attackkeydown = 0;
}
- if (collided < 1 || animTarget != jumpupanim)
+ if (collided < 1 || animTarget != jumpupanim) {
jumpkeydown = 0;
- if (collided > .8 && jumppower >= 5)
+ }
+ if (collided > .8 && jumppower >= 5) {
jumpkeydown = 1;
+ }
}
//retreiving a weapon on the ground
if (ally < 0) {
int closest = -1;
float closestdist = -1;
- for (unsigned k = 0; k < weapons.size(); k++)
+ for (unsigned k = 0; k < weapons.size(); k++) {
if (weapons[k].owner == -1) {
float distance = distsq(&coords, &weapons[k].position);
if (closestdist == -1 || distance < closestdist) {
}
closest = k;
}
- if (closest != -1)
+ }
+ if (closest != -1) {
ally = closest;
- else
+ } else {
ally = -1;
+ }
}
lastseentime = 12;
- if (!Person::players[0]->dead && ((!Tutorial::active || cananger) && hostile))
+ if (!Person::players[0]->dead && ((!Tutorial::active || cananger) && hostile)) {
if (ally < 0 || weaponactive != -1 || lastchecktime <= 0) {
aitype = attacktypecutoff;
lastseentime = 1;
}
- if (!Person::players[0]->dead)
+ }
+ if (!Person::players[0]->dead) {
if (ally >= 0) {
if (weapons[ally].owner != -1 ||
distsq(&coords, &weapons[ally].position) > 16) {
forwardkeydown = 1;
if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
- if (!avoidsomething)
+ if (!avoidsomething) {
targetyaw += 90 * (whichdirection * 2 - 1);
- else {
+ } else {
XYZ leftpos, rightpos;
float leftdist, rightdist;
leftpos = coords + DoRotation(facing, 0, 90, 0);
rightpos = coords - DoRotation(facing, 0, 90, 0);
leftdist = distsq(&leftpos, &avoidwhere);
rightdist = distsq(&rightpos, &avoidwhere);
- if (leftdist < rightdist)
+ if (leftdist < rightdist) {
targetyaw += 90;
- else
+ } else {
targetyaw -= 90;
+ }
}
}
}
+ }
leftkeydown = 0;
backkeydown = 0;
throwkeydown = 1;
crouchkeydown = 0;
if (animTarget != crouchremoveknifeanim &&
- animTarget != removeknifeanim)
+ animTarget != removeknifeanim) {
throwtogglekeydown = 0;
+ }
drawkeydown = 0;
}
- if (collided < 1 || animTarget != jumpupanim)
+ if (collided < 1 || animTarget != jumpupanim) {
jumpkeydown = 0;
- if ((collided > .8 && jumppower >= 5))
+ }
+ if ((collided > .8 && jumppower >= 5)) {
jumpkeydown = 1;
+ }
}
if (aitype == attacktypecutoff) {
aiupdatedelay -= multiplier;
//dodge or reverse rabbit kicks, knife throws, flips
- if (damage < damagetolerance * 2 / 3)
+ if (damage < damagetolerance * 2 / 3) {
if ((Person::players[0]->animTarget == rabbitkickanim ||
Person::players[0]->animTarget == knifethrowanim ||
(Person::players[0]->isFlip() &&
!Person::players[0]->skeleton.free &&
(aiupdatedelay < .1)) {
attackkeydown = 0;
- if (isIdle())
+ if (isIdle()) {
crouchkeydown = 1;
+ }
if (Person::players[0]->animTarget != rabbitkickanim && Person::players[0]->weaponactive != -1) {
if (weapons[Person::players[0]->weaponids[0]].getType() == knife) {
if (isIdle() || isCrouch() || isRun() || isFlip()) {
forwardkeydown = 0;
aiupdatedelay = .02;
}
+ }
//get confused by flips
if (Person::players[0]->isFlip() &&
!Person::players[0]->skeleton.free &&
Person::players[0]->animTarget != walljumprightkickanim &&
Person::players[0]->animTarget != walljumpleftkickanim) {
- if (distsq(&Person::players[0]->coords, &coords) < 25)
- if ((1 - damage / damagetolerance) > .5)
+ if (distsq(&Person::players[0]->coords, &coords) < 25) {
+ if ((1 - damage / damagetolerance) > .5) {
stunned = 1;
+ }
+ }
}
//go for weapon on the ground
- if (wentforweapon < 3)
- for (unsigned k = 0; k < weapons.size(); k++)
- if (creature != wolftype)
+ if (wentforweapon < 3) {
+ for (unsigned k = 0; k < weapons.size(); k++) {
+ if (creature != wolftype) {
if (num_weapons == 0 &&
weapons[k].owner == -1 &&
weapons[k].velocity.x == 0 &&
ally = -1;
}
}
+ }
+ }
+ }
//dodge/reverse walljump kicks
- if (damage < damagetolerance / 2)
- if (Animation::animations[animTarget].height != highheight)
+ if (damage < damagetolerance / 2) {
+ if (Animation::animations[animTarget].height != highheight) {
if (damage < damagetolerance * .5 &&
((Person::players[0]->animTarget == walljumprightkickanim ||
Person::players[0]->animTarget == walljumpleftkickanim) &&
difficulty != 2)))) {
crouchkeydown = 1;
}
+ }
+ }
//walked off a ledge (?)
- if (isRun() && !onground)
+ if (isRun() && !onground) {
if (coords.y > terrain.getHeight(coords.x, coords.z) + 10) {
XYZ test2 = coords + facing;
test2.y += 5;
XYZ test = coords + facing;
test.y -= 10;
j = Object::checkcollide(test2, test, laststanding);
- if (j == -1)
+ if (j == -1) {
j = Object::checkcollide(test2, test);
+ }
if (j == -1) {
velocity = 0;
setTargetAnimation(getStop());
lastpathfindpoint2 = -1;
lastpathfindpoint3 = -1;
lastpathfindpoint4 = -1;
- } else
+ } else {
laststanding = j;
+ }
}
+ }
//lose sight of player in the air (?)
if (Person::players[0]->coords.y > coords.y + 5 &&
Animation::animations[Person::players[0]->animTarget].height != highheight &&
animTarget != backhandspringanim &&
animTarget != dodgebackanim) {
//draw weapon
- if (weaponactive == -1 && num_weapons > 0)
+ if (weaponactive == -1 && num_weapons > 0) {
drawkeydown = Random() % 2;
- else
+ } else {
drawkeydown = 0;
+ }
rabbitkickenabled = Random() % 2;
//chase player
XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity;
XYZ targetpoint = Person::players[0]->coords;
if (distsq(&Person::players[0]->coords, &coords) <
- distsq(&rotatetarget, &coords))
+ distsq(&rotatetarget, &coords)) {
targetpoint += Person::players[0]->velocity *
findDistance(&Person::players[0]->coords, &coords) / findLength(&velocity);
+ }
targetyaw = roughDirectionTo(coords, targetpoint);
lookyaw = targetyaw;
aiupdatedelay = .2 + fabs((float)(Random() % 100) / 1000);
- if (distsq(&coords, &Person::players[0]->coords) > 5 && (Person::players[0]->weaponactive == -1 || weaponactive != -1))
+ if (distsq(&coords, &Person::players[0]->coords) > 5 && (Person::players[0]->weaponactive == -1 || weaponactive != -1)) {
forwardkeydown = 1;
- else if ((distsq(&coords, &Person::players[0]->coords) > 16 ||
- distsq(&coords, &Person::players[0]->coords) < 9) &&
- Person::players[0]->weaponactive != -1)
+ } else if ((distsq(&coords, &Person::players[0]->coords) > 16 ||
+ distsq(&coords, &Person::players[0]->coords) < 9) &&
+ Person::players[0]->weaponactive != -1) {
forwardkeydown = 1;
- else if (Random() % 6 == 0 || (creature == wolftype && Random() % 3 == 0))
+ } else if (Random() % 6 == 0 || (creature == wolftype && Random() % 3 == 0)) {
forwardkeydown = 1;
- else
+ } else {
forwardkeydown = 0;
+ }
//chill out around the corpse
if (Person::players[0]->dead) {
forwardkeydown = 0;
- if (Random() % 10 == 0)
+ if (Random() % 10 == 0) {
forwardkeydown = 1;
+ }
if (Random() % 100 == 0) {
aitype = pathfindtype;
finalfinaltarget = waypoints[waypoint];
crouchkeydown = 0;
throwkeydown = 0;
- if (avoidcollided > .8 && !jumpkeydown && collided < .8)
+ if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
targetyaw += 90 * (whichdirection * 2 - 1);
+ }
//attack!!!
- if (Random() % 2 == 0 || weaponactive != -1 || creature == wolftype)
+ if (Random() % 2 == 0 || weaponactive != -1 || creature == wolftype) {
attackkeydown = 1;
- else
+ } else {
attackkeydown = 0;
- if (isRun() && Random() % 6 && distsq(&coords, &Person::players[0]->coords) > 7)
+ }
+ if (isRun() && Random() % 6 && distsq(&coords, &Person::players[0]->coords) > 7) {
attackkeydown = 0;
+ }
//TODO: wat
if (aitype != playercontrolled &&
isCrouch() ||
isRun())) {
int target = -2;
- for (unsigned j = 0; j < Person::players.size(); j++)
+ for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != id && !Person::players[j]->skeleton.free &&
Person::players[j]->hasvictim &&
(Tutorial::active && reversaltrain ||
Person::players[j]->animTarget == swordslashanim &&
weaponactive != -1 ||
Person::players[j]->animTarget == staffhitanim ||
- Person::players[j]->animTarget == staffspinhitanim))
+ Person::players[j]->animTarget == staffspinhitanim)) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 4 &&
Person::players[j]->victim == Person::players[id] &&
(Person::players[j]->animTarget == sweepanim ||
target = j;
}
}
- if (target >= 0)
+ }
+ }
+ if (target >= 0) {
Person::players[target]->Reverse();
+ }
}
- if (collided < 1)
+ if (collided < 1) {
jumpkeydown = 0;
+ }
if (collided > .8 && jumppower >= 5 ||
distsq(&coords, &Person::players[0]->coords) > 400 &&
onterrain &&
- creature == rabbittype)
+ creature == rabbittype) {
jumpkeydown = 1;
+ }
//TODO: why are we controlling the human?
- if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0)
+ if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0) {
Person::players[0]->jumpkeydown = 0;
+ }
if (Person::players[0]->animTarget == jumpdownanim &&
- distsq(&Person::players[0]->coords, &coords) < 40)
+ distsq(&Person::players[0]->coords, &coords) < 40) {
crouchkeydown = 1;
- if (jumpkeydown)
+ }
+ if (jumpkeydown) {
attackkeydown = 0;
+ }
- if (Tutorial::active)
- if (!canattack)
+ if (Tutorial::active) {
+ if (!canattack) {
attackkeydown = 0;
+ }
+ }
XYZ facing = coords;
XYZ flatfacing = Person::players[0]->coords;
facing.y += jointPos(head).y * scale;
flatfacing.y += Person::players[0]->jointPos(head).y * Person::players[0]->scale;
- if (occluded >= 2)
+ if (occluded >= 2) {
if (-1 != Object::checkcollide(facing, flatfacing)) {
- if (!pause)
+ if (!pause) {
lastseentime -= .2;
+ }
if (lastseentime <= 0 &&
(creature != wolftype ||
weaponstuck == -1)) {
lastseen = Person::players[0]->coords;
lastseentime = 12;
}
- } else
+ } else {
lastseentime = 1;
+ }
+ }
}
}
if (Animation::animations[Person::players[0]->animTarget].height == highheight &&
(aitype == attacktypecutoff ||
- aitype == searchtype))
+ aitype == searchtype)) {
if (Person::players[0]->coords.y > terrain.getHeight(Person::players[0]->coords.x, Person::players[0]->coords.z) + 10) {
XYZ test = Person::players[0]->coords;
test.y -= 40;
- if (-1 == Object::checkcollide(Person::players[0]->coords, test))
+ if (-1 == Object::checkcollide(Person::players[0]->coords, test)) {
stunned = 1;
+ }
}
+ }
//stunned
if (aitype == passivetype && !(numwaypoints > 1) ||
stunned > 0 ||
pause && damage > superpermanentdamage) {
- if (pause)
+ if (pause) {
lastseentime = 1;
+ }
targetyaw = yaw;
forwardkeydown = 0;
leftkeydown = 0;
Person::players[owner]->num_weapons--;
if (Person::players[owner]->num_weapons) {
Person::players[owner]->weaponids[0] = Person::players[owner]->weaponids[Person::players[owner]->num_weapons];
- if (Person::players[owner]->weaponstuck == Person::players[owner]->num_weapons)
+ if (Person::players[owner]->weaponstuck == Person::players[owner]->num_weapons) {
Person::players[owner]->weaponstuck = 0;
+ }
}
}
owner = -1;
Object::objects[k]->model.MakeDecal(breakdecal, DoRotation(colpoint - Object::objects[k]->position, 0, -Object::objects[k]->yaw, 0), .1, 1, Random() % 360);
normalrot = DoRotation(Object::objects[k]->model.Triangles[whichhit].facenormal, 0, Object::objects[k]->yaw, 0);
velocity = 0;
- if (type == knife)
+ if (type == knife) {
position = colpoint - normalrot * .1;
- else if (type == sword)
+ } else if (type == sword) {
position = colpoint - normalrot * .2;
- else if (type == staff)
+ } else if (type == staff) {
position = colpoint - normalrot * .2;
+ }
XYZ temppoint1, temppoint2;
float distance;
temppoint2.y = 0;
rotation1 = acos((temppoint1.z - temppoint2.z) / findDistance(&temppoint1, &temppoint2));
rotation1 *= 360 / 6.28;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
rotation1 = 360 - rotation1;
+ }
rotation3 = 0;
smallrotation = 90;
Person::players[j]->aitype = attacktypecutoff;
} else {
- if (j != 0)
+ if (j != 0) {
numthrowkill++;
+ }
Person::players[j]->num_weapons++;
Person::players[j]->weaponstuck = Person::players[j]->num_weapons - 1;
- if (normaldotproduct(Person::players[j]->facing, velocity) > 0)
+ if (normaldotproduct(Person::players[j]->facing, velocity) > 0) {
Person::players[j]->weaponstuckwhere = 1;
- else
+ } else {
Person::players[j]->weaponstuckwhere = 0;
+ }
Person::players[j]->weaponids[Person::players[j]->num_weapons - 1] = i;
Person::players[j]->jointVel(neck) += velocity * 2;
Person::players[j]->jointVel(rightshoulder) += velocity * 2;
Person::players[j]->jointVel(leftshoulder) += velocity * 2;
- if (bloodtoggle && !Tutorial::active)
+ if (bloodtoggle && !Tutorial::active) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
- if (Tutorial::active)
+ }
+ if (Tutorial::active) {
Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .8, .3);
+ }
footvel = tippoint - position;
Normalise(&footvel);
- if (bloodtoggle && !Tutorial::active)
+ if (bloodtoggle && !Tutorial::active) {
Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * -1, 1, 0, 0, .6, 1);
+ }
if (!Tutorial::active) {
- if (Person::players[j]->weaponstuckwhere == 0)
+ if (Person::players[j]->weaponstuckwhere == 0) {
Person::players[j]->DoBloodBig(2, 205);
- if (Person::players[j]->weaponstuckwhere == 1)
+ }
+ if (Person::players[j]->weaponstuckwhere == 1) {
Person::players[j]->DoBloodBig(2, 200);
+ }
Person::players[j]->damage += 200 / Person::players[j]->armorhigh;
Person::players[j]->deathbleeding = 1;
Person::players[j]->bloodloss += (200 + abs((float)(Random() % 40)) - 20) / Person::players[j]->armorhigh;
emit_sound_at(fleshstabsound, position, 128.);
- if (Animation::animations[Person::players[0]->animTarget].height == highheight)
+ if (Animation::animations[Person::players[0]->animTarget].height == highheight) {
award_bonus(0, ninja);
- else
+ } else {
award_bonus(0, Bullseyebonus);
+ }
}
} else {
missed = 1;
XYZ terrainlight;
terrainlight = terrain.getLighting(position.x, position.z);
if (environment == snowyenvironment) {
- if (distsq(&position, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&position, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, position, velocity, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7);
+ }
} else if (environment == grassyenvironment) {
- if (distsq(&position, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&position, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, position, velocity, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5);
+ }
} else if (environment == desertenvironment) {
- if (distsq(&position, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&position, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, position, velocity, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7);
+ }
}
bloody = 0;
bigtilt = 0;
bigtilt2 = 0;
bigrotation = 0;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
rotation1 = 360 - rotation1;
+ }
}
}
position += terrainnormal * .002;
bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
- if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&velocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(velocity, terrainnormal));
velocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
velocity *= 1 - friction * frictionness;
- else
+ } else {
velocity = 0;
+ }
velocity += bounceness * elasticity;
if (findLengthfast(&bounceness) > 1) {
int whichsound;
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- else
+ } else {
whichsound = clank1sound + abs(Random() % 4);
+ }
emit_sound_at(whichsound, position, 128 * findLengthfast(&bounceness));
}
}
tippoint += terrainnormal * .002;
bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
- if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
tipvelocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
tipvelocity *= 1 - friction * frictionness;
- else
+ } else {
tipvelocity = 0;
+ }
tipvelocity += bounceness * elasticity;
if (findLengthfast(&bounceness) > 1) {
int whichsound;
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- else
+ } else {
whichsound = clank1sound + abs(Random() % 4);
+ }
emit_sound_at(whichsound, position, 128 * findLengthfast(&bounceness));
}
}
- if ((Object::objects[k]->type != boxtype && Object::objects[k]->type != platformtype && Object::objects[k]->type != walltype && Object::objects[k]->type != weirdtype) || Object::objects[k]->pitch != 0)
+ if ((Object::objects[k]->type != boxtype && Object::objects[k]->type != platformtype && Object::objects[k]->type != walltype && Object::objects[k]->type != weirdtype) || Object::objects[k]->pitch != 0) {
for (int m = 0; m < 2; m++) {
mid = (position * (21 + (float)m * 10) + tippoint * (19 - (float)m * 10)) / 40;
oldmid2 = mid;
ReflectVector(&velocity, &terrainnormal);
bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
- if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&velocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(velocity, terrainnormal));
velocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
velocity *= 1 - friction * frictionness;
- else
+ } else {
velocity = 0;
+ }
velocity += bounceness * elasticity;
if (findLengthfast(&bounceness) > 1) {
int whichsound;
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- else
+ } else {
whichsound = clank1sound + abs(Random() % 4);
+ }
emit_sound_at(whichsound, mid, 128 * findLengthfast(&bounceness));
}
position += (mid - oldmid2) * (20 / (1 + (float)m * 10));
ReflectVector(&tipvelocity, &terrainnormal);
bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
- if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
tipvelocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
tipvelocity *= 1 - friction * frictionness;
- else
+ } else {
tipvelocity = 0;
+ }
tipvelocity += bounceness * elasticity;
if (findLengthfast(&bounceness) > 1) {
int whichsound;
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- else
+ } else {
whichsound = clank1sound + abs(Random() % 4);
+ }
emit_sound_at(whichsound, mid, 128 * findLengthfast(&bounceness));
}
tippoint += (mid - oldmid2) * (20 / (1 + (float)m * 10));
}
}
- else {
+ } else {
start = position;
end = tippoint;
whichhit = Object::objects[k]->model.LineCheck(&start, &end, &colpoint, &Object::objects[k]->position, &Object::objects[k]->yaw);
whichhit = terrain.lineTerrain(oldposition, position, &colpoint);
if (whichhit != -1 || position.y < terrain.getHeight(position.x, position.z)) {
hitsomething = 1;
- if (whichhit != -1)
+ if (whichhit != -1) {
position = colpoint * terrain.scale;
- else
+ } else {
position.y = terrain.getHeight(position.x, position.z);
+ }
terrainnormal = terrain.getNormal(position.x, position.z);
ReflectVector(&velocity, &terrainnormal);
position += terrainnormal * .002;
bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
- if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&velocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(velocity, terrainnormal));
velocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
velocity *= 1 - friction * frictionness;
- else
+ } else {
velocity = 0;
- if (terrain.getOpacity(position.x, position.z) < .2)
+ }
+ if (terrain.getOpacity(position.x, position.z) < .2) {
velocity += bounceness * elasticity * .3;
- else
+ } else {
velocity += bounceness * elasticity;
+ }
if (findLengthfast(&bounceness) > 1) {
int whichsound;
if (terrain.getOpacity(position.x, position.z) > .2) {
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- else
+ } else {
whichsound = clank1sound + abs(Random() % 4);
+ }
} else {
whichsound = footstepsound + abs(Random() % 2);
}
XYZ terrainlight;
terrainlight = terrain.getLighting(position.x, position.z);
if (environment == snowyenvironment) {
- if (distsq(&position, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&position, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, position, velocity, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7);
+ }
} else if (environment == grassyenvironment) {
- if (distsq(&position, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&position, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, position, velocity, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5);
+ }
} else if (environment == desertenvironment) {
- if (distsq(&position, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&position, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, position, velocity, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7);
+ }
}
}
}
}
whichhit = terrain.lineTerrain(oldtippoint, tippoint, &colpoint);
if (whichhit != -1 || tippoint.y < terrain.getHeight(tippoint.x, tippoint.z)) {
- if (whichhit != -1)
+ if (whichhit != -1) {
tippoint = colpoint * terrain.scale;
- else
+ } else {
tippoint.y = terrain.getHeight(tippoint.x, tippoint.z);
+ }
terrainnormal = terrain.getNormal(tippoint.x, tippoint.z);
ReflectVector(&tipvelocity, &terrainnormal);
tippoint += terrainnormal * .002;
bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
- if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
tipvelocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
tipvelocity *= 1 - friction * frictionness;
- else
+ } else {
tipvelocity = 0;
- if (terrain.getOpacity(tippoint.x, tippoint.z) < .2)
+ }
+ if (terrain.getOpacity(tippoint.x, tippoint.z) < .2) {
tipvelocity += bounceness * elasticity * .3;
- else
+ } else {
tipvelocity += bounceness * elasticity;
+ }
if (findLengthfast(&bounceness) > 1) {
int whichsound;
if (terrain.getOpacity(tippoint.x, tippoint.z) > .2) {
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- else
+ } else {
whichsound = clank1sound + abs(Random() % 4);
+ }
} else {
whichsound = footstepsound + abs(Random() % 2);
}
XYZ terrainlight;
terrainlight = terrain.getLighting(tippoint.x, tippoint.z);
if (environment == snowyenvironment) {
- if (distsq(&tippoint, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&tippoint, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, tippoint, tipvelocity, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7);
+ }
} else if (environment == grassyenvironment) {
- if (distsq(&tippoint, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&tippoint, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, tippoint, tipvelocity, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5);
+ }
} else if (environment == desertenvironment) {
- if (distsq(&tippoint, &viewer) < viewdistance * viewdistance / 4)
+ if (distsq(&tippoint, &viewer) < viewdistance * viewdistance / 4) {
Sprite::MakeSprite(cloudsprite, tippoint, tipvelocity, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7);
+ }
}
}
}
ReflectVector(&velocity, &terrainnormal);
//mid+=terrainnormal*.002;
bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
- if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&velocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(velocity, terrainnormal));
velocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
velocity *= 1 - friction * frictionness;
- else
+ } else {
velocity = 0;
- if (terrain.getOpacity(mid.x, mid.z) < .2)
+ }
+ if (terrain.getOpacity(mid.x, mid.z) < .2) {
velocity += bounceness * elasticity * .3;
- else
+ } else {
velocity += bounceness * elasticity;
+ }
if (findLengthfast(&bounceness) > 1) {
int whichsound;
if (terrain.getOpacity(mid.x, mid.z) > .2) {
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- if (type != staff)
+ }
+ if (type != staff) {
whichsound = clank1sound + abs(Random() % 4);
+ }
} else {
whichsound = footstepsound + abs(Random() % 2);
}
ReflectVector(&tipvelocity, &terrainnormal);
//mid+=terrainnormal*.002;
bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
- if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+ if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness)) {
bounceness = 0;
+ }
frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
tipvelocity -= bounceness;
- if (1 - friction * frictionness > 0)
+ if (1 - friction * frictionness > 0) {
tipvelocity *= 1 - friction * frictionness;
- else
+ } else {
tipvelocity = 0;
- if (terrain.getOpacity(mid.x, mid.z) < .2)
+ }
+ if (terrain.getOpacity(mid.x, mid.z) < .2) {
tipvelocity += bounceness * elasticity * .3;
- else
+ } else {
tipvelocity += bounceness * elasticity;
+ }
if (findLengthfast(&bounceness) > 1) {
int whichsound;
if (terrain.getOpacity(mid.x, mid.z) > .2) {
- if (type == staff)
+ if (type == staff) {
whichsound = footstepsound3 + abs(Random() % 2);
- if (type != staff)
+ }
+ if (type != staff) {
whichsound = clank1sound + abs(Random() % 4);
+ }
} else {
whichsound = footstepsound + abs(Random() % 2);
}
bigtilt = 0;
bigtilt2 = 0;
bigrotation = 0;
- if (temppoint1.x > temppoint2.x)
+ if (temppoint1.x > temppoint2.x) {
rotation1 = 360 - rotation1;
+ }
//Stop moving
if (findLengthfast(&velocity) < .3 && findLengthfast(&tipvelocity) < .3 && hitsomething) {
if (blooddrip && bloody) {
blooddripdelay -= blooddrip * multiplier / 2;
blooddrip -= multiplier;
- if (blooddrip < 0)
+ if (blooddrip < 0) {
blooddrip = 0;
- if (blooddrip > 5)
+ }
+ if (blooddrip > 5) {
blooddrip = 5;
+ }
if (blooddripdelay < 0 && bloodtoggle) {
blooddripdelay = 1;
XYZ bloodvel;
bool draw = false;
if (owner == -1) {
draw = true;
- if (velocity.x && !physics)
+ if (velocity.x && !physics) {
drawhowmany = 10;
- else
+ } else {
drawhowmany = 1;
+ }
} else {
- if (Person::players[owner]->occluded < 25)
- if ((frustum.SphereInFrustum(Person::players[owner]->coords.x, Person::players[owner]->coords.y + Person::players[owner]->scale * 3, Person::players[owner]->coords.z, Person::players[owner]->scale * 8) && distsq(&viewer, &Person::players[owner]->coords) < viewdistance * viewdistance) || Person::players[owner]->skeleton.free == 3)
+ if (Person::players[owner]->occluded < 25) {
+ if ((frustum.SphereInFrustum(Person::players[owner]->coords.x, Person::players[owner]->coords.y + Person::players[owner]->scale * 3, Person::players[owner]->coords.z, Person::players[owner]->scale * 8) && distsq(&viewer, &Person::players[owner]->coords) < viewdistance * viewdistance) || Person::players[owner]->skeleton.free == 3) {
draw = true;
+ }
+ }
if (
(Person::players[owner]->animTarget == knifeslashstartanim ||
Person::players[owner]->animTarget == swordsneakattackanim ||
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, j / drawhowmany);
- if (owner == -1)
+ if (owner == -1) {
glTranslatef(position.x * (((float)(j)) / drawhowmany) + lastdrawnposition.x * (1 - ((float)(j)) / drawhowmany), position.y * (((float)(j)) / drawhowmany) + lastdrawnposition.y * (1 - ((float)(j)) / drawhowmany), position.z * (((float)(j)) / drawhowmany) + lastdrawnposition.z * (1 - ((float)(j)) / drawhowmany));
- else
+ } else {
glTranslatef(position.x * (((float)(j)) / drawhowmany) + lastdrawnposition.x * (1 - ((float)(j)) / drawhowmany), position.y * (((float)(j)) / drawhowmany) - .02 + lastdrawnposition.y * (1 - ((float)(j)) / drawhowmany), position.z * (((float)(j)) / drawhowmany) + lastdrawnposition.z * (1 - ((float)(j)) / drawhowmany));
+ }
glRotatef(bigrotation * (((float)(j)) / drawhowmany) + lastdrawnbigrotation * (1 - ((float)(j)) / drawhowmany), 0, 1, 0);
glRotatef(bigtilt2 * (((float)(j)) / drawhowmany) + lastdrawnbigtilt2 * (1 - ((float)(j)) / drawhowmany), 1, 0, 0);
glRotatef(bigtilt * (((float)(j)) / drawhowmany) + lastdrawnbigtilt * (1 - ((float)(j)) / drawhowmany), 0, 0, 1);
glEnable(GL_LIGHTING);
switch (type) {
case knife:
- if (!bloody || !bloodtoggle)
+ if (!bloody || !bloodtoggle) {
throwingknifemodel.drawdifftex(knifetextureptr);
+ }
if (bloodtoggle) {
- if (bloody == 1)
+ if (bloody == 1) {
throwingknifemodel.drawdifftex(lightbloodknifetextureptr);
- if (bloody == 2)
+ }
+ if (bloody == 2) {
throwingknifemodel.drawdifftex(bloodknifetextureptr);
+ }
}
break;
case sword:
- if (!bloody || !bloodtoggle)
+ if (!bloody || !bloodtoggle) {
swordmodel.drawdifftex(swordtextureptr);
+ }
if (bloodtoggle) {
- if (bloody == 1)
+ if (bloody == 1) {
swordmodel.drawdifftex(lightbloodswordtextureptr);
- if (bloody == 2)
+ }
+ if (bloody == 2) {
swordmodel.drawdifftex(bloodswordtextureptr);
+ }
}
break;
case staff:
lastdrawnbigtilt2 = bigtilt2;
lastdrawnsmallrotation = smallrotation;
lastdrawnsmallrotation2 = smallrotation2;
- if (owner != -1)
+ if (owner != -1) {
lastdrawnanim = Person::players[owner]->animCurrent;
+ }
}
if (owner != -1) {
glMatrixMode(GL_MODELVIEW);
for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
if (Random() % 2 == 0) {
- if (!Person::players[1]->skeleton.free)
+ if (!Person::players[1]->skeleton.free) {
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp2 = Person::players[1]->skeleton.joints[i].velocity * Person::players[1]->scale / 2;
- if (!Person::players[1]->skeleton.free)
+ }
+ if (!Person::players[1]->skeleton.free) {
temp = DoRotation(DoRotation(DoRotation(Person::players[1]->skeleton.joints[i].position, 0, 0, Person::players[1]->tilt), Person::players[1]->tilt2, 0, 0), 0, Person::players[1]->yaw, 0) * Person::players[1]->scale + Person::players[1]->coords;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp = Person::players[1]->skeleton.joints[i].position * Person::players[1]->scale + Person::players[1]->coords;
+ }
Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
}
}
if (bonus == cannon) {
bonus = Slicebonus;
againbonus = 1;
- } else
+ } else {
againbonus = 0;
+ }
break;
case 27:
maxtime = 4;
Person::players[1]->num_weapons = 1;
Person::players[1]->weaponids[0] = 0;
- if (Person::players[0]->weaponactive != -1)
+ if (Person::players[0]->weaponactive != -1) {
weapons[Person::players[0]->weaponids[Person::players[0]->weaponactive]].setType(staff);
- else
+ } else {
weapons[0].setType(staff);
+ }
break;
case 49:
canattack = 0;
for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
if (Random() % 2 == 0) {
- if (!Person::players[1]->skeleton.free)
+ if (!Person::players[1]->skeleton.free) {
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp2 = Person::players[1]->skeleton.joints[i].velocity * Person::players[1]->scale / 2;
- if (!Person::players[1]->skeleton.free)
+ }
+ if (!Person::players[1]->skeleton.free) {
temp = DoRotation(DoRotation(DoRotation(Person::players[1]->skeleton.joints[i].position, 0, 0, Person::players[1]->tilt), Person::players[1]->tilt2, 0, 0), 0, Person::players[1]->yaw, 0) * Person::players[1]->scale + Person::players[1]->coords;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp = Person::players[1]->skeleton.joints[i].position * Person::players[1]->scale + Person::players[1]->coords;
+ }
Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
}
}
default:
break;
}
- if (stage <= 51)
+ if (stage <= 51) {
stagetime = 0;
+ }
}
//Tutorial success
if (stagetime < maxtime - 3) {
switch (stage) {
case 3:
- if (Game::deltah || Game::deltav)
+ if (Game::deltah || Game::deltav) {
success += multiplier;
+ }
break;
case 4:
- if (Person::players[0]->forwardkeydown || Person::players[0]->backkeydown || Person::players[0]->leftkeydown || Person::players[0]->rightkeydown)
+ if (Person::players[0]->forwardkeydown || Person::players[0]->backkeydown || Person::players[0]->leftkeydown || Person::players[0]->rightkeydown) {
success += multiplier;
+ }
break;
case 5:
- if (Person::players[0]->jumpkeydown)
+ if (Person::players[0]->jumpkeydown) {
success = 1;
+ }
break;
case 6:
- if (Person::players[0]->isCrouch())
+ if (Person::players[0]->isCrouch()) {
success = 1;
+ }
break;
case 7:
- if (Person::players[0]->animTarget == rollanim)
+ if (Person::players[0]->animTarget == rollanim) {
success = 1;
+ }
break;
case 8:
- if (Person::players[0]->animTarget == sneakanim)
+ if (Person::players[0]->animTarget == sneakanim) {
success += multiplier;
+ }
break;
case 9:
- if (Person::players[0]->animTarget == rabbitrunninganim || Person::players[0]->animTarget == wolfrunninganim)
+ if (Person::players[0]->animTarget == rabbitrunninganim || Person::players[0]->animTarget == wolfrunninganim) {
success += multiplier;
+ }
break;
case 11:
- if (Person::players[0]->isWallJump())
+ if (Person::players[0]->isWallJump()) {
success = 1;
+ }
break;
case 12:
- if (Person::players[0]->animTarget == flipanim)
+ if (Person::players[0]->animTarget == flipanim) {
success = 1;
+ }
break;
case 15:
- if (Person::players[0]->animTarget == upunchanim || Person::players[0]->animTarget == winduppunchanim)
+ if (Person::players[0]->animTarget == upunchanim || Person::players[0]->animTarget == winduppunchanim) {
success = 1;
+ }
break;
case 16:
- if (Person::players[0]->animTarget == winduppunchanim)
+ if (Person::players[0]->animTarget == winduppunchanim) {
success = 1;
+ }
break;
case 17:
- if (Person::players[0]->animTarget == spinkickanim)
+ if (Person::players[0]->animTarget == spinkickanim) {
success = 1;
+ }
break;
case 18:
- if (Person::players[0]->animTarget == sweepanim)
+ if (Person::players[0]->animTarget == sweepanim) {
success = 1;
+ }
break;
case 19:
- if (Person::players[0]->animTarget == dropkickanim)
+ if (Person::players[0]->animTarget == dropkickanim) {
success = 1;
+ }
break;
case 20:
- if (Person::players[0]->animTarget == rabbitkickanim)
+ if (Person::players[0]->animTarget == rabbitkickanim) {
success = 1;
+ }
break;
case 21:
- if (bonus == cannon)
+ if (bonus == cannon) {
success = 1;
+ }
break;
case 22:
- if (bonus == spinecrusher)
+ if (bonus == spinecrusher) {
success = 1;
+ }
break;
case 23:
- if (Person::players[0]->animTarget == walljumprightkickanim || Person::players[0]->animTarget == walljumpleftkickanim)
+ if (Person::players[0]->animTarget == walljumprightkickanim || Person::players[0]->animTarget == walljumpleftkickanim) {
success = 1;
+ }
break;
case 24:
- if (Person::players[0]->animTarget == rabbittacklinganim)
+ if (Person::players[0]->animTarget == rabbittacklinganim) {
success = 1;
+ }
break;
case 25:
- if (Person::players[0]->animTarget == backhandspringanim)
+ if (Person::players[0]->animTarget == backhandspringanim) {
success = 1;
+ }
break;
case 28:
- if (Animation::animations[Person::players[0]->animTarget].attack == reversed && Person::players[0]->feint)
+ if (Animation::animations[Person::players[0]->animTarget].attack == reversed && Person::players[0]->feint) {
success = 1;
+ }
break;
case 29:
if (Person::players[0]->escapednum == 2) {
for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
if (Random() % 2 == 0) {
- if (!Person::players[1]->skeleton.free)
+ if (!Person::players[1]->skeleton.free) {
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp2 = Person::players[1]->skeleton.joints[i].velocity * Person::players[1]->scale / 2;
- if (!Person::players[1]->skeleton.free)
+ }
+ if (!Person::players[1]->skeleton.free) {
temp = DoRotation(DoRotation(DoRotation(Person::players[1]->skeleton.joints[i].position, 0, 0, Person::players[1]->tilt), Person::players[1]->tilt2, 0, 0), 0, Person::players[1]->yaw, 0) * Person::players[1]->scale + Person::players[1]->coords;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp = Person::players[1]->skeleton.joints[i].position * Person::players[1]->scale + Person::players[1]->coords;
+ }
Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
}
}
for (unsigned i = 0; i < Person::players[1]->skeleton.joints.size(); i++) {
Person::players[1]->skeleton.joints[i].velocity = 0;
if (Random() % 2 == 0) {
- if (!Person::players[1]->skeleton.free)
+ if (!Person::players[1]->skeleton.free) {
temp2 = (Person::players[1]->coords - Person::players[1]->oldcoords) / multiplier / 2; //velocity/2;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp2 = Person::players[1]->skeleton.joints[i].velocity * Person::players[1]->scale / 2;
- if (!Person::players[1]->skeleton.free)
+ }
+ if (!Person::players[1]->skeleton.free) {
temp = DoRotation(DoRotation(DoRotation(Person::players[1]->skeleton.joints[i].position, 0, 0, Person::players[1]->tilt), Person::players[1]->tilt2, 0, 0), 0, Person::players[1]->yaw, 0) * Person::players[1]->scale + Person::players[1]->coords;
- if (Person::players[1]->skeleton.free)
+ }
+ if (Person::players[1]->skeleton.free) {
temp = Person::players[1]->skeleton.joints[i].position * Person::players[1]->scale + Person::players[1]->coords;
+ }
Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
}
}
void Account::winLevel(int level, float score, float time)
{
if (!devtools) {
- if (score > highscore[level])
+ if (score > highscore[level]) {
highscore[level] = score;
- if (time < fasttime[level] || fasttime[level] == 0)
+ }
+ if (time < fasttime[level] || fasttime[level] == 0) {
fasttime[level] = time;
+ }
}
- if (progress < level + 1)
+ if (progress < level + 1) {
progress = level + 1;
+ }
}
void Account::loadFile(string filename)
void SaveSettings()
{
- if (newdetail < 0)
+ if (newdetail < 0) {
newdetail = 0;
- if (newdetail > 2)
+ }
+ if (newdetail > 2) {
newdetail = 2;
- if (newscreenwidth > 3000)
+ }
+ if (newscreenwidth > 3000) {
newscreenwidth = screenwidth;
- if (newscreenwidth < 0)
+ }
+ if (newscreenwidth < 0) {
newscreenwidth = screenwidth;
- if (newscreenheight > 3000)
+ }
+ if (newscreenheight > 3000) {
newscreenheight = screenheight;
- if (newscreenheight < 0)
+ }
+ if (newscreenheight < 0) {
newscreenheight = screenheight;
+ }
errno = 0;
ofstream opstream(Folders::getConfigFilePath());
if (opstream.fail()) {
opstream << "\nInvert mouse:\n";
opstream << invertmouse;
opstream << "\nGamespeed:\n";
- if (oldgamespeed == 0)
+ if (oldgamespeed == 0) {
oldgamespeed = 1;
+ }
opstream << oldgamespeed;
opstream << "\nDamage effects(blackout, doublevision):\n";
opstream << damageeffects;
// skip blank lines
// assume lines starting with spaces are all blank
- if (strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
+ if (strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') {
continue;
+ }
//~ printf("setting : %s\n",setting);
if (ipstream.eof() || ipstream.fail()) {
ipstream.close();
- if (detail > 2)
+ if (detail > 2) {
detail = 2;
- if (detail < 0)
+ }
+ if (detail < 0) {
detail = 0;
- if (screenwidth < 0)
+ }
+ if (screenwidth < 0) {
screenwidth = 1024;
- if (screenheight < 0)
+ }
+ if (screenheight < 0) {
screenheight = 768;
+ }
newdetail = detail;
return true;
const char* Folders::getHomeDirectory()
{
const char* homedir = getenv("HOME");
- if (homedir != NULL)
+ if (homedir != NULL) {
return homedir;
+ }
struct passwd* pw = getpwuid(getuid());
- if (pw != NULL)
+ if (pw != NULL) {
return pw->pw_dir;
+ }
return NULL;
}
#endif
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL)
+ if (png_ptr == NULL) {
goto png_done;
+ }
info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL)
+ if (info_ptr == NULL) {
goto png_done;
+ }
- if (setjmp(png_jmpbuf(png_ptr)))
+ if (setjmp(png_jmpbuf(png_ptr))) {
goto png_done;
+ }
png_init_io(png_ptr, fp);
png_read_png(png_ptr, info_ptr,
png_get_IHDR(png_ptr, info_ptr, &width, &height,
&bit_depth, &color_type, &interlace_type, NULL, NULL);
- if (bit_depth != 8) // transform SHOULD handle this...
+ if (bit_depth != 8) { // transform SHOULD handle this...
goto png_done;
+ }
- if (color_type & PNG_COLOR_MASK_PALETTE) // !!! FIXME?
+ if (color_type & PNG_COLOR_MASK_PALETTE) { // !!! FIXME?
goto png_done;
+ }
- if ((color_type & PNG_COLOR_MASK_COLOR) == 0) // !!! FIXME?
+ if ((color_type & PNG_COLOR_MASK_COLOR) == 0) { // !!! FIXME?
goto png_done;
+ }
hasalpha = ((color_type & PNG_COLOR_MASK_ALPHA) != 0);
row_pointers = png_get_rows(png_ptr, info_ptr);
- if (!row_pointers)
+ if (!row_pointers) {
goto png_done;
+ }
if (!hasalpha) {
png_byte* dst = tex.data;
else {
png_byte* dst = tex.data;
int pitch = width * 4;
- for (int i = height - 1; i >= 0; i--, dst += pitch)
+ for (int i = height - 1; i >= 0; i--, dst += pitch) {
memcpy(dst, row_pointers[i], pitch);
+ }
}
tex.sizeX = width;
cerr << "There was a problem loading " << file_name << endl;
}
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
- if (fp)
+ if (fp) {
fclose(fp);
+ }
return (retval);
}
png_bytep* row_pointers = new png_bytep[kContextHeight];
png_bytep screenshot = new png_byte[kContextWidth * kContextHeight * 3];
- if ((!screenshot) || (!row_pointers))
+ if ((!screenshot) || (!row_pointers)) {
goto save_png_done;
+ }
glGetError();
glReadPixels(0, 0, kContextWidth, kContextHeight,
GL_RGB, GL_UNSIGNED_BYTE, screenshot);
- if (glGetError() != GL_NO_ERROR)
+ if (glGetError() != GL_NO_ERROR) {
goto save_png_done;
+ }
- for (int i = 0; i < kContextHeight; i++)
+ for (int i = 0; i < kContextHeight; i++) {
row_pointers[i] = screenshot + ((kContextWidth * ((kContextHeight - 1) - i)) * 3);
+ }
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL)
+ if (png_ptr == NULL) {
goto save_png_done;
+ }
info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL)
+ if (info_ptr == NULL) {
goto save_png_done;
+ }
- if (setjmp(png_jmpbuf(png_ptr)))
+ if (setjmp(png_jmpbuf(png_ptr))) {
goto save_png_done;
+ }
png_init_io(png_ptr, fp);
- if (setjmp(png_jmpbuf(png_ptr)))
+ if (setjmp(png_jmpbuf(png_ptr))) {
goto save_png_done;
+ }
png_set_IHDR(png_ptr, info_ptr, kContextWidth, kContextHeight,
8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
png_write_info(png_ptr, info_ptr);
- if (setjmp(png_jmpbuf(png_ptr)))
+ if (setjmp(png_jmpbuf(png_ptr))) {
goto save_png_done;
+ }
png_write_image(png_ptr, row_pointers);
- if (setjmp(png_jmpbuf(png_ptr)))
+ if (setjmp(png_jmpbuf(png_ptr))) {
goto save_png_done;
+ }
png_write_end(png_ptr, NULL);
retval = true;
png_destroy_write_struct(&png_ptr, &info_ptr);
delete[] screenshot;
delete[] row_pointers;
- if (fp)
+ if (fp) {
fclose(fp);
- if (!retval)
+ }
+ if (!retval) {
unlink(file_name);
+ }
return retval;
}
if ((e.key.keysym.scancode == SDL_SCANCODE_G) &&
(e.key.keysym.mod & KMOD_CTRL)) {
SDL_bool mode = SDL_TRUE;
- if ((SDL_GetWindowFlags(sdlwindow) & SDL_WINDOW_FULLSCREEN) == 0)
+ if ((SDL_GetWindowFlags(sdlwindow) & SDL_WINDOW_FULLSCREEN) == 0) {
mode = (SDL_GetWindowGrab(sdlwindow) ? SDL_FALSE : SDL_TRUE);
+ }
SDL_SetWindowGrab(sdlwindow, mode);
SDL_SetRelativeMouseMode(mode);
} else if ((e.key.keysym.scancode == SDL_SCANCODE_RETURN) && (e.key.keysym.mod & KMOD_ALT)) {
DefaultSettings();
- if (!SDL_WasInit(SDL_INIT_VIDEO))
+ if (!SDL_WasInit(SDL_INIT_VIDEO)) {
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
return false;
}
+ }
if (!LoadSettings()) {
fprintf(stderr, "Failed to load config, creating default\n");
SaveSettings();
for (int displayIdx = 0; displayIdx < SDL_GetNumVideoDisplays(); ++displayIdx) {
for (int i = 0; i < SDL_GetNumDisplayModes(displayIdx); ++i) {
SDL_DisplayMode mode;
- if (SDL_GetDisplayMode(displayIdx, i, &mode) == -1)
+ if (SDL_GetDisplayMode(displayIdx, i, &mode) == -1) {
continue;
- if ((mode.w < 640) || (mode.h < 480))
+ }
+ if ((mode.w < 640) || (mode.h < 480)) {
continue; // sane lower limit.
+ }
pair<int, int> resolution(mode.w, mode.h);
resolutions.insert(resolution);
}
return false;
}
- if (SDL_GL_SetSwapInterval(-1) == -1) // try swap_tear first.
+ if (SDL_GL_SetSwapInterval(-1) == -1) { // try swap_tear first.
SDL_GL_SetSwapInterval(1);
+ }
SDL_ShowCursor(0);
if (!commandLineOptions[NOMOUSEGRAB].last()->type()) {
deltav *= usermousesensitivity;
mousecoordh += deltah;
mousecoordv += deltav;
- if (mousecoordh < 0)
+ if (mousecoordh < 0) {
mousecoordh = 0;
- else if (mousecoordh >= kContextWidth)
+ } else if (mousecoordh >= kContextWidth) {
mousecoordh = kContextWidth - 1;
- if (mousecoordv < 0)
+ }
+ if (mousecoordv < 0) {
mousecoordv = 0;
- else if (mousecoordv >= kContextHeight)
+ } else if (mousecoordv >= kContextHeight) {
mousecoordv = kContextHeight - 1;
+ }
}
}
AbsoluteTime currTime = UpTime();
double deltaTime = (float)AbsoluteDeltaToDuration(currTime, frametime);
- if (0 > deltaTime) // if negative microseconds
+ if (0 > deltaTime) { // if negative microseconds
deltaTime /= -1000000.0;
- else // else milliseconds
+ } else { // else milliseconds
deltaTime /= 1000.0;
+ }
multiplier = deltaTime;
- if (multiplier < .001)
+ if (multiplier < .001) {
multiplier = .001;
- if (multiplier > 10)
+ }
+ if (multiplier > 10) {
multiplier = 10;
- if (update)
+ }
+ if (update) {
frametime = currTime; // reset for next time interval
+ }
deltaTime = (float)AbsoluteDeltaToDuration(currTime, time);
- if (0 > deltaTime) // if negative microseconds
+ if (0 > deltaTime) { // if negative microseconds
deltaTime /= -1000000.0;
- else // else milliseconds
+ } else { // else milliseconds
deltaTime /= 1000.0;
+ }
frames++;
if (0.001 <= deltaTime) { // has update interval passed
if (update) {
static float oldmult;
DoFrameRate(1);
- if (multiplier > .6)
+ if (multiplier > .6) {
multiplier = .6;
+ }
fps = 1 / multiplier;
count = multiplier * sps;
- if (count < 2)
+ if (count < 2) {
count = 2;
+ }
realmultiplier = multiplier;
multiplier *= gamespeed;
- if (difficulty == 1)
+ if (difficulty == 1) {
multiplier *= .9;
- if (difficulty == 0)
+ }
+ if (difficulty == 0) {
multiplier *= .8;
+ }
- if (loading == 4)
+ if (loading == 4) {
multiplier *= .00001;
- if (slomo && !mainmenu)
+ }
+ if (slomo && !mainmenu) {
multiplier *= slomospeed;
+ }
oldmult = multiplier;
multiplier /= (float)count;
do {
size_t size;
ptr = strchr(start, ':'); /* find next $PATH separator. */
- if (ptr)
+ if (ptr) {
*ptr = '\0';
-
+ }
size = strlen(start) + strlen(bin) + 2;
if (size > alloc_size) {
char* x = (char*)realloc(exe, size);
if (x == NULL) {
- if (exe != NULL)
+ if (exe != NULL) {
free(exe);
+ }
return (NULL);
} /* if */
/* build full binary path... */
strcpy(exe, start);
- if ((exe[0] == '\0') || (exe[strlen(exe) - 1] != '/'))
+ if ((exe[0] == '\0') || (exe[strlen(exe) - 1] != '/')) {
strcat(exe, "/");
+ }
strcat(exe, bin);
if (access(exe, X_OK) == 0) { /* Exists as executable? We're done. */
start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
- if (exe != NULL)
+ if (exe != NULL) {
free(exe);
+ }
return (NULL); /* doesn't exist in path. */
} /* findBinaryInPath */
if (strchr(argv0, '/')) {
retval = strdup(argv0);
- if (retval)
+ if (retval) {
*((char*)strrchr(retval, '/')) = '\0';
+ }
return (retval);
}
envr = getenv("PATH");
- if (!envr)
+ if (!envr) {
return NULL;
+ }
envr = strdup(envr);
- if (!envr)
+ if (!envr) {
return NULL;
+ }
retval = findBinaryInPath(argv0, envr);
free(envr);
return (retval);