Exemplo n.º 1
0
void PokeTeam::load()
{
    PokeGeneral::load();
    /*set the default gender & ability */
    if (genderAvail() == Pokemon::NeutralAvail)
    {
        gender() = Pokemon::Neutral;
    }
    else if (genderAvail() == Pokemon::FemaleAvail)
    {
        gender() = Pokemon::Female;
    }
    else if (genderAvail() == Pokemon::MaleAvail)
    {
        gender() = Pokemon::Male;
    } else
    {
        if (gender() == Pokemon::Neutral) {
            /* Gen 2 has to do with IVs, so since we set max Att IV by default, it's male */
            gender() = gen() <= 2 ? Pokemon::Male : (true_rand() % 2 ? Pokemon::Male : Pokemon::Female);
        }
    }

    if (ability() == 0 || !abilities().contains(ability())) {
        ability() = abilities().ab(0);
    }

    /* Crashes on headless servers / etc otherwise */
    if (PokemonInfoConfig::getFillMode() == FillMode::Client) {
        PokeGraphics::load(gender(), false);
        PokeGraphics::loadIcon(num());
    }
}
Exemplo n.º 2
0
void PokePersonal::reset()
{
    num() = Pokemon::NoPoke;
    level() = 100;
    for (int i = 0; i < 4; i++)
        m_moves[i] = 0;
    happiness() = 0;
    shiny() = false;
    gender() = Pokemon::Neutral;
    ability() = 0;
    nickname() = "";
    nature() = 0;
    item() = 0;

    for (int i = 0; i < 6; i ++) {
        if (gen() >= 3) {
            m_EVs[i] = 0;
            m_DVs[i] = 31;
        }
        else {
            m_EVs[i] = 255;
            m_DVs[i] = 15;
        }
    }
}
Exemplo n.º 3
0
void CPoltergeist::net_Destroy()
{
	inherited::net_Destroy();
	Energy::disable();

	ability()->on_destroy();
}
Exemplo n.º 4
0
void CPoltergeist::UpdateCL()
{
	inherited::UpdateCL();
	def_lerp(m_height, target_height, HEIGHT_CHANGE_VELOCITY, client_update_fdelta());
	
	ability()->update_frame	();
}
void PokeTeam::load()
{
    PokeGeneral::load();
    /*set the default gender & ability */
    if (genderAvail() == Pokemon::NeutralAvail)
    {
        gender() = Pokemon::Neutral;
    }
    else if (genderAvail() == Pokemon::FemaleAvail)
    {
        gender() = Pokemon::Female;
    }
    else if (genderAvail() == Pokemon::MaleAvail)
    {
        gender() = Pokemon::Male;
    } else
    {
        gender() = true_rand() % 2 ? Pokemon::Male : Pokemon::Female;
    }

    ability() = abilities().ab(0);
    nickname() = PokemonInfo::Name(num());
    PokeGraphics::load(gender(), false);
    PokeGraphics::loadIcon(num());
}
Exemplo n.º 6
0
void CPoltergeist::shedule_Update(u32 dt)
{
	inherited::shedule_Update(dt);
	CTelekinesis::schedule_update();
	Energy::schedule_update();

	UpdateHeight();

	ability()->update_schedule();
}
Exemplo n.º 7
0
BOOL CPoltergeist::net_Spawn (CSE_Abstract* DC) 
{
	if (!inherited::net_Spawn(DC)) return(FALSE);

	// спаунится нивидимым
	setVisible		(false);
	ability()->on_hide();
	

	return			(TRUE);
}
Exemplo n.º 8
0
void CPoltergeist::Hide()
{
	if (state_invisible) return;
	
	state_invisible		= true;	
	setVisible			(false);
	
	m_current_position	= Position		();
	character_physics_support()->movement()->DestroyCharacter();

	ability()->on_hide	();
}
Exemplo n.º 9
0
// -------- begin of function ItemRes::can_equip ----------//
//
int ItemRes::can_equip( short itemId, int unitId, Skill &skill )
{
	if( !itemId )
		return 0;

	if( !unit_res[unitId]->race_id || unitId == UNIT_WAGON )		// only human or monster can equip
		return 0;

	err_when( itemId > ITEM_TYPE_COUNT );

	// if an item has ITEM_ABILITY_ARROW_DAMAGE but no ITEM_ABILITY_DAMAGE
	// it must be wear by an archer unit

	Item tempItem( itemId, 0 );
	if( ability( tempItem, ITEM_ABILITY_ARROW_DAMAGE) > 0
		&& ability( tempItem, ITEM_ABILITY_DAMAGE) == 0 )
	{
		// find unit attack record to see if any range attack

		int canRangeAttack = 0;
		UnitInfo *unitInfo = unit_res[unitId];
		for( int curAttack = unitInfo->attack_count-1; curAttack >= 0; --curAttack )
		{
			AttackInfo *attackInfo = 
				unit_res.get_attack_info( unitInfo->first_attack + curAttack );
			if( attackInfo->attack_range > 1 
				&& skill.actual_skill_level(NULL) >= attackInfo->combat_level )
			{
				canRangeAttack = 1;
			}
		}

		if( !canRangeAttack )
			return 0;
	}

	return 1;
}
Exemplo n.º 10
0
void CPoltergeist::Show()
{
	if (!state_invisible) return;

	state_invisible = false;
	
	setVisible(TRUE);

	com_man().seq_run(anim().get_motion_id(eAnimMiscAction_00));

	Position() = m_current_position;
	character_physics_support()->movement()->SetPosition(Position());
	character_physics_support()->movement()->CreateCharacter();
	
	ability()->on_show	();
}
Exemplo n.º 11
0
QDomElement & PokeTeam::toXml(QDomElement &el) const
{
    const_cast<PokeTeam*>(this)->sanityCheck();

    QDomDocument doc;

    el.setAttribute("Nickname", nickname());
    el.setAttribute("Num", num().pokenum);
    el.setAttribute("Item", item());
    el.setAttribute("Ability", ability());
    el.setAttribute("Nature", nature());
    el.setAttribute("Gender", gender());
    el.setAttribute("Shiny", shiny());
    el.setAttribute("Happiness", happiness());
    el.setAttribute("Forme", num().subnum);
    el.setAttribute("Lvl", level());
    el.setAttribute("Gen", gen().num);
    el.setAttribute("SubGen", gen().subnum);

    for(int i = 0; i < 4; i++)
    {
        QDomElement move = doc.createElement("Move");
        el.appendChild(move);

        QDomText name = doc.createTextNode(QString("%1").arg(this->move(i)));
        move.appendChild(name);
    }
    for(int i = 0; i < 6; i++)
    {
        QDomElement Dv = doc.createElement("DV");
        el.appendChild(Dv);

        QDomText Dvname = doc.createTextNode(QString("%1").arg(DV(i)));
        Dv.appendChild(Dvname);
    }
    for(int i = 0; i < 6; i++)
    {
        QDomElement Ev = doc.createElement("EV");
        el.appendChild(Ev);

        QDomText Evname = doc.createTextNode(QString("%1").arg(EV(i)));
        Ev.appendChild(Evname);
    }

    return el;
}
Exemplo n.º 12
0
void UGSAbilitiesComponent::InitializeAbilityBook()
{
	int32 SetCounter = 0;
	for (FGSAbilityBookConfig& set : AbilityBookSlotsConfig)
	{
		FGSAbilityBookTab setIn;
		setIn.TabIndex = SetCounter;
		for (int32 Index = 0; Index < set.SlotNumber; Index++)
		{
			FGSAbilityBookSlot ability(Index, SetCounter);
			setIn.Abilities.Add(ability);

		}
		OwnedAbilities.AbilitiesTab.Add(setIn);
		SetCounter++;
	}

}
Exemplo n.º 13
0
void CPoltergeist::Die(CObject* who)
{
	if (m_tele) {
		if (state_invisible) {
			setVisible(true);

			if (PPhysicsShell()) {
				Fmatrix M;
				M.set							(XFORM());
				M.translate_over				(m_current_position);
				PPhysicsShell()->SetTransform	(M);
			} else 
				Position() = m_current_position;
		}
	}

	inherited::Die				(who);
	Energy::disable				();

	ability()->on_die			();
}
Exemplo n.º 14
0
int main(){

    const int B = 3;
    std::vector<std::vector<int> > ability(B);

    int n; scanf("%d\n", &n);
    for(int p = 1; p <= n; p++){
        int current; scanf("%d", &current);
        ability[current - 1].push_back(p);
    }

    int total = ability[0].size();
    for(int p = 1; p < B; p++){if(ability[p].size() < total){total = ability[p].size();}}

    printf("%d\n", total);
    for(int p = 0; p < total; p++){
        for(int q = 0; q < B; q++){
            printf("%d ", ability[q][p]);
        }
        puts("");
    }

    return 0;
}
Exemplo n.º 15
0
void PokeTeam::loadFromXml(const QDomElement &poke, int version)
{
    if (poke.hasAttribute("Gen")) {
        setGen(Pokemon::gen(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt(),
                            poke.attribute("SubGen", QString::number(GenInfo::NumberOfSubgens(poke.attribute("Gen", QString::number(GenInfo::GenMax())).toInt())-1)).toInt()));
    }

    reset();

    /* Code to import old teams which had different formes registered as different pokemon numbers */
    int num = poke.attribute("Num").toInt();
    int forme = poke.attribute("Forme").toInt();

    if (gen().num == 4 && num > 493 && forme == 0 && !PokemonInfo::Exists(Pokemon::uniqueId(num, 0), 4)) {
        //Old way
        int indexes[] = {
            479,479,479,479,479,386,386,386,413,413,492,487
        };
        int formes[] = {
            1,2,3,4,5,1,2,3,1,2,1,1
        };

        int i = num - 494;

        setNum(Pokemon::uniqueId(indexes[i], formes[i]));
    } else {
        setNum(Pokemon::uniqueId(num, forme));
    }

    bool outdated = gen() < 5 && version < 1;

    load();
    nickname() = poke.attribute("Nickname");
    item() = poke.attribute("Item").toInt();
    ability() = poke.attribute("Ability").toInt();
    if (outdated) {
        ability() = AbilityInfo::ConvertFromOldAbility(ability());
    }
    nature() = poke.attribute("Nature").toInt();
    gender() = poke.attribute("Gender").toInt();
    shiny() = QVariant(poke.attribute("Shiny")).toBool();
    happiness() = poke.attribute("Happiness").toInt();
    level() = poke.attribute("Lvl").toInt();

    int cptMove=0;

    QDomElement moveElement = poke.firstChildElement("Move");
    while(!moveElement.isNull())
    {
        int movenum = moveElement.text().toInt();
        if (outdated) {
            movenum = MoveInfo::ConvertFromOldMove(movenum);
        }
        setMove(movenum,cptMove,false);
        cptMove++;
        moveElement = moveElement.nextSiblingElement("Move");
    }
    int cptDV=0;
    QDomElement DVElement = poke.firstChildElement("DV");
    while(!DVElement.isNull())
    {
        setDV(outdated ? NatureInfo::ConvertToStat(cptDV) : cptDV,DVElement.text().toInt());
        cptDV++;
        DVElement = DVElement.nextSiblingElement("DV");
    }
    int cptEV=0;
    QDomElement EVElement = poke.firstChildElement("EV");
    while(!EVElement.isNull())
    {
        setEV(outdated ? NatureInfo::ConvertToStat(cptEV) : cptEV,EVElement.text().toInt());
        cptEV++;
        EVElement = EVElement.nextSiblingElement("EV");
    }
}
Exemplo n.º 16
0
void PokePersonal::runCheck()
{
    if (!PokemonInfo::Exists(num(), gen())) {
        reset();
        return;
    }

    if (!PokemonInfo::AFormesShown(num())) {
        num() = num().original();
    }

    if (gen() <= 2) {
        ability() = 0;
        nature() = 0;
    } else {
        AbilityGroup ab = PokemonInfo::Abilities(num(), gen());

        if (ability() == 0 || (ability() != ab.ab(2) && ability() != ab.ab(1)))
            ability() = ab.ab(0);
    }

    if (gen().num == 2)
        controlGender();

    if (!ItemInfo::Exists(item(), gen())) {
        item() = 0;
    }

    for (int i = 0; i < 6; i++)
        controlEVs(i);

    if (gen() <= 2) {
        for (int i = 0; i < 6; i++) {
            if (DV(i) >= 15)
                setDV(i, 15);
        }
    }

    if (gen().num == 2) {
        setEV(SpDefense, EV(SpAttack));
        setDV(SpDefense, DV(SpAttack));
    }

    int avail = PokemonInfo::Gender(num());

    if (avail != Pokemon::MaleAndFemaleAvail) {
        gender() = avail;
    } else if (gender() == Pokemon::Neutral){
        gender() = Pokemon::Male;
    }

    int minLevel = PokemonInfo::AbsoluteMinLevel(num(), gen());

    if (MoveSetChecker::enforceMinLevels && level() < minLevel) {
        level() = minLevel;
    }

    QSet<int> invalidMoves;

    MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves);

    while (invalidMoves.size() > 0) {
        for (int i = 0; i < 4; i++) {
            if (invalidMoves.contains(move(i))) {
                setMove(0, i, false);
            }
        }
        invalidMoves.clear();

        MoveSetChecker::isValid(num(), gen(), move(0), move(1), move(2), move(3), ability(), gender(), level(), false, &invalidMoves);
    }

    if (num().pokenum == Pokemon::Keldeo) {
        if (move(0) == Move::SecretSword || move(1) == Move::SecretSword || move(2) == Move::SecretSword || move(3) == Move::SecretSword) {
            num() = Pokemon::Keldeo_R;
        } else {
            num() = num().original();
        }
    }
}
Exemplo n.º 17
0
void PokePersonal::setMove(int moveNum, int moveSlot, bool check) throw(QString)
{
    if (moveNum == move(moveSlot))
        return;

    if (check && moveNum != 0) {
        m_moves[moveSlot] = Move::NoMove;

        if (hasMove(moveNum))
            throw QObject::tr("%1 already has move %2.").arg(nickname(), MoveInfo::Name(moveNum));
        else if (gen() > 1 && !PokemonInfo::Moves(num(), gen()).contains(moveNum))
            throw QObject::tr("%1 can't learn %2.").arg(nickname(), MoveInfo::Name(moveNum));
    }

    m_moves[moveSlot] = moveNum;

    if (check) {
        QSet<int> invalid_moves;
        QString error;
        if (!MoveSetChecker::isValid(num(), gen(), m_moves[0],m_moves[1],m_moves[2],m_moves[3],ability(),gender(),level(),false,&invalid_moves, &error)) {
            m_moves[moveSlot] = Move::NoMove;
            throw error;
        }
    }
}
Exemplo n.º 18
0
void Stat::Save( moPropBagRef& propBag )
{
    // Do not save if deleted
    //
    if( f_deleted ) return;

    moPropStringRef id               ( f_idName               );
    moPropStringRef abilityId        ( f_abilityIdName        );
    moPropStringRef name             ( f_nameName             );
    moPropIntRef    dice             ( f_diceName             );
    moPropIntRef    faces            ( f_facesName            );
    moPropIntRef    modifier         ( f_modifierName         );
    moPropIntRef    deleted          ( f_deletedName          );
    moPropStringRef accel            ( f_accelName            );
    moPropIntRef    showMonsterOnHUD ( f_showMonsterOnHUDName );
    moPropIntRef    showOnToolbar    ( f_showOnToolbarName    );
    moPropIntRef    showOnHUD        ( f_showOnHUDName        );
    moPropIntRef    internal         ( f_internalName         );
    moPropIntRef    ability          ( f_abilityName          );
    moPropIntRef    order            ( f_orderName            );

    // Create the properties first
    //
    id        		.NewProp();
    abilityId 		.NewProp();
    name      		.NewProp();
    dice      		.NewProp();
    faces     		.NewProp();
    modifier  		.NewProp();
    deleted   		.NewProp();
    accel     		.NewProp();
    showMonsterOnHUD.NewProp();
    showOnToolbar	.NewProp();
    showOnHUD		.NewProp();
    internal		.NewProp();
    ability			.NewProp();
    order			.NewProp();
    //
    id        		= static_cast<moWCString>(moName(f_id));
    abilityId 		= static_cast<moWCString>(moName(f_abilityId));
    name      		= f_name.c_str();
    dice      		= f_dice;
    faces     		= f_faces;
    modifier  		= f_modifier;
    deleted   		= f_deleted? 1: 0;
    accel     		= f_accel.c_str();
    showMonsterOnHUD= f_showMonsterOnHUD;
    showOnToolbar	= f_showOnToolbar;
    showOnHUD		= f_showOnHUD;
    internal		= f_internal;
    ability			= f_ability;
    order			= f_order;

    propBag += id;
    propBag += abilityId;
    propBag += name;
    propBag += dice;
    propBag += faces;
    propBag += modifier;
    propBag += deleted;
    propBag += accel;
    propBag += showMonsterOnHUD;
    propBag += showOnToolbar;
    propBag += showOnHUD;
    propBag += internal;
    propBag += ability;
    propBag	+= order;
}
Exemplo n.º 19
0
void CPoltergeist::Hit(SHit* pHDS)
{
	ability()->on_hit(pHDS);
	inherited::Hit(pHDS);
}
Exemplo n.º 20
0
void Stat::Load( moPropBagRef& propBag )
{
    moPropStringRef id               ( f_idName               );
    moPropStringRef abilityId        ( f_abilityIdName        );
    moPropIntRef    legacyId         ( f_legacyIdName         );
    moPropIntRef    legacyType       ( f_legacyTypeName       );
    moPropStringRef name             ( f_nameName             );
    moPropIntRef    dice             ( f_diceName             );
    moPropIntRef    faces            ( f_facesName            );
    moPropIntRef    modifier         ( f_modifierName         );
    moPropIntRef    deleted          ( f_deletedName          );
    moPropStringRef accel            ( f_accelName            );
    moPropIntRef    showOnToolbar    ( f_showOnToolbarName    );
    moPropIntRef    showOnHUD        ( f_showOnHUDName        );
    moPropIntRef    showMonsterOnHUD ( f_showMonsterOnHUDName );
    moPropIntRef    internal         ( f_internalName         );
    moPropIntRef    ability          ( f_abilityName          );
    moPropIntRef    order            ( f_orderName            );

    id       			.Link( propBag );
    abilityId			.Link( propBag );
    legacyId 			.Link( propBag );
    legacyType			.Link( propBag );
    name     			.Link( propBag );
    dice     			.Link( propBag );
    faces    			.Link( propBag );
    modifier 			.Link( propBag );
    deleted  			.Link( propBag );
    accel    			.Link( propBag );
    showOnToolbar		.Link( propBag );
    showOnHUD			.Link( propBag );
    showMonsterOnHUD	.Link( propBag );
    internal			.Link( propBag );
    ability				.Link( propBag );
    order				.Link( propBag );

    if( id.HasProp() )
    {
        f_id 			= moName( static_cast<moWCString>(id) );
    }
    else if( legacyId.HasProp() && legacyType.HasProp() )
    {
        f_legacyId 		= legacyId;
        f_legacyType	= legacyType;
    }
    else
    {
        throw moError( "Bad Stat data for object!" );
    }

    if( abilityId.HasProp() )
    {
        f_abilityId = moName( static_cast<moWCString>(abilityId) );
    }
    else
    {
        f_abilityId = moName( "UNNAMED" );
    }

    f_name     = static_cast<moWCString>(name).c_str();
    f_dice     = dice;
    f_faces    = faces;
    f_modifier = modifier;
    f_deleted  = deleted? true: false;
    //
    if( showMonsterOnHUD.HasProp() && showOnToolbar.HasProp() && showOnHUD.HasProp() )
    {
        f_showOnToolbar		= showOnToolbar? true: false;
        f_showOnHUD			= showOnHUD? true: false;
        f_showMonsterOnHUD	= showMonsterOnHUD? true: false;
    }
    //
    if( accel.HasProp() )
    {
        // This is a bug in moProps--if a blank string, then we should have a property
        //
        f_accel = static_cast<moWCString>(accel).c_str();
    }

    if( internal.HasProp() ) f_internal = internal;
    if( ability.HasProp()  ) f_ability  = ability;
    if( order.HasProp()    ) f_order    = order;

    if( f_legacyId != -1 )
    {
        f_showMonsterOnHUD = f_showOnToolbar = f_showOnHUD = f_internal = f_ability = false;

        auto statMgr = StatManager::Instance().lock();
        assert(statMgr);

        // We must assign the custom stat value for later editing in the StatEditor.
        // The idea is that certain stats are fixed, immutable, but others, like
        // Spot/Listen/Will are custom, plus new stats are also.
        //
        if( f_name == "Spot" 		) {
            f_id = statMgr->spotId();
            f_showOnToolbar = true;
            f_accel = "s";
        }
        else if( f_name == "Listen"		) {
            f_id = statMgr->listenId();
            f_showOnToolbar = true;
            f_accel = "l";
        }
        else if( f_name == "Will"		) {
            f_id = statMgr->willId();
            f_showOnToolbar = true;
            f_accel = "w";
        }
        else if( f_name == "Init"  		) {
            f_id = statMgr->initId();
            f_internal = true;
        }
        else if( f_name == "Hit Points"	) {
            f_id = statMgr->hpId();
            f_internal = true;
        }
        else if( f_name == "Level" 		) {
            f_id = statMgr->levelId();
            f_internal = true;
        }

#ifdef DEBUG
        std::cerr	<< "Legacy Id: " 	 << f_legacyId
                    << ", Legacy Type: " << f_legacyType
                    << ", ID name= " 	 << f_name.c_str()
                    << ", NEW ID=" 		 << moWCString(moName(f_id)).c_str()
                    << std::endl;
#endif
    }

    f_statChanged.emit();
}