Example #1
0
void InventoryState::onAutoequip(Action *)
{
	// don't act when moving items
	if (_inv->getSelectedItem() != 0)
	{
		return;
	}

	BattleUnit               *unit          = _battleGame->getSelectedUnit();
	Tile                     *groundTile    = unit->getTile();
	std::vector<BattleItem*> *groundInv     = groundTile->getInventory();
	Mod                      *mod           = _game->getMod();
	RuleInventory            *groundRuleInv = mod->getInventory("STR_GROUND", true);
	int                       worldShade    = _battleGame->getGlobalShade();

	std::vector<BattleUnit*> units;
	units.push_back(unit);
	BattlescapeGenerator::autoEquip(units, mod, NULL, groundInv, groundRuleInv, worldShade, true, true);

	// refresh ui
	_inv->arrangeGround(false);
	updateStats();
	_refreshMouse();

	// give audio feedback
	_game->getMod()->getSoundByDepth(_battleGame->getDepth(), Mod::ITEM_DROP)->play();
}
Example #2
0
void MCModInfoFrame::updateWithMod(Mod &m)
{
	if(m.type() == m.MOD_FOLDER)
	{
		clear();
		return;
	}

	QString text = "";
	QString name = "";
	if(m.name().isEmpty()) name = m.mmc_id();
	else name = m.name();

	if(m.homeurl().isEmpty()) text = name;
	else text = "<a href=\"" + m.homeurl() + "\">" + name + "</a>";
	if(!m.authors().isEmpty()) text += " by " + m.authors();

	setModText(text);

	if(m.description().isEmpty())
	{
		setModDescription(tr("No description provided in mcmod.info"));
	}
	else
	{
		setModDescription(m.description());
	}
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OrientationMath::AxisAngletoHomochoric(float w, float n1, float n2, float n3, float& r1, float& r2, float& r3)
{
  // Bring omega into proper range.
  Mod<float> mod;
  w = mod.WrapTwoPI(w);

  float denom = 0.0f;

  denom = (n1 * n1) + (n2 * n2) + (n3 * n3);
  denom = sqrt(denom);
  if(denom == 0.0)
  {
    r1 = 0.0, r2 = 0.0, r3 = 0.0;
    return;
  }
  n1 = n1 / denom;
  n2 = n2 / denom;
  n3 = n3 / denom;
  if (w >= 0.0f && w < DREAM3D::Constants::k_Pi)
  {
    float temp = powf(((0.75f) * (w - sinf(w))), DREAM3D::Constants::k_1Over3);
    r1 = n1 * temp;
    r2 = n2 * temp;
    r3 = n3 * temp;
  }
  else
  {
    float temp = powf(((0.75f) * (DREAM3D::Constants::k_2Pi - w + sinf(w))), DREAM3D::Constants::k_1Over3);
    r1 = n1 * temp;
    r2 = n2 * temp;
    r3 = n3 * temp;
  }
}
Example #4
0
Mod::Mod(const Mod& mod)
{
	modFile = mod.GetFileName();
	modName = mod.GetName();
	modVersion = mod.GetModVersion();
	mcVersion = mod.GetMCVersion();
}
Example #5
0
int main()
{
	char szError[cbErrMax];
	EC ec;
	PDB* ppdb = PDB::Open("001.PDB", pdbWrite, 0, &ec, szError);

	assert(ppdb);
	DBI* pdbi = ppdb->OpenDBI(pdbWrite, "<target>");
	assert(pdbi);
	TS ts = pdbi->OpenTpi(pdbWrite);
	assert(ts);

	struct {
		unsigned short	len;
		unsigned short	leaf;
		unsigned long	signature;
		unsigned long	age;
		unsigned char	name[9];
	} typeUseTypeServer = {
		20,	
		LF_TYPESERVER,
		123456789,
		1,
		"\x07""002.PDB"
	};

	struct {
		unsigned short	reclen;	
		unsigned short	rectyp;	
		CV_uoff32_t 	off;
		unsigned short	seg;
		CV_typ_t		typind;	
		unsigned char	name[5];
	} aSymbol = {
		16,
		S_GDATA32,
		0,
		0,
		0,
		"\x03""ABC"
	};

	Mod* pmod = pdbi->OpenMod(ts, 1, "<mod>");
	assert(pmod->AddTypes((PB)&typeUseTypeServer, 20));
	for (TI ti = 0x1000; ti < 0x12e0; ti++) {
		aSymbol.typind = ti;
		assert(pmod->AddSymbols((PB)&aSymbol, 16));
	}
	pmod->Commit();
	pmod->Close();

	ts->Commit();
	ts->Close();
	ppdb->Commit();
	pdbi->Close();
	ppdb->Commit();
	ppdb->Close();

	return 0;
}
Example #6
0
	void operator()()
	{
		while (_flcPlayer->getFrameCount() >= introSoundTrack[trackPosition].frameNumber)
		{
			int command = introSoundTrack[trackPosition].sound;

			if (command & 0x200)
			{
#ifndef __NO_MUSIC
				switch(command)
				{
				case 0x200:
					Log(LOG_DEBUG) << "Playing gmintro1";
					m = mod->getMusic("GMINTRO1");
					m->play(1);
					break;
				case 0x201:
					Log(LOG_DEBUG) << "Playing gmintro2";
					m = mod->getMusic("GMINTRO2");
					m->play(1);
					break;
				case 0x202:
					Log(LOG_DEBUG) << "Playing gmintro3";
					m = mod->getMusic("GMINTRO3");
					m->play(1);
					//Mix_HookMusicFinished(_FlcPlayer::stop);
					break;
				}
#endif
			}
			else if (command & 0x400)
			{
				int newSpeed = (command & 0xff);
				_flcPlayer->setHeaderSpeed(newSpeed);
				Log(LOG_DEBUG) << "Frame delay now: " << newSpeed;
			}
			else if (command <= 0x19)
			{
				for (soundInFile **sounds = introSounds; *sounds; ++sounds) // try hybrid sound set, then intro.cat or sample3.cat alone
				{
					soundInFile *sf = (*sounds) + command;
					int channel = trackPosition % 4; // use at most four channels to play sound effects
					double ratio = (double)Options::soundVolume / MIX_MAX_VOLUME;
					Log(LOG_DEBUG) << "playing: " << sf->catFile << ":" << sf->sound << " for index " << command;
					s = mod->getSound(sf->catFile, sf->sound, false);
					if (s)
					{
						s->play(channel);
						Mix_Volume(channel, sf->volume * ratio);
						break;
					}
					else Log(LOG_DEBUG) << "Couldn't play " << sf->catFile << ":" << sf->sound;
				}
			}
			++trackPosition;
		}

	}
Example #7
0
bool PedInstance::createActQFindEnemy(actionQueueGroupType &as) {
    as.state = 1;
    actionQueueType aq;
    aq.as = PedInstance::pa_smNone;
    aq.group_desc = PedInstance::gd_mThink;
    aq.state = 1;
    aq.ot_execute = PedInstance::ai_aFindEnemy;
    as.actions.push_back(aq);
    pedWeaponToUse pw_to_use;
    Mod *pMod = slots_[Mod::MOD_BRAIN];
    if (getMainType() == PedInstance::m_tpAgent) {
        aq.multi_var.enemy_var.pw_to_use.use_ranks = pMod || (!isOurAgent())
            ? true: false;
        WeaponInstance *wi = selectedWeapon();
        if (wi && wi->usesAmmo() && wi->ammoRemaining() == 0) {
            wi = NULL;
            setSelectedWeapon(-1);
        }
        if (wi && wi->canShoot()) {
            if (pMod) {
                // This overrides selected weapon
                // might be confusing for player
                if (pMod->getVersion() == Mod::MOD_V3) {
                    pw_to_use.desc = 5;
                    pw_to_use.wpn.dmg_type = wi->dmgType();
                } else if (pMod->getVersion() == Mod::MOD_V2) {
                    pw_to_use.desc = 4;
                    pw_to_use.wpn.dmg_type = wi->dmgType();
                } else {
                    // Mod::MOD_V1
                    pw_to_use.desc = 3;
                    pw_to_use.wpn.wpn_type = wi->getWeaponType();
                }
            } else {
                pw_to_use.desc = 2;
                pw_to_use.wpn.wi = wi;
            }
        } else {
            pw_to_use.desc = 5;
            pw_to_use.wpn.dmg_type = MapObject::dmg_Physical;
        }
    } else {
        pw_to_use.desc = 5;
        pw_to_use.wpn.dmg_type = MapObject::dmg_Physical;
    }
    if (createActQFiring(as, NULL, NULL, false, 0, &pw_to_use))
        as.actions.back().state |= 64;
    else
        return false;
    createActQFollowing(as, NULL, 1);
    as.actions.back().state |= 64;
    return true;
}
Example #8
0
void Instance::DeleteMLMod(size_t index)
{
	Mod *mod = &mlModList[index];
	if (wxRemoveFile(mod->GetFileName().GetFullPath()))
	{
		mlModList.erase(mlModList.begin() + index);
	}
	else
	{
		wxLogError(_("Failed to delete mod."));
	}
}
Example #9
0
Mod& Mod::operator*=(const Mod& m){ //repeated doubling is used for efficiency and prevention of overflow
	long b = m.val();
	Mod temp = 0; 
	while (b > 0){
		if (b % 2 == 1){
			temp += *this;
		}
		*this += *this;
		b = b / 2;
	}
	x = temp.val();
	return *this;
}
Example #10
0
bool Mod::operator==(const Mod& mod){
	if( get_a() == mod.get_a() ){
		return true;
	}else{
		return false;
	}
}
Example #11
0
bool Mod::replace(Mod &with)
{
	if (!destroy())
		return false;
	bool success = false;
	auto t = with.type();

	if (t == MOD_ZIPFILE || t == MOD_SINGLEFILE)
	{
		QLOG_DEBUG() << "Copy: " << with.m_file.filePath() << " to " << m_file.filePath();
		success = QFile::copy(with.m_file.filePath(), m_file.filePath());
	}
	if (t == MOD_FOLDER)
	{
		success = copyPath(with.m_file.filePath(), m_file.path());
	}
	if (success)
	{
		m_name = with.m_name;
		m_mmc_id = with.m_mmc_id;
		m_mod_id = with.m_mod_id;
		m_version = with.m_version;
		m_mcversion = with.m_mcversion;
		m_description = with.m_description;
		m_authors = with.m_authors;
		m_credits = with.m_credits;
		m_homeurl = with.m_homeurl;
		m_type = with.m_type;
		m_file.refresh();
	}
	return success;
}
Example #12
0
/**
* Load stuff from the currently loaded mods into some arrays.
**/
void Menu::loadModBits(UIUpdate* ui)
{
	Mod* mod = GEng()->mm->getSupplOrBase();

	this->gm->loadModBits(ui);

	// Logo
	delete(this->logo);
	this->logo = this->render->loadSprite("menu/logo.png", mod);
	if (!this->logo) {
		this->logo = this->render->loadSprite("menu/logo.png", GEng()->mm->getBase());
	}

	// Background
	delete(this->bg);
	this->bg = this->render->loadSprite("menu/bg.jpg", mod);
	if (!this->bg) {
		this->bg = this->render->loadSprite("menu/bg.jpg", GEng()->mm->getBase());
	}

	// Rotating model
	delete(this->play);
	this->model = NULL;
	this->play = NULL;
	if (!mod->getMenuModelName().empty()) {
		this->model_rot = -10.0f;
		this->model = mod->getAssimpModel(mod->getMenuModelName());
		if (this->model != NULL) {
			this->play = new AnimPlay(this->model);
		}
	}

	// Font always loaded from base mod
	if (this->font == NULL) {
		this->font = new OpenGLFont(this->render, "DejaVuSans", GEng()->mm->getBase(), 20.0f * GEng()->gui_scale);
	}

	this->loadMenuItems();
}
Example #13
0
/**
* Load main menu items
**/
void Menu::loadMenuItems()
{
	Mod* mod = GEng()->mm->getSupplOrBase();
	int offsetX = 40;
	int menus = 4 + mod->hasArcade() * 3 + mod->hasCampaign();
	int offsetY = MIN(40, render->getHeight() / (menus + 1)) * GEng()->gui_scale;
	int offsetYFirst = MIN(60, render->getHeight() / (menus + 1));

	this->menuClear();

	int y = render->getHeight() - offsetYFirst;
	this->menuAdd(_(STRING_MENU_QUIT), offsetX, y, MC_QUIT);

	y -= offsetY;
	this->menuAdd(_(STRING_MENU_HELP), offsetX, y, MC_HELP);

	y -= offsetY;
	this->menuAdd(_(STRING_MENU_MODS), offsetX, y, MC_MODS);

	y -= offsetY;
	this->menuAdd(_(STRING_MENU_SETTINGS), offsetX, y, MC_SETTINGS);

	if (mod->hasArcade()) {
		y -= offsetY;
		this->menuAdd(_(STRING_MENU_NETWORK), offsetX, y, MC_NETWORK);

		y -= offsetY;
		this->menuAdd(_(STRING_MENU_SPLIT), offsetX, y, MC_SPLITSCREEN);

		y -= offsetY;
		this->menuAdd(_(STRING_MENU_SINGLE), offsetX, y, MC_SINGLEPLAYER);
	}

	if (mod->hasCampaign()) {
		y -= offsetY;
		this->menuAdd(_(STRING_MENU_CAMPAIGN), offsetX, y, MC_CAMPAIGN);
	}
}
Example #14
0
void showWebsiteForMod(QWidget *parentDlg, Mod &m)
{
	QString url = m.homeurl();
	if (url.size())
	{
		// catch the cases where the protocol is missing
		if (!url.startsWith("http"))
		{
			url = "http://" + url;
		}
		QDesktopServices::openUrl(url);
	}
	else
	{
		CustomMessageBox::selectable(
			parentDlg, parentDlg->tr("How sad!"),
			parentDlg->tr("The mod author didn't provide a website link for this mod."),
			QMessageBox::Warning);
	}
}
Example #15
0
bool Mod::strongCompare(const Mod &other) const
{
	return mmc_id() == other.mmc_id() && version() == other.version() && type() == other.type();
}
Example #16
0
bool operator!=(const Mod& a, const Mod& b) {
	return a.val() != b.val();
}
Example #17
0
bool operator==(const Mod& a, const Mod& b) {
	return a.val() == b.val();
}
Example #18
0
Mod::Mod(const Mod& m) {
	this->x = m.val();
}
Example #19
0
bool PedInstance::createActQFiring(actionQueueGroupType &as, PathNode *tpn,
    ShootableMapObject *tsmo, bool forced_shot, uint32 make_shots, 
    pedWeaponToUse *pw_to_use, int32 value)
{
    as.state = 1;
    actionQueueType aq;
    aq.group_desc = PedInstance::gd_mFire;
    bool can_shoot = false;
    bool does_phys_dmg = false;
    Weapon *pWeapon = NULL;
    if (pw_to_use) {
        switch (pw_to_use->desc) {
            case 1:
                pw_to_use->wpn.wi = weapon(pw_to_use->wpn.indx);
                can_shoot = pw_to_use->wpn.wi->canShoot();
                does_phys_dmg = pw_to_use->wpn.wi->doesPhysicalDmg();
                pw_to_use->desc = 2;
                break;
            case 2:
                // pointer
                can_shoot = pw_to_use->wpn.wi->canShoot();
                does_phys_dmg = pw_to_use->wpn.wi->doesPhysicalDmg();
                break;
            case 3:
                // weapon type
                pWeapon = g_App.weapons().getWeapon(pw_to_use->wpn.wpn_type);
                can_shoot = pWeapon->canShoot();
                does_phys_dmg = pWeapon->doesPhysicalDmg();
                break;
            case 4:
                // strict damage type
                if(!g_App.weapons().checkDmgTypeCanShootStrict(
                    pw_to_use->wpn.dmg_type, can_shoot)) {
                    return false;
                }
                does_phys_dmg = (pw_to_use->wpn.dmg_type
                    & MapObject::dmg_Physical) != 0;
                break;
            case 5:
                // non-strict damage type
                if(!g_App.weapons().checkDmgTypeCanShootNonStrict(
                    pw_to_use->wpn.dmg_type, can_shoot)) {
                    return false;
                }
                does_phys_dmg = (pw_to_use->wpn.dmg_type
                    & MapObject::dmg_Physical) != 0;
                break;
        }
        aq.multi_var.enemy_var.pw_to_use = *pw_to_use;
    } else {
        WeaponInstance *wi = selectedWeapon();
        if (wi) {
            can_shoot = wi->canShoot();
            does_phys_dmg = wi->doesPhysicalDmg();
            Mod *pMod = slots_[Mod::MOD_BRAIN];
            if (pMod) {
                if (pMod->getVersion() == Mod::MOD_V3) {
                    aq.multi_var.enemy_var.pw_to_use.desc = 5;
                    aq.multi_var.enemy_var.pw_to_use.wpn.dmg_type = wi->dmgType();
                } else if (pMod->getVersion() == Mod::MOD_V2) {
                    aq.multi_var.enemy_var.pw_to_use.desc = 4;
                    aq.multi_var.enemy_var.pw_to_use.wpn.dmg_type = wi->dmgType();
                } else {
                    aq.multi_var.enemy_var.pw_to_use.desc = 3;
                    aq.multi_var.enemy_var.pw_to_use.wpn.wpn_type = wi->getWeaponType();
                }
            } else {
                aq.multi_var.enemy_var.pw_to_use.desc = 2;
                aq.multi_var.enemy_var.pw_to_use.wpn.wi = wi;
            }
        } else
            return false;
    }

    if (!can_shoot)
        return false;

    aq.multi_var.enemy_var.pw_to_use.use_ranks = slots_[Mod::MOD_BRAIN] ? true: false;
    aq.multi_var.enemy_var.value = value;
    aq.multi_var.enemy_var.forced_shot = forced_shot;
    if (does_phys_dmg) {
        aq.as = PedInstance::pa_smFiring;
        // TODO: use condition to set more information for action execution
        // continuos shooting until ammo ends(or all weapons ammo),
        // until target destroyed, type of damage that will complete action
        aq.multi_var.enemy_var.make_shots = make_shots;
        aq.multi_var.enemy_var.shots_done = 0;
        if (tpn) {
            aq.t_pn = *tpn;
            aq.ot_execute = PedInstance::ai_aAttackLocation;
            aq.t_smo = NULL;
        } else {
            aq.t_smo = tsmo;
            aq.ot_execute = PedInstance::ai_aDestroyObject;
        }
    } else {
        if (tsmo && tsmo->majorType() == MapObject::mjt_Ped) {
            aq.as = PedInstance::pa_smNone;
            aq.multi_var.enemy_var.make_shots = make_shots;
            aq.multi_var.enemy_var.shots_done = 0;
            aq.t_smo = tsmo;
            aq.ot_execute = PedInstance::ai_aAquireControl;
        } else
            return false;
    }
    aq.state = 1;
    aq.ot_execute |= PedInstance::ai_aWait;
    aq.multi_var.time_var.desc = 1;
    as.actions.push_back(aq);
    return true;
}
Example #20
0
bool Mod::operator ==(const Mod &other) const
{
	return GetFileName().SameAs(other.GetFileName());
}
Example #21
0
Mod operator*(const Mod& mod1, const Mod& mod2){
	return Mod( mod1.get_a() * mod2.get_a() );
}
Example #22
0
bool Mod::operator==(const Mod &other) const
{
	return mmc_id() == other.mmc_id();
}
Example #23
0
bool operator!=(long t, const Mod& m){
	return (!(t == m.val()));
}
Example #24
0
bool operator!=(const Mod& a, const Mod& b){
	return (!(a.val() == b.val()));
}