예제 #1
0
파일: spell.cpp 프로젝트: Fredi/Cpp
void Spell::Cast()
{
    if (!m_caster)
        return;

    for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
    {
        if (m_spellInfo->Effect[i] == 0)
            continue;

        HandleEffects(m_caster, i);
        m_effectMask |= (1 << i);
    }

    DoAllEffectOnTarget();
}
예제 #2
0
파일: entities.cpp 프로젝트: janisl/jlquake
//	Create visible entities in the correct position
// for all current players
static void CLHW_LinkPlayers() {
	double playertime = cls.realtime * 0.001 - cls.qh_latency + 0.02;
	if ( playertime > cls.realtime * 0.001 ) {
		playertime = cls.realtime * 0.001;
	}

	hwframe_t* frame = &cl.hw_frames[ cl.qh_parsecount & UPDATE_MASK_HW ];

	h2player_info_t* info = cl.h2_players;
	hwplayer_state_t* state = frame->playerstate;
	for ( int j = 0; j < MAX_CLIENTS_QHW; j++, info++, state++ ) {
		info->shownames_off = true;
		if ( state->messagenum != cl.qh_parsecount ) {
			continue;	// not present this frame

		}
		if ( !state->modelindex ) {
			continue;
		}

		cl.h2_players[ j ].modelindex = state->modelindex;

		// the player object never gets added
		if ( j == cl.playernum ) {
			continue;
		}

		// grab an entity to fill in
		refEntity_t ent;
		Com_Memset( &ent, 0, sizeof ( ent ) );
		ent.reType = RT_MODEL;

		ent.hModel = cl.model_draw[ state->modelindex ];
		ent.skinNum = state->skinnum;
		ent.frame = state->frame;

		int drawflags = state->drawflags;
		if ( ent.hModel == clh2_player_models[ 0 ] ||
			 ent.hModel == clh2_player_models[ 1 ] ||
			 ent.hModel == clh2_player_models[ 2 ] ||
			 ent.hModel == clh2_player_models[ 3 ] ||
			 ent.hModel == clh2_player_models[ 4 ] ||	//mg-siege
			 ent.hModel == clh2_player_models[ 5 ] ) {
			// use custom skin
			info->shownames_off = false;
		}

		//
		// angles
		//
		vec3_t angles;
		angles[ PITCH ] = -state->viewangles[ PITCH ] / 3;
		angles[ YAW ] = state->viewangles[ YAW ];
		angles[ ROLL ] = 0;
		angles[ ROLL ] = VQH_CalcRoll( angles, state->velocity ) * 4;

		// only predict half the move to minimize overruns
		int msec = 500 * ( playertime - state->state_time );
		if ( msec <= 0 || ( !cl_predict_players->value && !cl_predict_players2->value ) || j == cl.playernum ) {
			VectorCopy( state->origin, ent.origin );
		} else {
			// predict players movement
			if ( msec > 255 ) {
				msec = 255;
			}
			state->command.msec = msec;

			int oldphysent = qh_pmove.numphysent;
			CLQHW_SetSolidPlayers( j );
			hwplayer_state_t exact;
			CLHW_PredictUsercmd( state, &exact, &state->command, false );
			qh_pmove.numphysent = oldphysent;
			VectorCopy( exact.origin, ent.origin );
		}

		if ( clhw_siege ) {
			if ( ( int )state->effects & H2EF_NODRAW ) {
				ent.skinNum = 101;	//ice, but in siege will be invis skin for dwarf to see
				drawflags |= H2DRF_TRANSLUCENT;
				state->effects &= ~H2EF_NODRAW;
			}
		}

		vec3_t angleAdd;
		HandleEffects( state->effects, j + 1, &ent, angles, angleAdd );

		//	This uses behavior of software renderer as GL version was f****d
		// up because it didn't take into the account the fact that shadelight
		// has divided by 200 at this point.
		int colorshade = 0;
		if ( !info->shownames_off ) {
			int my_team = cl.h2_players[ cl.playernum ].siege_team;
			int ve_team = info->siege_team;
			float ambientlight = R_CalcEntityLight( &ent );
			float shadelight = ambientlight;

			// clamp lighting so it doesn't overbright as much
			if ( ambientlight > 128 ) {
				ambientlight = 128;
			}
			if ( ambientlight + shadelight > 192 ) {
				shadelight = 192 - ambientlight;
			}
			if ( ( ambientlight + shadelight ) > 75 || ( clhw_siege && my_team == ve_team ) ) {
				info->shownames_off = false;
			} else {
				info->shownames_off = true;
			}
			if ( clhw_siege ) {
				if ( cl.h2_players[ cl.playernum ].playerclass == CLASS_DWARF && ent.skinNum == 101 ) {
					colorshade = 141;
					info->shownames_off = false;
				} else if ( cl.h2_players[ cl.playernum ].playerclass == CLASS_DWARF && ( ambientlight + shadelight ) < 151 ) {
					colorshade = 138 + ( int )( ( ambientlight + shadelight ) / 30 );
					info->shownames_off = false;
				} else if ( ve_team == HWST_DEFENDER ) {
					//tint gold since we can't have seperate skins
					colorshade = 165;
				}
			} else {
				char client_team[ 16 ];
				String::NCpy( client_team, Info_ValueForKey( cl.h2_players[ cl.playernum ].userinfo, "team" ), 16 );
				client_team[ 15 ] = 0;
				if ( client_team[ 0 ] ) {
					char this_team[ 16 ];
					String::NCpy( this_team, Info_ValueForKey( info->userinfo, "team" ), 16 );
					this_team[ 15 ] = 0;
					if ( String::ICmp( client_team, this_team ) == 0 ) {
						colorshade = clhw_teamcolor->value;
					}
				}
			}
		}

		CLH2_SetRefEntAxis( &ent, angles, angleAdd, state->scale, state->abslight, drawflags );
		CLH2_HandleCustomSkin( &ent );
		CLH2_SetPlayerColours( &ent, j );
		R_AddRefEntityToScene( &ent );
		CLH2_AddColourShadeRefEnt( &ent, colorshade, drawflags );
	}
}
예제 #3
0
파일: entities.cpp 프로젝트: janisl/jlquake
static void CLHW_LinkPacketEntities() {
	hwpacket_entities_t* pack = &cl.hw_frames[ clc.netchan.incomingSequence & UPDATE_MASK_HW ].packet_entities;
	hwpacket_entities_t* PrevPack = &cl.hw_frames[ ( clc.netchan.incomingSequence - 1 ) & UPDATE_MASK_HW ].packet_entities;

	float f = 0;		// FIXME: no interpolation right now

	for ( int pnum = 0; pnum < pack->num_entities; pnum++ ) {
		h2entity_state_t* s1 = &pack->entities[ pnum ];
		h2entity_state_t* s2 = s1;	// FIXME: no interpolation right now

		// if set to invisible, skip
		if ( !s1->modelindex ) {
			continue;
		}

		// create a new entity
		refEntity_t ent;
		Com_Memset( &ent, 0, sizeof ( ent ) );

		ent.reType = RT_MODEL;
		qhandle_t model = cl.model_draw[ s1->modelindex ];
		ent.hModel = model;

		// set skin
		ent.skinNum = s1->skinnum;

		// set frame
		ent.frame = s1->frame;

		int drawflags = s1->drawflags;

		vec3_t angles;
		for ( int i = 0; i < 3; i++ ) {
			float a1 = s1->angles[ i ];
			float a2 = s2->angles[ i ];
			if ( a1 - a2 > 180 ) {
				a1 -= 360;
			}
			if ( a1 - a2 < -180 ) {
				a1 += 360;
			}
			angles[ i ] = a2 + f * ( a1 - a2 );
		}

		// calculate origin
		for ( int i = 0; i < 3; i++ ) {
			ent.origin[ i ] = s2->origin[ i ] + f * ( s1->origin[ i ] - s2->origin[ i ] );
		}

		// scan the old entity display list for a matching
		vec3_t old_origin;
		int i;
		for ( i = 0; i < PrevPack->num_entities; i++ ) {
			if ( PrevPack->entities[ i ].number == s1->number ) {
				VectorCopy( PrevPack->entities[ i ].origin, old_origin );
				break;
			}
		}
		if ( i == PrevPack->num_entities ) {
			CLH2_SetRefEntAxis( &ent, angles, oldvec3_origin, s1->scale, s1->abslight, drawflags );
			R_AddRefEntityToScene( &ent );
			CLH2_AddColourShadeRefEnt( &ent, s1->colormap, drawflags );
			continue;		// not in last message
		}

		for ( i = 0; i < 3; i++ )
			//if ( abs(old_origin[i] - ent->origin[i]) > 128)
			if ( abs( old_origin[ i ] - ent.origin[ i ] ) > 512 ) {	// this is an issue for laggy situations...
				// no trail if too far
				VectorCopy( ent.origin, old_origin );
				break;
			}

		// some of the effects need to know how far the thing has moved...

		if ( clhw_siege ) {
			if ( ( int )s1->effects & H2EF_NODRAW ) {
				ent.skinNum = 101;	//ice, but in siege will be invis skin for dwarf to see
				drawflags |= H2DRF_TRANSLUCENT;
				s1->effects &= ~H2EF_NODRAW;
			}
		}

		vec3_t angleAdd;
		HandleEffects( s1->effects, s1->number, &ent, angles, angleAdd );
		CLH2_SetRefEntAxis( &ent, angles, angleAdd, s1->scale, s1->abslight, drawflags );
		R_AddRefEntityToScene( &ent );
		CLH2_AddColourShadeRefEnt( &ent, s1->colormap, drawflags );

		// add automatic particle trails
		int ModelFlags = R_ModelFlags( ent.hModel );
		if ( !ModelFlags ) {
			continue;
		}

		// Model Flags
		if ( ModelFlags & H2MDLEF_GIB ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_blood );
		} else if ( ModelFlags & H2MDLEF_ZOMGIB ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_slight_blood );
		} else if ( ModelFlags & H2MDLEF_TRACER ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_tracer );
		} else if ( ModelFlags & H2MDLEF_TRACER2 ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_tracer2 );
		} else if ( ModelFlags & H2MDLEF_ROCKET ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_rocket_trail );
		} else if ( ModelFlags & H2MDLEF_FIREBALL ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_fireball );
			CLH2_FireBallLight( i, ent.origin );
		} else if ( ModelFlags & H2MDLEF_ICE ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_ice );
		} else if ( ModelFlags & H2MDLEF_SPIT ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_spit );
			CLH2_SpitLight( i, ent.origin );
		} else if ( ModelFlags & H2MDLEF_SPELL ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_spell );
		} else if ( ModelFlags & H2MDLEF_GRENADE ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_grensmoke );
		} else if ( ModelFlags & H2MDLEF_TRACER3 ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_voor_trail );
		} else if ( ModelFlags & H2MDLEF_VORP_MISSILE ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_vorpal );
		} else if ( ModelFlags & H2MDLEF_SET_STAFF ) {
			CLH2_TrailParticles( old_origin, ent.origin,rt_setstaff );
		} else if ( ModelFlags & H2MDLEF_MAGICMISSILE ) {
			if ( ( rand() & 3 ) < 1 ) {
				CLH2_TrailParticles( old_origin, ent.origin, rt_magicmissile );
			}
		} else if ( ModelFlags & H2MDLEF_BONESHARD ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_boneshard );
		} else if ( ModelFlags & H2MDLEF_SCARAB ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_scarab );
		} else if ( ModelFlags & H2MDLEF_ACIDBALL ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_acidball );
		} else if ( ModelFlags & H2MDLEF_BLOODSHOT ) {
			CLH2_TrailParticles( old_origin, ent.origin, rt_bloodshot );
		}
	}
}