Пример #1
0
bool CDotaItems::PickUpItem (uint32_t nItem)
{
	vector<uint32_t> items;
	CDotaItem* oItem = m_AllItems->find(nItem);
//	CONSOLE_Print( "[CDotaItems:PickUpItem] Start ["+m_AllItems->find(nItem)->name+"] ["+UTIL_ToString(oItem->recipes.size())+"].");
	// update recipe list info and check for a building of a new item.
	for (vector<CDotaItemRecipe*>::iterator it = oItem->recipes.begin(); it != oItem->recipes.end(); it++)
	{
		items = (*it)->PickUpItem(nItem);
		if (!items.empty()) // we have a new item
		{
			uint32_t nItem = items.back();
			items.pop_back();
			// drop all items that in recipe
			while(!items.empty())
			{
				// we cant drop an item that we just try to pick up
				if(items.back() == nItem)
				{
					// but we just do incriment for all the recipes, and now we need to do it back.
					for (vector<CDotaItemRecipe*>::iterator it2 = oItem->recipes.begin(); it2 != oItem->recipes.end(); it2++)
						(*it2)->DropItem(nItem);
				}else
					DropItem(items.back());
				items.pop_back();
			}
			PickUpItem(nItem);
//			CONSOLE_Print( "[CDotaItems:PickUpItem] End with recipe.");
			return true;
		}
	}
//	CONSOLE_Print( "[CDotaItems:PickUpItem] End without recipe.");
	// Pick up a new item
	return PickUpPItem(nItem);
};
Пример #2
0
/* virtual */ void COrder_Still::Execute(CUnit &unit)
{
	// If unit is not bunkered and removed, wait
	if (unit.Removed
		//Wyrmgus start
//		&& (unit.Container == nullptr || unit.Container->Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value == false)) {
		&& (unit.Container == nullptr || !unit.Container->Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value || !unit.Type->BoolFlag[ATTACKFROMTRANSPORTER_INDEX].value)) { // make both the unit and the transporter have the tag be necessary for the attack to be possible
			if (unit.Container != nullptr) {
				LeaveShelter(unit); // leave shelter if surrounded
			}
		//Wyrmgus end
		return ;
	}
	this->Finished = false;

	switch (this->State) {
		case SUB_STILL_STANDBY:
			//Wyrmgus start
//			UnitShowAnimation(unit, unit.Type->Animations->Still);
			if (unit.Variable[STUN_INDEX].Value == 0) { //only show the idle animation when still if the unit is not stunned
				UnitShowAnimation(unit, unit.GetAnimations()->Still);
			}
			if (SyncRand(100000) == 0) {
				PlayUnitSound(unit, VoiceIdle);
			}
			unit.StepCount = 0;
			//Wyrmgus end
			break;
		case SUB_STILL_ATTACK: // attacking unit in attack range.
			AnimateActionAttack(unit, *this);
			break;
	}
	if (unit.Anim.Unbreakable) { // animation can't be aborted here
		return;
	}
	//Wyrmgus start
	if (unit.Variable[STUN_INDEX].Value > 0) { //if unit is stunned, remain still
		return;
	}
	//Wyrmgus end
	this->State = SUB_STILL_STANDBY;
	this->Finished = (this->Action == UnitActionStill);
	if (this->Action == UnitActionStandGround || unit.Removed || unit.CanMove() == false) {
		if (unit.AutoCastSpell) {
			this->AutoCastStand(unit);
		}
		if (unit.IsAgressive()) {
			this->AutoAttackStand(unit);
		}
	} else {
		if (AutoCast(unit) || (unit.IsAgressive() && AutoAttack(unit))
			|| AutoRepair(unit)
			//Wyrmgus start
//			|| MoveRandomly(unit)) {
			|| MoveRandomly(unit) || PickUpItem(unit)) {
			//Wyrmgus end
		}
	}
}
Пример #3
0
void CFootBotForagingNR::Explore() {
  // This should be implemented differently: check whether we are on a
  // food item, and if so, pick it up.
  if (IsOverFoodItem() && !IsCarryingFood()) {
    PickUpItem();
  }
  else {
    bool collision;
    CVector2 diffusion = DiffusionVector(collision);
    SetWheelSpeedsFromVector(WheelTurningParams.MaxSpeed * diffusion);
  }
}
Пример #4
0
void ItemMover::OnRightClick(bool up, int x, int y, bool* block) {
	BnetData* pData = (*p_D2LAUNCH_BnData);
	UnitAny *unit = D2CLIENT_GetPlayerUnit();
	bool shiftState = ((GetKeyState(VK_LSHIFT) & 0x80) || (GetKeyState(VK_RSHIFT) & 0x80));
	bool ctrlState = ((GetKeyState(VK_LCONTROL) & 0x80) || (GetKeyState(VK_RCONTROL) & 0x80));
	if (up || !pData || !unit || !(shiftState || ctrlState)) {
		return;
	}

	Init();

	int xpac = pData->nCharFlags & PLAYER_TYPE_EXPANSION;

	int inventoryRight = INVENTORY_LEFT + (CELL_SIZE * INVENTORY_WIDTH);
	int inventoryBottom = INVENTORY_TOP + (CELL_SIZE * INVENTORY_HEIGHT);
	int stashRight = STASH_LEFT + (CELL_SIZE * STASH_WIDTH);
	int stashTop = xpac ? LOD_STASH_TOP : CLASSIC_STASH_TOP;
	int stashHeight = xpac ? LOD_STASH_HEIGHT : CLASSIC_STASH_HEIGHT;
	int stashBottom = stashTop + (CELL_SIZE * stashHeight);
	int cubeRight = CUBE_LEFT + (CELL_SIZE * CUBE_WIDTH);
	int cubeBottom = CUBE_TOP + (CELL_SIZE * CUBE_HEIGHT);

	int source, sourceX, sourceY;
	int invUI = D2CLIENT_GetUIState(UI_INVENTORY);
	int stashUI = D2CLIENT_GetUIState(UI_STASH);
	int cubeUI = D2CLIENT_GetUIState(UI_CUBE);
	if ((invUI || stashUI || cubeUI) && x >= INVENTORY_LEFT && x <= inventoryRight && y >= INVENTORY_TOP && y <= inventoryBottom) {
		source = STORAGE_INVENTORY;
		sourceX = (x - INVENTORY_LEFT) / CELL_SIZE;
		sourceY = (y - INVENTORY_TOP) / CELL_SIZE;
	} else if (stashUI && x >= STASH_LEFT && x <= stashRight && y >= stashTop && y <= stashBottom) {
		source = STORAGE_STASH;
		sourceX = (x - STASH_LEFT) / CELL_SIZE;
		sourceY = (y - stashTop) / CELL_SIZE;
	} else if (cubeUI && x >= CUBE_LEFT && x <= cubeRight && y >= CUBE_TOP && y <= cubeBottom) {
		source = STORAGE_CUBE;
		sourceX = (x - CUBE_LEFT) / CELL_SIZE;
		sourceY = (y - CUBE_TOP) / CELL_SIZE;
	} else {
		return;
	}

	bool moveItem = LoadInventory(unit, xpac, source, sourceX, sourceY, shiftState, ctrlState, stashUI, invUI);
	if (moveItem) {
		PickUpItem();
	}
	*block = true;
}