LTBOOL CMissionData::AddWeapon(int weaponID) { CWeaponData* pData = GetWeaponData(weaponID); if (pData == LTNULL) { pData = debug_new(CWeaponData); m_Weapons.Add(pData); pData->m_nID = weaponID; return LTTRUE; } return LTFALSE; }
static void JKG_FireModeUpdate(void) { const weaponData_t *wpData = GetWeaponData( cg.predictedPlayerState.weapon, cg.predictedPlayerState.weaponVariation ); const char *previousFM = CG_Argv(1); int previousFMInt = atoi(previousFM); if( wpData->visuals.visualFireModes[ cg.predictedPlayerState.firingMode ].switchToSound[0] && wpData->numFiringModes > 1 ) { trap->S_StartLocalSound( trap->S_RegisterSound( wpData->visuals.visualFireModes[ cg.predictedPlayerState.firingMode ].switchToSound ), CHAN_AUTO ); } //if( wpData->visuals.visualFireModes[ previousFMInt ].animType != wpData->visuals.visualFireModes[ cg.predictedPlayerState.firingMode ].animType ) { cg.fireModeTransition = JKG_GetTransitionForFiringModeSet( wpData->visuals.visualFireModes[ previousFMInt ].animType, wpData->visuals.visualFireModes[ cg.predictedPlayerState.firingMode ].animType ); } cg.fireModeChangeTime = cg.time; }
/* ============================ BG_WeaponAcceptsAlternateAmmo Returns true if the weapon accepts alternate ammo, false otherwise ============================ */ qboolean BG_WeaponAcceptsAlternateAmmo(int weapon, int variation) { weaponData_t* wp = GetWeaponData(weapon, variation); switch (weapon) { case WP_SABER: case WP_NONE: case WP_MELEE: return qfalse; default: break; } if (wp->firemodes[0].clipSize <= 0) { return qfalse; } if (wp->firemodes[0].useQuantity) { return qfalse; } return qtrue; }
//check/select the chosen weapon int BotSelectChoiceWeapon(bot_state_t *bs, int weapon, int doselection) { //if !doselection then bot will only check if he has the specified weapon and return 1 (yes) or 0 (no) int i; int hasit = 0; i = 0; while (i < WP_NUM_WEAPONS) { if (bs->cur_ps.ammo > GetWeaponData( bs->cur_ps.weapon, bs->cur_ps.weaponVariation )->firemodes[0].cost && i == weapon && (bs->cur_ps.stats[STAT_WEAPONS] & (1 << i))) { hasit = 1; break; } i++; } if (hasit && bs->cur_ps.weapon != weapon && doselection && bs->virtualWeapon != weapon) { int index = BG_GetWeaponIndexFromClass (weapon, 0); bs->virtualWeapon = weapon; BotSelectWeapon(bs->client, index); //bs->cur_ps.weapon = weapon; //level.clients[bs->client].ps.weapon = weapon; return 2; } if (hasit) { return 1; } return 0; }
void G_MissileImpact( gentity_t *ent, trace_t *trace ) { gentity_t *other; qboolean hitClient = qfalse; qboolean isKnockedSaber = qfalse; other = &g_entities[trace->entityNum]; // check for bounce if ( !other->takedamage && (ent->bounceCount > 0 || ent->bounceCount == -5) && ( ent->flags & ( FL_BOUNCE | FL_BOUNCE_HALF ) ) ) { int originalBounceCount = ent->bounceCount; G_BounceMissile( ent, trace ); if ( originalBounceCount != ent->bounceCount ) { G_GrenadeBounceEvent ((const gentity_t *)ent); } return; } else if (ent->neverFree && ent->s.weapon == WP_SABER && (ent->flags & FL_BOUNCE_HALF)) { //this is a knocked-away saber if (ent->bounceCount > 0 || ent->bounceCount == -5) { int originalBounceCount = ent->bounceCount; G_BounceMissile( ent, trace ); G_GrenadeBounceEvent ((const gentity_t *)ent); if ( originalBounceCount != ent->bounceCount ) { G_GrenadeBounceEvent ((const gentity_t *)ent); } return; } isKnockedSaber = qtrue; } // I would glom onto the FL_BOUNCE code section above, but don't feel like risking breaking something else if ( (!other->takedamage && (ent->bounceCount > 0 || ent->bounceCount == -5) && ( ent->flags&(FL_BOUNCE_SHRAPNEL) ) ) || ((trace->surfaceFlags&SURF_FORCEFIELD)&&!ent->splashDamage&&!ent->splashRadius&&(ent->bounceCount > 0 || ent->bounceCount == -5)) ) { G_BounceMissile( ent, trace ); if ( ent->bounceCount < 1 ) { ent->flags &= ~FL_BOUNCE_SHRAPNEL; } return; } /* if ( !other->takedamage && ent->s.weapon == WP_THERMAL && !ent->alt_fire ) {//rolling thermal det - FIXME: make this an eFlag like bounce & stick!!! //G_BounceRollMissile( ent, trace ); if ( ent->owner && ent->owner->s.number == 0 ) { G_MissileAddAlerts( ent ); } //gi.linkentity( ent ); return; } */ if ((other->r.contents & CONTENTS_LIGHTSABER) && !isKnockedSaber) { //hit this person's saber, so.. gentity_t *otherOwner = &g_entities[other->r.ownerNum]; if (otherOwner->takedamage && otherOwner->client && otherOwner->client->ps.duelInProgress && otherOwner->client->ps.duelIndex != ent->r.ownerNum) { goto killProj; } } else if (!isKnockedSaber) { if (other->takedamage && other->client && other->client->ps.duelInProgress && other->client->ps.duelIndex != ent->r.ownerNum) { goto killProj; } } if (other->flags & FL_DMG_BY_HEAVY_WEAP_ONLY) { if (ent->methodOfDeath != MOD_REPEATER_ALT && ent->methodOfDeath != MOD_ROCKET && ent->methodOfDeath != MOD_FLECHETTE_ALT_SPLASH && ent->methodOfDeath != MOD_ROCKET_HOMING && ent->methodOfDeath != MOD_THERMAL && ent->methodOfDeath != MOD_THERMAL_SPLASH && ent->methodOfDeath != MOD_TRIP_MINE_SPLASH && ent->methodOfDeath != MOD_TIMED_MINE_SPLASH && ent->methodOfDeath != MOD_DET_PACK_SPLASH && ent->methodOfDeath != MOD_VEHICLE && ent->methodOfDeath != MOD_CONC && ent->methodOfDeath != MOD_CONC_ALT && ent->methodOfDeath != MOD_SABER && ent->methodOfDeath != MOD_TURBLAST) { vec3_t fwd; if (trace) { VectorCopy(trace->plane.normal, fwd); } else { //oh well AngleVectors(other->r.currentAngles, fwd, NULL, NULL); } G_DeflectMissile(other, ent, fwd); G_MissileBounceEffect(ent, ent->r.currentOrigin, fwd); return; } } if ((other->flags & FL_SHIELDED) && ent->s.weapon != WP_ROCKET_LAUNCHER && ent->s.weapon != WP_THERMAL && ent->s.weapon != WP_TRIP_MINE && ent->s.weapon != WP_DET_PACK && ent->s.weapon != WP_EMPLACED_GUN && ent->methodOfDeath != MOD_REPEATER_ALT && ent->methodOfDeath != MOD_FLECHETTE_ALT_SPLASH && ent->methodOfDeath != MOD_TURBLAST && ent->methodOfDeath != MOD_VEHICLE && ent->methodOfDeath != MOD_CONC && ent->methodOfDeath != MOD_CONC_ALT && !(ent->dflags&DAMAGE_HEAVY_WEAP_CLASS) ) {// entity is shielded vec3_t fwd; if (other->client) { AngleVectors(other->client->ps.viewangles, fwd, NULL, NULL); } else { AngleVectors(other->r.currentAngles, fwd, NULL, NULL); } G_DeflectMissile(other, ent, fwd); G_MissileBounceEffect(ent, ent->r.currentOrigin, fwd); return; } // SABERFIXME: make this based on .wpn file? some conc rifles should be able to be deflected... if (other->takedamage && other->client && ent->s.weapon != WP_ROCKET_LAUNCHER && ent->s.weapon != WP_THERMAL && ent->s.weapon != WP_TRIP_MINE && ent->s.weapon != WP_DET_PACK && ent->methodOfDeath != MOD_REPEATER_ALT && ent->methodOfDeath != MOD_FLECHETTE_ALT_SPLASH && ent->methodOfDeath != MOD_CONC && ent->methodOfDeath != MOD_CONC_ALT && other->client->saberBlockDebounce < level.time && !isKnockedSaber && WP_SaberCanBlock(other, ent->r.currentOrigin, 0, 0, qtrue, 0)) { //only block one projectile per 200ms (to prevent giant swarms of projectiles being blocked) vec3_t fwd; gentity_t *te; int otherDefLevel = other->client->ps.fd.forcePowerLevel[FP_SABER_DEFENSE]; te = G_TempEntity( ent->r.currentOrigin, EV_SABER_BLOCK ); VectorCopy(ent->r.currentOrigin, te->s.origin); VectorCopy(trace->plane.normal, te->s.angles); te->s.eventParm = 0; te->s.weapon = 0;//saberNum te->s.legsAnim = 0;//bladeNum /*if (other->client->ps.velocity[2] > 0 || other->client->pers.cmd.forwardmove || other->client->pers.cmd.rightmove) */ if (other->client->ps.velocity[2] > 0 || other->client->pers.cmd.forwardmove < 0) //now we only do it if jumping or running backward. Should be able to full-on charge. { otherDefLevel -= 1; if (otherDefLevel < 0) { otherDefLevel = 0; } } AngleVectors(other->client->ps.viewangles, fwd, NULL, NULL); // SABERFIXME: Don't make this force based. This code is ugly as f**k anyway other->client->saberBlockDebounce = level.time + (350 - (otherDefLevel*100)); //200; //For jedi AI other->client->ps.saberEventFlags |= SEF_DEFLECTED; if ( other->client->ps.saberActionFlags & (1 << SAF_BLOCKING) && !(other->client->ps.saberActionFlags & ( 1 << SAF_PROJBLOCKING) ) ) { goto killProj; } else if ( other->client->ps.saberActionFlags & SAF_PROJBLOCKING ) { JKG_SaberDeflectMissile(other, ent, fwd); other->client->saberProjBlockTime += 500; // give them a little bit of leeway --eez } return; } else if ((other->r.contents & CONTENTS_LIGHTSABER) && !isKnockedSaber) { //hit this person's saber, so.. gentity_t *otherOwner = &g_entities[other->r.ownerNum]; if (otherOwner->takedamage && otherOwner->client && ent->s.weapon != WP_ROCKET_LAUNCHER && ent->s.weapon != WP_THERMAL && ent->s.weapon != WP_TRIP_MINE && ent->s.weapon != WP_DET_PACK && ent->methodOfDeath != MOD_REPEATER_ALT && ent->methodOfDeath != MOD_FLECHETTE_ALT_SPLASH && ent->methodOfDeath != MOD_CONC && ent->methodOfDeath != MOD_CONC_ALT /*&& otherOwner->client->ps.saberBlockTime < level.time*/) { //for now still deflect even if saberBlockTime >= level.time because it hit the actual saber vec3_t fwd; gentity_t *te; int otherDefLevel = otherOwner->client->ps.fd.forcePowerLevel[FP_SABER_DEFENSE]; //in this case, deflect it even if we can't actually block it because it hit our saber //WP_SaberCanBlock(otherOwner, ent->r.currentOrigin, 0, 0, qtrue, 0); if (otherOwner->client && otherOwner->client->ps.weaponTime <= 0) { WP_SaberBlockNonRandom(otherOwner, NULL, ent->r.currentOrigin, qtrue); // <-- ??? --eez } te = G_TempEntity( ent->r.currentOrigin, EV_SABER_BLOCK ); VectorCopy(ent->r.currentOrigin, te->s.origin); VectorCopy(trace->plane.normal, te->s.angles); te->s.eventParm = 0; te->s.weapon = 0;//saberNum te->s.legsAnim = 0;//bladeNum /*if (otherOwner->client->ps.velocity[2] > 0 || otherOwner->client->pers.cmd.forwardmove || otherOwner->client->pers.cmd.rightmove)*/ if (otherOwner->client->ps.velocity[2] > 0 || otherOwner->client->pers.cmd.forwardmove < 0) //now we only do it if jumping or running backward. Should be able to full-on charge. { otherDefLevel -= 1; if (otherDefLevel < 0) { otherDefLevel = 0; } } AngleVectors(otherOwner->client->ps.viewangles, fwd, NULL, NULL); otherOwner->client->saberBlockDebounce = level.time + (350 - (otherDefLevel*100));//200; //For jedi AI otherOwner->client->ps.saberEventFlags |= SEF_DEFLECTED; // um...this code is a lil messed up, so i'll replace it with my own --eez if ( otherOwner->client->ps.saberActionFlags & (1 << SAF_BLOCKING) && !(otherOwner->client->ps.saberActionFlags & ( 1 << SAF_PROJBLOCKING )) ) { goto killProj; } else if ( otherOwner->client->ps.saberActionFlags & ( 1 << SAF_PROJBLOCKING ) ) { // SABERFIXME: Write new function for this JKG_SaberDeflectMissile(otherOwner, ent, fwd); otherOwner->client->saberProjBlockTime += 500; // give them a little bit of leeway --eez } return; } } if( ent->genericValue10 ) // nerf this check in order to make grenade bouncing work --eez { vec3_t fwd; if (other->client) { AngleVectors(other->client->ps.viewangles, fwd, NULL, NULL); } else { AngleVectors(other->r.currentAngles, fwd, NULL, NULL); } VectorScale(ent->s.pos.trDelta, 0.2, ent->s.pos.trDelta); G_Damage(other, ent, ent->parent, fwd, ent->s.origin, ent->genericValue9, 0, MOD_THERMAL); G_DeflectMissile(other, ent, fwd); //G_MissileBounceEffect(ent, ent->r.currentOrigin, fwd); return; } // check for sticking if ( !other->takedamage && ( ent->s.eFlags & EF_MISSILE_STICK ) ) { laserTrapStick( ent, trace->endpos, trace->plane.normal ); G_AddEvent( ent, EV_MISSILE_STICK, 0 ); return; } // impact damage if (other->takedamage && !isKnockedSaber) { // FIXME: wrong damage direction? weaponData_t *weapon = GetWeaponData (ent->s.weapon, ent->s.weaponVariation); weaponFireModeStats_t *fireMode = &weapon->firemodes[ent->s.firingMode]; if ( ent->damage || fireMode->damageTypeHandle || fireMode->secondaryDmgHandle ) { vec3_t velocity; hitClient = qtrue; BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity ); if ( VectorLength( velocity ) == 0 ) { velocity[2] = 1; // stepped on a grenade } if ( fireMode->damageTypeHandle ) { JKG_DoDamage (fireMode->damageTypeHandle, other, ent, &g_entities[ent->r.ownerNum], velocity, ent->r.currentOrigin, 0, ent->methodOfDeath); } else if ( ent->damage ) { G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity, ent->r.currentOrigin, ent->damage, 0, ent->methodOfDeath); } if ( fireMode->secondaryDmgHandle ) { JKG_DoDamage (fireMode->secondaryDmgHandle, other, ent, &g_entities[ent->r.ownerNum], velocity, ent->r.currentOrigin, 0, ent->methodOfDeath); } if (other->client) { //What I'm wondering is why this isn't in the NPC pain funcs. But this is what SP does, so whatever. class_t npc_class = other->client->NPC_class; // If we are a robot and we aren't currently doing the full body electricity... if ( npc_class == CLASS_SEEKER || npc_class == CLASS_PROBE || npc_class == CLASS_MOUSE || npc_class == CLASS_GONK || npc_class == CLASS_R2D2 || npc_class == CLASS_R5D2 || npc_class == CLASS_REMOTE || npc_class == CLASS_MARK1 || npc_class == CLASS_MARK2 || //npc_class == CLASS_PROTOCOL ||//no protocol, looks odd npc_class == CLASS_INTERROGATOR || npc_class == CLASS_ATST || npc_class == CLASS_SENTRY ) { // special droid only behaviors if ( other->client->ps.electrifyTime < level.time + 100 ) { // ... do the effect for a split second for some more feedback other->client->ps.electrifyTime = level.time + 450; } //FIXME: throw some sparks off droids,too } } } } killProj: // is it cheaper in bandwidth to just remove this ent and create a new // one, rather than changing the missile into the explosion? if ( other->takedamage && other->client && !isKnockedSaber ) { { G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) ); ent->s.otherEntityNum = other->s.number; } } else if( trace->surfaceFlags & SURF_METALSTEPS ) { G_AddEvent( ent, EV_MISSILE_MISS_METAL, DirToByte( trace->plane.normal ) ); } else if (ent->s.weapon != G2_MODEL_PART && !isKnockedSaber) { G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) ); } if (!isKnockedSaber) { ent->freeAfterEvent = qtrue; // change over to a normal entity right at the point of impact ent->s.eType = ET_GENERAL; } SnapVectorTowards( trace->endpos, ent->s.pos.trBase ); // save net bandwidth G_SetOrigin( ent, trace->endpos ); ent->takedamage = qfalse; if (ent->s.weapon == G2_MODEL_PART) { ent->freeAfterEvent = qfalse; //it will free itself } if(ent->splashRadius && ent->splashDamage && !ent->genericValue10) { G_RadiusDamage(trace->endpos, &g_entities[ent->r.ownerNum], ent->splashDamage, ent->splashRadius, NULL, ent, ent->methodOfDeath); } trap->LinkEntity( (sharedEntity_t *)ent ); }
} } const SSCHAR* CSrWeapRecord::GetEquipSlot (void) { return m_pEquipSlot && m_pParent ? m_pParent->GetEditorID(m_pEquipSlot->GetValue()) : ""; } /*=========================================================================== * * Begin CSrWeapRecord Get Field Methods * *=========================================================================*/ DEFINE_SRGETFIELD(CSrWeapRecord::GetFieldWeight, String.Format(SR_FORMATSTR_WEIGHT, GetWeaponData().Weight)) DEFINE_SRGETFIELD(CSrWeapRecord::GetFieldValue, String.Format("%u", GetWeaponData().Value)) DEFINE_SRGETFIELD(CSrWeapRecord::GetFieldDamage, String.Format("%d", (int)GetWeaponData().Damage)) DEFINE_SRGETFIELD(CSrWeapRecord::GetFieldVNAM, String.Format("%u", GetVNAM())) DEFINE_SRGETFIELD(CSrWeapRecord::GetFieldEquipSlot, String = GetEquipSlot()) /*=========================================================================== * End of CSrWeapRecord Get Field Methods *=========================================================================*/ /*=========================================================================== * * Begin CSrWeapRecord Compare Field Methods * *=========================================================================*/ DEFINE_SRCOMPFIELDFLOAT1(CSrWeapRecord, CompareFieldWeight, GetWeaponData().Weight, 100.0f)
/* ================ CG_DrawAmmo ================ */ static void CG_DrawAmmo( centity_t *cent,menuDef_t *menuHUD) { playerState_t *ps; int ammo; itemDef_t *focusItem; float width; const char *text; vec4_t opacity; const weaponInfo_t *weaponInfo; if( cg.jkg_WHUDOpacity < 1.0f ) { MAKERGBA(opacity, 1,1,1, cg.jkg_WHUDOpacity); } else { MAKERGBA(opacity, 1,1,1, cg.jkg_HUDOpacity); } ps = &cg.snap->ps; // Can we find the menu? if (!menuHUD) { return; } if (!cent->currentState.weapon ) // We don't have a weapon right now { return; } #ifndef NO_SP_STYLE_AMMO // Figure out whether or not we want to do the thing where we highlight the text whenever we consume ammo or change firing mode (or, change weapon) if (cg.lastAmmo != cg.predictedPlayerState.stats[STAT_AMMO] || cg.lastAmmoGun != cg.predictedPlayerState.weaponId) { cg.lastAmmo = cg.predictedPlayerState.stats[STAT_AMMO]; cg.lastAmmoTime = cg.time + 200; // matches SP 1:1 cg.lastAmmoGun = cg.predictedPlayerState.weaponId; } if(cg.lastAmmoTime > cg.time) { vec4_t colorCopy = { 0.2, 0.72, 0.86, 1 }; Q_RGBCopy(&opacity, colorCopy); } #endif weaponInfo = CG_WeaponInfo (cent->currentState.weapon, cent->currentState.weaponVariation); if ( GetWeaponData( cent->currentState.weapon, cent->currentState.weaponVariation )->firemodes[0].cost == 0 && GetWeaponData( cent->currentState.weapon, cent->currentState.weaponVariation )->firemodes[1].cost == 0) { //just draw "infinite" text = "Ammo: Infinite"; } else { if ( GetWeaponAmmoClip( cent->currentState.weapon, cent->currentState.weaponVariation )) { ammo = ps->stats[STAT_AMMO]; } else { ammo = ps->ammo; } if ( GetWeaponAmmoClip( cent->currentState.weapon, cent->currentState.weaponVariation )) { // Display the amount of clips too float temp; temp = ceil(( float ) ps->ammo / ( float ) GetWeaponAmmoClip( cent->currentState.weapon, cent->currentState.weaponVariation )); text = va( "Ammo: %i (%i)", ammo, ( int ) temp ); } else { text = va( "Ammo: %i", ammo ); } } // Now then, lets render this text ^_^ width = (float)trap_R_Font_StrLenPixels(text, cgDC.Assets.qhSmallFont, 1) * 0.6f; focusItem = Menu_FindItemByName(menuHUD, "infobar"); if (focusItem) { trap_R_Font_DrawString(focusItem->window.rect.x + ((focusItem->window.rect.w/2) - (width/2)), focusItem->window.rect.y, text, opacity, cgDC.Assets.qhSmall3Font, -1, 0.5f); } focusItem = Menu_FindItemByName(menuHUD, "weapicon"); if (focusItem) { trap_R_SetColor( opacity ); CG_DrawPic( focusItem->window.rect.x, focusItem->window.rect.y, focusItem->window.rect.w, focusItem->window.rect.h, weaponInfo->hudIcon ); } }
/*ゲーム中の敵とのあたり&攻撃判定を行います。*/ int Weapon::AttackEnemy( Enemy *Ene, PlayerChara *PC, int ScreenPosArray[2], Stage *Stg){ /*変数の初期*/ int ech = 0;//エラー確認変数 int NowWpKind = 0;//今の武器の種類を取得します int NearEnemyID = 0;//一番近い敵キャラの識別番号 int EnemyConflict = 0;//敵に当たった数の合計 int EneHitResult = 0;//敵が照準に入っているかの結果を入れます int GarbageInt = 0;//いらないデータを格納します float NowWpRange = 0.0f;//今の武器の射程を代入します float EneDistance = 0.0f;//当たった敵のところからの距離が代入されます float EneNearDistance = 0.0f;//当たっている一番近い敵の距離が代入されます float Wall_HitDistance = 0.0f;//一番近い壁の距離が代入されます。 D3DXVECTOR3 GunTargetPos( 0.0, 0.0, 0.0);//銃が向くべき座標 D3DXVECTOR3 WantVec( 0.0, 0.0, 0.0);//「首つけ根」の向きたい方向へのベクトル D3DXVECTOR3 BaseVec( 0.0, 0.0, -1.0);//向きの初期方向ベクトル D3DXVECTOR3 GarbageD3DVec( 0.0, 0.0, 0.0);//要らないXYZのデータの一次入れ POINT ScreenPos = { ScreenPosArray[0], ScreenPosArray[1]};//2Dスクリーン座標構造体 /*装備をきちんとつけていれば*/ if( PC->Get_Wp_equipment() != -1){ NowWpKind = GetWeaponData( PC->Get_Wp_equipment(), 0);//武器の種類 NowWpRange = float( GetWeaponData( PC->Get_Wp_equipment(), 4) * 500);// EneNearDistance = float(NowWpRange); } /**/ //まず、状態的に攻撃判定させるかどうか決めます /**/ /*発射状態で、敵がいるなら*/ if( ( GetWeaponFireFlag() == 1) && ( 0 < Ene->EnemyNum)){ //ハンドガンなら if( ( NowWpKind == 1) || ( NowWpKind == 4)){ /*通常モード( モデル[0]から取得する )*/ if( Stg->Stage_GunTarget == 0){//壁データより敵が手前にいたら攻撃可能なので、ここでカーソル上のステージを取得しています ech = E3DPickFace( System::scid1, Stg->Stage_hsid[0], ScreenPos, NowWpRange, &GarbageInt, &GarbageInt, &GarbageD3DVec, &GarbageD3DVec, &Wall_HitDistance); if(ech != 0 ){//エラーチェック _ASSERT( 0 );//エラーダイアログ }; } /*当たり判定中にいる敵をチェックします*/ for( int i=0; i < Ene->EnemyNum; i++){//エネミーの数だけ ech = E3DPickFace( System::scid1, Ene->Ene[i]->Get_BodyModel(), ScreenPos, NowWpRange, &EneHitResult, &EneHitResult, &GarbageD3DVec, &GarbageD3DVec, &EneDistance); if(ech != 0 ){//エラーチェック _ASSERT( 0 );//エラーダイアログ }; if( (EneHitResult != 0) && ( EneDistance < EneNearDistance) ){ EneNearDistance = EneDistance;//一番近い敵の距離に更新します NearEnemyID = i;//一番近いモデル番号を入れます EnemyConflict = 1;//近い敵がいることを代入します } } /*もし、当たり判定上に敵がいれば*/ if( ( EnemyConflict == 1) && ( EneNearDistance < Wall_HitDistance)){ // !!壁との当たり判定が必要!! //敵にダメージを与える Ene->Ene[NearEnemyID]->Set_HP( Ene->Ene[NearEnemyID]->Get_HP() - GetWeaponData( PC->Get_Wp_equipment(), 5)); } } } return 0; }
// Creates weightless weapon items if no item files // exist for items. void BG_LoadDefaultWeaponItems ( void ) { int i = 0; int end = BG_NumberOfLoadedWeapons(); qboolean weaponHasItem[MAX_WEAPON_TABLE_SIZE] = { qfalse }; for ( i = 1; i < MAX_ITEM_TABLE_SIZE; i++ ) { bgItemData_t *item = &itemTable[i]; if ( !item->itemID ) { continue; } if ( item->itemType != ITEM_WEAPON ) { continue; } weaponHasItem[item->varID] = qtrue; } for ( i = 0; i < end; i++ ) { weaponData_t *weaponData; int weapon, variation; int itemID; bgItemData_t item; if ( weaponHasItem[i] ) { continue; } if ( !BG_GetWeaponByIndex (i, &weapon, &variation) ) { break; } memset (&item, 0, sizeof (item)); weaponData = GetWeaponData (weapon, variation); Q_strncpyz (item.displayName, weaponData->displayName, sizeof (item.displayName)); itemID = BG_GetNextFreeItemSlot(); if ( !itemID ) { Com_Printf ("Ran out of item space for weapons.\n"); break; } item.itemID = itemID; item.itemType = ITEM_WEAPON; item.weapon = weapon; item.variation = variation; item.varID = i; #ifdef CGAME strcpy(item.itemIcon, weaponData->visuals.icon); #endif itemTable[itemID] = item; } }
/* ================= CG_RegisterWeapon The server says this item is used on this level ================= */ void CG_RegisterWeapon( int weaponNum, int variation ) { weaponInfo_t *weaponInfo; const weaponData_t *weaponData; gitem_t *item/*, *ammo*/; char path[MAX_QPATH]; vec3_t mins, maxs; int i; if ( weaponNum == 0 ) { return; } weaponInfo = CG_WeaponInfoUnsafe (weaponNum, variation); if ( weaponInfo ) { // Non-null means the weapon exists. return; } weaponInfo = CG_NextFreeWeaponInfo(); if ( weaponInfo == NULL ) { trap->Error( ERR_DROP, "Max weapon info slots exceeded.\n" ); return; } #ifdef _DEBUG //trap->Print ("Registering weapon %d variation %d\n", weaponNum, variation); #endif memset( weaponInfo, 0, sizeof( *weaponInfo ) ); weaponInfo->registered = qtrue; weaponInfo->weaponNum = weaponNum; weaponInfo->variation = variation; for ( item = bg_itemlist + 1 ; item->classname ; item++ ) { if ( item->giType == IT_WEAPON && item->giTag == weaponNum ) { weaponInfo->item = item; break; } } if ( !item->classname ) { trap->Error( ERR_DROP, "Couldn't find weapon %i", weaponNum ); } CG_RegisterItemVisuals( item - bg_itemlist ); weaponData = GetWeaponData (weaponNum, variation); // load cmodel before model so filecache works if (weaponData->visuals.world_model[0] != '\0') { // Don't spam the console. weaponInfo->weaponModel = trap->R_RegisterModel(weaponData->visuals.world_model); } // load in-view model also weaponInfo->viewModel = NULL_HANDLE; if ( weaponInfo->g2ViewModel ) { trap->G2API_CleanGhoul2Models (&weaponInfo->g2ViewModel); weaponInfo->g2ViewModel = NULL; } if ( CG_IsGhoul2Model (weaponData->visuals.view_model) ) { CG_LoadViewWeapon (weaponInfo, weaponData->visuals.view_model); } else if (weaponData->visuals.view_model[0] != '\0') { weaponInfo->viewModel = trap->R_RegisterModel(weaponData->visuals.view_model); } // calc midpoint for rotation if (weaponInfo->weaponModel != NULL_HANDLE) { trap->R_ModelBounds(weaponInfo->weaponModel, mins, maxs); for (i = 0; i < 3; i++) { weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * (maxs[i] - mins[i]); } } weaponInfo->hudIcon = trap->R_RegisterShaderNoMip (weaponData->visuals.icon); weaponInfo->hudNAIcon = trap->R_RegisterShaderNoMip (weaponData->visuals.icon_na); if (weaponNum != WP_SABER) { strcpy( path, weaponData->visuals.view_model ); COM_StripExtension( path, path, sizeof( path ) ); strcat( path, "_hand.md3" ); weaponInfo->handsModel = trap->R_RegisterModel( path ); } else { weaponInfo->handsModel = 0; } for(i = 0; i < weaponData->numFiringModes; i++) { // this only deals with them one at a time from now on --eez JKG_SetWeaponEventsHandler (weaponInfo, weaponData->visuals.visualFireModes[i].type, i); } JKG_LoadWeaponAssets (weaponInfo, weaponData); switch ( weaponNum ) { case WP_STUN_BATON: case WP_MELEE: trap->FX_RegisterEffect( "stunBaton/flesh_impact" ); if (weaponNum == WP_STUN_BATON) { trap->S_RegisterSound( "sound/weapons/baton/idle.wav" ); weaponInfo->flashSound[0] = trap->S_RegisterSound( "sound/weapons/baton/fire.mp3" ); weaponInfo->altFlashSound[0] = trap->S_RegisterSound( "sound/weapons/baton/fire.mp3" ); } break; case WP_SABER: MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f ); weaponInfo->firingSound = trap->S_RegisterSound( "sound/weapons/saber/saberhum1.wav" ); weaponInfo->missileModel = trap->R_RegisterModel( "models/weapons2/saber/saber_w.glm" ); break; case WP_TURRET: weaponInfo->flashSound[0] = NULL_SOUND; weaponInfo->firingSound = NULL_SOUND; weaponInfo->chargeSound = NULL_SOUND; weaponInfo->muzzleEffect = NULL_HANDLE; weaponInfo->missileModel = NULL_HANDLE; weaponInfo->missileSound = NULL_SOUND; weaponInfo->missileDlight = 0; weaponInfo->missileHitSound = NULL_SOUND; weaponInfo->missileTrailFunc = FX_TurretProjectileThink; trap->FX_RegisterEffect("effects/blaster/wall_impact.efx"); trap->FX_RegisterEffect("effects/blaster/flesh_impact.efx"); break; default: MAKERGB( weaponInfo->flashDlightColor, 1, 1, 1 ); weaponInfo->flashSound[0] = trap->S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav" ); break; } }
short GetWeaponAmmoMax ( unsigned char baseIndex, unsigned char modIndex ) { return ammoTable[GetWeaponData( baseIndex, modIndex )->ammoIndex].ammoMax; }
short GetWeaponAmmoClip ( unsigned char baseIndex, unsigned char modIndex ) { return GetWeaponData( baseIndex, modIndex )->clipSize; }
unsigned char GetWeaponAmmoIndex ( unsigned char baseIndex, unsigned char modIndex ) { return GetWeaponData( baseIndex, modIndex )->ammoIndex; }