Eyeseezya Posted August 24, 2021 Share Posted August 24, 2021 I'm in the process of working on a mod and I've hit a snag. the staff I've made for the mod is supposed to give you a blessing at night depending on the current month but I've been having trouble with it, there are no errors as far as i can tell but the script wont execute ingame, could someone have a look at it and tell me what im doing wrong? Begin LaW_Staff_SilyanornScript float starmonthshort OnPCEquipshort staffOutshort addOnceshort starblessing if ( menumode == 1)returnendif if ( starblessing == 1 )set starmonth to Monthendif if ( OnPCEquip == 0 )if ( player->GetWeaponDrawn == 0 )set staffOut to 0endifelseif ( OnPCEquip == 1 )if ( player->GetWeaponDrawn == 0 )set staffOut to 0endifendif if ( OnPCEquip == 1 )if ( player->GetWeaponDrawn == 1 )set staffOut to 1endifendif if ( staffOut == 0 )if ( Player->GetItemCount "LaW_Staff_Light" > 0 )Player->RemoveItem "LaW_Staff_Light" 1set addOnce to 0endifendif if ( staffOut == 1 )if ( addOnce == 0 )Player->AddItem "LaW_Staff_Light" 1set addOnce to 1endifendif if ( starblessing == 0 )if ( GameHour > 20 )if ( GameHour < 6 ) ;hour is 6 to 8 AMset starblessing to 1Messagebox "Underneath the stars, you feel the staff of silyanorn swell with their power.'"endifendifendif if ( starblessing == 1 )if ( GameHour > 6 )if ( GameHour < 20 ) ;hour is 6 to 8 AMset starblessing to 0Messagebox "As the stars fade with the dawn, so to does the power within the staff of Silyanorn.'"endifendifendif if ( starblessing == 1 )if ( starmonth == 0 )Player->Addspell "LaW_Staff_Ritural_Blessing" ;the Rituralendifif ( starmonth == 1 )Player->Addspell "LaW_Staff_Lover_Blessing" ;the Loverendifif ( starmonth == 2 )Player->Addspell "LaW_Staff_Lord_Blessing" ;the Lordendifelseif ( starmonth == 3 )Player->Addspell "LaW_Staff_Mage_Blessing" ;the Mageendifif ( starmonth == 4 )Player->Addspell "LaW_Staff_Shadow_Blessing" ;the Shadowendifif ( starmonth == 5 )Player->Addspell "LaW_Staff_Steed_Blessing" ;the Steedendifif ( starmonth == 6 )Player->Addspell "LaW_Staff_Apprentice_Blessing" ;the Apprenticeendifif ( starmonth == 7 )Player->Addspell "LaW_Staff_Warrior_Blessing" ;the Warriorendifif ( starmonth == 8 )Player->Addspell "LaW_Staff_Lady_Blessing" ;the Ladyendifif ( starmonth == 9 )Player->Addspell "LaW_Staff_Tower_Blessing" ;the Towerendifif ( starmonth == 10 )Player->Addspell "LaW_Staff_Attronach_Blessing" ;the Attronachendifif ( starmonth == 11 )Player->Addspell "LaW_Staff_Thief_Blessing" ;the Theifendif if ( starblessing == 0 )Player->removespell "LaW_Staff_Ritural_Blessing"Player->removespell "LaW_Staff_Lover_Blessing"Player->removespell "LaW_Staff_Lord_Blessing"Player->removespell "LaW_Staff_Mage_Blessing"Player->removespell "LaW_Staff_Shadow_Blessing"Player->removespell "LaW_Staff_Steed_Blessing"Player->removespell "LaW_Staff_Apprentice_Blessing"Player->removespell "LaW_Staff_Warrior_Blessing"Player->removespell "LaW_Staff_Lady_Blessing"Player->removespell "LaW_Staff_Tower_Blessing"Player->removespell "LaW_Staff_Attronach_Blessing"Player->removespell "LaW_Staff_Thief_Blessing"endif End LaW_Staff_SilyanornScript Link to comment Share on other sites More sharing options...
cyran0 Posted August 24, 2021 Share Posted August 24, 2021 There are two critical issues that I see: if ( starblessing == 0 ) if ( GameHour > 20 ) if ( GameHour < 6 ) ;hour is 6 to 8 AM set starblessing to 1 Messagebox "Underneath the stars, you feel the staff of silyanorn swell with their power.'" endif endif endif GameHour > 20 and GameHouse < 6 are mutually exclusive. It is impossible to satisfy both of these conditions at the same time. Therefore, starblessing is never set to 1 and you spells cannot be added. What you want is: if ( starblessing == 0 ) if ( GameHour > 20 ) ; evening/night set starblessing to 1 Messagebox "Underneath the stars, you feel the staff of silyanorn swell with their power.'" elseif ( GameHour < 6 ) ; night/early morning set starblessing to 1 Messagebox "Underneath the stars, you feel the staff of silyanorn swell with their power.'" endif endif The other issue occurs after starblessing is set to 1 elseif ( starmonth == 3 ) Player->Addspell "LaW_Staff_Mage_Blessing" ;the Mage endif This creates the structure: if ( starblessing == 1 ) if ( starmonth == 0 ) endif if ( starmonth == 1 ) endif if ( starmonth == 2 ) endif elseif ( starmonth == 3 ) endif if ( starmonth == 4 ) endif if ( starmonth == 5 ) endif if ( starmonth == 6 ) endif if ( starmonth == 7 ) endif if ( starmonth == 8 ) endif if ( starmonth == 9 ) endif if ( starmonth == 10 ) endif if ( starmonth == 11 ) endif This terminates the starblessing == 1 logical block before the end and sets up the remaining months to operate independently. You want if ( starmonth == 3 ), or make all of them elseif after starmonth == 0 and eliminate all of the endifs (except for the last, of course). Lesser issues: if ( staffOut == 0 ) if ( Player->GetItemCount "LaW_Staff_Light" > 0 ) Player->RemoveItem "LaW_Staff_Light" 1 set addOnce to 0 endif endif Add an addOnce == 1 check so the script is not doing an item count every frame. Similarly, you are removing spells every frame that starblessing == 0 is true. You could introduce a doOnce condition to prevent that from happening. There may be other ways of tightening up your code, but I have to run (literally). Link to comment Share on other sites More sharing options...
Eyeseezya Posted August 24, 2021 Author Share Posted August 24, 2021 Thanks for the help, i'm not that good with scripting barely script kiddie tbh. that elseif was from an earlier version of the script i can't belive i missed one :confused:. im gonna make your suggested fixes to the script and try to lighten it without breaking it hopefully. thanks again for your help. Link to comment Share on other sites More sharing options...
cyran0 Posted August 24, 2021 Share Posted August 24, 2021 You're welcome. Sometimes it just takes a pair of fresh eyes. The first was just a copy and paste error without making the proper adjustment for the different circumstances. The second was just your subconscious telling you that it would run more efficiently with a series of elseifs. Link to comment Share on other sites More sharing options...
Recommended Posts