Пример #1
0
void Game::ShareXP(int xp, int flags)
{
	int individual;

	if (flags&SX_CR) {
		xp = GetXPFromCR(xp);
	}

	if (flags&SX_DIVIDE) {
		int PartySize = GetPartySize(true); //party size, only alive
		if (PartySize<1) {
			return;
		}
		individual = xp / PartySize;
	} else {
		individual = xp;
	}

	if (!individual) {
		return;
	}

	if (xp>0) {
		displaymsg->DisplayConstantStringValue( STR_GOTXP, DMC_BG2XPGREEN, (ieDword) xp); //you have gained ... xp
	} else {
		displaymsg->DisplayConstantStringValue( STR_LOSTXP, DMC_BG2XPGREEN, (ieDword) -xp); //you have lost ... xp
	}
	for (unsigned int i=0; i<PCs.size(); i++) {
		if (PCs[i]->GetStat(IE_STATE_ID)&STATE_DEAD) {
			continue;
		}
		PCs[i]->AddExperience(individual, flags&SX_COMBAT);
	}
}
Пример #2
0
int Game::GetXPFromCR(int cr)
{
	if (!crtable) LoadCRTable();
	if (crtable) {
		int size = GetPartySize(true);
		if (!size) return 0; // everyone just died anyway
		int level = GetPartyLevel(true) / size;
		if (cr+1>=MAX_CRLEVEL) {
			cr=MAX_CRLEVEL-2;
		}
		Log(MESSAGE, "Game", "Challenge Rating: %d, party level: %d", cr, level);
		// it also has a column for cr 0.25 and 0.5
		return crtable[level-1][cr+1];
	}
	Log(ERROR, "Game", "Cannot find moncrate.2da!");
	return 0;
}
Пример #3
0
// check if the actor is in npclevel.2da and replace accordingly
bool Game::CheckForReplacementActor(int i)
{
	if (core->InCutSceneMode() || npclevels.empty()) {
		return false;
	}

	Actor* act = NPCs[i];
	ieDword level = GetPartyLevel(false) / GetPartySize(false);
	if (!(act->Modified[IE_MC_FLAGS]&MC_BEENINPARTY) && !(act->Modified[IE_STATE_ID]&STATE_DEAD) && act->GetXPLevel(false) < level) {
		ieResRef newcre = "****"; // default table value
		std::vector<std::vector<char *> >::iterator it;
		for (it = npclevels.begin(); it != npclevels.end(); it++) {
			if (!stricmp((*it)[0], act->GetScriptName()) && (level > 2)) {
				// the tables have entries only up to level 24
				ieDword safeLevel = npclevels[0].size() - 1;
				if (level < safeLevel) {
					safeLevel = level;
				}
				CopyResRef(newcre, (*it)[safeLevel-2]);
				break;
			}
		}

		if (stricmp(newcre, "****")) {
			int pos = gamedata->LoadCreature(newcre, 0, false, act->version);
			if (pos < 0) {
				error("Game::CheckForReplacementActor", "LoadCreature failed: pos is negative!\n");
			} else {
				Actor *newact = GetNPC(pos);
				if (!newact) {
					error("Game::CheckForReplacementActor", "GetNPC failed: cannot find act!\n");
				} else {
					newact->Pos = act->Pos; // the map is not loaded yet, so no SetPosition
					newact->TalkCount = act->TalkCount;
					newact->InteractCount = act->InteractCount;
					CopyResRef(newact->Area, act->Area);
					DelNPC(InStore(act), true);
					return true;
				}
			}
		}
	}
	return false;
}
Пример #4
0
void scene_StartWildBattle()
{
	// Which Pokémon will join the battle?
	int chosenPkmn = 0;

	if(MyPlayer.gender == 0)
	{
		DmaArrayCopy(dannybackPal, MEM_PAL_OBJ + 0x40);
		DmaArrayCopy(dannybackTiles, MEM_VRAM_OBJ + 0x4000);
	}
	else
	{
		DmaArrayCopy(danibackPal, MEM_PAL_OBJ + 0x40);
		DmaArrayCopy(danibackTiles, MEM_VRAM_OBJ + 0x4000);
	}
#ifdef WITH_SHIRTCOLORS
		*(u16*)0x0500025C= shirtcolors[(MyPlayer.shirtColor*2) + ((MyPlayer.gender%2)*16)];
		*(u16*)0x0500025E = shirtcolors[(MyPlayer.shirtColor*2)+1+((MyPlayer.gender%2)*16)];
#endif
	if(demo==1) //are we running a demo?
	{
		DmaArrayCopy(demobackPal, MEM_PAL_OBJ + 0x40);
		DmaArrayCopy(demobackTiles, MEM_VRAM_OBJ + 0x4000);
	}

	//char buffy[255];
	int i=0;

	OamBak[0].CharNo = 512;
	OamBak[0].Pltt = 2;
	OamBak[0].HPos = 24;
	OamBak[0].VPos = 54;
	OamBak[0].Priority = 1;

	//sndPlaySound(6,SOUND_NORESTART);

	fighters_Initialize(1,0);
	battle_SendOut(1,0,0);
	OamBak[1].Priority = 1;
	battle_OpenAnimation();
	battle_SendOut(1,0,SEND_SCROLLCRY);
	btlWindowShifts[1] = 0;
	scene_BuildPlayerPartyWin();

	// Displays message until A or B is pressed
	btlsays(strBattleFooAppeared, fighters_This(1));
	while(!(Trg & KEY_A || Trg & KEY_B))
	{
		KeyRead();
		DoVBlank();
	}

//KAWA - This part is for the demo game.
	if(GetPartySize(&MyParty)==0)
	{
		OamBak[0].CharNo = 832;
		btlsays(strBattleDemoNoParty);
		ThisBattle.decision = 10;
		return;
	}
// </demo>
	//Runaway hack
	if(	demo == 0	 &&
		Cont & KEY_A &&
		Cont & KEY_B)
	{
		int run = battle_Run(i,0);
		if(run > 0)
		{
			ThisBattle.decision = 3;
			return;
		}
	}

	if(demo==1)
	{
		btlsays(strBattleDemoSendOut, MyParty[0].Personal.Nickname);
	}
	else
	{
	// Check for fainted Pokémon.
	// If all of them fainted, return
		while(	MyParty[chosenPkmn].Status.CurrentHP == 0 &&
				chosenPkmn < GetPartySize())
			chosenPkmn++;
		if(chosenPkmn >= GetPartySize())
		{
			AGBPrintf("*scene_StartWildBattle: chosenPkmn has an invalid value!");
			return;
		}

		btlsays(strBattleIChooseYou, MyParty[chosenPkmn].Personal.Nickname); //fighters_This(0));
	}
	for(i = 0; i < 64; i++)
	{
		DoVBlank();
		OamBak[0].HPos = 24 - i*2;
		if(i < 48)
			OamBak[0].CharNo = 512 + (64 * (i/10));
	}
//	OamBak[0].CharNo = 0;
//	OamBak[0].Pltt = 0;
//	OamBak[0].HPos = 24;
	fighters_Initialize(0,0);
	battle_SendOut(0,chosenPkmn,SEND_ALL);

	ThisBattle.duringBattle = 1;
	ThisBattle.trainer = 0;
	ThisBattle.runCommand = 0;
	ThisBattle.doublebattle = 0;
	ThisBattle.internalbattle = 1;
	ThisBattle.decision = 0;
	ThisBattle.roamer = 0;
}