mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 12:56:39 +00:00 
			
		
		
		
	Play "attack" voiced dialogue entries randomly based on iVoiceAttackOdds.
This commit is contained in:
		
							parent
							
								
									d9d6f37619
								
							
						
					
					
						commit
						621e52f09d
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
					@ -7,6 +7,7 @@
 | 
				
			||||||
#include "../mwbase/world.hpp"
 | 
					#include "../mwbase/world.hpp"
 | 
				
			||||||
#include "../mwbase/environment.hpp"
 | 
					#include "../mwbase/environment.hpp"
 | 
				
			||||||
#include "../mwbase/mechanicsmanager.hpp"
 | 
					#include "../mwbase/mechanicsmanager.hpp"
 | 
				
			||||||
 | 
					#include "../mwbase/dialoguemanager.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "creaturestats.hpp"
 | 
					#include "creaturestats.hpp"
 | 
				
			||||||
#include "npcstats.hpp"
 | 
					#include "npcstats.hpp"
 | 
				
			||||||
| 
						 | 
					@ -118,6 +119,17 @@ namespace MWMechanics
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if( mTimer > 1)
 | 
					            if( mTimer > 1)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
 | 
					                if (actor.getClass().isNpc())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
 | 
				
			||||||
 | 
					                    int chance = store.get<ESM::GameSetting>().find("iVoiceAttackOdds")->getInt();
 | 
				
			||||||
 | 
					                    int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
 | 
				
			||||||
 | 
					                    if (roll < chance)
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        MWBase::Environment::get().getDialogueManager()->say(actor, "attack");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(true);
 | 
					                MWWorld::Class::get(actor).getCreatureStats(actor).setAttackingOrSpell(true);
 | 
				
			||||||
                mTimer = 0;
 | 
					                mTimer = 0;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue