kxdace Posted February 13, 2021 Posted February 13, 2021 Hello beautiful people! So I created a simple mod that allows you to increase relationship rank using various vanilla in game values. Everything works great but I was hoping to get a pair of experienced eyes to look over my code and make sure I’m not doing anything that could corrupt a saved game down the road. The methodology is simple. At relationship rank 0 you walk up to an NPC and start a conversation. You chose a dialog option that makes sense based on the NPC’s characteristics (Merchant, Warrior, Mage, ETC) and if you chose the correct characteristic a small calculation is performed to see if you can level up your relationship based on your Fame (Number of quests completed) and Speech craft. For example: Relationship Level 0 I really admire how much effort it takes to be a merchant (isInFaction(JobMerchant)) Warriors are to be admired (CombatClass = 1) ETC If you chose the correct Class \ Faction dialogue then a small calculation is performed Total Fame = Number of quests completed (+2 for every quest completed) Total Speech = Skillpoints in speechcraft (+2 for every 20 points) Total Sway = Total Fame + Total Speech Then a random number is generated between 0 and 10. If Total swag is greater than the random number the relationship rank is increased by 1. Relationship Level 1 Same as above except the random value is between 10 and 20. Relationship Level 2 ETC ===CODE=== Scriptname TIF__02006C7C Extends TopicInfo Hidden Faction Property JobMerchantFaction Auto int property FameL Auto int property TSwag Auto Quest property BFalls auto Quest property WHThane Auto Quest property DRising Auto Function Fragment_0(ObjectReference akSpeakerRef) ;;;Speech Check int speechTotal = 0 int currentS = game.getplayer().getAV("Speechcraft") as int if (currentS >= 25) speechTotal = 2 elseIf(currentS >= 50) speechTotal = 4 elseIf(currentS >= 75) speechTotal = 6 elseIf(currentS >= 90) speechTotal = 10 else endIf ;;;Fame Check if (BFalls.IsStageDone(190)) FameL = FameL + 2 endIF if (WHThane.IsStageDone(200)) FameL = FameL + 2 endIF if(DRising.IsStageDone(160)) FameL = Fame: +2 endIf TSwag = FameL + SpeechTotal debug.notification("Total Swag is: " + TSwag) ;debug.notification("Current relationship Rank is: " + akSpeaker.GetRelationshipRank(Game.GetPlayer())) utility.wait(0.5) Actor akSpeaker = akSpeakerRef as Actor if(akSpeaker.isInFaction(JobMerchantFaction)) int rando = Utility.RandomInt (0,10) debug.notification("Rando value: " + rando) if(rando < TSwag) akSpeaker.SetRelationshipRank(Game.GetPlayer(), 1) debug.notification("Players Relations ship rank is increased") else debug.notification("No Increase") endIf endIf utility.wait(0.5) ;debug.notification("Players Relations ship rank is now: " + akSpeaker.GetRelationshipRank(Game.GetPlayer())) EndFunction
Andy14 Posted February 13, 2021 Posted February 13, 2021 50 minutes ago, kxdace said: if (currentS >= 25) speechTotal = 2 elseIf(currentS >= 50) speechTotal = 4 elseIf(currentS >= 75) speechTotal = 6 elseIf(currentS >= 90) speechTotal = 10 else endIf That will never go into the elseif because the if is always fulfilled. Invert the if query Top-> Down ... if (currentS >= 90) speechTotal = 10 elseIf(currentS >= 75) speechTotal = 6 elseIf(currentS >= 50) speechTotal = 4 elseIf(currentS >= 25) speechTotal = 2 endIf
Recommended Posts
Archived
This topic is now archived and is closed to further replies.