Advertisement
expired6978

DLC1_NPCMentalModelScript

Aug 14th, 2012
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.24 KB | None | 0 0
  1. Scriptname DLC1_NPCMentalModelScript extends Quest conditional
  2.  
  3. Bool Property PlayerInsultedFamily Auto
  4. Int Property MentionedLoneliness Auto
  5. Bool Property IsWillingToWait Auto
  6. faction Property WIFollowerCommentFaction Auto
  7. Bool Property PlayerTalkedAboutParents Auto
  8. referencealias Property RNPC Auto
  9. Quest Property DialogueFollower Auto
  10. Bool Property SimpleFollow Auto
  11. Bool Property TalkedPostQuest Auto
  12. referencealias Property CentralFollowerAlias Auto
  13. actor Property Serana Auto
  14. Int Property DebugGuardedToOpen
  15. Function Set(Int val)
  16. __axisGuardedToOpen = val
  17. EndFunction
  18.  
  19. endProperty
  20.  
  21. objectreference Property PreChoiceMarker Auto
  22. Bool Property TurnOffComeWithMe Auto
  23. Bool Property CutOffCureDiscussion Auto
  24. Bool Property IsWaiting Auto
  25. idle Property RF_MoodChangeGuarded Auto
  26. Bool Property HadMarriageTalk Auto
  27. Bool Property DTR Auto
  28. Int Property AxisGuardedToOpen
  29. Int Function Get()
  30. return __axisGuardedToOpen
  31. EndFunction
  32.  
  33. Function Set(Int newValue)
  34. Int oldValue
  35. oldValue = __axisGuardedToOpen
  36. __axisGuardedToOpen = ClampInt(newValue, __axisMin, __axisMax)
  37. if ((oldValue < 0) as Bool) && ((__axisGuardedToOpen >= 0) as Bool)
  38. AxisCrossedOver()
  39. endif
  40. if ((oldValue >= 0) as Bool) && ((__axisGuardedToOpen < 0) as Bool)
  41. AxisCrossedOver()
  42. endif
  43. EndFunction
  44.  
  45. endProperty
  46.  
  47. Bool Property SpouseIsMale Auto
  48. Bool Property UnhappyHomeLife Auto
  49. Float Property PlayerAssessmentIndependence
  50. Float Function Get()
  51. return __playerAssessmentIndependence
  52. EndFunction
  53.  
  54. Function Set(Float newValue)
  55. __playerAssessmentIndependence = ClampFloat(newValue, __assessmentMin, __assessmentMax)
  56. EndFunction
  57.  
  58. endProperty
  59.  
  60. Bool Property HappyHomeLife Auto
  61. Float Property PlayerAssessmentIntelligence
  62. Float Function Get()
  63. return __playerAssessmentIntelligence
  64. EndFunction
  65.  
  66. Function Set(Float newValue)
  67. __playerAssessmentIntelligence = ClampFloat(newValue, __assessmentMin, __assessmentMax)
  68. EndFunction
  69.  
  70. endProperty
  71.  
  72. idle Property RF_MoodChangePlayful Auto
  73. Bool Property IsDismissed Auto
  74. Bool Property LockedIn Auto
  75. Bool Property BelievesPlayerIsMarried Auto
  76. dlc1npcmonitoringplayerscript Property MonitoringQuest Auto
  77. armor Property Hoodie Auto
  78. Bool Property FollowDistanceFar Auto
  79. Int Property SecondsBetweenPeriodicUpdates Auto
  80. Bool Property TalkedAboutKillingHarkon Auto
  81. Bool Property PlayerOrphan Auto
  82. Int Property AxisSeriousToPlayful
  83. Int Function Get()
  84. return __axisSeriousToPlayful
  85. EndFunction
  86.  
  87. Function Set(Int newValue)
  88. Int oldValue
  89. oldValue = __axisSeriousToPlayful
  90. __axisSeriousToPlayful = ClampInt(newValue, __axisMin, __axisMax)
  91. if ((oldValue < 0) as Bool) && ((__axisSeriousToPlayful >= 0) as Bool)
  92. AxisCrossedOver()
  93. endif
  94. if ((oldValue >= 0) as Bool) && ((__axisSeriousToPlayful < 0) as Bool)
  95. AxisCrossedOver()
  96. endif
  97. EndFunction
  98.  
  99. endProperty
  100.  
  101. Bool Property WillingToTradeItemsWithPlayer Auto
  102. Bool Property LikesPlayerPostQuest Auto
  103. globalvariable Property FollowerCount Auto
  104. Bool Property PlayerLikedParents Auto
  105. Bool Property FollowDistanceMedium Auto
  106. objectreference Property HunterHomeMarker Auto
  107. Bool Property FollowDistanceClose Auto
  108. Bool Property ToldPlayerSheDidntWantCure Auto
  109. Bool Property QuestLineCompleted Auto
  110. Bool Property TalkedAboutKillingHarkonForReal Auto
  111. armor Property VampArmor Auto
  112. formlist Property SunDamageExceptionList Auto
  113. Bool Property PlayerNaive Auto
  114. idle Property RF_MoodChangeSerious Auto
  115. Bool Property PlayerParentsAlive Auto
  116. Bool Property IsFollowing Auto
  117. objectreference Property VampHomeMarker Auto
  118. Int Property DebugSeriousToPlayful
  119. Function Set(Int val)
  120. __axisSeriousToPlayful = val
  121. EndFunction
  122.  
  123. endProperty
  124.  
  125. referencealias Property HomeMarker Auto
  126. Bool Property CanFollow Auto
  127. Bool Property PlayerSettled Auto
  128. referencealias Property RNPC_Essential Auto
  129. idle Property RF_MoodChangeOpen Auto
  130. Bool Property CanBeDismissed Auto
  131. referencealias Property RNPC_Keywords Auto
  132.  
  133. Int __historySize = 10
  134. Float __assessmentMax = 10.00000
  135. Int[] __axisHistoryGuardedToOpen = None
  136. Float __minorAssessment = 0.25000
  137. Int __axisAnchorGuardedToOpen = -1
  138. Float __majorAssessment = 1.00000
  139. Float __assessmentAnchorIndependence = 6.50000
  140. Int __axisAnchorSeriousToPlayful = -2
  141. Int __axisSeriousToPlayful = 0
  142. Int __axisMax = 3
  143. Float __playerAssessmentIntelligence = 0.00000
  144. Float __moderateAssessment = 0.50000
  145. Float __playerAssessmentIndependence = 0.00000
  146. Float __assessmentAnchorIntelligence = 5.00000
  147. Int[] __axisHistorySeriousToPlayful = None
  148. Int __axisMin = -3
  149. Bool __axisCrossingTimeout = false
  150. Float __assessmentMin = 0.00000
  151. Float[] __assessmentHistoryIndependence = None
  152. Bool __isSetup = false
  153. Int __axisGuardedToOpen = 0
  154. Float[] __assessmentHistoryIntelligence = None
  155.  
  156. Float Function ClampFloat(Float value, Float min, Float max)
  157. if (value > max)
  158. value = max
  159. endif
  160. if (value < min)
  161. value = min
  162. endif
  163. return value
  164. EndFunction
  165.  
  166. Function Wait()
  167. debug.Trace("RNPC: Being told to wait...", 0)
  168. if !(IsWillingToWait)
  169. debug.Trace("RNPC: ... but not listening.", 0)
  170. IsWaiting = true
  171. endif
  172. debug.Trace("RNPC: ... and obeying.", 0)
  173. IsWaiting = true
  174. RNPC.GetActorReference()
  175. RNPC.GetActorReference().SetAV("WaitingForPlayer", (1 as Float))
  176. RNPC.GetActorReference()
  177. RNPC.GetActorReference().EvaluatePackage()
  178. (RNPC as dlc1rnpcaliasscript).RegisterForUpdateGameTime((72 as Float))
  179. EndFunction
  180.  
  181. Int Function ClampInt(Int value, Int min, Int max)
  182. if (value > max)
  183. value = max
  184. endif
  185. if (value < min)
  186. value = min
  187. endif
  188. return value
  189. EndFunction
  190.  
  191. Function FinishWaiting()
  192. IsWaiting = false
  193. RNPC.GetActorReference()
  194. RNPC.GetActorReference().SetAV("WaitingForPlayer", (0 as Float))
  195. if CanBeDismissed
  196. DisengageFollowBehavior()
  197. Dismiss()
  198. endif
  199. RNPC.GetActorReference()
  200. RNPC.GetActorReference().EvaluatePackage()
  201. EndFunction
  202.  
  203. Function Dismiss()
  204. if CanBeDismissed
  205. DisengageFollowBehavior()
  206. IsDismissed = true
  207. if (CentralFollowerAlias.GetReference() == RNPC.GetReference())
  208. (DialogueFollower as dialoguefollowerscript).DismissFollower(0, 1)
  209. endif
  210. RNPC.GetActorReference()
  211. RNPC.GetActorReference().SetPlayerTeammate(false, true)
  212. endif
  213. EndFunction
  214.  
  215. Function IncreaseSerious(Int amount)
  216. ModAxis(1, amount)
  217. EndFunction
  218.  
  219. Function IncreasePlayful(Int amount)
  220. ModAxis(1, amount)
  221. EndFunction
  222.  
  223. Function DebugOutput()
  224. debug.OpenUserLog("RNPC_MentalModel")
  225. debug.TraceUser("RNPC_MentalModel", ((((((((" " + (__axisGuardedToOpen as String)) + " ") + (__axisSeriousToPlayful as String)) + " ") + (__playerAssessmentIntelligence as String)) + " ") + (__playerAssessmentIndependence as String)) + " "), 0)
  226. EndFunction
  227.  
  228. Function IncreaseGuarded(Int amount)
  229. ModAxis(2, amount)
  230. EndFunction
  231.  
  232. Function ModAxis(Int axisIndex, Int amount)
  233. if (axisIndex == 1)
  234. AxisSeriousToPlayful = (AxisSeriousToPlayful + amount)
  235. endif
  236. if (axisIndex == 2)
  237. AxisGuardedToOpen = (AxisGuardedToOpen + amount)
  238. endif
  239. EndFunction
  240.  
  241. Function Unlock()
  242. debug.Trace("RNPC: Unlocking.", 0)
  243. LockedIn = false
  244. DisengageFollowBehavior()
  245. FollowerCount.SetValue((0 as Float))
  246. EndFunction
  247.  
  248. Function QuestLineFinish()
  249. EndFunction
  250.  
  251. Function SlamToPlayful()
  252. debug.Trace("RNPC: Forcing to 'playful' animation base.", 0)
  253. __axisSeriousToPlayful = 3
  254. __axisGuardedToOpen = 3
  255. AxisCrossedOver()
  256. EndFunction
  257.  
  258. Function LockIn()
  259. debug.Trace("RNPC: Locking.", 0)
  260. LockedIn = true
  261. EngageFollowBehavior(false)
  262. FollowerCount.SetValue((1 as Float))
  263. EndFunction
  264.  
  265. Function DisengageFollowBehavior()
  266. debug.Trace("RNPC: Disengaging follow.", 0)
  267. IsFollowing = false
  268. IsWaiting = false
  269. CanBeDismissed = true
  270. RNPC.GetActorReference()
  271. RNPC.GetActorReference().SetPlayerTeammate(false, true)
  272. RNPC.GetActorReference()
  273. RNPC.GetActorReference().EvaluatePackage()
  274. RNPC.GetActorReference()
  275. RNPC.GetActorReference().RemoveFromFaction(WIFollowerCommentFaction)
  276. if ((CentralFollowerAlias.GetReference() == None) as Bool) && ((FollowerCount.GetValue() == (1 as Float)) as Bool)
  277. FollowerCount.SetValue((0 as Float))
  278. endif
  279. MonitoringQuest.Stop()
  280. EndFunction
  281.  
  282. Function SlamToSerious()
  283. debug.Trace("RNPC: Forcing to 'serious' animation base.", 0)
  284. __axisSeriousToPlayful = 3
  285. __axisGuardedToOpen = -3
  286. AxisCrossedOver()
  287. EndFunction
  288.  
  289. Function DecreaseIndependenceModerate()
  290. ModAssessment(3, __moderateAssessment)
  291. EndFunction
  292.  
  293. {Function that switches this object to the specified state}
  294. Function GotoState(String newState)
  295. onEndState()
  296. ::State = newState
  297. onBeginState()
  298. EndFunction
  299.  
  300. Function IncreaseIntelligenceModerate()
  301. ModAssessment(2, __moderateAssessment)
  302. EndFunction
  303.  
  304. Function DecreaseSerious(Int amount)
  305. ModAxis(1, amount)
  306. EndFunction
  307.  
  308. Function IncreaseIndependenceModerate()
  309. ModAssessment(3, __moderateAssessment)
  310. EndFunction
  311.  
  312. Function DumpHistory()
  313. Int count
  314. count = 0
  315. while (count < __historySize)
  316. debug.TraceUser("RNPC_HistoryDump", (((((((("" + (__axisHistoryGuardedToOpen[count] as String)) + " ") + (__axisHistorySeriousToPlayful[count] as String)) + " ") + (__assessmentHistoryIntelligence[count] as String)) + " ") + (__assessmentHistoryIndependence[count] as String)) + " "), 0)
  317. count = (count + 1)
  318. endWhile
  319. EndFunction
  320.  
  321. {Function that returns the current state}
  322. String Function GetState()
  323. return ::State
  324. EndFunction
  325.  
  326. Function OnUpdate()
  327. Int count
  328. debug.Trace("RNPC: Periodic update check.", 0)
  329. DebugOutput()
  330. count = 0
  331. while (count < (__historySize - 1))
  332. __axisHistoryGuardedToOpen[count] = __axisHistoryGuardedToOpen[(count + 1)]
  333. __axisHistorySeriousToPlayful[count] = __axisHistorySeriousToPlayful[(count + 1)]
  334. __assessmentHistoryIntelligence[count] = __assessmentHistoryIntelligence[(count + 1)]
  335. __assessmentHistoryIndependence[count] = __assessmentHistoryIndependence[(count + 1)]
  336. count = (count + 1)
  337. endWhile
  338. __axisHistoryGuardedToOpen[(__historySize - 1)] = __axisGuardedToOpen
  339. __axisHistorySeriousToPlayful[(__historySize - 1)] = __axisSeriousToPlayful
  340. __assessmentHistoryIntelligence[(__historySize - 1)] = __playerAssessmentIntelligence
  341. __assessmentHistoryIndependence[(__historySize - 1)] = __playerAssessmentIndependence
  342. if FollowDistanceFar FollowDistanceFar = true
  343. FollowDistanceMedium = false
  344. FollowDistanceClose = false
  345. endif
  346. && FollowDistanceMediumFollowDistanceFar = false
  347. FollowDistanceMedium = true
  348. FollowDistanceClose = false
  349. endif
  350. && FollowDistanceClose
  351. FollowDistanceFar = false
  352. FollowDistanceMedium = false
  353. FollowDistanceClose = true
  354. endif
  355. FollowDistanceFar = false
  356. FollowDistanceMedium = false
  357. FollowDistanceClose = false
  358. if QuestLineCompleted
  359. CanFollow = true
  360. IsWillingToWait = true
  361. CanBeDismissed = true
  362. endif
  363. CheckOutfit()
  364. RegisterForSingleUpdate((SecondsBetweenPeriodicUpdates as Float))
  365. EndFunction
  366.  
  367. Function IncreaseIntelligenceMinor()
  368. ModAssessment(2, __minorAssessment)
  369. EndFunction
  370.  
  371. Function SetHomeMarker(Int choiceSet, objectreference newHomeMarker)
  372. if !((newHomeMarker == None))
  373. HomeMarker.ForceRefTo(newHomeMarker)
  374. endif
  375. if (choiceSet == 1)
  376. HomeMarker.ForceRefTo(HunterHomeMarker)
  377. endif
  378. if (choiceSet == 2)
  379. HomeMarker.ForceRefTo(VampHomeMarker)
  380. endif
  381. EndFunction
  382.  
  383. Function ModAssessment(Int assessmentIndex, Float amount)
  384. if (assessmentIndex == 1)
  385. endif
  386. if (assessmentIndex == 2)
  387. PlayerAssessmentIndependence = (PlayerAssessmentIndependence + amount)
  388. endif
  389. if (assessmentIndex == 3)
  390. PlayerAssessmentIndependence = (PlayerAssessmentIndependence + amount)
  391. endif
  392. EndFunction
  393.  
  394. Function IncreaseIntelligenceMajor()
  395. ModAssessment(2, __majorAssessment)
  396. EndFunction
  397.  
  398. Function Setup(Int forceNPC)
  399. Int count
  400. if __isSetup
  401. return
  402. endif
  403. __isSetup = true
  404. debug.Trace("RNPC: Initiating NPC mental model.", 0)
  405. __axisHistoryGuardedToOpen = new Int[10]
  406. __axisHistorySeriousToPlayful = new Int[10]
  407. __assessmentHistoryIntelligence = new Float[10]
  408. __assessmentHistoryIndependence = new Float[10]
  409. count = 0
  410. while (count < __historySize)
  411. __axisHistoryGuardedToOpen[count] = __axisAnchorGuardedToOpen
  412. __axisHistorySeriousToPlayful[count] = __axisAnchorSeriousToPlayful
  413. __assessmentHistoryIntelligence[count] = __assessmentAnchorIntelligence
  414. __assessmentHistoryIndependence[count] = __assessmentAnchorIndependence
  415. count = (count + 1)
  416. endWhile
  417. __axisGuardedToOpen = __axisAnchorGuardedToOpen
  418. __axisSeriousToPlayful = __axisAnchorSeriousToPlayful
  419. RNPC.GetReference()
  420. RNPC_Keywords.ForceRefTo(RNPC.GetReference())
  421. RegisterForSingleUpdate((SecondsBetweenPeriodicUpdates as Float))
  422. EndFunction
  423.  
  424. Function DecreaseIntelligenceMinor()
  425. ModAssessment(2, __minorAssessment)
  426. EndFunction
  427.  
  428. Function EngageFollowBehavior(Bool allowDismiss)
  429. debug.Trace("RNPC: Engaging follow.", 0)
  430. if ((CentralFollowerAlias.GetReference() == None) as Bool) && ((FollowerCount.GetValue() == (0 as Float)) as Bool)FollowerCount.SetValue((1 as Float))
  431. endif
  432. && QuestLineCompleted
  433. allowDismiss = true
  434. endif
  435. IsFollowing = true
  436. IsWaiting = false
  437. SimpleFollow = false
  438. CanFollow = true
  439. IsDismissed = false
  440. CanBeDismissed = allowDismiss
  441. RNPC.GetActorReference()
  442. RNPC.GetActorReference().SetPlayerTeammate(true, true)
  443. RNPC.GetActorReference()
  444. RNPC.GetActorReference().EvaluatePackage()
  445. RNPC.GetActorReference()
  446. RNPC.GetActorReference().AddToFaction(WIFollowerCommentFaction)
  447. MonitoringQuest.Start()
  448. EndFunction
  449.  
  450. Function StopWaiting()
  451. if IsDismissed
  452. EngageFollowBehavior(CanBeDismissed)
  453. endif
  454. IsWaiting = false
  455. (RNPC as dlc1rnpcaliasscript).UnregisterForUpdateGameTime()
  456. RNPC.GetActorReference()
  457. RNPC.GetActorReference().SetAV("WaitingForPlayer", (0 as Float))
  458. RNPC.GetActorReference()
  459. RNPC.GetActorReference().EvaluatePackage()
  460. EndFunction
  461.  
  462. Function DecreaseOpen(Int amount)
  463. ModAxis(2, amount)
  464. EndFunction
  465.  
  466. Function SlamToGuarded()
  467. debug.Trace("RNPC: Forcing to 'guarded' animation base.", 0)
  468. __axisSeriousToPlayful = -3
  469. __axisGuardedToOpen = -3
  470. AxisCrossedOver()
  471. EndFunction
  472.  
  473. Function DecreaseIntelligenceMajor()
  474. ModAssessment(2, __majorAssessment)
  475. EndFunction
  476.  
  477. Function DecreaseIndependenceMinor()
  478. ModAssessment(3, __minorAssessment)
  479. EndFunction
  480.  
  481. Function IncreaseIndependenceMinor()
  482. ModAssessment(3, __minorAssessment)
  483. EndFunction
  484.  
  485. Function CheckOutfit()
  486. actor rnpcActor
  487. Bool shouldWearHood
  488. worldspace currentSpace
  489. rnpcActor = RNPC.GetActorReference()
  490. shouldWearHood = false
  491. if rnpcActor.IsInInterior()
  492. shouldWearHood = false
  493. endif
  494. RNPC.GetReference()
  495. currentSpace = RNPC.GetReference().GetWorldSpace()
  496. if (SunDamageExceptionList.Find((currentSpace as form)) < 0)
  497. shouldWearHood = true
  498. endif
  499. shouldWearHood = false
  500. if !(shouldWearHood)
  501. if (rnpcActor.IsEquipped((VampArmor as form)) as Bool) && (rnpcActor.IsEquipped((Hoodie as form)) as Bool)
  502. debug.Trace("RNPC: Inside, taking off hood.", 0)
  503. rnpcActor.RemoveItem((Hoodie as form), 1, false, None)
  504. endif
  505. endif
  506. if (rnpcActor.IsEquipped((VampArmor as form)) as Bool) && (!(rnpcActor.IsEquipped((Hoodie as form))) as Bool)
  507. debug.Trace("RNPC: Outside, putting on hood.", 0)
  508. rnpcActor.AddItem((Hoodie as form), 1, false)
  509. rnpcActor.EquipItem((Hoodie as form), false, false)
  510. endif
  511. EndFunction
  512.  
  513. Function DecreaseGuarded(Int amount)
  514. ModAxis(2, amount)
  515. EndFunction
  516.  
  517. Function DecreaseIntelligenceModerate()
  518. ModAssessment(2, __moderateAssessment)
  519. EndFunction
  520.  
  521. Function DecreasePlayful(Int amount)
  522. ModAxis(1, amount)
  523. EndFunction
  524.  
  525. Function SlamToOpen()
  526. debug.Trace("RNPC: Forcing to 'open' animation base.", 0)
  527. __axisSeriousToPlayful = -3
  528. __axisGuardedToOpen = 3
  529. AxisCrossedOver()
  530. EndFunction
  531.  
  532. Function IncreaseIndependenceMajor()
  533. ModAssessment(3, __majorAssessment)
  534. EndFunction
  535.  
  536. Function DecreaseIndependenceMajor()
  537. ModAssessment(3, __majorAssessment)
  538. EndFunction
  539.  
  540. Function AxisCrossedOver()
  541. if __axisCrossingTimeout
  542. return
  543. endif
  544. debug.Trace("RNPC: Axis crossed.", 0)
  545. __axisCrossingTimeout = true
  546. if ((__axisGuardedToOpen < 0) as Bool) && ((__axisSeriousToPlayful < 0) as Bool)
  547. RNPC.GetActorReference()
  548. endif
  549. if ((__axisGuardedToOpen >= 0) as Bool) && ((__axisSeriousToPlayful < 0) as Bool)
  550. RNPC.GetActorReference()
  551. endif
  552. if ((__axisGuardedToOpen < 0) as Bool) && ((__axisSeriousToPlayful >= 0) as Bool)
  553. RNPC.GetActorReference()
  554. endif
  555. if ((__axisGuardedToOpen >= 0) as Bool) && ((__axisSeriousToPlayful >= 0) as Bool)
  556. RNPC.GetActorReference()
  557. RNPC.GetActorReference().PlayIdle(RF_MoodChangePlayful)
  558. endif
  559. utility.Wait(0.10000)
  560. __axisCrossingTimeout = false
  561. EndFunction
  562.  
  563. Function IncreaseOpen(Int amount)
  564. ModAxis(2, amount)
  565. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement