Beispiel #1
0
CCharBase *CItemSpawn::SetTrackID()
{
	ADDTOCALLSTACK("CitemSpawn:SetTrackID");
	SetAttr(ATTR_INVIS);	// Indicate to GM's that it is invis.
	if (GetHue() == 0)
		SetHue(HUE_RED_DARK);

	if ( !IsType(IT_SPAWN_CHAR) )
	{
		SetDispID(ITEMID_WorldGem_lg);
		return NULL;
	}

	CCharBase *pCharDef = NULL;
	RESOURCE_ID_BASE rid = m_itSpawnChar.m_CharID;

	if ( rid.GetResType() == RES_CHARDEF )
	{
		CREID_TYPE id = static_cast<CREID_TYPE>(rid.GetResIndex());
		pCharDef = CCharBase::FindCharBase(id);
	}
	if ( pCharDef )		// They must want it to look like this.
		SetDispID(pCharDef ? pCharDef->m_trackID : ITEMID_TRACK_WISP);
		
	return pCharDef;
}
Beispiel #2
0
// Create the char corpse when i die (STATF_DEAD) or fall asleep (STATF_Sleeping)
// Summoned (STATF_Conjured) and some others creatures have no corpse.
CItemCorpse * CChar::MakeCorpse( bool fFrontFall )
{
	ADDTOCALLSTACK("CChar::MakeCorpse");

	word wFlags = (word)(m_TagDefs.GetKeyNum("DEATHFLAGS", true));
	if (wFlags & DEATH_NOCORPSE)
		return( NULL );
	if (IsStatFlag(STATF_Conjured) && !(wFlags & (DEATH_NOCONJUREDEFFECT|DEATH_HASCORPSE)))
	{
		Effect(EFFECT_XYZ, ITEMID_FX_SPELL_FAIL, this, 1, 30);
		return( NULL );
	}

	CItemCorpse *pCorpse = dynamic_cast<CItemCorpse *>(CItem::CreateScript(ITEMID_CORPSE, this));
	if (pCorpse == NULL)	// weird internal error
		return( NULL );

	tchar *pszMsg = Str_GetTemp();
	sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_MSG_CORPSE_OF), GetName());
	pCorpse->SetName(pszMsg);
	pCorpse->SetHue(GetHue());
	pCorpse->SetCorpseType(GetDispID());
	pCorpse->SetAttr(ATTR_MOVE_NEVER);
	pCorpse->m_itCorpse.m_BaseID = m_prev_id;	// id the corpse type here !
	pCorpse->m_itCorpse.m_facing_dir = m_dirFace;
	pCorpse->m_uidLink = GetUID();

	// TO-DO: Fix corpses always turning to the same dir (DIR_N) after resend it to clients

	if (fFrontFall)
		pCorpse->m_itCorpse.m_facing_dir = static_cast<DIR_TYPE>(m_dirFace|0x80);

	int iDecayTimer = -1;	// never decay
	if (IsStatFlag(STATF_DEAD))
	{
		iDecayTimer = (m_pPlayer) ? g_Cfg.m_iDecay_CorpsePlayer : g_Cfg.m_iDecay_CorpseNPC;
		pCorpse->SetTimeStamp(CServerTime::GetCurrentTime().GetTimeRaw());	// death time
		if (Attacker_GetLast())
			pCorpse->m_itCorpse.m_uidKiller = Attacker_GetLast()->GetUID();
		else
			pCorpse->m_itCorpse.m_uidKiller.InitUID();
	}
	else	// sleeping (not dead)
	{
		pCorpse->SetTimeStamp(0);
		pCorpse->m_itCorpse.m_uidKiller = GetUID();
	}

	if ((m_pNPC && m_pNPC->m_bonded) || IsStatFlag(STATF_Conjured|STATF_Sleeping))
		pCorpse->m_itCorpse.m_carved = 1;	// corpse of bonded and summoned creatures (or sleeping players) can't be carved

	if ( !(wFlags & DEATH_NOLOOTDROP) )		// move non-newbie contents of the pack to corpse
		DropAll( pCorpse );

	pCorpse->SetKeyNum("OVERRIDE.MAXWEIGHT", g_Cfg.Calc_MaxCarryWeight(this) / 10);		// set corpse maxweight to prevent weird exploits like when someone place many items on an player corpse just to make this player get stuck on resurrect
	pCorpse->MoveToDecay(GetTopPoint(), iDecayTimer);
	return( pCorpse );
}
bool CItemMulti::Multi_CreateComponent( ITEMID_TYPE id, int dx, int dy, int dz, DWORD dwKeyCode )
{
	CItem * pItem = CreateTemplate( id );
	ASSERT(pItem);

	CPointMap pt = GetTopPoint();
	pt.m_x += dx;
	pt.m_y += dy;
	pt.m_z += dz;

	bool fNeedKey = false;

	switch ( pItem->GetType() )
	{
	case IT_KEY:	// it will get locked down with the house ?
	case IT_SIGN_GUMP:
	case IT_SHIP_TILLER:
		pItem->m_itKey.m_lockUID.SetPrivateUID( dwKeyCode );	// Set the key id for the key/sign.
		fNeedKey = true;
		break;
	case IT_DOOR:
		pItem->SetType(IT_DOOR_LOCKED);
fNeedKey = true;
		break;
	case IT_CONTAINER:
		pItem->SetType(IT_CONTAINER_LOCKED);
fNeedKey = true;
		break;
	case IT_SHIP_SIDE:
		pItem->SetType(IT_SHIP_SIDE_LOCKED);
		break;
	case IT_SHIP_HOLD:
		pItem->SetType(IT_SHIP_HOLD_LOCK);
		break;
	}

	pItem->SetAttr( ATTR_MOVE_NEVER | (m_Attr&(ATTR_MAGIC|ATTR_INVIS)));
	pItem->SetHue( GetHue());
	pItem->m_uidLink = GetUID();	// lock it down with the structure.

	if ( pItem->IsTypeLockable() || pItem->IsTypeLocked())
	{
		pItem->m_itContainer.m_lockUID.SetPrivateUID( dwKeyCode );	// Set the key id for the door/key/sign.
		pItem->m_itContainer.m_lock_complexity = 10000;	// never pickable.
	}

	pItem->MoveTo( pt );
	return( fNeedKey );
}
Beispiel #4
0
CCharBase * CItem::Spawn_SetTrackID()
{
	if ( ! IsType(IT_SPAWN_CHAR))
		return NULL;
	CCharBase * pCharDef = NULL;
	RESOURCE_ID_BASE rid = m_itSpawnChar.m_CharID;

	if ( rid.GetResType() == RES_CHARDEF )
	{
		CREID_TYPE id = (CREID_TYPE) rid.GetResIndex();
		pCharDef = CCharBase::FindCharBase( id );
	}
	if ( pCharDef )
		SetAttr( ATTR_INVIS );
	if ( IsAttr(ATTR_INVIS))	// They must want it to look like this.
	{
		SetDispID( ( pCharDef == NULL ) ? ITEMID_TRACK_WISP : pCharDef->m_trackID );
		if ( GetHue() == 0 )
			SetHue( HUE_RED_DARK );	// Indicate to GM's that it is invis.
	}
	return( pCharDef );
}
Beispiel #5
0
void RGBtoHSBService (double dRed, double dGreen, double dBlue,
					  double &rdHue, double &rdSat, double &rdBright)
{
// 1. Helligkeit berechnen
double dYR = HelligkeitRot(dRed);
double dYG = HelligkeitGruen(dGreen);
double dYB = HelligkeitBlau(dBlue);
double dY = dYR + dYG + dYB;			// Gesamtluminanz

	rdBright = Wahrnehmung(dY);

// 2. Sättigung berechnen
double dYRGrau = BEZUGSWERT_ROT*dY;		// anteilige Helligkeiten des zugehörigen Grauwertes
double dYGGrau = BEZUGSWERT_GRUEN*dY;
double dYBGrau = BEZUGSWERT_BLAU*dY;

HIGHLOW rgStatus = HIGHLOW_UNKNOWN;
TARGETCOLOR rgTarget = TARGETCOLOR_UNKNOWN;

// 2.1. testen, ob eine der Farbanteile bereits gesättigt ist
double dYRSatt = dYR;
double dYGSatt = dYG;
double dYBSatt = dYB;
int fSaturatedRot = IsSaturated (dYR, BEZUGSWERT_ROT);
int fSaturatedGruen = IsSaturated (dYG, BEZUGSWERT_GRUEN);
int fSaturatedBlau = IsSaturated (dYB, BEZUGSWERT_BLAU);

int fSaturatedSum = fSaturatedRot & fSaturatedGruen;

	fSaturatedSum &= fSaturatedBlau;
	if (fSaturatedSum) {
	// weiß oder schwarz
		rdSat = 0.0;	// Farbe ist vollständig entsättigt
		rdHue = 0.0;	// per Definition
		return;	
	}

	if (fSaturatedRot) {
		rgStatus = (0.0 == dYR) ? HIGHLOW_LOW : HIGHLOW_HIGH;
		rgTarget = TARGETCOLOR_RED;
		rdSat = 1.0;				// volle Sättigung
	} else if (fSaturatedGruen) {
		rgStatus = (0.0 == dYG) ? HIGHLOW_LOW : HIGHLOW_HIGH;
		rgTarget = TARGETCOLOR_GREEN;
		rdSat = 1.0;				// volle Sättigung
	} else if (fSaturatedBlau) {
		rgStatus = (0.0 == dYB) ? HIGHLOW_LOW : HIGHLOW_HIGH;
		rgTarget = TARGETCOLOR_BLUE;
		rdSat = 1.0;				// volle Sättigung
	} else {
	// gesättigte Farbe bestimmen
	HIGHLOW rgRStatus = HIGHLOW_UNKNOWN;
	HIGHLOW rgGStatus = HIGHLOW_UNKNOWN;
	HIGHLOW rgBStatus = HIGHLOW_UNKNOWN;
	double dKR = EvalSatKoeff (dYRGrau, dYR, BEZUGSWERT_ROT, rgRStatus);
	double dKG = EvalSatKoeff (dYGGrau, dYG, BEZUGSWERT_GRUEN, rgGStatus);
	double dKB = EvalSatKoeff (dYBGrau, dYB, BEZUGSWERT_BLAU, rgBStatus);

	// der Farbanteil mit dem maximalen (inversen) Koeffizienten
	// ist die entscheidende
	double dKMax = __max(fabs(dKR), __max(fabs(dKG), fabs(dKB)));

		if (0.0 == dKMax) {
			rdSat = 0.0;	// Farbe ist vollständig entsättigt
			rdHue = 0.0;	// per Definition
			return;	
		} else {
			if (dKMax == fabs(dKR)) {
				rgStatus = rgRStatus;
				rgTarget = TARGETCOLOR_RED;
			} else if (dKMax == fabs(dKG)) {
				rgStatus = rgGStatus;
				rgTarget = TARGETCOLOR_GREEN;
			} else if (dKMax == fabs(dKB)) {
				rgStatus = rgBStatus;
				rgTarget = TARGETCOLOR_BLUE;
			} 

		// gesättigte Farbanteile berechnen
			dYRSatt = CorrectColor (dYRGrau, dYR, dKMax);
			dYGSatt = CorrectColor (dYGGrau, dYG, dKMax);
			dYBSatt = CorrectColor (dYBGrau, dYB, dKMax);

			if (dYRSatt != dYRGrau)
				rdSat = (dYR - dYRGrau)/(dYRSatt - dYRGrau);
			else if (dYGSatt != dYGGrau)
				rdSat = (dYG - dYGGrau)/(dYGSatt - dYGGrau);
			else if (dYBSatt != dYBGrau)
				rdSat = (dYB - dYBGrau)/(dYBSatt - dYBGrau);
			else
				ASSERT(false);
		}
	}

	ASSERT(rgTarget != TARGETCOLOR_UNKNOWN);
	ASSERT(rgStatus != HIGHLOW_UNKNOWN);

// 3. Farbwert bestimmen
double dRSatt = Farbanteil (dYRSatt, BEZUGSWERT_ROT);
double dGSatt = Farbanteil (dYGSatt, BEZUGSWERT_GRUEN);
double dBSatt = Farbanteil (dYBSatt, BEZUGSWERT_BLAU);

	if (HIGHLOW_LOW == rgStatus) {
		switch (rgTarget) {
		case TARGETCOLOR_RED:
			rdHue = GetHue (dGSatt, dBSatt) + 3.0;
			break;

		case TARGETCOLOR_GREEN:
			rdHue = GetHue (dBSatt, dRSatt) + 5.0;
			break;

		case TARGETCOLOR_BLUE:
			rdHue = GetHue (dRSatt, dGSatt) + 1.0;
			break;
		}
	} else {
		switch (rgTarget) {
		case TARGETCOLOR_RED:
			rdHue = GetHue (1.0-dGSatt, 1.0-dBSatt);
			if (rdHue < 0.0) rdHue += 6.0;
			break;

		case TARGETCOLOR_GREEN:
			rdHue = GetHue (1.0-dBSatt, 1.0-dRSatt) + 2.0;
			break;

		case TARGETCOLOR_BLUE:
			rdHue = GetHue (1.0-dRSatt, 1.0-dGSatt) + 4.0;
			break;
		}
	}
	rdHue *= 60.0;
	while (rdHue >= 360.0)
		rdHue -= 360.0;
}