~ubuntu-branches/ubuntu/trusty/manaplus/trusty

« back to all changes in this revision

Viewing changes to src/being/being.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-10-07 10:26:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131007102614-tg2zjdz8vmtl6n7i
Tags: 1.3.9.29-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
    mSpecialParticle(nullptr),
148
148
    mX(0),
149
149
    mY(0),
 
150
    mSortOffsetY(0),
 
151
    mOffsetY(0),
 
152
    mOldHeight(0),
150
153
    mDamageTaken(0),
151
154
    mHP(0),
152
155
    mMaxHP(0),
645
648
    {
646
649
        if (attacker)
647
650
        {
648
 
            const ItemInfo *attackerWeapon = attacker->getEquippedWeapon();
 
651
            const ItemInfo *const attackerWeapon
 
652
                = attacker->getEquippedWeapon();
649
653
            if (attackerWeapon && attacker->getType() == PLAYER)
650
654
            {
651
655
                if (type == MISS)
660
664
                const BeingInfo *const info = attacker->getInfo();
661
665
                if (info)
662
666
                {
663
 
                    const Attack *atk = info->getAttack(attackId);
 
667
                    const Attack *const atk = info->getAttack(attackId);
664
668
                    if (atk)
665
669
                    {
666
670
                        if (type == MISS)
765
769
    if (this != player_node)
766
770
        setAction(Being::ATTACK, 1);
767
771
 
768
 
    SkillInfo *const skill = skillDialog->getSkill(skillId);
 
772
    const SkillInfo *const skill = skillDialog->getSkill(skillId);
769
773
    const SkillData *const data = skill
770
774
        ? skill->getData1(skillLevel) : nullptr;
771
775
    if (data)
1058
1062
    if (!weapon)
1059
1063
        return SpriteAction::ATTACK;
1060
1064
 
1061
 
    if (serverVersion < 0 || !weapon)
 
1065
    if (serverVersion < 0)
1062
1066
    {
1063
1067
        return weapon->getAttackAction();
1064
1068
    }
1081
1085
    if (!attack1)
1082
1086
        return SpriteAction::ATTACK;
1083
1087
 
1084
 
    if (serverVersion < 0 || !attack1)
 
1088
    if (serverVersion < 0)
1085
1089
    {
1086
1090
        return attack1->mAction;
1087
1091
    }
1352
1356
    else
1353
1357
        mSpeed = mWalkSpeed.x;
1354
1358
 
 
1359
    if (mX != pos.x || mY != pos.y)
 
1360
        mOldHeight = mMap->getHeightOffset(mX, mY);
1355
1361
    mX = pos.x;
1356
1362
    mY = pos.y;
 
1363
    const uint8_t height = mMap->getHeightOffset(mX, mY);
 
1364
    mOffsetY = height - mOldHeight;
1357
1365
    setAction(MOVE);
1358
1366
}
1359
1367
 
1514
1522
            }
1515
1523
        }
1516
1524
 
1517
 
        // Update pixel coordinates
1518
 
        setPosition(static_cast<float>(mX * 32 + 16 + getXOffset()),
1519
 
                    static_cast<float>(mY * 32 + 32 + getYOffset()));
 
1525
        if (mAction == MOVE)
 
1526
        {
 
1527
            const int xOffset = getXOffset();
 
1528
            const int yOffset = getYOffset();
 
1529
            int offset = xOffset;
 
1530
            if (!offset)
 
1531
                offset = yOffset;
 
1532
 
 
1533
            mSortOffsetY = (mOldHeight * 16) + (mOffsetY * 16)
 
1534
                * (32 - abs(offset)) / 32;
 
1535
            const int yOffset2 = yOffset - mSortOffsetY;
 
1536
 
 
1537
            // Update pixel coordinates
 
1538
            setPosition(static_cast<float>(mX * 32 + 16 + xOffset),
 
1539
                static_cast<float>(mY * 32 + 32 + yOffset2));
 
1540
        }
 
1541
        else
 
1542
        {
 
1543
            setPosition(static_cast<float>(mX * 32 + 16),
 
1544
                static_cast<float>(mY * 32 + 32));
 
1545
        }
1520
1546
    }
1521
1547
 
1522
1548
    if (mEmotionSprite)
1559
1585
}
1560
1586
 
1561
1587
void Being::drawEmotion(Graphics *const graphics, const int offsetX,
1562
 
                        const int offsetY)
 
1588
                        const int offsetY) const
1563
1589
{
1564
1590
    const int px = getPixelX() - offsetX - 16;
1565
1591
    const int py = getPixelY() - offsetY - 64 - 32;
3003
3029
}
3004
3030
 
3005
3031
void Being::playSfx(const SoundInfo &sound, Being *const being,
3006
 
                    const bool main, const int x, const int y)
 
3032
                    const bool main, const int x, const int y) const
3007
3033
{
3008
3034
    if (being)
3009
3035
    {
3039
3065
    if (mType == PLAYER)
3040
3066
        setSubtype(mSubType, look);
3041
3067
}
 
3068
 
 
3069
void Being::setTileCoords(const int x, const int y)
 
3070
{
 
3071
    mX = x;
 
3072
    mY = y;
 
3073
    if (mMap)
 
3074
        mOffsetY = mMap->getHeightOffset(mX, mY);
 
3075
}
 
3076
 
 
3077
void Being::setMap(Map *const map)
 
3078
{
 
3079
    ActorSprite::setMap(map);
 
3080
    if (mMap)
 
3081
        mOffsetY = mMap->getHeightOffset(mX, mY);
 
3082
}