#include "cg_local.h"#include "..\game\q_shared.h"#include "..\ghoul2\g2.h"Go to the source code of this file.
Functions | |
| void | CreepToPosition (vec3_t ideal, vec3_t current) |
| void | TurretClientRun (centity_t *ent) |
|
||||||||||||
|
Definition at line 7 of file cg_turret.c. References PITCH, vec3_t, and YAW. Referenced by TurretClientRun().
00008 {
00009 float max_degree_switch = 90;
00010 int degrees_negative = 0;
00011 int degrees_positive = 0;
00012 int doNegative = 0;
00013
00014 int angle_ideal;
00015 int angle_current;
00016
00017 angle_ideal = (int)ideal[YAW];
00018 angle_current = (int)current[YAW];
00019
00020 if (angle_ideal <= angle_current)
00021 {
00022 degrees_negative = (angle_current - angle_ideal);
00023
00024 degrees_positive = (360 - angle_current) + angle_ideal;
00025 }
00026 else
00027 {
00028 degrees_negative = angle_current + (360 - angle_ideal);
00029
00030 degrees_positive = (angle_ideal - angle_current);
00031 }
00032
00033 if (degrees_negative < degrees_positive)
00034 {
00035 doNegative = 1;
00036 }
00037
00038 if (doNegative)
00039 {
00040 current[YAW] -= max_degree_switch;
00041
00042 if (current[YAW] < ideal[YAW] && (current[YAW]+(max_degree_switch*2)) >= ideal[YAW])
00043 {
00044 current[YAW] = ideal[YAW];
00045 }
00046
00047 if (current[YAW] < 0)
00048 {
00049 current[YAW] += 361;
00050 }
00051 }
00052 else
00053 {
00054 current[YAW] += max_degree_switch;
00055
00056 if (current[YAW] > ideal[YAW] && (current[YAW]-(max_degree_switch*2)) <= ideal[YAW])
00057 {
00058 current[YAW] = ideal[YAW];
00059 }
00060
00061 if (current[YAW] > 360)
00062 {
00063 current[YAW] -= 361;
00064 }
00065 }
00066
00067 if (ideal[PITCH] < 0)
00068 {
00069 ideal[PITCH] += 360;
00070 }
00071
00072 angle_ideal = (int)ideal[PITCH];
00073 angle_current = (int)current[PITCH];
00074
00075 doNegative = 0;
00076
00077 if (angle_ideal <= angle_current)
00078 {
00079 degrees_negative = (angle_current - angle_ideal);
00080
00081 degrees_positive = (360 - angle_current) + angle_ideal;
00082 }
00083 else
00084 {
00085 degrees_negative = angle_current + (360 - angle_ideal);
00086
00087 degrees_positive = (angle_ideal - angle_current);
00088 }
00089
00090 if (degrees_negative < degrees_positive)
00091 {
00092 doNegative = 1;
00093 }
00094
00095 if (doNegative)
00096 {
00097 current[PITCH] -= max_degree_switch;
00098
00099 if (current[PITCH] < ideal[PITCH] && (current[PITCH]+(max_degree_switch*2)) >= ideal[PITCH])
00100 {
00101 current[PITCH] = ideal[PITCH];
00102 }
00103
00104 if (current[PITCH] < 0)
00105 {
00106 current[PITCH] += 361;
00107 }
00108 }
00109 else
00110 {
00111 current[PITCH] += max_degree_switch;
00112
00113 if (current[PITCH] > ideal[PITCH] && (current[PITCH]-(max_degree_switch*2)) <= ideal[PITCH])
00114 {
00115 current[PITCH] = ideal[PITCH];
00116 }
00117
00118 if (current[PITCH] > 360)
00119 {
00120 current[PITCH] -= 361;
00121 }
00122 }
00123 }
|
|
|
Definition at line 125 of file cg_turret.c. References entityState_s::bolt2, centity_s::bolt4, BONE_ANGLES_POSTMULT, BONE_ANGLES_REPLACE, BONE_ANIM_OVERRIDE_FREEZE, centity_t, cg, CG_ConfigString(), cg_entities, CG_RegisterWeapon(), cg_weapons, cgs, CreepToPosition(), CS_MODELS, centity_s::currentState, centity_s::dustTrailTime, cgs_t::effects, ENTITYNUM_NONE, entityState_s::fireflag, centity_s::frame_minus1_refreshed, cgs_t::gameModels, centity_s::ghoul2, centity_s::lerpOrigin, entityState_s::modelindex, centity_s::modelScale, cgEffects_t::mTurretMuzzleFlash, NEGATIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, ORIGIN, PITCH, entityState_s::pos, POSITIVE_X, POSITIVE_Y, POSITIVE_Z, weaponInfo_s::registered, ROLL, cg_t::time, centity_s::torsoBolt, trap_FX_PlayEffectID(), trap_G2API_AddBolt(), trap_G2API_GetBoltMatrix(), trap_G2API_InitGhoul2Model(), trap_G2API_SetBoneAngles(), trap_G2API_SetBoneAnim(), trajectory_t::trBase, centity_s::turAngles, vec3_origin, vec3_t, vectoangles(), VectorCopy, VectorNormalize(), VectorSubtract, weaponInfo_t, WP_TURRET, and YAW.
00126 {
00127 if (!ent->ghoul2)
00128 {
00129 weaponInfo_t *weaponInfo;
00130
00131 trap_G2API_InitGhoul2Model(&ent->ghoul2, CG_ConfigString( CS_MODELS+ent->currentState.modelindex ), 0, 0, 0, 0, 0);
00132
00133 if (!ent->ghoul2)
00134 { //bad
00135 return;
00136 }
00137
00138 ent->torsoBolt = trap_G2API_AddBolt( ent->ghoul2, 0, "*flash02" );
00139
00140 trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_hinge", vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, 100, cg.time );
00141 trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_gback", vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, 100, cg.time );
00142 trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_barrel", vec3_origin, BONE_ANGLES_POSTMULT, POSITIVE_Y, POSITIVE_Z, POSITIVE_X, NULL, 100, cg.time );
00143
00144 trap_G2API_SetBoneAnim( ent->ghoul2, 0, "model_root", 0, 11, BONE_ANIM_OVERRIDE_FREEZE, 0.8f, cg.time, 0, 0 );
00145
00146 ent->turAngles[ROLL] = 0;
00147 ent->turAngles[PITCH] = 90;
00148 ent->turAngles[YAW] = 0;
00149
00150 weaponInfo = &cg_weapons[WP_TURRET];
00151
00152 if ( !weaponInfo->registered )
00153 {
00154 CG_RegisterWeapon(WP_TURRET);
00155 }
00156 }
00157
00158 if (ent->currentState.fireflag == 2)
00159 { //I'm about to blow
00160 if (ent->turAngles)
00161 {
00162 trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_hinge", ent->turAngles, BONE_ANGLES_REPLACE, NEGATIVE_Y, NEGATIVE_Z, NEGATIVE_X, NULL, 100, cg.time );
00163 }
00164 return;
00165 }
00166 else if (ent->currentState.fireflag && ent->bolt4 != ent->currentState.fireflag)
00167 {
00168 vec3_t muzzleOrg, muzzleDir;
00169 mdxaBone_t boltMatrix;
00170
00171 trap_G2API_GetBoltMatrix(ent->ghoul2, 0, ent->torsoBolt, &boltMatrix, /*ent->lerpAngles*/vec3_origin, ent->lerpOrigin, cg.time, cgs.gameModels, ent->modelScale);
00172 BG_GiveMeVectorFromMatrix(&boltMatrix, ORIGIN, muzzleOrg);
00173 BG_GiveMeVectorFromMatrix(&boltMatrix, NEGATIVE_X, muzzleDir);
00174
00175 trap_FX_PlayEffectID(cgs.effects.mTurretMuzzleFlash, muzzleOrg, muzzleDir, -1, -1);
00176
00177 ent->bolt4 = ent->currentState.fireflag;
00178 }
00179 else if (!ent->currentState.fireflag)
00180 {
00181 ent->bolt4 = 0;
00182 }
00183
00184 if (ent->currentState.bolt2 != ENTITYNUM_NONE)
00185 { //turn toward the enemy
00186 centity_t *enemy = &cg_entities[ent->currentState.bolt2];
00187
00188 if (enemy)
00189 {
00190 vec3_t enAng;
00191 vec3_t enPos;
00192
00193 VectorCopy(enemy->currentState.pos.trBase, enPos);
00194
00195 VectorSubtract(enPos, ent->lerpOrigin, enAng);
00196 VectorNormalize(enAng);
00197 vectoangles(enAng, enAng);
00198 enAng[ROLL] = 0;
00199 enAng[PITCH] += 90;
00200
00201 CreepToPosition(enAng, ent->turAngles);
00202 }
00203 }
00204 else
00205 {
00206 vec3_t idleAng;
00207 float turnAmount;
00208
00209 if (ent->turAngles[YAW] > 360)
00210 {
00211 ent->turAngles[YAW] -= 361;
00212 }
00213
00214 if (!ent->dustTrailTime)
00215 {
00216 ent->dustTrailTime = cg.time;
00217 }
00218
00219 turnAmount = (cg.time-ent->dustTrailTime)*0.03;
00220
00221 if (turnAmount > 360)
00222 {
00223 turnAmount = 360;
00224 }
00225
00226 idleAng[PITCH] = 90;
00227 idleAng[ROLL] = 0;
00228 idleAng[YAW] = ent->turAngles[YAW] + turnAmount;
00229 ent->dustTrailTime = cg.time;
00230
00231 CreepToPosition(idleAng, ent->turAngles);
00232 }
00233
00234 if (cg.time < ent->frame_minus1_refreshed)
00235 {
00236 ent->frame_minus1_refreshed = cg.time;
00237 return;
00238 }
00239
00240 ent->frame_minus1_refreshed = cg.time;
00241 trap_G2API_SetBoneAngles( ent->ghoul2, 0, "bone_hinge", ent->turAngles, BONE_ANGLES_REPLACE, NEGATIVE_Y, NEGATIVE_Z, NEGATIVE_X, NULL, 100, cg.time );
00242 }
|