Esempio n. 1
0
void ThrowObject::Pickup( Event *ev )
{
	Entity * ent;
	//Event * e;
	str bone;
	
	ent = ev->GetEntity( 1 );
	
	assert( ent );
	if ( !ent )
	{
		return;
	}
	bone = ev->GetString( 2 );
	
	/*
	setOrigin( pickup_offset );
	
	  e = new Event( EV_Attach );
	  e->AddEntity( ent );
	  e->AddString( bone );
	  ProcessEvent( e );
	  
		edict->s.renderfx &= ~RF_FRAMELERP;
	*/
	
	Pickup( ent , bone );
}
Esempio n. 2
0
/*
================
idItem::Event_Trigger
================
*/
void idItem::Event_Trigger( idEntity *activator ) {

	if ( !canPickUp && spawnArgs.GetBool( "triggerFirst" ) ) {
		canPickUp = true;
		return;
	}

	if ( activator && activator->IsType( idPlayer::Type ) ) {
		Pickup( static_cast<idPlayer *>( activator ) );
	}
}
Esempio n. 3
0
/*
================
idItem::Event_Touch
================
*/
void idItem::Event_Touch( idEntity *other, trace_t *trace ) {
	if ( !other->IsType( idPlayer::Type ) ) {
		return;
	}

	if ( !canPickUp ) {
		return;
	}

	Pickup( static_cast<idPlayer *>(other) );
}
Esempio n. 4
0
Pickup GameEngine::registerInventoryClick() {
	int relX = lib.res().x() - 3;
	if ((lib.mouseLoc().x() == relX || lib.mouseLoc().x() == relX + 1) && lib.mouseLoc().y() >= 3 && lib.mouseLoc().y() <= 9) {
		if (!invLog.itemAlreadyEquipped(lib.mouseLoc()))
			return invLog.useItem(lib.mouseLoc());
		else if(invLog.getInvItemAtLoc(lib.mouseLoc()).getLoc() != Point(-1, -1)) {
			string event = "A " + invLog.getInvItemAtLoc(lib.mouseLoc()).getPickupDef().getTypeName() + " is already equipped!";
			log.registerEvent(event.c_str());
		}
	}
	return Pickup();
}
Esempio n. 5
0
void Eat(int phil) {
    _T(pthread_mutex_lock(&aux_mutex));
    block_time[phil] += time(0) - block_start[phil];
    int eat_len = random_time();
    eat_time[phil] += eat_len;
    Pickup(phil);
    printf("Philosopher %d is eating for %d s\n", phil, eat_len);
    _T(pthread_mutex_unlock(&aux_mutex));
    sleep(eat_len);
     _T(pthread_mutex_lock(&aux_mutex));
    printf("Philosopher %d stopped eating\n", phil);
    Pickdown(phil);
     _T(pthread_mutex_unlock(&aux_mutex));
}
Esempio n. 6
0
void APacmanPickup::NotifyActorBeginOverlap(AActor *OtherActor)
{
	Super::NotifyActorBeginOverlap(OtherActor);
	
	// Pickup can be taken only once
	if (!IsPendingKill())
	{
		// Apply pickup effect
		Pickup(OtherActor);

		UGameplayStatics::PlaySound2D(this, PickupSound);

		SetActorHiddenInGame(true);
		Destroy();
	}
}
Esempio n. 7
0
void Shop::buy(Point loc) {
	int idx = idxFromPoint(loc);
	Pickup itemToBuy = storeItems[idx];
	int price = itemToBuy.getPickupDef().getPrice();

	if (invLog->getGold() >= price && !invLog->isInventoryFull()) { //Make sure hero has enough cash and inv isn't full
		invLog->addItem(itemToBuy);
		storeItems[idx] = Pickup();
		invLog->changeGold(-price);
		log->registerEvent("Bought a " + itemToBuy.getPickupDef().getName() + " for " + to_string(price));
		lib->play("Buy");
	}
	else {
		log->registerEvent("Not enough gold!");
		lib->play("CantBuy");
	}
}
Esempio n. 8
0
void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
    int ItemTag = a_NBT.FindChildByName(a_TagIdx, "Item");
    if ((ItemTag < 0) || (a_NBT.GetType(ItemTag) != TAG_Compound))
    {
        return;
    }
    cItem Item;
    if (!LoadItemFromNBT(Item, a_NBT, ItemTag))
    {
        return;
    }
    std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false
    if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx))
    {
        return;
    }
    a_Entities.push_back(Pickup.release());
}
Esempio n. 9
0
Shop::Shop(Point loc, int difficulty, vector<PickupDef> potItems, TileLibrary* lib, Hero* hero, MessageLog* log, InventoryLog* invLog) {
	this->loc = loc;
	this->difficulty = difficulty;
	this->potItems = potItems;
	this->lib = lib;
	this->hero = hero;
	this->log = log;
	this->invLog = invLog;

	start = Point(2, 2);
	end = Point(lib->res().x() - 6, lib->res().y() - 4);

	//Fill the store
	int which = 0;
	lib->loop_portion_reverse(start + Point(5, 5), end + Point(-5, -5), [&](Point p) {
		which = rand() % potItems.size();
		storeItems.push_back(Pickup(potItems[which], p));
	});
}
void USCarryObjectComponent::ServerPickup_Implementation()
{
	Pickup();
}
Esempio n. 11
0
//Function to simulate the twin lifts.
//VARIABLE EXPLANATION:-
//	qf: array of array of queues
//	mq: main queue which contains people int their order of ariival.
//	num_floors: total number of floors.
void Simulate(pqueue ** qf, pqueue * mq, int num_floors)
{
	State * lift1 = State_new(0, num_floors, 0, 1, 1);
	State * lift2 = State_new(num_floors, num_floors, 0, -1, 2);
	person * p;
	for(p=mq->head;p!=NULL;p=p->mainnext)
	{
		if(p->time!=-1)
			continue;

		int reserved = CalculateNumPersons(qf[p->floor_arrival]);
		
		int a1 = lift1->floor-p->floor_arrival;
		int a2 = lift2->floor-p->floor_arrival;
		
		if(a1<0)a1*=-1;
		if(a2<0)a2*=-1;

		a1*=FLOOR_TIME;
		a2*=FLOOR_TIME;

		if(a1+lift1->time<=a2+lift2->time)
		{
			GoTo(lift1->floor, p->floor_arrival, lift1, qf, num_floors, reserved);
			Pickup(p->floor_arrival, lift1, qf); 
			Drop(lift1->floor, p->floor_dest, lift1, qf, num_floors);
		}
		else
		{
			GoTo(lift2->floor, p->floor_arrival, lift2, qf, num_floors, reserved);
			Pickup(p->floor_arrival, lift2, qf); 
			Drop(lift2->floor, p->floor_dest, lift2, qf, num_floors);
		}
			

		printf("Lift 1: %d  %d\n",lift1->time,lift1->floor);
		printf("Lift 2: %d  %d\n",lift2->time,lift2->floor);
	
	}
	lift1->num_people-=lift1->dst[lift1->floor];
	lift2->num_people-=lift2->dst[lift2->floor];
	if(lift1->num_people==0 && lift2->num_people==0)
		printf("\nSuccessfuly simulated!!\n\n");
	int j;

	
	lift1->place_time[lift1->time+1] = lift1->floor;
	lift2->place_time[lift2->time+1] = lift2->floor;
	findfloors(lift1->place_time,lift1->time+1);    
	findfloors(lift2->place_time,lift2->time+1);    
													
	/*printf("\nLift1 : \n");                         
	for(j=0;j<=lift1->time;++j)                     
	{                                               
		printf("%d  %.1f\n",j,lift1->place_time[j]);	
	}                                               
	printf("\nLift2 : \n");                         
	for(j=0;j<=lift2->time;++j)                     
	{                                               
		printf("%d  %.1f\n",j,lift2->place_time[j]);	
	}*/                                              
	
	state_print(qf, num_floors, lift1, lift2, lift1->time>lift2->time?lift1->time:lift2->time);
}