Jeoshua Posted November 17, 2011 Share Posted November 17, 2011 (edited) scn BookPerkBarterScript short BooksToRead short BooksPerRank short currSkill short reqSkill Begin OnEquip player set currSkill to player.GetAV Barter set reqSkill to ( 40 + ( 10 * GlobalBookPerkBarterRank ) ) if ( currSkill < 35 ) ShowMessage BookPerkInsufficientSkillMSG2 elseif ( currSkill < reqSkill ) && ( reqSkill <= 100 ) ShowMessage BookPerkInsufficientSkillMSG, currSkill, reqSkill else if (player.HasPerk Comprehension == 1 && GlobalBookPerkBarterRank < 7 ) set BooksToRead to ( ( GlobalBookPerkBarter % 3 ) +1 ) set BooksPerRank to 3 if ( GlobalBookPerkBarter % 3 == 2 ) set GlobalBookPerkBarterRank to GlobalBookPerkBarterRank + 1 player.AddPerk BookPerkBarter ShowMessage BookPerkBarterMSG elseif ShowMessage BookPerkKeepReadingMSG, BooksToRead, BooksPerRank endif set GlobalBookPerkBarter to GlobalBookPerkBarter + 1 elseif (player.HasPerk Comprehension == 0 && GlobalBookPerkBarterRank < 5 ) set BooksToRead to ( ( GlobalBookPerkBarter % 4 ) +1 ) set BooksPerRank to 4 if ( GlobalBookPerkBarter % 4 == 3 ) set GlobalBookPerkBarterRank to GlobalBookPerkBarterRank + 1 player.AddPerk BookPerkBarter ShowMessage BookPerkBarterMSG elseif ShowMessage BookPerkKeepReadingMSG, BooksToRead, BooksPerRank endif set GlobalBookPerkBarter to GlobalBookPerkBarter + 1 elseif ShowMessage BookPerkMasteryMSG endif player.RemoveItem BookSkillBarter 1 1 ModPCMiscStat "Books Read" 1 player.AddItem BookSkillBarterRead 1 1 endif END Note the last bit of those if statements: elseif ShowMessage BookPerkMasteryMSG That doesn't seem right to me. Edited November 17, 2011 by Jeoshua Link to comment Share on other sites More sharing options...
Jeoshua Posted November 17, 2011 Author Share Posted November 17, 2011 So far, so good here. I changed these elseifs to ifs and so far I haven't experienced a book-skill crash. It's an intermittent thing so it begs more testing, but so far everything is peachy? What would drive an author to use an elseif to run a command like that, I wondeR? Link to comment Share on other sites More sharing options...
Cyberlazy Posted November 17, 2011 Share Posted November 17, 2011 Somehow I think you need 'Else' and not 'Elseif' on 'elseif ShowMessage BookPerkMasteryMSG ' Link to comment Share on other sites More sharing options...
rickerhk Posted November 17, 2011 Share Posted November 17, 2011 I would replace three elseif's with else.Though obviously the script compiled as it was and it might be an undocumented shortcut - I stay away from that sort of thing, myself. Begin OnEquip player set currSkill to player.GetAV Barter set reqSkill to ( 40 + ( 10 * GlobalBookPerkBarterRank ) ) if ( currSkill < 35 ) ShowMessage BookPerkInsufficientSkillMSG2 elseif ( currSkill < reqSkill ) && ( reqSkill <= 100 ) ShowMessage BookPerkInsufficientSkillMSG, currSkill, reqSkill else if (player.HasPerk Comprehension == 1 && GlobalBookPerkBarterRank < 7 ) set BooksToRead to ( ( GlobalBookPerkBarter % 3 ) +1 ) set BooksPerRank to 3 if ( GlobalBookPerkBarter % 3 == 2 ) set GlobalBookPerkBarterRank to GlobalBookPerkBarterRank + 1 player.AddPerk BookPerkBarter ShowMessage BookPerkBarterMSG else ShowMessage BookPerkKeepReadingMSG, BooksToRead, BooksPerRank ; <----- endif set GlobalBookPerkBarter to GlobalBookPerkBarter + 1 elseif (player.HasPerk Comprehension == 0 && GlobalBookPerkBarterRank < 5 ) set BooksToRead to ( ( GlobalBookPerkBarter % 4 ) +1 ) set BooksPerRank to 4 if ( GlobalBookPerkBarter % 4 == 3 ) set GlobalBookPerkBarterRank to GlobalBookPerkBarterRank + 1 player.AddPerk BookPerkBarter ShowMessage BookPerkBarterMSG else ShowMessage BookPerkKeepReadingMSG, BooksToRead, BooksPerRank ; <----- endif set GlobalBookPerkBarter to GlobalBookPerkBarter + 1 else ShowMessage BookPerkMasteryMSG ;<----- endif player.RemoveItem BookSkillBarter 1 1 ModPCMiscStat "Books Read" 1 player.AddItem BookSkillBarterRead 1 1 endif END Link to comment Share on other sites More sharing options...
Jeoshua Posted November 17, 2011 Author Share Posted November 17, 2011 (edited) That's what I sas thinking, and my code that I ended up replacing those lines with is basically the same thing as what you posted rickerk. FWE and Book Perks both contained this code since 2009. It USED to work. I fixed several scripts just like this, in various ways. On a whim I recompiled the basic one without changing it and checked the script in FO3edit. The compiled code showed up as different than in the original file. So at some point the way in which scripts compile changed between 2009 and now. I think that these scripts were incorporated into FWE wholesale, and never actually recompiled or fixed in any way. So the code itself is a relic, and should not exist! Now, in C++ this kind of behavior (running procedures/functions under a conditional) would be acceptable. Apparently, in Gamebryo Script it is not. ----- I do not know if Gamebryo script has returns on everything. Sometimes these scripts ran just fine the way that they were. Other times they caused a CTD. I can only assume that this means they were not returning back a variable, and the code was left to look into a presumably empty piece of memory. I say presumably, because they would often work right after starting Fallout, but once you had gone through a few cell changes or walked outside, they would CTD when running. That tells me that when the memory spaces that Fallout reserved were null (0x00), it worked fine. But when they had other data in them, the whole stack of cards fell apart. ----- I am incorporating these changes into the Remastered FWE patch. So far I've been putting it through rigorous testing and not one crash has occured. Before the changes, it was hit and miss whether these scripts would cause a complete CTD. Edited November 17, 2011 by Jeoshua Link to comment Share on other sites More sharing options...
Recommended Posts