FiLTHYESKiMO Posted February 28, 2012 Share Posted February 28, 2012 (edited) Hey guys, So it has been awhile since I've done any modding. I understand the fundamentals of programming so it shouldn't take me too long to catch on. I've noticed that Skyrim also uses some Homebrew script engine, so I am still a little confused on how it works. But, I've written a little script. I know it is not accurate but anyone that knows a little coding should know what I am trying to accomplish. If you could just point out things that need changing (even though it doesn't make the script work) it will help me learn. Scriptname HumanAging Conditional {Player aging system.} int TheYear = GameYear.GetValue() ActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBase Race PlayerRace = PlayerBase.GetRace() If (PlayerRace = "Redguard" or "Imperial" or "Nord") If (TheYear <= 220) Game.GetPlayer().AddPerk AgePerk1 (AgePerk1) endif elseif (TheYear >= 221) && (TheYear <= 231) Game.GetPlayer().RemovePerk AgePerk1 Game.GetPlayer().AddPerk AgePerk2 (AgePerk2) endif elseif (TheYear == 241) Game.GetPlayer().kill endif endif I already noticed that I should make the code check whether he already has the perk before adding again. Edited February 28, 2012 by FiLTHYESKiMO Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted February 29, 2012 Author Share Posted February 29, 2012 Any thoughts? Link to comment Share on other sites More sharing options...
darkneon Posted February 29, 2012 Share Posted February 29, 2012 Scriptname HumanAging Conditional {Player aging system.} int TheYear = GameYear.GetValue() ActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBase Race PlayerRace = PlayerBase.GetRace() If (PlayerRace = "Redguard" or "Imperial" or "Nord") If (TheYear <= 220) Game.GetPlayer().AddPerk AgePerk1 (AgePerk1) endif elseif (TheYear >= 221) && (TheYear <= 231) Game.GetPlayer().RemovePerk AgePerk1 Game.GetPlayer().AddPerk AgePerk2 (AgePerk2) elseif (TheYear == 241) Game.GetPlayer().kill endif endif i don't have much experience with Papyrus...but from what i saw, you had one EndIf too much (the one between AgePerk2 and the ElseIf(TheYear == 241)) see if this fixes your problems. (P.S. why would you want to kill the player at an exact year?) Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted February 29, 2012 Author Share Posted February 29, 2012 (edited) Scriptname HumanAging Conditional {Player aging system.} int TheYear = GameYear.GetValue() ActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBase Race PlayerRace = PlayerBase.GetRace() If (PlayerRace = "Redguard" or "Imperial" or "Nord") If (TheYear <= 220) Game.GetPlayer().AddPerk AgePerk1 (AgePerk1) endif elseif (TheYear >= 221) && (TheYear <= 231) Game.GetPlayer().RemovePerk AgePerk1 Game.GetPlayer().AddPerk AgePerk2 (AgePerk2) elseif (TheYear == 241) Game.GetPlayer().kill endif endif i don't have much experience with Papyrus...but from what i saw, you had one EndIf too much (the one between AgePerk2 and the ElseIf(TheYear == 241)) see if this fixes your problems. (P.S. why would you want to kill the player at an exact year?) Well this is just a muck-up. I think the finish code would increase your chances of randomly dying instead of just flat out killing you. I also noticed that the EndIf is just at the wrong location, not too many, Still, I am not exactly sure whether this script is Papyrus friendly. So, if anyone can point out things that are wrong, I would greatly appreciate it, :) Edited February 29, 2012 by FiLTHYESKiMO Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted February 29, 2012 Author Share Posted February 29, 2012 (edited) Scriptname HumanAging Conditional {Player aging system.} int TheYear = GameYear.GetValue() int Stage1 = Player.HasPerk AgePerkID (AgePerk1) int Stage2 = Player.HasPerk AgePerkID (AgePerk2) int Stage3 = Player.HasPerk AgePerkID (AgePerk3) ActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBase Race PlayerRace = PlayerBase.GetRace() If (PlayerRace = "Redguard" or "Imperial" or "Nord") If (TheYear <= 220) && (Stage1 == 0) Game.GetPlayer().AddPerk AgePerk1 (AgePerk1) elseif (TheYear >= 221) && (TheYear <= 231) && (Stage1 == 1) Game.GetPlayer().RemovePerk AgePerk1ID Game.GetPlayer().AddPerk AgePerk2ID (AgePerk2) elseif (TheYear >= 241) && (Stage2 == 1) Game.GetPlayer().RemovePerk AgePerk2ID Game.GetPlayer().AddPerk AgePerk3ID (AgePerk3) endif endif Revised. Added a perk check to ensure the code doesn't already add a perk that's there. Edited February 29, 2012 by FiLTHYESKiMO Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted February 29, 2012 Author Share Posted February 29, 2012 Scriptname HumanAging {Gives age perks for human players} GlobalVariable property GameYearVar auto int property Stage auto Perk property AgePerk1 auto Perk property AgePerk2 auto Perk property AgePerk3 auto Function AgePerks() ActorBase PlayerBase = Game.GetPlayer().GetBaseObject() as ActorBase Race PlayerRace = PlayerBase.GetRace() float GameYear = GameYearVar.Value If (PlayerRace == "Redguard" || "Imperial" || "Nord") If (GameYear <= 220) && (Stage == 0) Stage += 1 Game.GetPlayer().AddPerk(AgePerk1) else if (GameYear >= 221) && (GameYear <= 231) && (Stage == 1) Game.GetPlayer().AddPerk(AgePerk2) Stage += 1 else if (GameYear >= 241) && (Stage == 2) Game.GetPlayer().AddPerk(AgePerk3) endif endif endif endif endFunction This is how the new code looks. Seems like I was a little ways off. Got this thanks to Irfeir. Link to comment Share on other sites More sharing options...
Recommended Posts