예제 #1
0
// Updated to update colors for magicka and stamina as well.s
void ObjectWidget::UpdateColors()
{
	GFxValue update[9]; // original size of 3
	if (!IsFriendly()) {
		update[0] = params[kProperty_HealthPrimaryColor];
		update[1] = params[kProperty_HealthSecondaryColor];
		update[2] = params[kProperty_HealthFlashColor];
		update[3] = params[kProperty_MagickaPrimaryColor];
		update[4] = params[kProperty_MagickaSecondaryColor];
		update[5] = params[kProperty_MagickaFlashColor];
		update[6] = params[kProperty_StaminaPrimaryColor];
		update[7] = params[kProperty_StaminaSecondaryColor];
		update[8] = params[kProperty_StaminaFlashColor];
	}
	else {
		update[0] = params[kProperty_HealthPrimaryFriendlyColor];
		update[1] = params[kProperty_HealthSecondaryFriendlyColor];
		update[2] = params[kProperty_HealthFlashFriendlyColor];
		update[3] = params[kProperty_MagickaPrimaryFriendlyColor];
		update[4] = params[kProperty_MagickaSecondaryFriendlyColor];
		update[5] = params[kProperty_MagickaFlashFriendlyColor];
		update[6] = params[kProperty_StaminaPrimaryFriendlyColor];
		update[7] = params[kProperty_StaminaSecondaryFriendlyColor];
		update[8] = params[kProperty_StaminaFlashFriendlyColor];
	}
	object.Invoke("setColors", NULL, update, 9);
}
            Creature* GetValidVehicle(Creature* cVeh)
            {
                if (!cVeh->HasAura(SPELL_VEHICLE_TELEPORT))
                    if (Vehicle* vehicle = cVeh->GetVehicleKit())
                        if (Unit* passenger = vehicle->GetPassenger(0))
                            if (IsFriendly(passenger))
                                if (Creature* teleportTrigger = passenger->SummonTrigger(go->GetPositionX()-60.0f, go->GetPositionY(), go->GetPositionZ()+1.0f, cVeh->GetOrientation(), 1000))
                                    return teleportTrigger;

                return nullptr;
            }
예제 #3
0
// this involves positioning of the hud elements so i'm assuming magicka and stamina
// will need separate positions below the health bar.
void ObjectWidget::UpdateComponent(GFxMovieView * view, float * depth)
{
	TESForm * form = LookupFormByID(formId);
	if(form) {
		TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR);
		if(reference) {
			NiPoint3 markerPos;
			reference->GetMarkerPosition(&markerPos);
			markerPos.z += 25;

			float x_out = 0.0;
			float y_out = 0.0;
			float z_out = 0.0;

			GRectF rect = view->GetVisibleFrameRect();

			WorldPtToScreenPt3_Internal(g_worldToCamMatrix, g_viewPort, &markerPos, &x_out, &y_out, &z_out, 1e-5);

			// Move component, update component stats
			y_out = 1.0 - y_out; // Flip y for Flash coordinate system
			y_out = rect.top + (rect.bottom - rect.top) * y_out;
			x_out = rect.left + (rect.right - rect.left) * x_out;

			*depth = z_out;

			bool isVisible = false;
			bool isFriendly = false;
			QueryState(reference, &isVisible, &isFriendly);

			if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideName) == HUDExtension::kFlags_HideName || (flags & ObjectWidget::kFlag_HideName) == ObjectWidget::kFlag_HideName) {
				params[kProperty_Name].SetString("");
				UpdateText();
			} else {
				const char * text = CALL_MEMBER_FN(reference, GetReferenceName)();
				if (params[kProperty_Name].GetString() != text) {
					params[kProperty_Name].SetString(text);
					UpdateText();
				}
			}

			if ((flags & ObjectWidget::kFlag_UseHostility) == ObjectWidget::kFlag_UseHostility) {
				bool nowFriendly = IsFriendly();
				if (nowFriendly && !isFriendly) { // Turned hostile
					flags &= ~ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
				else if (!nowFriendly && isFriendly) { // Turned friendly
					flags |= ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
			}

			double scale = min(((100 - z_out * 100) * 10), 50);//(1.0 - z_out) * 100;//min(((100 - z_out * 100) * 10), 50);
			if(object.IsDisplayObject()) {
				GFxValue::DisplayInfo dInfo;
				dInfo.SetPosition(x_out, y_out);
				dInfo.SetScale(scale, scale);
				dInfo.SetVisible(isVisible);
				object.SetDisplayInfo(&dInfo);

				if((flags & kFlag_UpdatePercent) == kFlag_UpdatePercent)
					UpdateValues();
			}
		}
	}
}