示例#1
0
void sc_light_updateSpotMtx(ENTITY* inLight)
{
	SC_OBJECT* ObjData = (SC_OBJECT*)(inLight.SC_SKILL);
	
	
	float fTexAdj[16] =
	{ 0.5, 0.0, 0.0, 0.0,
		0.0,-0.5,	0.0, 0.0,
		0.0, 0.0, 1.0, 0.0,
	0.0, 0.0, 0.0, 1.0 };
	
	fTexAdj[12] = 0.5 + ((float)0.5/(float)256);
	fTexAdj[13] = 0.5 + ((float)0.5/(float)256);
	
	
	VECTOR lightDir;

	//lightDir = malloc(sizeof(VECTOR));
	if(inLight.tilt > 89.9 && inLight.tilt < 90.1 || inLight.tilt < -89.9 && inLight.tilt > -90.1)
	{
		vec_set(lightDir, inLight.pan);
		lightDir.y += 0.2;
		vec_for_angle(lightDir,lightDir);
	}
	else vec_for_angle(lightDir, inLight.pan);
	
	sc_skill(inLight, SC_OBJECT_LIGHT_DIR, lightDir);
	//if(lightDir.y == -90) lightDir.y = 80; //might have to comment this in again (?)
	
	/*
	//if spotlight has a shadowview attached
	if(ObjData.light.view != NULL)
	{
		D3DXMATRIX matView_, matProj_;
		view_to_matrix(ObjData.light.view, &matView_, &matProj_);
		mat_multiply(&matView_, &matProj_);
		mat_multiply(&matView_, fTexAdj);
		sc_skill(inLight, SC_OBJECT_LIGHT_MATRIX, &matView_);
		
		ptr_remove(matView_);
		ptr_remove(matProj_);
		return;
	}
	*/
	
	
	//create lightViewMatrix
	D3DXVECTOR3 vEyePt;
	D3DXVECTOR3 vLookatPt;
	D3DXVECTOR3 vUpVec;
	//vEyePt = sys_malloc(sizeof(D3DXVECTOR3));
	//vLookatPt = sys_malloc(sizeof(D3DXVECTOR3));
	//vUpVec = sys_malloc(sizeof(D3DXVECTOR3));
	
	vEyePt.x = inLight.x;
	vEyePt.y = inLight.z;
	vEyePt.z = inLight.y;
	vLookatPt.x = inLight.x + lightDir.x;	
	vLookatPt.y = inLight.z + lightDir.z;
	vLookatPt.z = inLight.y + lightDir.y;
	vUpVec.x = 0;
	vUpVec.y = 1;
	vUpVec.z = 0;

	D3DXMATRIX mtxLightView;
	//mtxLightView = sys_malloc(sizeof(D3DXMATRIX));
	D3DXMatrixLookAtLH( &mtxLightView, vEyePt, vLookatPt, vUpVec);
	
	//create lightProjectionMatrix
	D3DXMATRIX mtxLightProj;
	D3DXMatrixPerspectiveFovLH(&mtxLightProj, 	(((float)ObjData.light.arc/(float)180))*SC_PI, (float)1, (float)1, (float)ObjData.light.range );
	
	
	//pass projection matrix to light	
	D3DXMATRIX mtxLightWorldViewProj;
	//mtxLightWorldViewProj = sys_malloc(sizeof(D3DXMATRIX));
	mat_set(&mtxLightWorldViewProj, &mtxLightView);
	mat_multiply(&mtxLightWorldViewProj, &mtxLightProj);
	mat_multiply(&mtxLightWorldViewProj, fTexAdj);
	
	sc_skill(inLight, SC_OBJECT_LIGHT_MATRIX, &mtxLightWorldViewProj);
	
	/*
	//this lags like hell
	sys_free(vEyePt);
	sys_free(vLookatPt);
	sys_free(vUpVec);
	sys_free(mtxLightView);
	sys_free(mtxLightProj);
	sys_free(mtxLightWorldViewProj);
	*/
	
	//better
	ptr_remove(vEyePt);
	ptr_remove(vLookatPt);
	ptr_remove(vUpVec);
	ptr_remove(mtxLightView);
	ptr_remove(mtxLightProj);
	ptr_remove(mtxLightWorldViewProj);
}
示例#2
0
action ebWarghost ()
{
	g_entEbWarghost = my;
	my->material = g_mtlBossGhost;
	
	lvlLavaSuperReset ();
	
	var deadRotate = 0;
	
	var origScale = my->scale_x;
	var deadScale = origScale;
	
	BOOL isSpining = false;
	
	while (1)
	{
		// pos
		{
			VECTOR vecPos;
			vecPos.x = my->x;
			vecPos.y = 1024;
			vecPos.z = 150;
			
			if (player != NULL)
			{
				vecPos.x = player->x;
				vecPos.z = player->z;
			}
				
			vec_lerp(my->x, my->x, &vecPos, time_step * 0.025);
		}
		
		// ang
		{
			VECTOR vecLookAt, vecLook;
			vec_set(&vecLookAt, my->x);
			
			vecLookAt.y -= 1000;
			
			if (player != NULL)
			{
				vecLookAt.x = player->x;
				vecLookAt.y = player->y;
			}
			
			vec_diff(&vecLook, &vecLookAt, my->x);
			vec_to_angle(my->pan, &vecLook);
			
			if (!isEbWarghostAlive())
			{
				setPlayerControls(false);
				setPlayerPan(my);
				
				deadRotate += 10 * time_step;
				deadScale += 0.3 * time_step;
				
				g_sndEbVol = clamp(g_sndEbVol - g_sndEbVolDec * time_step, 0, 100);
				snd_tune(g_fhLvlLavastageSong, g_sndEbVol, 3, 0);
				
				if (!isSpining)
				{
					snd_play(g_sndBossSpin, 100, 0);
					snd_play(g_sndBossDeadSpeech, 100, 0);
					
					isSpining = true;
				}
			}
			
			my->pan += deadRotate;
			my->scale_x = my->scale_y = my->scale_z = deadScale;
			
			if (my->scale_x / origScale > 3)
				break;
		}
		
		if (g_ebDoHit)
			ent_animate(my, "jump", g_ebDoHitPercent, ANM_CYCLE);
		else
			ent_animate(my, "attack", total_ticks % 100, ANM_CYCLE);
			
		wait(1);
	}
	
	snd_play(g_sndBossSplatter, 100, 0);
	
	VECTOR vecPos, vecDir;
	int i, j, numVerts = ent_status(my, 0);
	
	snd_play(g_sndBossDead, 100, 0);
	
	set(my, INVISIBLE);
	
	for (i = 0; i < numVerts; i++)
	{
		vec_for_vertex(&vecPos, my, i+1);
		
		vec_diff(&vecDir, &vecPos, my->x);
		vec_normalize(&vecDir, 1);
		
		effEbBlood(&vecPos, &vecDir, 25+random(100), false, 1, 4 + random(4));
	}
	
	while (redness < 100)
	{
		redness = clamp(redness + g_rednessInc * time_step, 0, 100);
		
		g_sndEbVol = clamp(g_sndEbVol - g_sndEbVolDec * time_step, 0, 100);
		snd_tune(g_fhLvlLavastageSong, g_sndEbVol, 5, 0);		
		
		wait(1);
	}
	
	wait(-1);
	
	proc_mode = PROC_GLOBAL;
	ptr_remove(my);
	
	creditsInit();
}
示例#3
0
void ebHandJoint ()
{
	set(my, INVISIBLE);
	
	vec_scale(my->scale_x, 2);
	c_updatehull(my, 0);
	
	VECTOR v0, v1, v, diff;
	
	BOOL isChopped = false;
	
	while (1)
	{
		updateHandChopped(g_ebHand);
		
		int myid = (int)my->skill1;
		
		if (myid % 2 == 0)
			set(my, FLAG2);
		
		if (g_ebHand != NULL)
		{
			if (g_ebHand->skill1 != 1)
				break;
				
			BOOL bLeftHand = (g_ebHand->skill20 != 0);
			int fingerId = myid;
			VECTOR vecFingerPos, vecFingerDir;
			
			handFingerPos(g_ebHand, bLeftHand, fingerId, &vecFingerPos, &vecFingerDir);
			
			vecFingerPos.y = player->y;
			vecFingerPos.z -= 32;
			
			vec_diff(&diff, &vecFingerPos, my->x);
			
			var distplayer = absv(my->x - player->x);
			
			if (g_handDropping && vec_length(&diff) > 2)
			{
				var distmove = c_move(my, NULL, &diff, IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_FLAG2);
				
				if (g_ebHand->skill2 != 0 && distmove <= 0 && (distplayer < my->max_x * 1.25))
					player->PL_HEALTH = 0;
			}
			else
			{
				if (!g_handDropping && !g_fingerChopped)
				{
					if (distplayer < my->max_x * 2)
					{
						if (g_playerIsAttacking)
						{
							set(my, PASSABLE);
						
							if (bLeftHand) // left
								g_handChopL[my->skill1] = true;
							else // right
								g_handChopR[my->skill1] = true;
								
							isChopped = true;
							g_fingerChopped = true;
							
							doChopped(g_ebHand, g_ebHand->skill20, my->skill1);							
							updateHandChopped(g_ebHand);
							
							ebDoCrazyness();
							ebDoHit();
								
							break;
						}
					}
				}
			}
		}
		
		wait(1);
	}
	
	ptr_remove(my);
}
示例#4
0
void ebHandWatch ()
{
	updateHandChopped(my);
	
	ebDoSparkle(my, 2000);
	snd_play(g_sndSparkle, 100, 0);
	
	set(my, PASSABLE);
	my->ambient = 75;
	
	var moveAnim = 10;
	
	var t = maxv(g_facTimeEbHandWatchMin, g_facTimeEbHandWatch * (5 + random(3))) * 16;
	
	vec_scale(my->scale_x, g_handScale);
	
	var ground, height;
	var heightSub = 32;
	
	g_ebHand = my;
	
	snd_play(g_sndHandFly, 100, 0);
	
	// move with player
	set(player, FLAG2);
	while (t > 0)
	{
		VECTOR vecBoneGround, vecTraceStart, vecTraceEnd;
		vec_for_bone(&vecBoneGround, my, "ground");
		
		vec_set(&vecTraceStart, my->x);
		vecTraceStart.y = vecBoneGround.y;
		
		vec_set(&vecTraceEnd, &vecTraceStart);
		vecTraceEnd.z -= 2000;
		
		height = player->z + 250;
		
		if (c_trace(&vecTraceStart, &vecTraceEnd, IGNORE_ME | USE_POLYGON | IGNORE_FLAG2 ) > 0)
		{
			ground = hit.z;
			height = ground + (my->z - vecBoneGround.z);
		}
		
		VECTOR v;
		vec_set(&v, player->x);
		v.z = height;
		
		vec_lerp(my->x, my->x, &v, 0.25 * time_step);
		
		ent_animate(my, "idleH", 50 + sin(total_ticks * moveAnim) * 50, ANM_CYCLE);
		
		t -= time_step;
		
		doHandChopBlood(my);
		
		wait(1);
	}
	
	g_facTimeEbHandWatch *= g_facTimeEbHandWatchDec;
	
	reset(player, FLAG2);
	
	// drop
	
	g_handDropping = true;
	
	g_ebHand->skill1 = 1; // joints = on
	g_ebHand->skill2 = 1; // joints death = on
	
	g_playerDontScanFlag2 = true;
	g_playerNoYou = true;
	
	ebCreateHandJoints(g_ebHand);
	
	set(player, ZNEAR);
	
	t = 0;
	
	BOOL bSndHandDrop = true;
	while (t < 100)
	{
		VECTOR vecBoneGround;
		vec_for_bone(&vecBoneGround, g_ebHand, "ground");
		height = ground + (g_ebHand->z - vecBoneGround.z) - heightSub;
		
		VECTOR v;
		vec_set(&v, g_ebHand->x);
		v.z = height;
		
		vec_lerp(g_ebHand->x, g_ebHand->x, &v, 0.25 * time_step);
		
		t = clamp(t + 5 * time_step, 0, 100);
		ent_animate(g_ebHand, "drop", t, 0);

		doHandChopBlood(my);
		
		if (t > 90 && bSndHandDrop)
		{
			bSndHandDrop = false;
			snd_play(g_sndHandDrop, 100, 0);
		}
		
		wait(1);
	}
	
	g_handDropping = false;
	
	g_ebHand->skill2 = 0; // joints death = off
	
	t = maxv(g_facTimeEbHandDroppedMin, g_facTimeEbHandDropped * (3+random(2)) * 16);
	
	g_fingerChopped = false;
	
	// wait	
	while (t > 0 && !g_fingerChopped)
	{
		ent_animate(g_ebHand, "down", (total_ticks * 4), ANM_CYCLE);
		t -= time_step;
		
		doHandChopBlood(my);
		
		wait(1);
	}
	
	g_facTimeEbHandDropped *= g_facTimeEbHandDroppedDec;
	
	snd_play(g_sndHandUp, 100, 0);
	
	reset(player, ZNEAR);
	
	g_ebHand->skill1 = 0;
	
	// up
	while (t < 100)
	{
		VECTOR vecBoneGround;
		vec_for_bone(&vecBoneGround, g_ebHand, "ground");
		height = ground + (g_ebHand->z - vecBoneGround.z) - heightSub;
		
		VECTOR v;
		vec_set(&v, g_ebHand->x);
		v.z = height;
		
		vec_lerp(g_ebHand->x, g_ebHand->x, &v, 0.25 * time_step);
		
		t = clamp(t + 2 * time_step, 0, 100);
		ent_animate(g_ebHand, "up", t, 0);		
		
		doHandChopBlood(my);
		
		wait(1);
	}
	
	g_playerDontScanFlag2 = false;
	g_playerNoYou = false;
	
	t = 1.5 * 16;
	
	snd_play(g_sndHandBliss, 100, 0);
	
	// go away
	while (t > 0)
	{
		t -= time_step;
		g_ebHand->z += 10 * time_step;
		g_ebHand->y -= 20 * time_step;
		g_ebHand->roll += 5 * time_step;
		
		doHandChopBlood(my);
		
		wait(1);
	}

	set(g_ebHand, INVISIBLE);
	ebDoSparkle(g_ebHand, 2000);
	snd_play(g_sndSparkle, 100, 0);

	wait(1);
	
	ent_create(NULL, nullvector, ebHandsBgFly);
	ptr_remove(g_ebHand);
}
示例#5
0
		void ebHandFly ()
		{
			updateHandChopped(my);
			
			set(my, PASSABLE);
			my->ambient = 75;
			
			VECTOR startPos, targetPos;
			vec_set(&startPos, my->x);
			
			ebDoSparkle(my, 2000);
			
			var t = 0;
			
			var distX = 500;
			
			var moveDist = 200;
			var moveTime = 0.5;
			var moveLerp = 0.2;
			var moveAnim = 2;
			
			vec_scale(my->scale_x, g_handScale);
			
			var targetRoll = -90;
			
			// Stone rain
			var randomStoneRain = 0;
			var randomStoneModel = 0;
			
			while (my->skill1 == 0)
			{
				if (t <= 0)
				{
					vec_set(&targetPos, vector(25+random(moveDist), 0, 0));
					vec_rotate(&targetPos, vector(random(360),random(360),random(360)));
					vec_add(&targetPos, &startPos);
					
					t += moveTime * 16;
				}
				else
					t -= time_step;
				
				VECTOR nuPos;
				vec_set(&nuPos, &targetPos);
				
				if (player != NULL)
					nuPos.x += player->x;
				
				vec_lerp(my->x, my->x, &nuPos, moveLerp * time_step);
					
				ent_animate(my, "idleH", (total_ticks * moveAnim) % 100, ANM_CYCLE);
				my->roll += (targetRoll - my->roll) * 0.05 * clamp(time_step, 0.001, 1);
				
				doHandChopBlood(my);
				
				if (!isEbWarghostAlive())
				{
					startPos.z -= 10 * time_step;
					targetPos.z -= 10 * time_step;
					targetRoll -= 10 * time_step;
				}
				
				// Stone rain
				
				randomStoneRain = random(1000);
				if (randomStoneRain > 950) {
					randomStoneModel = integer(random(2));
					switch(randomStoneModel) {
						case 0: ent_create("stein1.mdl", vector(player.x - 500 + random(1000), player.y, my.z + 300 + random(50)), ebHandStone); break;
						case 1: ent_create("stein2.mdl", vector(player.x - 500 + random(1000), player.y, my.z + 300 + random(50)), ebHandStone); break;
						case 2: ent_create("stein3.mdl", vector(player.x - 500 + random(1000), player.y, my.z + 300 + random(50)), ebHandStone); break;
					}
				}
				
				// -- end stone rain
				
				wait(1);
			}
			
			while (my->skill2 > 0)
			{
				my->skill2 -= time_step;
				my->z += 10 * time_step;
				my->y -= 20 * time_step;
				my->roll += 2 * time_step;
				
				doHandChopBlood(my);
				
				wait(1);
			}
			
			set(my, INVISIBLE);
			ebDoSparkle(my, 2000);
			
			wait(1);
			ptr_remove(my);
		}