void CAI_PlayerAlly::OnChangeRunningBehavior( CAI_BehaviorBase *pOldBehavior, CAI_BehaviorBase *pNewBehavior ) { BaseClass::OnChangeRunningBehavior( pOldBehavior, pNewBehavior ); CAI_FollowBehavior *pFollowBehavior; if ( dynamic_cast<CAI_FollowBehavior *>(pNewBehavior) != NULL ) { GetExpresser()->SetSpokeConcept( TLK_HELLO, NULL ); // Don't say hi after you've started following if ( IsOkToCombatSpeak() ) Speak( TLK_USE ); SetSpeechTarget( GetTarget() ); ClearCondition( COND_PLAYER_PUSHING ); } else if ( ( pFollowBehavior = dynamic_cast<CAI_FollowBehavior *>(pOldBehavior) ) != NULL ) { if ( !(m_afMemory & bits_MEMORY_PROVOKED) ) { if ( IsOkToCombatSpeak() ) { if ( pFollowBehavior->GetFollowTarget() == NULL ) Speak( TLK_UNUSE ); else Speak( TLK_STOP ); } SetSpeechTarget( FindNearestFriend(true) ); } } }
bool CChar::NPC_SetVendorPrice( CItem * pItem, int iPrice ) { ADDTOCALLSTACK("CChar::NPC_SetVendorPrice"); // player vendors. // CLIMODE_PROMPT_VENDOR_PRICE // This does not check who is setting the price if if it is valid for them to do so. if ( ! NPC_IsVendor()) return( false ); if ( pItem == NULL || pItem->GetTopLevelObj() != this || pItem->GetParent() == this ) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_INV_ONLY ) ); return( false ); } CItemVendable * pVendItem = dynamic_cast <CItemVendable *> (pItem); if ( pVendItem == NULL ) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_CANTSELL ) ); return( false ); } if ( iPrice < 0 ) // just a test. return( true ); TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_VENDOR_SETPRICE_1), pVendItem->GetName(), iPrice); Speak(pszMsg); pVendItem->SetPlayerVendorPrice( iPrice ); return( true ); }
bool CChar::NPC_StablePetRetrieve( CChar * pCharPlayer ) { ADDTOCALLSTACK("CChar::NPC_StablePetRetrieve"); // Get pets for this person from my inventory. // May want to put up a menu ??? if ( !m_pNPC || m_pNPC->m_Brain != NPCBRAIN_STABLE ) return false; int iCount = 0; CItem *pItemNext = NULL; for ( CItem *pItem = GetBank()->GetContentHead(); pItem != NULL; pItem = pItemNext ) { pItemNext = pItem->GetNext(); if ( pItem->IsType(IT_FIGURINE) && pItem->m_uidLink == pCharPlayer->GetUID() ) { if ( !pCharPlayer->Use_Figurine(pItem) ) { tchar *pszTemp = Str_GetTemp(); sprintf(pszTemp, g_Cfg.GetDefaultMsg(DEFMSG_NPC_STABLEMASTER_CLAIM_FOLLOWER), pItem->GetName()); Speak(pszTemp); return true; } pItem->Delete(); iCount++; } } Speak(g_Cfg.GetDefaultMsg((iCount > 0) ? DEFMSG_NPC_STABLEMASTER_CLAIM : DEFMSG_NPC_STABLEMASTER_CLAIM_NOPETS)); return true; }
int CChar::NPC_OnTrainCheck( CChar * pCharSrc, SKILL_TYPE Skill ) { ADDTOCALLSTACK("CChar::NPC_OnTrainCheck"); // Can we train in this skill ? // RETURN: Amount of skill we can train. // if ( !IsSkillBase(Skill) ) { Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_TRAINER_DUNNO_1)); return 0; } int iSkillSrcVal = pCharSrc->Skill_GetBase(Skill); int iSkillVal = Skill_GetBase(Skill); int iTrainVal = NPC_GetTrainMax(pCharSrc, Skill) - iSkillSrcVal; // Train npc skill cap int iMaxDecrease = 0; if ( (pCharSrc->GetSkillTotal() + iTrainVal) > pCharSrc->Skill_GetMax(static_cast<SKILL_TYPE>(g_Cfg.m_iMaxSkill)) ) { for ( size_t i = 0; i < g_Cfg.m_iMaxSkill; i++ ) { if ( !g_Cfg.m_SkillIndexDefs.IsValidIndex(static_cast<SKILL_TYPE>(i)) ) continue; if ( pCharSrc->Skill_GetLock(static_cast<SKILL_TYPE>(i)) == SKILLLOCK_DOWN ) iMaxDecrease += pCharSrc->Skill_GetBase(static_cast<SKILL_TYPE>(i)); } iMaxDecrease = minimum(iTrainVal, iMaxDecrease); } else { iMaxDecrease = iTrainVal; } lpctstr pszMsg; if ( iSkillVal <= 0 ) { pszMsg = g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_DUNNO_2 ); } else if ( iSkillSrcVal > iSkillVal ) { pszMsg = g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_DUNNO_3 ); } else if ( iMaxDecrease <= 0 ) { pszMsg = g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_DUNNO_4 ); } else { return( iMaxDecrease ); } char *z = Str_GetTemp(); sprintf(z, pszMsg, g_Cfg.GetSkillKey(Skill)); Speak(z); return 0; }
void KilledUnit(Unit *victim) { if(urand(0,1)) Speak(CHAT_TYPE_SAY,16145,"Cafard insignifiant !"); else Speak(CHAT_TYPE_SAY,16146,"Banni, au néant !"); if(victim->GetTypeId() == TYPEID_PLAYER) SetInstanceData(TYPE_TRY,1); }
bool CChar::NPC_CheckHirelingStatus() { ADDTOCALLSTACK("CChar::NPC_CheckHirelingStatus"); // Am i happy at the moment ? // If not then free myself. // // RETURN: // true = happy. if ( ! IsStatFlag( STATF_Pet )) return( true ); CCharBase * pCharDef = Char_GetDef(); int iFoodConsumeRate = g_Cfg.m_iRegenRate[STAT_FOOD]; unsigned int iWage = pCharDef->GetHireDayWage(); if ( ! iWage || ! iFoodConsumeRate ) return( true ); // I am hired for money not for food. unsigned int iPeriodWage = IMULDIV( iWage, iFoodConsumeRate, 24 * 60 * g_Cfg.m_iGameMinuteLength ); if ( iPeriodWage <= 0 ) iPeriodWage = 1; CItemContainer * pBank = GetBank(); if ( pBank->m_itEqBankBox.m_Check_Amount > iPeriodWage ) { pBank->m_itEqBankBox.m_Check_Amount -= iPeriodWage; } else { TCHAR* pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_WAGE_COST ), iWage); Speak(pszMsg); CChar * pOwner = NPC_PetGetOwner(); if ( pOwner ) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_HIRE_TIMEUP ) ); CItem * pMemory = Memory_AddObjTypes( pOwner, MEMORY_SPEAK ); if ( pMemory ) pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_SPEAK_HIRE; NPC_PetDesert(); return false; } // Some sort of strange bug to get here. Memory_ClearTypes( MEMORY_IPET ); StatFlag_Clear( STATF_Pet ); } return( true ); }
void CNPCSimpleTalker::OnStoppingFollow( CBaseEntity *pTarget ) { if ( !(m_afMemory & bits_MEMORY_PROVOKED) ) { if ( IsOkToCombatSpeak() ) { if ( pTarget == NULL ) Speak( TLK_STOPFOLLOW ); else Speak( TLK_STOP ); } SetSpeechTarget( FindNearestFriend(true) ); } }
void JustDied(Unit *victim) { if (pInstance) { SetInstanceData(TYPE_JARAXXUS, DONE); Speak(CHAT_TYPE_SAY,16147,"Un autre prendra ma place. Votre monde est condamné."); if (Creature* Ann = ((Creature*)Unit::GetUnit(*me, pInstance ? pInstance->GetData64(DATA_ANNOUNCER) : 0))) ((npc_toc10_announcerAI*)Ann->AI())->StartEvent(NULL,EVENT_TYPE_JARAXXUS_OUTRO); } switch(m_difficulty) { case RAID_DIFFICULTY_10MAN_NORMAL: GiveEmblemsToGroup(CONQUETE,2); break; case RAID_DIFFICULTY_25MAN_NORMAL: GiveEmblemsToGroup(TRIOMPHE,2); break; case RAID_DIFFICULTY_10MAN_HEROIC: GiveEmblemsToGroup(TRIOMPHE,3); break; case RAID_DIFFICULTY_25MAN_HEROIC: GiveEmblemsToGroup(TRIOMPHE,3); break; } me->ForcedDespawn(TEN_MINS*1000); }
void UpdateAI(const uint32 diff) { if (!CanDoSomething()) return; if(incinerate_Timer <= diff) { Yell(16149,"Que brûle la chair !"); DoCastRandom(SPELL_INCINERATE_FLESH); incinerate_Timer = 20000; } else incinerate_Timer -= diff; if(portal_Timer <= diff) { Speak(CHAT_TYPE_SAY,16150,"Viens, ma soeur, ton maître t'appelle."); CallCreature(34825,TEN_MINS,NEAR_15M,AGGRESSIVE_MAIN); portal_Timer = 120000; } else portal_Timer -= diff; UpdateEvent(diff); DoMeleeAttackIfReady(); }
//========================================================= // IdleHello // Try to greet player first time he's seen //========================================================= int CAI_PlayerAlly::FIdleHello( void ) { if (!IsOkToSpeak()) return false; // if this is first time scientist has seen player, greet him if (!GetExpresser()->SpokeConcept(TLK_HELLO)) { // get a player CBaseEntity *pPlayer = FindNearestFriend(true); if (pPlayer) { if (FInViewCone(pPlayer) && FVisible(pPlayer)) { SetSpeechTarget( pPlayer ); Speak( TLK_HELLO ); return true; } } } return false; }
//========================================================= // IdleRespond // Respond to a previous question //========================================================= void CAI_PlayerAlly::IdleRespond( void ) { //int pitch = GetVoicePitch(); // play response Speak( TLK_ANSWER ); }
//--------------------------------------------------------- void CAI_PlayerAlly::OnTargetOrder() { if ( IsOkToCombatSpeak() ) Speak( TLK_COMMANDED ); BaseClass::OnTargetOrder(); }
//--------------------------------------------------------- void CAI_PlayerAlly::OnPlayerSelect() { if ( IsOkToCombatSpeak() ) Speak( TLK_SELECTED ); BaseClass::OnPlayerSelect(); }
void CChar::NPC_OnHirePayMore(CItem *pGold, bool bHire) { ADDTOCALLSTACK("CChar::NPC_OnHirePayMore"); // We have been handed money. // similar to PC_STATUS CCharBase *pCharDef = Char_GetDef(); CItemContainer *pBank = GetContainerCreate(LAYER_BANKBOX); if ( !pCharDef->m_iHireDayWage || !pBank ) return; if ( pGold ) { if ( bHire ) pBank->m_itEqBankBox.m_Check_Amount = 0; // clear previous balance pBank->m_itEqBankBox.m_Check_Amount += pGold->GetAmount(); Sound(pGold->GetDropSound(NULL)); pGold->Delete(); } TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_HIRE_TIME), pBank->m_itEqBankBox.m_Check_Amount / pCharDef->m_iHireDayWage); Speak(pszMsg); }
void CMenuMarcher::Think() { BaseClass::Think(); Speak(); Vector vecNewOrigin = GetGlobalOrigin() + Vector(0, 5, 0) * (float)GameServer()->GetFrameTime(); if (vecNewOrigin.y > 80) vecNewOrigin.y -= 160; vecNewOrigin.z = vecNewOrigin.z + GetGlobalVelocity().z * (float)GameServer()->GetFrameTime(); float flNewHoverHeight = FindHoverHeight(vecNewOrigin) + 2; if (vecNewOrigin.z > flNewHoverHeight) { SetGlobalVelocity(Vector(0, 0, GetGlobalVelocity().z - 5 * (float)GameServer()->GetFrameTime())); } else { vecNewOrigin.z = flNewHoverHeight; SetGlobalVelocity(Vector(0, 0, Approach(0, GetGlobalVelocity().z, 1 * (float)GameServer()->GetFrameTime()))); } SetGlobalOrigin(vecNewOrigin); }
already_AddRefed<nsSpeechTask> nsSynthVoiceRegistry::SpeakUtterance(SpeechSynthesisUtterance& aUtterance, const nsAString& aDocLang) { nsString lang = nsString(aUtterance.mLang.IsEmpty() ? aDocLang : aUtterance.mLang); nsAutoString uri; if (aUtterance.mVoice) { aUtterance.mVoice->GetVoiceURI(uri); } nsRefPtr<nsSpeechTask> task; if (XRE_GetProcessType() == GeckoProcessType_Content) { task = new SpeechTaskChild(&aUtterance); SpeechSynthesisRequestChild* actor = new SpeechSynthesisRequestChild(static_cast<SpeechTaskChild*>(task.get())); mSpeechSynthChild->SendPSpeechSynthesisRequestConstructor(actor, aUtterance.mText, lang, uri, aUtterance.Volume(), aUtterance.Rate(), aUtterance.Pitch()); } else { task = new nsSpeechTask(&aUtterance); Speak(aUtterance.mText, lang, uri, aUtterance.Rate(), aUtterance.Pitch(), task); } return task.forget(); }
void CItemCommCrystal::OnHear(LPCTSTR pszCmd, CChar *pSrc) { ADDTOCALLSTACK("CItemCommCrystal::OnHear"); // IT_COMM_CRYSTAL // STATF_COMM_CRYSTAL = if i am on a person. TALKMODE_TYPE mode = TALKMODE_SAY; for ( size_t i = 0; i < m_Speech.GetCount(); i++ ) { CResourceLink *pLink = m_Speech[i]; ASSERT(pLink); CResourceLock s; if ( !pLink->ResourceLock(s) ) continue; TRIGRET_TYPE iRet = OnHearTrigger(s, pszCmd, pSrc, mode); if ( iRet == TRIGRET_ENDIF || iRet == TRIGRET_RET_FALSE ) continue; break; } // That's prevent @ -1 crash speech :P if ( *pszCmd == '@' ) return; if ( m_uidLink.IsValidUID() ) { // I am linked to something ? // Transfer the sound. CItem *pItem = m_uidLink.ItemFind(); if ( pItem && pItem->IsType(IT_COMM_CRYSTAL) ) pItem->Speak(pszCmd); } else if ( m_Speech.GetCount() <= 0 ) Speak(pszCmd); }
void CNPC_HL1Barney::DeclineFollowing( void ) { if ( CanSpeakAfterMyself() ) { Speak( BA_POK ); } }
void CChar::NPC_OnHirePayMore( CItem * pGold, bool fHire ) { ADDTOCALLSTACK("CChar::NPC_OnHirePayMore"); // We have been handed money. // similar to PC_STATUS CCharBase * pCharDef = Char_GetDef(); unsigned int iWage = pCharDef->GetHireDayWage(); CItemContainer *pBank = GetBank(); if ( !iWage || !pBank ) return; if ( pGold ) { if ( fHire ) { pBank->m_itEqBankBox.m_Check_Amount = 0; // zero any previous balance. } pBank->m_itEqBankBox.m_Check_Amount += pGold->GetAmount(); Sound( pGold->GetDropSound( NULL )); pGold->Delete(); } TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, g_Cfg.GetDefaultMsg(DEFMSG_NPC_PET_HIRE_TIME), pBank->m_itEqBankBox.m_Check_Amount / iWage); Speak(pszMsg); }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void CNPC_Monk::DeathSound( const CTakeDamageInfo &info ) { // Sentences don't play on dead NPCs SentenceStop(); Speak( TLK_DEATH ); }
bool CChar::NPC_OnTrainPay(CChar *pCharSrc, CItemMemory *pMemory, CItem * pGold) { ADDTOCALLSTACK("CChar::NPC_OnTrainPay"); SKILL_TYPE skill = static_cast<SKILL_TYPE>(pMemory->m_itEqMemory.m_Skill); if ( !IsSkillBase(skill) || !g_Cfg.m_SkillIndexDefs.IsValidIndex(skill) ) { Speak(g_Cfg.GetDefaultMsg(DEFMSG_NPC_TRAINER_FORGOT)); return false; } int iTrainCost = (int)GetKeyNum("OVERRIDE.TRAINSKILLCOST", true); if ( !iTrainCost ) iTrainCost = g_Cfg.m_iTrainSkillCost; iTrainCost *= NPC_OnTrainCheck(pCharSrc, skill); if ( (iTrainCost <= 0) || !pGold ) return false; Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_SUCCESS ) ); // Can't ask for more gold than the maximum amount of the gold stack i am giving to the npc word iTrainCostFinal = (word)minimum(UINT16_MAX, iTrainCost); // Consume as much money as we can train for. if ( pGold->GetAmount() < iTrainCost ) { iTrainCostFinal = pGold->GetAmount(); } else if ( pGold->GetAmount() == iTrainCostFinal) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_THATSALL_1 ) ); pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_NONE; } else { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_TRAINER_THATSALL_2 ) ); pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_NONE; // Give change back. pGold->UnStackSplit( iTrainCostFinal, pCharSrc ); } GetPackSafe()->ContentAdd( pGold ); // take my cash. // Give credit for training. NPC_TrainSkill( pCharSrc, skill, iTrainCost ); return true; }
bool CChar::NPC_OnHireHear( CChar * pCharSrc ) { ADDTOCALLSTACK("CChar::NPC_OnHireHear"); if ( !m_pNPC ) return false; CCharBase * pCharDef = Char_GetDef(); unsigned int iWage = pCharDef->GetHireDayWage(); if ( ! iWage ) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_NOT_FOR_HIRE ) ); return false; } CItemMemory * pMemory = Memory_FindObj( pCharSrc ); if ( pMemory ) { if ( pMemory->IsMemoryTypes(MEMORY_IPET|MEMORY_FRIEND)) { // Next gold i get goes toward hire. pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_SPEAK_HIRE; NPC_OnHirePayMore( NULL, false ); return true; } if ( pMemory->IsMemoryTypes( MEMORY_FIGHT|MEMORY_HARMEDBY|MEMORY_IRRITATEDBY )) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_NOT_WORK ) ); return false; } } if ( IsStatFlag( STATF_Pet )) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_EMPLOYED ) ); return false; } TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, Calc_GetRandVal(2) ? g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_HIRE_AMNT ) : g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_HIRE_RATE ), iWage ); Speak(pszMsg); pMemory = Memory_AddObjTypes( pCharSrc, MEMORY_SPEAK ); if ( pMemory ) pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_SPEAK_HIRE; return true; }
bool CChar::NPC_OnHirePay( CChar * pCharSrc, CItemMemory * pMemory, CItem * pGold ) { ADDTOCALLSTACK("CChar::NPC_OnHirePay"); if ( !m_pNPC || !pCharSrc || !pMemory ) return false; CCharBase * pCharDef = Char_GetDef(); if ( IsStatFlag( STATF_Pet )) { if ( ! pMemory->IsMemoryTypes(MEMORY_IPET|MEMORY_FRIEND)) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_EMPLOYED ) ); return false; } } else { unsigned int iWage = pCharDef->GetHireDayWage(); if ( iWage <= 0 ) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_NOT_FOR_HIRE ) ); return false; } if ( pGold->GetAmount() < iWage ) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_NOT_ENOUGH ) ); return false; } // NOTO_TYPE ? if ( pMemory->IsMemoryTypes( MEMORY_FIGHT|MEMORY_HARMEDBY|MEMORY_IRRITATEDBY )) { Speak( g_Cfg.GetDefaultMsg( DEFMSG_NPC_PET_NOT_WORK ) ); return false; } // Put all my loot cash away. ContentConsume( RESOURCE_ID(RES_TYPEDEF,IT_GOLD), INT_MAX, false, 0 ); // Mark all my stuff ATTR_OWNED - i won't give it away. ContentAttrMod( ATTR_OWNED, true ); NPC_PetSetOwner( pCharSrc ); } pMemory->m_itEqMemory.m_Action = NPC_MEM_ACT_NONE; NPC_OnHirePayMore( pGold, true ); return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CBaseMultiplayerPlayer::SpeakIfAllowed( AIConcept_t concept, SpeechPriorityType priority, const char *modifiers, char *pszOutResponseChosen, size_t bufsize, IRecipientFilter *filter ) { if ( !IsAlive() ) return false; //if ( IsAllowedToSpeak( concept, bRespondingToPlayer ) ) return Speak( concept, modifiers, pszOutResponseChosen, bufsize, filter ); }
// try to smell something void CNPCSimpleTalker::TrySmellTalk( void ) { if ( !IsOkToSpeak() ) return; if ( HasCondition( COND_SMELL ) && GetExpresser()->CanSpeakConcept( TLK_SMELL ) ) Speak( TLK_SMELL ); }
void CNPCSimpleTalker::OnStartingFollow( CBaseEntity *pTarget ) { GetExpresser()->SetSpokeConcept( TLK_HELLO, NULL ); // Don't say hi after you've started following if ( IsOkToSpeak() ) // don't speak if idle talk is blocked. player commanded/use follow will always speak Speak( TLK_STARTFOLLOW ); SetSpeechTarget( GetTarget() ); ClearCondition( COND_PLAYER_PUSHING ); }
// try to smell something void CAI_PlayerAlly::TrySmellTalk( void ) { if ( !IsOkToSpeak() ) return; if ( HasCondition( COND_SMELL ) && GetExpresser()->CanSpeakConcept( TLK_SMELL ) ) Speak( TLK_SMELL ); }
void CHL1NPCTalker::StartFollowing( CBaseEntity *pLeader ) { if ( !HasSpawnFlags( SF_NPC_GAG ) ) { Speak( TLK_USE ); SetSpeechTarget( pLeader ); } BaseClass::StartFollowing( pLeader ); }
//========================================================= // FIdleStare //========================================================= int CAI_PlayerAlly::FIdleStare( void ) { if (!IsOkToSpeak()) return false; Speak( TLK_STARE ); SetSpeechTarget( FindNearestFriend( true ) ); return true; }
//----------------------------------------------------------------------------- void CAI_PlayerAlly::PlayerSelect( bool select ) { if( select && HasMemory( bits_MEMORY_PROVOKED ) ) { Speak( TLK_BETRAYED ); return; } BaseClass::PlayerSelect( select ); }