I have written a script to give "potions" to npc's (well, potion AI even with MCP isn't reliable enough to use it). All around it seems to work ok, but there is one problem - I tried to make so that npcs don't drink potions when they are paralized but it somehow doesn't work. So maybe some of you scripting gurus can spot some mistake in this script and give some insight . Here is the script:
begin ES_potionsshort doonceshort drinked_magshort drinked_fatshort drinked_hlshort mag_countshort fat_countshort hl_countshort var1short var2short var3float ini_magfloat cur_magfloat ini_fatfloat cur_fatfloat timerfloat mag_ratfloat fat_ratfloat hl_ratif ( MenuMode == 1 ) Returnendifif ( GetHealth < 1 ) returnendifif ( doonce == 0 ) set ini_mag to GetMagicka set ini_fat to GetFatigue set doonce to 1 if ( GetLevel < 10 ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if ( random100 < 60 ) set var1 to random, 3 set mag_count to ( var1 + 1 ) else set mag_count to 0 endif set random100 to random, 101 if ( random100 < 60 ) set var2 to random, 4 set fat_count to ( var2 + 1 ) else set fat_count to 0 endif set random100 to random, 101 if ( random100 < 60 ) set var3 to random, 4 set hl_count to ( var3 + 1 ) else set hl_count to 0 endif elseif ( GetLevel < 20 ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if ( random100 < 70 ) set var1 to random, 4 set mag_count to ( var1 + 1 ) else set mag_count to 0 endif set random100 to random, 101 if ( random100 < 70 ) set var2 to random, 5 set fat_count to ( var2 + 1 ) else set fat_count to 0 endif set random100 to random, 101 if ( random100 < 70 ) set var3 to random, 5 set hl_count to ( var3 + 1 ) else set hl_count to 0 endif elseif ( GetLevel < 30 ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if ( random100 < 75 ) set var1 to random, 4 set mag_count to ( var1 + 1 ) else set mag_count to 0 endif set random100 to random, 101 if ( random100 < 75 ) set var2 to random, 6 set fat_count to ( var2 + 1 ) else set fat_count to 0 endif set random100 to random, 101 if ( random100 < 75 ) set var3 to random, 6 set hl_count to ( var3 + 1 ) else set hl_count to 0 endif else ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if ( random100 < 85 ) set var1 to random, 5 set mag_count to ( var1 + 1 ) else set mag_count to 0 endif set random100 to random, 101 if ( random100 < 85 ) set var2 to random, 7 set fat_count to ( var2 + 1 ) else set fat_count to 0 endif set random100 to random, 101 if ( random100 < 85 ) set var3 to random, 7 set hl_count to ( var3 + 1 ) else set hl_count to 0 endif endifendifset timer to ( timer + GetSecondsPassed )if ( timer > 1.5 ) set timer to 0 set cur_mag to ( getmagicka ) set cur_fat to ( getfatigue ) set mag_rat to ( cur_mag / ini_mag ) set fat_rat to ( cur_fat / ini_fat ) set hl_rat to ( gethealthgetratio ) if ( GetEffect, sEffectParalyze != 1 ) ; <----- THERE if ( mag_rat < 0.5 ) if ( drinked_mag < mag_count ) PlaySound3DVP, "restoration hit" 1.0, 0.8 ModCurrentMagicka, 70 set drinked_mag to ( drinked_mag + 1 ) endif endif if ( fat_rat < 0.66 ) if ( drinked_fat < fat_count ) PlaySound3DVP, "restoration hit" 1.0, 0.6 ModCurrentFatigue, 70 set drinked_fat to ( drinked_fat + 1 ) endif endif if ( hl_rat < 0.5 ) if ( drinked_hl < hl_count ) PlaySound3DVP, "restoration hit" 1.0, 1.0 ModCurrentHealth, 70 set drinked_hl to ( drinked_hl + 1 ) endif endif endifendifend
And one more thing - is there any limits on if-endif count (or deepness of if-endif structures). I had some problems with some of my longer scripts recently - these problems solved when I divided those scripts in shorter parts, so it would be nice to know.