Jump to content

[LE] Script to Add Perks on Button Press?


Recommended Posts

So I am having a heck of a time trying to get this script to work. I'm essentially just making myself a little cheat room, where pushing a button automatically levels the associated skill to 100 and gives the player all the perks for that skill. It's a doozy of a script, and likely not anywhere as neat and concise as it could be, but it works... mostly.

 

Here's a chunk of it:

Scriptname SC_AutoMaxSkill extends ObjectReference  

string[] SkillName ;array for holding the skill names
int property WhichSkill = 0 auto ;what skill should be maxed
Actor Property PlayerRef Auto hidden

Perk Property IllusionNovice00 Auto hidden
Perk Property IllusionDualCasting Auto hidden
Perk Property Animage Auto hidden
Perk Property IllusionApprentice25 Auto hidden
Perk Property HypnoticGaze Auto hidden
Perk Property KindredMage Auto hidden
Perk Property IllusionAdept50 Auto hidden
Perk Property AspectofTerror Auto hidden
Perk Property QuietCasting Auto hidden
Perk Property Rage Auto hidden
Perk Property IllusionExpert75 Auto hidden
Perk Property MasteroftheMind Auto hidden
Perk Property IllusionMaster100 Auto hidden

event onCellLoad()
	SkillName = new string[18] ;initializing the array
	SkillName[0]="Illusion"
	SkillName[1]="Conjuration"
	SkillName[2]="Destruction"
	SkillName[3]="Restoration"
	SkillName[4]="Alteration"
	SkillName[5]="Enchanting"
	SkillName[6]="Smithing"
	SkillName[7]="HeavyArmor"
	SkillName[8]="Block"
	SkillName[9]="TwoHanded"
	SkillName[10]="OneHanded"
	SkillName[11]="Marksman"
	SkillName[12]="LightArmor"
	SkillName[13]="Sneak"
	SkillName[14]="Lockpicking"
	SkillName[15]="Pickpocket"
	SkillName[16]="Speechcraft"
	SkillName[17]="Alchemy"
endEvent

event onActivate(objectReference akActivator)
	PlayerRef = Game.GetPlayer()
	if WhichSkill <= 17
		Game.IncrementSkillBy(SkillName[WhichSkill], 100)
		addThesePerks(WhichSkill)
	endIf
endEvent

function addThesePerks(int WhichSkill)
	if WhichSkill == 0
		addIllusionPerks()
	elseif WhichSkill == 1
		addConjurationPerks()
	elseif WhichSkill == 2
		addDestructionPerks()
	elseif WhichSkill == 3
		addRestorationPerks()
	elseif WhichSkill == 4
		addAlterationPerks()
	elseif WhichSkill == 5
		addEnchantingPerks()
	elseif WhichSkill == 6
		addSmithingPerks()
	elseif WhichSkill == 7
		addHeavyArmorPerks()
	elseif WhichSkill == 8
		addBlockPerks()
	elseif WhichSkill == 9
		addTwoHandedPerks()
	elseif WhichSkill == 10
		addOneHandedPerks()
	elseif WhichSkill == 11
		addArcheryPerks()
	elseif WhichSkill == 12
		addLightArmorPerks()
	elseif WhichSkill == 13
		addSneakPerks()
	elseif WhichSkill == 14
		addLockpickingPerks()
	elseif WhichSkill == 15
		addPickpocketPerks()
	elseif WhichSkill == 16
		addSpeechPerks()
	elseif WhichSkill == 17
		addAlchemyPerks()
	endIf
endfunction

function addIllusionPerks()
	PlayerRef.AddPerk(IllusionNovice00)
	PlayerRef.AddPerk(IllusionDualCasting)
	PlayerRef.AddPerk(Animage)
	PlayerRef.AddPerk(IllusionApprentice25)
	PlayerRef.AddPerk(HypnoticGaze)
	PlayerRef.AddPerk(KindredMage)
	PlayerRef.AddPerk(IllusionAdept50)
	PlayerRef.AddPerk(AspectofTerror)
	PlayerRef.AddPerk(QuietCasting)
	PlayerRef.AddPerk(Rage)
	PlayerRef.AddPerk(IllusionExpert75)
	PlayerRef.AddPerk(MasteroftheMind)
	PlayerRef.AddPerk(IllusionMaster100)
	Debug.MessageBox("Hello, World!")
endfunction

The "Hello, World!" debug message will obviously be removed once the script is completely working, it's just there for testing. My script compiles, saves, and runs without apparent issue. When I press the button in-game, I get the appropriate skill maxed to 100, and I get the "Hello, World!" message box to pop up, but it just won't add the perks and I cannot for the life of me figure out what I'm missing.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...