Exemple #1
0
IICHAN::~IICHAN()
{
	if(GetSpriteAllocator())
	{
		delete GetSpriteAllocator();
		SetSpriteAllocator(NULL);
	}
	if(GetEventAllocator())
	{
		delete GetEventAllocator();
		SetEventAllocator(NULL);
	}
	if(GetItemAllocator())
	{
		delete GetItemAllocator();
		SetItemAllocator(NULL);
	}
	if(GetScreenTextAllocator())
	{
		delete GetScreenTextAllocator();
		SetScreenTextAllocator(NULL);
	}
	if(GetInstanceAllocator())
	{
		delete GetInstanceAllocator();
		SetInstanceAllocator(NULL);
	}
	if(GetHUD())
	{
		delete GetHUD();
		SetHUD(NULL);
	}
}
Exemple #2
0
IICHAN::IICHAN()
{
	SetSpriteAllocator(NULL);
	SetEventAllocator(NULL);
	SetItemAllocator(NULL);
	SetScreenTextAllocator(NULL);
	SetInstanceAllocator(NULL);
	SetHUD(NULL);
}
Exemple #3
0
void IICHAN::Init()
{
	IICHANSpriteAllocator* spr_alloc = new IICHANSpriteAllocator();
	IICHANEventAllocator* event_alloc = new IICHANEventAllocator();
	IICHANItemAllocator* item_alloc = new IICHANItemAllocator();
	IICHANScreenTextAllocator* scr_text_alloc = new IICHANScreenTextAllocator();
	IICHANInstanceAllocator* inst_alloc = new IICHANInstanceAllocator();
	HUD* hud = new HUD();
	SetItemAllocator(item_alloc);
	SetSpriteAllocator(spr_alloc);
	SetEventAllocator(event_alloc);
	SetScreenTextAllocator(scr_text_alloc);
	SetInstanceAllocator(inst_alloc);
	SetHUD(hud);
	GetItemAllocator()->SetHUD(hud);
	GetItemAllocator()->SetSpriteAllocator(GetSpriteAllocator());
	GetItemAllocator()->SetInstanceAllocator(GetInstanceAllocator());
	GetItemAllocator()->SetScreenTextAllocator(GetScreenTextAllocator());
	GetEventAllocator()->SetItemAllocator(GetItemAllocator());
	GetEventAllocator()->SetScreenTextAllocator(GetScreenTextAllocator());
	GetEventAllocator()->SetInstanceAllocator(GetInstanceAllocator());
	GetInstanceAllocator()->SetSpriteAllocator(GetSpriteAllocator());
	GetInstanceAllocator()->SetScreenTextAllocator(GetScreenTextAllocator());

	osl_Load_v_04("levels\\level1.txt");

	PLAYER* player = (PLAYER*)GetItemAllocator()->GetFirstPlayer();

	if(player)
	{
		for(int i = 0; i < player->GetHealth(); i++)
		{
			GetHUD()->AddHealth();
		}

		for(int i = 0; i < player->GetAmmo(); i++)
		{
			GetHUD()->AddAmmo();
		}

		for(int i = 0; i < player->GetScore(); i++)
		{
			GetHUD()->AddScore();
		}
	}


}
CInventoryItem::CInventoryItem(idEntity* itemEntity, idEntity* owner) {
	// Don't allow NULL pointers
	assert(owner && itemEntity);

	// Parse a few common spawnargs
	ParseSpawnargs(itemEntity->spawnArgs);

	m_Category = NULL;
	m_Overlay = OVERLAYS_INVALID_HANDLE;
	m_Hud = false;

	m_Owner = owner;
	m_Item = itemEntity;
	
	// Determine and set the loot type
	m_LootType = GetLootTypeFromSpawnargs(itemEntity->spawnArgs);

	// Read the spawnargs into the member variables
	m_Name = itemEntity->spawnArgs.GetString("inv_name", "");
	// Tels: Replace "\n" with \x0a, otherwise multiline names set inside DR do not work
	m_Name.Replace( "\\n", "\n" );
	m_Value	= itemEntity->spawnArgs.GetInt("inv_loot_value", "-1");
	m_Stackable	= itemEntity->spawnArgs.GetBool("inv_stackable", "0");
	m_UseOnFrob = itemEntity->spawnArgs.GetBool("inv_use_on_frob", "0");

	m_Count = (m_Stackable) ? itemEntity->spawnArgs.GetInt("inv_count", "1") : 1;

	m_Droppable = itemEntity->spawnArgs.GetBool("inv_droppable", "0");
	m_ItemId = itemEntity->spawnArgs.GetString("inv_item_id", "");

	if (m_Icon.IsEmpty() && m_LootType == LOOT_NONE)
	{
		DM_LOG(LC_INVENTORY, LT_INFO)LOGSTRING("Information: non-loot item %s has no icon.\r", itemEntity->name.c_str());
	}

	if (m_LootType != LOOT_NONE && m_Value <= 0)
	{
		DM_LOG(LC_INVENTORY, LT_ERROR)LOGSTRING("Warning: Value for loot item missing on entity %s\r", itemEntity->name.c_str());
	}

	// Set the item type according to the loot property
	m_Type = (m_LootType != LOOT_NONE) ? IT_LOOT : IT_ITEM;

	m_BindMaster = itemEntity->GetBindMaster();
	m_Orientated = itemEntity->fl.bindOrientated;

	idStr hudName;
	// Item could be added to the inventory, check for custom HUD
	if (itemEntity->spawnArgs.GetString("inv_hud", "", hudName) != false)
	{
		int hudLayer;
		itemEntity->spawnArgs.GetInt("inv_hud_layer", "0", hudLayer);
		SetHUD(hudName, hudLayer);
	}

	// Check for a preferred drop orientation, if not, use current orientation
	if( itemEntity->spawnArgs.FindKey("drop_angles") )
	{
		idAngles DropAngles;
		DropAngles = itemEntity->spawnArgs.GetAngles("drop_angles");
		m_DropOrientation = DropAngles.ToMat3();
	}
	else
	{
		idVec3 dummy;
		idMat3 playerView;
		gameLocal.GetLocalPlayer()->GetViewPos(dummy, playerView);
		// drop orientation is relative to the player view yaw only
		idAngles viewYaw = playerView.ToAngles();
		// ignore pitch and roll
		viewYaw[0] = 0;
		viewYaw[2] = 0;
		idMat3 playerViewYaw = viewYaw.ToMat3();

		m_DropOrientation = itemEntity->GetPhysics()->GetAxis() * playerViewYaw.Transpose();
	}
}