void CUser::UserInOut(uint8 bType) { if (GetRegion() == nullptr) return; Packet result; if (bType != INOUT_OUT) ResetGMVisibility(); GetInOut(result, bType); if (bType == INOUT_OUT) GetRegion()->Remove(this); else GetRegion()->Add(this); SendToRegion(&result, this, GetEventRoom()); if (bType == INOUT_OUT || !isBlinking()) { result.Initialize(AG_USER_INOUT); result.SByte(); result << bType << GetSocketID() << GetName() << m_curx << m_curz; Send_AIServer(&result); } }
void TextField::paintComponent( const PaintEvent &paintEvent ) { int caretLoc = getCaretLocation(); int textLoc = getTextOffset(); Rectangle sideclip = getInnerRectangle(); sideclip = Rectangle(sideclip.getX() + getLeftPadding() , sideclip.getY() + 2,sideclip.getSize().getWidth() - getLeftPadding() - getRightPadding() + 1, sideclip.getHeight() - 4); if(isReadOnly()) { paintEvent.graphics()->drawFilledRectangle( getSizeRectangle(),frameColor); } else { paintEvent.graphics()->drawFilledRectangle( getSizeRectangle(),getBackColor()); } paintEvent.graphics()->pushClippingRect(sideclip); if(getSelectionStart() != getSelectionEnd() && (isFocused() || !isHidingSelection()) ) { Rectangle selRect = Rectangle( getSelectionLocation(), (getInnerHeight() / 2) - (getFont()->getLineHeight() / 2), getSelectionWidth(), getFont()->getLineHeight()); paintEvent.graphics()->drawFilledRectangle( selRect,getSelectionBackColor()); } paintEvent.graphics()->drawText(Point(textLoc, + ((getInnerSize().getHeight() - getFont()->getLineHeight()) / 2)),getText().c_str(), getFontColor(),getFont()); if(isFocused()) { if(isBlinking()) paintEvent.graphics()->drawLine(Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) + (getFont()->getLineHeight() / 2))), Point(caretLoc + 1, ((getInnerSize().getHeight() / 2) - (getFont()->getLineHeight() / 2))), Color(0,0,0)); } paintEvent.graphics()->popClippingRect(); }
void MonoLed::loop() { if( isBlinking() ) { unsigned long timeSinceStart = pins->millis() - blinkStartMillis; unsigned long timeInBlinkPeriod = timeSinceStart % blinkPeriod; bool ledOn = ( timeInBlinkPeriod < blinkTimeOn ); setInternal( ledOn ); } }
void KopeteSystemTray::activate(const QPoint &pos) { if ( isBlinking() && Kopete::BehaviorSettings::self()->trayflashNotifyLeftClickOpensMessage() ) { if ( !mEventList.isEmpty() ) mEventList.first()->apply(); } else { KStatusNotifierItem::activate(pos); } }
void Blinkable::update(double elapsed) { updateBlinkTime(elapsed); if (isBlinking()) { if (!isToggling()) { toggle = !toggle; timeToggle = toggle ? ontime : offtime; } if (toggle) this->setColor(blinkColor); else this->setColor(baseColor); } else this->setColor(baseColor); }
void CUser::UserInOut(uint8 bType) { if (GetRegion() == NULL) return; Packet result; GetInOut(result, bType); if (bType == INOUT_OUT) GetRegion()->Remove(this); else GetRegion()->Add(this); SendToRegion(&result, this); if (bType == INOUT_OUT || !isBlinking()) { result.Initialize(AG_USER_INOUT); result.SByte(); result << bType << GetSocketID() << m_pUserData.m_id << m_pUserData.m_curx << m_pUserData.m_curz; g_pMain->Send_AIServer(&result); } }
//VOXOX CHANGE - Add support for ItemList style and change paint structure. void QtUMGroup::paintForeground(QPainter * painter, const QStyleOptionViewItem & option) { QMutexLocker locker(&_mutex); bool isGroupSelected = false;//VOXOX CHANGE by Rolando - 2009.09.03 bool isGroupBlinking = false;//VOXOX CHANGE by Rolando - 2009.09.08 QtUMItemListStyle * itemListStyle = QtUMItemListStyle::getInstance();//VOXOX CHANGE by Rolando - 2009.09.07 isGroupBlinking = isBlinking();//VOXOX CHANGE by Rolando - 2009.09.03 isGroupSelected = _isSelected;//VOXOX CHANGE by Rolando - 2009.10.01 if(isGroupSelected)//VOXOX CHANGE by Rolando - 2009.09.04 { painter->setPen(itemListStyle->getSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.09.04 } else { if(isGroupBlinking){ if(_blinkNow){//VOXOX CHANGE by Rolando - 2009.10.01 painter->setPen(itemListStyle->getGroupBlinkingFontColor());//VOXOX CHANGE by Rolando - 2009.10.01 } else{ painter->setPen(itemListStyle->getNonSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.10.01 } } else{ painter->setPen(itemListStyle->getNonSelectedGroupFontColor());//VOXOX CHANGE by Rolando - 2009.09.04 } } painter->drawPixmap(option.rect.left(),option.rect.top(),getGroupBackGround(option.rect,option, isGroupSelected, isGroupBlinking)); QFont font = option.font; painter->setFont(font); QPixmap px; if (option.state & QStyle::State_Open) { px = itemListStyle->getGroupPixmapOpen(); } else { px = itemListStyle->getGroupPixmapClose(); } int x = option.rect.left(); QRect r = option.rect; painter->drawPixmap(x, r.top() + 3, px); _posXArrowButton = x;//VOXOX CHANGE by Rolando - 2009.09.29 _posYArrowButton = r.top() + 3;//VOXOX CHANGE by Rolando - 2009.09.29 _widthArrowButton = px.width();//VOXOX CHANGE by Rolando - 2009.09.29 _heightArrowButton = px.height();//VOXOX CHANGE by Rolando - 2009.09.29 x += px.width() + 3; r.setLeft(x); int y = ((r.bottom()-r.top())-QFontMetrics(font).height())/2; r.setTop(y + r.top()); painter->drawText(r, Qt::AlignLeft, getGroupName(), 0); //VOXOX CHANGE by Rolando - 2009.08.25 - getting corresponding close button QPixmap closeButtonPixmap; if ((option.state & QStyle::State_Selected) == QStyle::State_Selected) { closeButtonPixmap = QPixmap(":/pics/chat/umtreewidget/btn_close_selected.png");//VOXOX CHANGE by Rolando - 2009.08.25 painter->setPen(_fontColor);//VOXOX CHANGE by Rolando - 2009.09.07 } else { closeButtonPixmap = QPixmap(":/pics/chat/umtreewidget/btn_close_nonselected.png");//VOXOX CHANGE by Rolando - 2009.08.25 painter->setPen(_fontColor);//VOXOX CHANGE by Rolando - 2009.09.07 } //VOXOX CHANGE by Rolando - 2009.08.25 - painting the close button _posXCloseButton = r.right() - closeButtonPixmap.width() - 5;//VOXOX CHANGE by Rolando - 2009.09.16 int centeredCloseButton_y = ((r.bottom() - r.top()) - closeButtonPixmap.size().height()) / 2; painter->drawPixmap(_posXCloseButton, r.top() + centeredCloseButton_y, closeButtonPixmap); _posYCloseButton = r.top() + centeredCloseButton_y; _widthCloseButton = closeButtonPixmap.width();//VOXOX CHANGE by Rolando - 2009.08.27 _heightCloseButton = closeButtonPixmap.height();//VOXOX CHANGE by Rolando - 2009.08.27 }
void CUser::Regene(uint8 regene_type, uint32 magicid /*= 0*/) { ASSERT(GetMap() != nullptr); _OBJECT_EVENT* pEvent = nullptr; _HOME_INFO* pHomeInfo = nullptr; float x = 0.0f, z = 0.0f; if (!isDead()) return; if (regene_type != 1 && regene_type != 2) regene_type = 1; if (regene_type == 2) { magicid = 490041; // The Stone of Ressurection magic ID // Is our level high enough to be able to resurrect using this skill? if (GetLevel() <= 5 // Do we have enough resurrection stones? || !RobItem(379006000, 3 * GetLevel())) return; } // If we're in a home zone, we'll want the coordinates from there. Otherwise, assume our own home zone. pHomeInfo = g_pMain->m_HomeArray.GetData(GetZoneID() <= ZONE_ELMORAD ? GetZoneID() : GetNation()); if (pHomeInfo == nullptr) return; UserInOut(INOUT_OUT); pEvent = GetMap()->GetObjectEvent(m_sBind); // If we're not using a spell to resurrect. if (magicid == 0) { // Resurrect at a bind/respawn point if (pEvent != nullptr && pEvent->byLife == 1) { SetPosition(pEvent->fPosX + x, 0.0f, pEvent->fPosZ + z); } // Are we trying to respawn in a home zone? else if (GetZoneID() <= ZONE_ELMORAD) { // Use the proper respawn area for our nation, as the opposite nation can // enter this zone at a war's invasion stage. if (GetNation() == KARUS) { x = (float)(pHomeInfo->KarusZoneX + myrand(0, pHomeInfo->KarusZoneLX)); z = (float)(pHomeInfo->KarusZoneZ + myrand(0, pHomeInfo->KarusZoneLZ)); } else { x = (float)(pHomeInfo->ElmoZoneX + myrand(0, pHomeInfo->ElmoZoneLX)); z = (float)(pHomeInfo->ElmoZoneZ + myrand(0, pHomeInfo->ElmoZoneLZ)); } } else { // If we're in a war zone (aside from snow wars, which apparently use different coords), use BattleZone coordinates. if (GetZoneID() != ZONE_SNOW_BATTLE && GetZoneID() == (ZONE_BATTLE_BASE + g_pMain->m_byBattleZone)) { x = (float)(pHomeInfo->BattleZoneX + myrand(0, pHomeInfo->BattleZoneLX)); z = (float)(pHomeInfo->BattleZoneZ + myrand(0, pHomeInfo->BattleZoneLZ)); } // If we died in the Moradon arena, we need to spawn near the Arena. else if (GetZoneID() == ZONE_MORADON && isInArena()) { x = (float)(MINI_ARENA_RESPAWN_X + myrand(-MINI_ARENA_RESPAWN_RADIUS, MINI_ARENA_RESPAWN_RADIUS)); z = (float)(MINI_ARENA_RESPAWN_Z + myrand(-MINI_ARENA_RESPAWN_RADIUS, MINI_ARENA_RESPAWN_RADIUS)); } // For all else, just grab the start position (/town coordinates) from the START_POSITION table. else { short sx, sz; GetStartPosition(sx, sz); x = sx; z = sz; } } SetPosition(x, 0.0f, z); m_bResHpType = USER_STANDING; m_bRegeneType = REGENE_NORMAL; } else // we're respawning using a resurrect skill. { _MAGIC_TYPE5 * pType = g_pMain->m_Magictype5Array.GetData(magicid); if (pType == nullptr) return; MSpChange(-m_iMaxMp); // reset us to 0 MP. if (m_sWhoKilledMe == -1) ExpChange((m_iLostExp * pType->bExpRecover) / 100); // Restore m_bResHpType = USER_STANDING; m_bRegeneType = REGENE_MAGIC; } Packet result(WIZ_REGENE); result << GetSPosX() << GetSPosZ() << GetSPosY(); Send(&result); HpChange(GetMaxHealth()); m_tLastRegeneTime = UNIXTIME; m_sWhoKilledMe = -1; m_iLostExp = 0; if (magicid == 0) BlinkStart(); if (!isBlinking()) { result.Initialize(AG_USER_REGENE); result << GetSocketID() << m_sHp; Send_AIServer(&result); } SetRegion(GetNewRegionX(), GetNewRegionZ()); UserInOut(INOUT_RESPAWN); g_pMain->RegionUserInOutForMe(this); g_pMain->RegionNpcInfoForMe(this); InitializeStealth(); SendUserStatusUpdate(USER_STATUS_DOT, USER_STATUS_CURE); SendUserStatusUpdate(USER_STATUS_POISON, USER_STATUS_CURE); if (isInArena()) SendUserStatusUpdate(USER_STATUS_SPEED, USER_STATUS_CURE); RecastSavedMagic(); // If we actually respawned (i.e. we weren't resurrected by a skill)... if (magicid == 0) { // In PVP zones (not war zones), we must kick out players if they no longer // have any national points. if (GetMap()->isNationPVPZone() && GetMap()->isWarZone() && GetLoyalty() == 0) KickOutZoneUser(false); } }
bool EyeExtractor::hasValidSample() { return Application::Components::calibrator->getPointFrameNo() >= 11 && !isBlinking(); }
void CUser::Attack(Packet & pkt) { Packet result; int16 sid = -1, tid = -1, damage, delaytime, distance; uint8 bType, bResult; CUser* pTUser = NULL; pkt >> bType >> bResult >> tid >> delaytime >> distance; // delaytime = delaytime / 100.0f; // distance = distance / 10.0f; if (isBlinking() || isDead()) return; _ITEM_TABLE *pTable = GetItemPrototype(RIGHTHAND); if (pTable == NULL) return; // If you're holding a weapon, do a client-based (ugh, do not trust!) delay check. if (pTable && (delaytime < pTable->m_sDelay || distance > pTable->m_sRange)) return; // Empty handed. else if (delaytime < 100) return; // We're attacking a player... if (tid < NPC_BAND) { pTUser = g_pMain->GetUserPtr(tid); if (pTUser == NULL || pTUser->isDead() || pTUser->isBlinking() || (pTUser->GetNation() == GetNation() && GetZoneID() != 48 /* TO-DO: implement better checks */) || !isAttackZone()) bResult = 0; else { damage = GetDamage(pTUser, NULL); if (GetZoneID() == ZONE_SNOW_BATTLE && g_pMain->m_byBattleOpen == SNOW_BATTLE) damage = 0; if (damage <= 0) bResult = 0; else { // TO-DO: Move all this redundant code into appropriate event-based methods so that all the other cases don't have to copypasta (and forget stuff). pTUser->HpChange(-damage, this); if (pTUser->isDead()) bResult = 2; ItemWoreOut(ATTACK, damage); pTUser->ItemWoreOut(DEFENCE, damage); SendTargetHP(0, tid, -damage); } } } // We're attacking an NPC... else if (tid >= NPC_BAND) { // AI hasn't loaded yet if (g_pMain->m_bPointCheckFlag == FALSE) return; CNpc *pNpc = g_pMain->m_arNpcArray.GetData(tid); if (pNpc != NULL && pNpc->isAlive() && (pNpc->GetNation() == 0 || pNpc->GetNation() == GetNation())) { result.SetOpcode(AG_ATTACK_REQ); result << bType << bResult << GetSocketID() << tid << uint16(m_sTotalHit * m_bAttackAmount / 100) << uint16(m_sTotalAc + m_sACAmount) << m_sTotalHitrate /* this is actually a float. screwed up naming... */ << m_sTotalEvasionrate /* also a float */ << m_sItemAc << m_bMagicTypeLeftHand << m_bMagicTypeRightHand << m_sMagicAmountLeftHand << m_sMagicAmountRightHand; g_pMain->Send_AIServer(&result); return; } } result.SetOpcode(WIZ_ATTACK); result << bType << bResult << GetSocketID() << tid; SendToRegion(&result); if (tid < NPC_BAND && bResult == 2 // 2 means a player died. && pTUser) { pTUser->Send(&result); TRACE("*** User Attack Dead, id=%s, result=%d, type=%d, HP=%d\n", pTUser->m_pUserData->m_id, bResult, pTUser->m_bResHpType, pTUser->m_pUserData->m_sHp); } }
void CUser::Regene(uint8 regene_type, uint32 magicid /*= 0*/) { ASSERT(GetMap() != NULL); CUser* pUser = NULL; _OBJECT_EVENT* pEvent = NULL; _HOME_INFO* pHomeInfo = NULL; _MAGIC_TYPE5* pType = NULL; if (!isDead()) return; InitType3(); InitType4(); if (regene_type != 1 && regene_type != 2) { regene_type = 1; } if (regene_type == 2) { magicid = 490041; // The Stone of Ressurection magic ID if (!RobItem(379006000, 3 * GetLevel())) { return; // Subtract resurrection stones. } if (GetLevel() <= 5) { return; // 5 level minimum. } } pHomeInfo = g_pMain->m_HomeArray.GetData(m_pUserData->m_bNation); if (!pHomeInfo) return; UserInOut(INOUT_OUT); float x = 0.0f, z = 0.0f; x = (float)(myrand( 0, 400 )/100.0f); z = (float)(myrand( 0, 400 )/100.0f); if( x < 2.5f ) x = 1.5f + x; if( z < 2.5f ) z = 1.5f + z; pEvent = GetMap()->GetObjectEvent(m_pUserData->m_sBind); // TO-DO: Clean this entire thing up. Wow. if (magicid == 0) { if( pEvent && pEvent->byLife == 1 ) { // Bind Point m_pUserData->m_curx = pEvent->fPosX + x; m_pUserData->m_curz = pEvent->fPosZ + z; m_pUserData->m_cury = 0; } else if( m_pUserData->m_bNation != m_pUserData->m_bZone) { // Free Zone or Opposite Zone if(m_pUserData->m_bZone > 200) { // Frontier Zone... x = (float)(pHomeInfo->FreeZoneX + myrand(0, pHomeInfo->FreeZoneLX)); z = (float)(pHomeInfo->FreeZoneZ + myrand(0, pHomeInfo->FreeZoneLZ)); } // else if(m_pUserData->m_bZone > 100 && m_pUserData->m_bZone < 200) { // Battle Zone... /* m_bResHpType = USER_STANDING; HpChange( m_iMaxHp ); KickOutZoneUser(); // Go back to your own zone! return; */ x = (float)(pHomeInfo->BattleZoneX + myrand(0, pHomeInfo->BattleZoneLX)); z = (float)(pHomeInfo->BattleZoneZ + myrand(0, pHomeInfo->BattleZoneLZ)); if (m_pUserData->m_bZone == ZONE_SNOW_BATTLE) { x = (float)(pHomeInfo->FreeZoneX + myrand(0, pHomeInfo->FreeZoneLX)); z = (float)(pHomeInfo->FreeZoneZ + myrand(0, pHomeInfo->FreeZoneLZ)); } } else if (m_pUserData->m_bZone > 10 && m_pUserData->m_bZone < 20) { x = (float)(527 + myrand(0, 10)); z = (float)(543 + myrand(0, 10)); } else if (m_pUserData->m_bZone < 3) { // Specific Lands... if (m_pUserData->m_bNation == KARUS) { x = (float)(pHomeInfo->ElmoZoneX + myrand(0, pHomeInfo->ElmoZoneLX)); z = (float)(pHomeInfo->ElmoZoneZ + myrand(0, pHomeInfo->ElmoZoneLZ)); } else if (m_pUserData->m_bNation == ELMORAD) { x = (float)(pHomeInfo->KarusZoneX + myrand(0, pHomeInfo->KarusZoneLX)); z = (float)(pHomeInfo->KarusZoneZ + myrand(0, pHomeInfo->KarusZoneLZ)); } else return; } else { short sx, sz; GetStartPosition(sx, sz); x = sx; z = sz; } m_pUserData->m_curx = x; m_pUserData->m_curz = z; } else { if (m_pUserData->m_bNation == KARUS) { x = (float)(pHomeInfo->KarusZoneX + myrand(0, pHomeInfo->KarusZoneLX)); z = (float)(pHomeInfo->KarusZoneZ + myrand(0, pHomeInfo->KarusZoneLZ)); } else if (m_pUserData->m_bNation == ELMORAD) { x = (float)(pHomeInfo->ElmoZoneX + myrand(0, pHomeInfo->ElmoZoneLX)); z = (float)(pHomeInfo->ElmoZoneZ + myrand(0, pHomeInfo->ElmoZoneLZ)); } else return; m_pUserData->m_curx = x; m_pUserData->m_curz = z; } } Packet result(WIZ_REGENE); result << GetSPosX() << GetSPosZ() << GetSPosY(); Send(&result); if (magicid > 0) { // Clerical Resurrection. pType = g_pMain->m_Magictype5Array.GetData(magicid); if ( !pType ) return; m_bResHpType = USER_STANDING; MSpChange(-m_iMaxMp); // Empty out MP. if (m_sWhoKilledMe == -1 && regene_type == 1) { ExpChange((m_iLostExp * pType->bExpRecover) / 100); // Restore Target Experience. } m_bRegeneType = REGENE_MAGIC; } else { // Normal Regene. // m_bAbnormalType = ABNORMAL_BLINKING; // m_bResHpType = USER_STANDING; m_bRegeneType = REGENE_NORMAL; } HpChange(m_iMaxHp); m_fLastRegeneTime = TimeGet(); m_sWhoKilledMe = -1; m_iLostExp = 0; if (!isBlinking()) { result.Initialize(AG_USER_REGENE); result << GetSocketID() << m_pUserData->m_sHp; g_pMain->Send_AIServer(&result); } SetRegion(GetNewRegionX(), GetNewRegionZ()); UserInOut(INOUT_RESPAWN); g_pMain->RegionUserInOutForMe(this); g_pMain->RegionNpcInfoForMe(this); BlinkStart(); if (isInParty()) { // TO-DO: Wrap these up into Party-specific methods (nothing for that yet) // UPDATE: Sticking them in the CUser class for the moment. Need to have them make sense, though. if (!m_bType3Flag) SendPartyStatusUpdate(1); if (!m_bType4Flag) SendPartyStatusUpdate(2); } }