//***********************************************************************************************
// flags & 1 == destroyed !
//***********************************************************************************************
void ARX_EQUIPMENT_UnEquip(Entity * target, Entity * tounequip, long flags)
{
	if(!target || !tounequip)
		return;

	if(target != entities.player())
		return;

	for(size_t i = 0; i < MAX_EQUIPED; i++) {
		if(ValidIONum(player.equiped[i]) && entities[player.equiped[i]] == tounequip) {
			EERIE_LINKEDOBJ_UnLinkObjectFromObject(target->obj, tounequip->obj);
			ARX_EQUIPMENT_Release(player.equiped[i]);
			target->bbox2D.min.x = 9999;
			target->bbox2D.max.x = -9999;
			
			if(!flags) {
				if(!DRAGINTER) {
					ARX_SOUND_PlayInterface(SND_INVSTD);
					Set_DragInter(tounequip);
				} else {
					giveToPlayer(tounequip);
				}
			}
			
			EVENT_SENDER = tounequip;
			SendIOScriptEvent(entities.player(), SM_EQUIPOUT);
			EVENT_SENDER = entities.player();
			SendIOScriptEvent(tounequip, SM_EQUIPOUT);
		}
	}

	if(tounequip->type_flags & (OBJECT_TYPE_HELMET | OBJECT_TYPE_ARMOR | OBJECT_TYPE_LEGGINGS))
		ARX_EQUIPMENT_RecreatePlayerMesh();
}
示例#2
0
void PlayerInventoryHud::dragEntity(Entity * io, const Vec2s &pos) {
	Vec2f anchorPos = g_playerInventoryHud.anchorPosition();
	
	Vec2i iPos = Vec2i(anchorPos);
	
	if(g_playerInventoryHud.containsPos(pos)) {
		if(!GInput->actionPressed(CONTROLS_CUST_STEALTHMODE)) {
			if((io->ioflags & IO_ITEM) && io->_itemdata->count > 1) {
				if(io->_itemdata->count - 1 > 0) {
					
					Entity * ioo = AddItem(io->classPath());
					ioo->show = SHOW_FLAG_NOT_DRAWN;
					ioo->_itemdata->count = 1;
					io->_itemdata->count--;
					ioo->scriptload = 1;
					ARX_SOUND_PlayInterface(SND_INVSTD);
					Set_DragInter(ioo);
					RemoveFromAllInventories(ioo);
					sInventory = 1;
					
					float fX = (pos.x - iPos.x) / (32 * m_scale);
					float fY = (pos.y - iPos.y) / (32 * m_scale);
					
					sInventoryPos.x = checked_range_cast<short>(fX);
					sInventoryPos.y = checked_range_cast<short>(fY);
					
					SendInitScriptEvent(ioo);
					ARX_INVENTORY_IdentifyIO(ioo);
					return;
				}
			}
		}
	}
	
	arx_assert(player.bag >= 0);
	arx_assert(player.bag <= 3);
	
	for(size_t bag = 0; bag < size_t(player.bag); bag++)
	for(size_t y = 0; y < INVENTORY_Y; y++)
	for(size_t x = 0; x < INVENTORY_X; x++) {
		INVENTORY_SLOT & slot = inventory[bag][x][y];
		
		if(slot.io == io) {
			slot.io = NULL;
			slot.show = true;
			sInventory = 1;
			
			float fX = (pos.x - iPos.x) / (32 * m_scale);
			float fY = (pos.y - iPos.y) / (32 * m_scale);
			
			sInventoryPos.x = checked_range_cast<short>(fX);
			sInventoryPos.y = checked_range_cast<short>(fY);
		}
	}
	
	Set_DragInter(io);
	
	RemoveFromAllInventories(io);
	ARX_INVENTORY_IdentifyIO(io);
}
void SecondaryInventoryCloseHudIcon::updateInput() {
	
	m_isSelected = m_rect.contains(Vec2f(DANAEMouse));
	
	if(m_isSelected) {
		SpecialCursor=CURSOR_INTERACTION_ON;
		
		if(eeMouseDown1()) {
			Entity * io = NULL;
			
			if(SecondaryInventory)
				io = SecondaryInventory->io;
			else if(player.Interface & INTER_STEAL)
				io = ioSteal;
			
			if(io) {
				ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
				g_secondaryInventoryHud.m_fadeDirection = SecondaryInventoryHud::Fade_left;
				SendIOScriptEvent(io,SM_INVENTORY2_CLOSE);
				TSecondaryInventory=SecondaryInventory;
				SecondaryInventory=NULL;
			}
		}
		
		if(DRAGINTER == NULL)
			return;
	}
}
示例#4
0
void StealIconGui::updateInput() {
	
	// steal
	if(player.Interface & INTER_STEAL) {
		if(m_rect.contains(Vec2f(DANAEMouse))) {
			
			eMouseState = MOUSE_IN_STEAL_ICON;
			cursorSetInteraction();
			
			if(eeMouseDown1()) {
				ARX_INVENTORY_OpenClose(ioSteal);
				
				if(player.Interface & (INTER_INVENTORY | INTER_INVENTORYALL)) {
					ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
				}
				
				if(SecondaryInventory) {
					SendIOScriptEvent(entities.player(), ioSteal, SM_STEAL);
					bForceEscapeFreeLook = true;
					lOldTruePlayerMouseLook = !TRUE_PLAYER_MOUSELOOK_ON;
				}
			}
			
			if(DRAGINTER == NULL) {
				return;
			}
			
		}
	}
	
}
示例#5
0
void PlayerInventoryHud::previousBag() {
	
	if((player.Interface & INTER_INVENTORY)) {
		if(player.bag) {
			if(g_currentInventoryBag > 0) {
				ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
				g_currentInventoryBag --;
			}
		}
	}
}
示例#6
0
void ARX_EQUIPMENT_UnEquipPlayerWeapon()
{
	if(ValidIONum(player.equiped[EQUIP_SLOT_WEAPON])) {
		Entity * pioOldDragInter = DRAGINTER;
		DRAGINTER = entities[player.equiped[EQUIP_SLOT_WEAPON]];

		if(DRAGINTER)
			ARX_SOUND_PlayInterface(SND_INVSTD);

		ARX_EQUIPMENT_UnEquip(entities.player(), entities[player.equiped[EQUIP_SLOT_WEAPON]]);
		DRAGINTER = pioOldDragInter;
	}

	player.equiped[EQUIP_SLOT_WEAPON] = EntityHandle();
}
void SecondaryInventoryHud::update() {
	Entity * io = getSecondaryOrStealInvEntity();
	if(io) {
		float dist = fdist(io->pos, player.pos + (Vec3f_Y_AXIS * 80.f));
		
		float maxDist = player.m_telekinesis ? 900.f : 350.f;
		
		if(dist > maxDist) {
			if(m_fadeDirection != Fade_left) {
				ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
				
				m_fadeDirection = Fade_left;
				SendIOScriptEvent(io,SM_INVENTORY2_CLOSE);
				TSecondaryInventory=SecondaryInventory;
				SecondaryInventory=NULL;
			} else {
				if(player.Interface & INTER_STEAL) {
					player.Interface &= ~INTER_STEAL;
				}
			}
		}
	} else if(m_fadeDirection != Fade_left) {
		m_fadeDirection = Fade_left;
	}
	
	
	if(!(player.Interface & INTER_COMBATMODE) && (player.Interface & INTER_MINIBACK)) {
		// Pick All/Close Secondary Inventory
		if(TSecondaryInventory) {
			//These have to be calculated on each frame (to make them move).
			Rectf parent = Rectf(Vec2f(m_fadePosition, 0), m_defaultBackground->m_size.x * m_scale, m_defaultBackground->m_size.y * m_scale);
			
			m_pickAllButton.setScale(m_scale);
			m_closeButton.setScale(m_scale);
			
			m_pickAllButton.update(parent);
			m_closeButton.update(parent);
		}
	}
}
示例#8
0
float ARX_DAMAGES_DamagePlayer(float dmg, DamageType type, EntityHandle source) {
	if (player.playerflags & PLAYERFLAGS_INVULNERABILITY)
		return 0;

	float damagesdone = 0.f;

	if(player.lifePool.current == 0.f)
		return damagesdone;

	if(dmg > player.lifePool.current)
		damagesdone = dmg;
	else
		damagesdone = player.lifePool.current;

	entities.player()->dmg_sum += dmg;

	if(float(arxtime) > entities.player()->ouch_time + 500) {
		Entity * oes = EVENT_SENDER;

		if(ValidIONum(source))
			EVENT_SENDER = entities[source];
		else
			EVENT_SENDER = NULL;

		entities.player()->ouch_time = (unsigned long)(arxtime);
		char tex[32];
		sprintf(tex, "%5.2f", entities.player()->dmg_sum);
		SendIOScriptEvent( entities.player(), SM_OUCH, tex );
		EVENT_SENDER = oes;
		float power = entities.player()->dmg_sum / player.lifePool.max * 220.f;
		AddQuakeFX(power * 3.5f, 500 + power * 3, rnd() * 100.f + power + 200, 0);
		entities.player()->dmg_sum = 0.f;
	}

	if(dmg > 0.f) {
		if(ValidIONum(source)) {
			Entity * pio = NULL;

			if(entities[source]->ioflags & IO_NPC) {
				pio = entities[source]->_npcdata->weapon;

				if(pio && (pio->poisonous == 0 || pio->poisonous_count == 0))
					pio = NULL;
			}

			if(!pio)
				pio = entities[source];

			if(pio && pio->poisonous && pio->poisonous_count != 0) {
				if(rnd() * 100.f > player.m_misc.resistPoison) {
					player.poison += pio->poisonous;
				}

				if(pio->poisonous_count != -1)
					pio->poisonous_count--;
			}
		}

		long alive;

		if(player.lifePool.current > 0)
			alive = 1;
		else
			alive = 0;

		if(!BLOCK_PLAYER_CONTROLS)
			player.lifePool.current -= dmg;

		if(player.lifePool.current <= 0.f) {
			player.lifePool.current = 0.f;

			if(alive) {
				//REFUSE_GAME_RETURN = 1;
				ARX_PLAYER_BecomesDead();

				if((type & DAMAGE_TYPE_FIRE) || (type & DAMAGE_TYPE_FAKEFIRE)) {
					ARX_SOUND_PlayInterface(SND_PLAYER_DEATH_BY_FIRE);
				}

				SendIOScriptEvent(entities.player(), SM_DIE);

				for(size_t i = 1; i < entities.size(); i++) {
					const EntityHandle handle = EntityHandle(i);
					Entity * ioo = entities[handle];
					
					if(ioo && (ioo->ioflags & IO_NPC)) {
						if(ioo->targetinfo == TARGET_PLAYER) {
							EVENT_SENDER = entities.player();
							std::string killer;
							if(source == PlayerEntityHandle) {
								killer = "player";
							} else if(source <= EntityHandle::Invalid) {
								killer = "none";
							} else if(ValidIONum(source)) {
								killer = entities[source]->idString();
							}
							SendIOScriptEvent(entities[handle], SM_NULL, killer, "target_death");
						}
					}
				}
			}
		}

		if(player.lifePool.max <= 0.f)
			return damagesdone;

		float t = dmg / player.lifePool.max;

		if(Blood_Pos == 0.f) {
			Blood_Pos = 0.000001f;
			Blood_Duration = 100 + (t * 200.f);
		} else {
			long temp = t * 800.f;
			Blood_Duration += temp;
		}
	}

	// revient les barres
	ResetPlayerInterface();

	return damagesdone;
}
示例#9
0
void PlayerInventoryHud::dropEntity() {
	if(!(player.Interface & INTER_INVENTORY) && !(player.Interface & INTER_INVENTORYALL))
		return;
	
	if(InventoryY != 0)
		return;
	
	if(!g_playerInventoryHud.containsPos(DANAEMouse))
		return;
	
	Vec2s s = DRAGINTER->m_inventorySize;
	
	int bag = 0;
	
	Vec2f anchorPos = g_playerInventoryHud.anchorPosition();
	
	float fCenterX	= anchorPos.x;
	float fSizY		= anchorPos.y;
	
	short iPosX = checked_range_cast<short>(fCenterX);
	short iPosY = checked_range_cast<short>(fSizY);
	
	Vec2s t = Vec2s_ZERO;
	
	if(player.Interface & INTER_INVENTORY) {
		t.x = DANAEMouse.x - iPosX;
		t.y = DANAEMouse.y - iPosY;
		t.x = t.x / (32 * m_scale); 
		t.y = t.y / (32 * m_scale); 
		
		if((t.x >= 0) && (t.x <= 16 - s.x) && (t.y >= 0) && (t.y <= 3 - s.y)) {
			bag = g_currentInventoryBag;
		} else {
			return;
		}
	} else {
		bool bOk = false;
		
		float fBag	= (player.bag - 1) * (-121 * m_scale);
		
		short iY = checked_range_cast<short>(fBag);
		
		//We must enter the for-loop to initialyze tx/ty
		arx_assert(0 < player.bag);
		
		for(int i = 0; i < player.bag; i++) {
			t.x = DANAEMouse.x - iPosX;
			t.y = DANAEMouse.y - iPosY - iY; 
			
			if((t.x >= 0) && (t.y >= 0)) {
				t.x = t.x / (32 * m_scale); 
				t.y = t.y / (32 * m_scale); 
				
				if((t.x >= 0) && (t.x <= 16 - s.x) && (t.y >= 0) && (t.y <= 3 - s.y)) {
					bOk = true;
					bag = i;
					break;
				}
			}
			
			float fRatio = (121 * m_scale);
			
			iY += checked_range_cast<short>(fRatio);
		}
		
		if(!bOk)
			return;
	}
	
	if(DRAGINTER->ioflags & IO_GOLD) {
		ARX_PLAYER_AddGold(DRAGINTER);
		Set_DragInter(NULL);
		return;
	}
	
	for(long j = 0; j < s.y; j++)
		for(long i = 0; i < s.x; i++) {
			Entity * ioo = inventory[bag][t.x+i][t.y+j].io;
			
			if(!ioo)
				continue;
			
			ARX_INVENTORY_IdentifyIO(ioo);
			
			if(   ioo->_itemdata->playerstacksize > 1
			&& IsSameObject(DRAGINTER, ioo)
			&& ioo->_itemdata->count < ioo->_itemdata->playerstacksize
			) {
				ioo->_itemdata->count += DRAGINTER->_itemdata->count;
				
				if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) {
					DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize;
					ioo->_itemdata->count = ioo->_itemdata->playerstacksize;
				} else {
					DRAGINTER->_itemdata->count = 0;
				}
				
				ioo->scale = 1.f;
				ARX_INVENTORY_Declare_InventoryIn(DRAGINTER);
				
				if(!DRAGINTER->_itemdata->count) {
					DRAGINTER->destroy();
				}
				
				ARX_SOUND_PlayInterface(SND_INVSTD);
				return;
			}
			
			return;
		}
	
	for(long j = 0; j < s.y; j++) {
		for(long i = 0; i < s.x; i++) {
			inventory[bag][t.x+i][t.y+j].io = DRAGINTER;
			inventory[bag][t.x+i][t.y+j].show = false;
		}
	}
	
	inventory[bag][t.x][t.y].show = true;
	
	ARX_INVENTORY_Declare_InventoryIn(DRAGINTER);
	ARX_SOUND_PlayInterface(SND_INVSTD);
	DRAGINTER->show = SHOW_FLAG_IN_INVENTORY;
	Set_DragInter(NULL);
}
示例#10
0
void PlayerInventoryHud::update() {
	if(player.Interface & INTER_INVENTORY) {
		if((player.Interface & INTER_COMBATMODE) || player.doingmagic >= 2) {
			long t = Original_framedelay * (1.f/5) + 2;
			InventoryY += t;

			if(InventoryY > 110) {
				InventoryY = 110;
			}
		} else {
			if(bInventoryClosing) {
				long t = Original_framedelay * (1.f/5) + 2;
				InventoryY += t;

				if(InventoryY > 110) {
					InventoryY = 110;
					bInventoryClosing = false;

					player.Interface &=~ INTER_INVENTORY;

					if(bInventorySwitch) {
						bInventorySwitch = false;
						ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
						player.Interface |= INTER_INVENTORYALL;
						ARX_INTERFACE_NoteClose();
						InventoryY = 121 * player.bag;
						lOldInterface=INTER_INVENTORYALL;
					}
				}
			} else if(InventoryY > 0) {
				InventoryY -= long((Original_framedelay * (1.f/5)) + 2.f);

				if(InventoryY < 0) {
					InventoryY = 0;
				}
			}
		}
	} else if((player.Interface & INTER_INVENTORYALL) || bInventoryClosing) {
		float fSpeed = (1.f/3);
		if((player.Interface & INTER_COMBATMODE) || player.doingmagic >= 2) {
			if(InventoryY < 121 * player.bag) {
				InventoryY += long((Original_framedelay * fSpeed) + 2.f);
			}
		} else {
			if(bInventoryClosing) {
				InventoryY += long((Original_framedelay * fSpeed) + 2.f);
				if(InventoryY > 121 * player.bag) {
					bInventoryClosing = false;
					if(player.Interface & INTER_INVENTORYALL) {
						player.Interface &= ~INTER_INVENTORYALL;
					}
					lOldInterface=0;
				}
			} else if(InventoryY > 0) {
				InventoryY -= long((Original_framedelay * fSpeed) + 2.f);
				if(InventoryY < 0) {
					InventoryY = 0;
				}
			}
		}
	}
}
示例#11
0
bool Manage3DCursor(Entity * io, bool simulate) {
	
	arx_assert(io);
	
	if(BLOCK_PLAYER_CONTROLS)
		return false;

	float ag = player.angle.getYaw();

	if(ag > 180)
		ag = ag - 360;

	float drop_miny = (float)(g_size.center().y) - g_size.center().y * (ag * (1.f/70));

	if(DANAEMouse.y < drop_miny)
		return false;
	
	Anglef temp = Anglef::ZERO;

	if(io->ioflags & IO_INVERTED) {
		temp.setYaw(180.f);
		temp.setPitch(-MAKEANGLE(270.f - io->angle.getPitch() - (player.angle.getPitch() - STARTED_ANGLE)));
	} else {
		temp.setPitch(MAKEANGLE(270.f - io->angle.getPitch() - (player.angle.getPitch() - STARTED_ANGLE)));
	}
	
	EERIE_3D_BBOX bbox;
	for(size_t i = 0; i < io->obj->vertexlist.size(); i++) {
		bbox.add(io->obj->vertexlist[i].v);
	}
	
	Vec3f mvectx = angleToVectorXZ(player.angle.getPitch() - 90.f);
	
	Vec2f mod = Vec2f(Vec2i(DANAEMouse) - g_size.center()) / Vec2f(g_size.center()) * Vec2f(160.f, 220.f);
	mvectx *= mod.x;
	Vec3f mvecty(0, mod.y, 0);

	Vec3f orgn = player.pos;
	orgn += angleToVector(player.angle) * 50.f;
	orgn += mvectx;
	orgn.y += mvecty.y;

	Vec3f dest = player.pos;
	dest += angleToVector(player.angle) * 10000.f;
	dest += mvectx;
	dest.y += mvecty.y * 5.f;
	
	Vec3f pos = orgn;

	Vec3f movev = glm::normalize(dest - orgn);

	float lastanything = 0.f;
	float height = -(bbox.max.y - bbox.min.y);

	if(height > -30.f)
		height = -30.f;
	
	Vec3f objcenter = bbox.min + (bbox.max - bbox.min) * Vec3f(0.5f);
	
	Vec3f collidpos = Vec3f_ZERO;
	bool collidpos_ok = false;
	
	{
	float maxdist = 0.f;
	
	for(size_t i = 0; i < io->obj->vertexlist.size(); i++) {
		const EERIE_VERTEX & vert = io->obj->vertexlist[i];
		
		float dist = glm::distance(Vec2f(objcenter.x, objcenter.z), Vec2f(vert.v.x, vert.v.z)) - 4.f;
		maxdist = std::max(maxdist, dist);
	}

	if(io->obj->pbox) {
		Vec2f tmpVert(io->obj->pbox->vert[0].initpos.x, io->obj->pbox->vert[0].initpos.z);
		
		for(int i = 1; i < io->obj->pbox->nb_physvert; i++) {
			const PHYSVERT & physVert = io->obj->pbox->vert[i];
			
			float dist = glm::distance(tmpVert, Vec2f(physVert.initpos.x, physVert.initpos.z)) + 14.f;
			maxdist = std::max(maxdist, dist);
		}
	}
	
	Cylinder cyl2;
	const float inc = 10.f;
	long iterating = 40;

	cyl2.height = std::min(-30.f, height);
	cyl2.radius = glm::clamp(maxdist, 20.f, 150.f);
	
	while(iterating > 0) {
		cyl2.origin = pos + movev * inc + Vec3f(0.f, bbox.max.y, 0.f);

		float anything = CheckAnythingInCylinder(cyl2, io, CFLAG_JUST_TEST | CFLAG_COLLIDE_NOCOL | CFLAG_NO_NPC_COLLIDE);

		if(anything < 0.f) {
			if(iterating == 40) {
				CANNOT_PUT_IT_HERE = 1;
				// TODO is this correct ?
				return true;
			}

			iterating = 0;

			collidpos = cyl2.origin;

			if(lastanything < 0.f) {
				pos.y += lastanything;
				collidpos.y += lastanything;
			}
		} else {
			pos = cyl2.origin;
			lastanything = anything;
		}

		iterating--;
	}
	collidpos_ok = iterating == -1;
	
	}
	
	objcenter = VRotateY(objcenter, temp.getPitch());
	
	collidpos.x -= objcenter.x;
	collidpos.z -= objcenter.z;

	pos.x -= objcenter.x;
	pos.z -= objcenter.z;

	if(!collidpos_ok) {
		CANNOT_PUT_IT_HERE = 1;
		return false;
	}

	if(collidpos_ok && closerThan(player.pos, pos, 300.f)) {
		if(simulate) {
			ARX_INTERACTIVE_Teleport(io, pos, true);

			io->gameFlags &= ~GFLAG_NOCOMPUTATION;
			
			glm::quat rotation = glm::toQuat(toRotationMatrix(temp));
			
			if(SPECIAL_DRAGINTER_RENDER) {
			if(glm::abs(lastanything) > glm::abs(height)) {
				TransformInfo t(collidpos, rotation, io->scale);

				static const float invisibility = 0.5f;

				DrawEERIEInter(io->obj, t, io, false, invisibility);
			} else {
				TransformInfo t(pos, rotation, io->scale);

				float invisibility = Cedric_GetInvisibility(io);

				DrawEERIEInter(io->obj, t, io, false, invisibility);
			}
			}
		} else {
			if(glm::abs(lastanything) > std::min(glm::abs(height), 12.0f)) {
				Entity * io = DRAGINTER;
				ARX_PLAYER_Remove_Invisibility();
				io->obj->pbox->active = 1;
				io->obj->pbox->stopcount = 0;
				io->pos = collidpos;
				io->velocity = Vec3f_ZERO;

				io->stopped = 1;

				movev.x *= 0.0001f;
				movev.y = 0.1f;
				movev.z *= 0.0001f;
				Vec3f viewvector = movev;

				Anglef angle = temp;
				io->soundtime = 0;
				io->soundcount = 0;
				EERIE_PHYSICS_BOX_Launch(io->obj, io->pos, angle, viewvector);
				ARX_SOUND_PlaySFX(SND_WHOOSH, &pos);
				io->show = SHOW_FLAG_IN_SCENE;
				Set_DragInter(NULL);
			} else {
				ARX_PLAYER_Remove_Invisibility();
				ARX_SOUND_PlayInterface(SND_INVSTD);
				ARX_INTERACTIVE_Teleport(io, pos, true);

				io->angle.setYaw(temp.getYaw());
				io->angle.setPitch(270.f - temp.getPitch());
				io->angle.setRoll(temp.getRoll());

				io->stopped = 0;
				io->show = SHOW_FLAG_IN_SCENE;
				io->obj->pbox->active = 0;
				Set_DragInter(NULL);
			}
		}

		GRenderer->SetCulling(Renderer::CullNone);
		return true;
	} else {
		CANNOT_PUT_IT_HERE=-1;
	}

	return false;
}
示例#12
0
static void PlayerBookDrawRune(Rune rune) {
	
	ARX_SPELLS_RequestSymbolDraw2(entities.player(), rune, ARX_SOUND_GetDuration(SND_SYMB[rune]));
	ARX_SOUND_PlayInterface(SND_SYMB[rune]);
}
bool SecondaryInventoryHud::dragEntity(Entity * io, const Vec2s & pos) {
	
	if(SecondaryInventory != NULL) {
		if(g_secondaryInventoryHud.containsPos(pos) && (io->ioflags & IO_ITEM)) {
			Entity * ioo = SecondaryInventory->io;
			
			if(ioo->ioflags & IO_SHOP) {
				long cos = ARX_INTERACTIVE_GetPrice(io, ioo);
				
				float fcos	= cos - cos * player.m_skillFull.intuition * 0.005f;
				cos = checked_range_cast<long>(fcos);
				
				if(player.gold < cos) {
					return false;
				}
				
				ARX_SOUND_PlayInterface(SND_GOLD);
				player.gold -= cos;
				
				if(io->_itemdata->count > 1) {
					Entity * ioo = CloneIOItem(io);
					ioo->show = SHOW_FLAG_NOT_DRAWN;
					ioo->scriptload = 1;
					ioo->_itemdata->count = 1;
					io->_itemdata->count--;
					ARX_SOUND_PlayInterface(SND_INVSTD);
					Set_DragInter(ioo);
					return true;
				}
			} else if(io->_itemdata->count > 1) {
				
				if(!GInput->actionPressed(CONTROLS_CUST_STEALTHMODE)) {
					Entity * ioo = CloneIOItem(io);
					ioo->show = SHOW_FLAG_NOT_DRAWN;
					ioo->scriptload = 1;
					ioo->_itemdata->count = 1;
					io->_itemdata->count--;
					ARX_SOUND_PlayInterface(SND_INVSTD);
					Set_DragInter(ioo);
					sInventory = 2;
					
					Vec2f calc;
					calc.x = (pos.x + m_fadePosition - (2 * m_scale)) / (32 * m_scale);
					calc.y = (pos.y - (13 * m_scale)) / (32 * m_scale);
					
					sInventoryPos.x = checked_range_cast<short>(calc.x);
					sInventoryPos.y = checked_range_cast<short>(calc.y);
					
					//ARX_INVENTORY_Object_Out(SecondaryInventory->io, ioo);
					
					ARX_INVENTORY_IdentifyIO(ioo);
					return true;
				}
			}
		}
		
		for(long j = 0; j < SecondaryInventory->m_size.y; j++)
		for(long i = 0; i < SecondaryInventory->m_size.x; i++) {
			INVENTORY_SLOT & slot = SecondaryInventory->slot[i][j];
			
			if(slot.io != io)
				continue;
			
			slot.io = NULL;
			slot.show = true;
			sInventory = 2;
			
			float fCalcX = (pos.x + m_fadePosition - (2 * m_scale)) / (32 * m_scale);
			float fCalcY = (pos.y - (13 * m_scale)) / (32 * m_scale);
			
			sInventoryPos.x = checked_range_cast<short>(fCalcX);
			sInventoryPos.y = checked_range_cast<short>(fCalcY);
		}
	}
	
	Set_DragInter(io);
	RemoveFromAllInventories(io);
	ARX_INVENTORY_IdentifyIO(io);
	return true;
}
void SecondaryInventoryHud::dropEntity() {
	
	// First Look for Identical Item...
	if(SecondaryInventory && g_secondaryInventoryHud.containsPos(DANAEMouse)) {
		Entity * io = SecondaryInventory->io;
		
		float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; //>>1;
		long price = checked_range_cast<long>(fprice);
		price *= DRAGINTER->_itemdata->count;
		fprice = price + price * player.m_skillFull.intuition * 0.005f;
		price = checked_range_cast<long>(fprice);
		
		// SHOP
		if(io->ioflags & IO_SHOP) {
			if(!io->shop_category.empty() && DRAGINTER->groups.find(io->shop_category) == DRAGINTER->groups.end())
				return;
			
			if(price <= 0)
				return;
			
			// Check shop group
			for(long j = 0; j < SecondaryInventory->m_size.y; j++) {
			for(long i = 0; i < SecondaryInventory->m_size.x; i++) {
				Entity * ioo = SecondaryInventory->slot[i][j].io;
				
				if(!ioo || !IsSameObject(DRAGINTER, ioo))
					continue;
				
				ioo->_itemdata->count += DRAGINTER->_itemdata->count;
				ioo->scale = 1.f;
				
				DRAGINTER->destroy();
				
				ARX_PLAYER_AddGold(price);
				ARX_SOUND_PlayInterface(SND_GOLD);
				ARX_SOUND_PlayInterface(SND_INVSTD);
				return;
			}
			}
		}
		
		Vec2s t = Vec2s_ZERO;
		t.x = DANAEMouse.x + static_cast<short>(m_fadePosition) - (2 * m_scale);
		t.y = DANAEMouse.y - (13 * m_scale);
		t.x = t.x / (32 * m_scale);
		t.y = t.y / (32 * m_scale);
		
		Vec2s s = DRAGINTER->m_inventorySize;
		
		if(t.x <= SecondaryInventory->m_size.x - s.x && t.y <= SecondaryInventory->m_size.y - s.y) {
			
			float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f;
			long price = checked_range_cast<long>(fprice);
			price *= DRAGINTER->_itemdata->count;
			fprice = price + price * player.m_skillFull.intuition * 0.005f;
			price = checked_range_cast<long>(fprice);
			
			for(long j = 0; j < s.y; j++) {
			for(long i = 0; i < s.x; i++) {
				Entity * ioo = SecondaryInventory->slot[t.x+i][t.y+j].io;
				
				if(!ioo)
					continue;
				
				DRAGINTER->show = SHOW_FLAG_IN_INVENTORY;
				
				if(   ioo->_itemdata->playerstacksize > 1
				   && IsSameObject(DRAGINTER, ioo)
				   && ioo->_itemdata->count < ioo->_itemdata->playerstacksize
				) {
					ioo->_itemdata->count += DRAGINTER->_itemdata->count;
					
					if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) {
						DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize;
						ioo->_itemdata->count = ioo->_itemdata->playerstacksize;
					} else {
						DRAGINTER->_itemdata->count = 0;
					}
				}
				
				if(DRAGINTER->_itemdata->count) {
					if(CanBePutInSecondaryInventory(SecondaryInventory, DRAGINTER)) {
						// SHOP
						if(io->ioflags & IO_SHOP) {
							ARX_PLAYER_AddGold(price);
							ARX_SOUND_PlayInterface(SND_GOLD);
						}
					} else {
						return;
					}
				}
				
				ARX_SOUND_PlayInterface(SND_INVSTD);
				Set_DragInter(NULL);
				return;
			}
			}
			
			if(DRAGINTER->ioflags & IO_GOLD) {
				ARX_PLAYER_AddGold(DRAGINTER);
				Set_DragInter(NULL);
				return;
			}

			for(long j = 0; j < s.y; j++) {
			for(long i = 0; i < s.x; i++) {
				SecondaryInventory->slot[t.x+i][t.y+j].io = DRAGINTER;
				SecondaryInventory->slot[t.x+i][t.y+j].show = false;
			}
			}
			
			// SHOP
			if(io->ioflags & IO_SHOP) {
				player.gold += price;
				ARX_SOUND_PlayInterface(SND_GOLD);
			}

			SecondaryInventory->slot[t.x][t.y].show = true;
			DRAGINTER->show = SHOW_FLAG_IN_INVENTORY;
			ARX_SOUND_PlayInterface(SND_INVSTD);
			Set_DragInter(NULL);
			return;
		}
	}
}
示例#15
0
void BackpackIconGui::updateInput() {
	
	static PlatformInstant flDelay = 0;
	
	// Check for backpack Icon
	if(m_rect.contains(Vec2f(DANAEMouse))) {
		if(eeMouseUp1() && playerInventory.insert(DRAGINTER)) {
			ARX_SOUND_PlayInterface(SND_INVSTD);
			Set_DragInter(NULL);
		}
	}
	
	if(m_rect.contains(Vec2f(DANAEMouse)) || flDelay != 0) {
		eMouseState = MOUSE_IN_INVENTORY_ICON;
		cursorSetInteraction();
		
		
		if(eeMouseDoubleClick1()) {
			ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
			
			playerInventory.optimize();
			
			flDelay = 0;
		} else if(eeMouseDown1() || flDelay != 0) {
			if(flDelay == 0) {
				flDelay = g_platformTime.frameStart();
				return;
			} else {
				if(g_platformTime.frameStart() - flDelay < PlatformDurationMs(300)) {
					return;
				} else {
					flDelay = 0;
				}
			}
			
			if(player.Interface & INTER_INVENTORYALL) {
				ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
				g_playerInventoryHud.close();
			} else {
				bInverseInventory = !bInverseInventory;
				lOldTruePlayerMouseLook = TRUE_PLAYER_MOUSELOOK_ON;
			}
		} else if(eeMouseDown2()) {
			g_playerBook.close();
			ARX_INVENTORY_OpenClose(NULL);
			
			if(player.Interface & INTER_INVENTORYALL) {
				g_playerInventoryHud.close();
			} else {
				if(player.Interface & INTER_INVENTORY) {
					ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
					g_playerInventoryHud.close();
					bInventorySwitch = true;
				} else {
					ARX_SOUND_PlayInterface(SND_BACKPACK, Random::getf(0.9f, 1.1f));
					player.Interface |= INTER_INVENTORYALL;
					
					g_playerInventoryHud.resetPos();
					
					ARX_INTERFACE_NoteClose();
					
					if(TRUE_PLAYER_MOUSELOOK_ON) {
						WILLRETURNTOFREELOOK = true;
					}
				}
			}
			
			TRUE_PLAYER_MOUSELOOK_ON = false;
		}
		
		if(DRAGINTER == NULL)
			return;
	}
}
示例#16
0
void ActivatePortalSpell::Launch()
{
	ARX_SOUND_PlayInterface(SND_SPELL_ACTIVATE_PORTAL);
	
	m_duration = 20;
}