short deadif ( dead ) returnendifif ( GetHealthGetRatio > 0.2 ) ; do nothingelseif ( GetHealthGetRatio < 0.03 ) set px to GetHealth if ( px > 0 ) set px to ( 10 + px ) set px to ( 0 - px ) ModCurrentHealth px ; force death to fix possible engine glitch endif set dead to 1 if ( companion == 1 ) MessageBox "Julan has fallen!" endif returnelseif ( companion == 1 ) ; collapse instead of death, Oblivion-like AIWander 0 0 0 0 0 ModCurrentHealth 10000 ModCurrentFatigue 10000 set px to GetFatigue set px to ( px + 70 ) ; the more you add, the more time collapsed set px to ( 0 - px ) ModCurrentFatigue px returnendif
begin mca_companions; changes, also give them corpses persist and a script to dispose of corpse after looting when sneaking /abot; open and quick close inventory while jumping = companion follow; open and quick close inventory while sneaking = companion stayshort followingshort noloreshort companionfloat minimumprofitfloat myxfloat myyfloat myzfloat timershort rememberspcshort leveldifshort pclevelshort mylevelshort mcanpcshort flycheckshort copyplayershort givenitemshort waterwalkcheckshort sheathingshort teleportedshort myMarksmanshort deadshort lastMenuModeshort i1float x1float y1float z1float t1if ( GetPCSleep ) if ( givenitem ) else set givenitem to 0 endif returnendifif ( OnActivate ) if ( dead ) if ( GetPCSneaking ) startscript ab01gCompCorpseScript endif endif playgroup idle ; fix if collapsed activate returnendifif ( dead ) returnendifif ( lastMenuMode == 0 ) if ( MenuMode ) if ( GetPCJumping ) set lastMenuMode to 1 elseif ( GetPCSneaking ) set lastMenuMode to 1 endif return endifelseif ( lastMenuMode == 2 ) if ( MenuMode ) return else set lastMenuMode to 0 endifelseif ( lastMenuMode == 1 ) if ( t1 < 0.35 ) set t1 to ( t1 + GetSecondsPassed ) if ( MenuMode ) return else if ( GetPCJumping ) if ( following == 2 ) StopCombat AiFollow player 0 0 0 0 set following to 1 endif elseif ( GetPCSneaking ) if ( following == 1 ) StopCombat AiWander 0 0 0 60 20 20 20 0 0 0 0 set following to 2 endif endif endif else set t1 to 0 set lastMenuMode to 2 endifendifif ( MenuMode ) returnendifif ( GetHealthGetRatio > 0.2 ) ; do nothingelseif ( GetHealthGetRatio < 0.03 ) set myx to GetHealth if ( myx > 0 ) set myx to ( 10 + myx ) set myx to ( 0 - myx ) ModCurrentHealth myx ; force death to fix possible engine glitch endif set dead to 1 if ( companion == 1 ) MessageBox "Your companion has fallen!" endif returnelseif ( companion == 1 ) ; collapse instead of death, Oblivion-like AIWander 0 0 0 0 0 ModCurrentHealth 10000 ModCurrentFatigue 10000 set myx to GetFatigue set myx to ( myx + 70 ) set myx to ( 0 - myx ) ModCurrentFatigue myx returnendifif ( CellChanged ) if ( GetHealthGetRatio < 1 ) cast "_MCA_restore_health" player endif SetAlarm 0 if ( GetWaterBreathing ) else SetWaterBreathing 1 endif if ( GetAcrobatics < 200 ) SetAcrobatics 200 endif if ( GetWeaponDrawn ) set i1 to 1 elseif ( GetSpellReadied ) set i1 to 1 else set i1 to 0 endif if ( i1 ) ; set sheathing to 1 StartCombat player StopCombat if ( GetFlying > 0 ) elseif ( GetEffect sEffectWaterWalking ) else disable ; reset AI enable endif if ( following == 1 ) AIFollow player 0 0 0 0 elseif ( following == 2 ) AiWander 256 5 0 60 20 20 20 0 0 0 0 endif ; set sheathing to 0 ; if ( ScriptRunning "mca_weaponsheathsounds" ) ; else ; StartScript "mca_weaponsheathsounds" ; endif endifendifif ( following )else returnendifif ( copyplayer == 1 ) if ( myMarksman == 0 ) set myMarksman to GetMarksman endif if ( "Player"->GetWeaponType <= 8 ) if ( GetMarksman > 0 ) SetMarksman 0 endif elseif ( GetMarksman < 150 ) SetMarksman 150 endifelseif ( GetMarksman < myMarksman ) SetMarksman myMarksman set myMarksman to 0endifif ( GetPCSneaking )elseif ( GetForceSneak ) ClearForceSneakendifif ( GetWeaponDrawn ) returnelseif ( GetSpellReadied ) returnendifif ( GetPCSneaking ) if ( GetForceSneak ) else ForceSneak endifendifif ( timer < 3.3 ) set timer to ( timer + GetSecondsPassed ) returnendifset timer to Random 10001set timer to ( timer * 0.00005 )if ( minimumprofit < 0 ) if ( GetDisposition < 50 ) if ( GetTarget "player" ) else set following to 0 StartCombat "player" endif endifendifset i1 to 0if ( following == 1 ) if ( GetCurrentAIPackage != 3 ) AIFollow player 0 0 0 0 endif set myz to ( GetDistance "Player" ) ; note: max activation distance is iMaxInfoDist=192, normally NPCs try staying at 180 max distance when following set myx to 800 ; store warpdistance if ( GetInterior ) if ( GetWaterLevel < -5000000 ) ; interior with no water thanks to MCP water level fix set myx to 700 elseif ( GetWindSpeed < 0.01 ) ; (usually) interior with no weather set myx to 700 endif endif if ( myz > myx ) set i1 to 1 ; warp elseif ( myz < 70 ) set timer to 2.3 AIWander 300 0 0 0 0 ; move away endifendifif ( waterwalkcheck ) if ( "Player"->GetEffect sEffectWaterWalking ) elseif ( player->GetWaterWalking ) else removespell "_MCA_companion_waterwalk" set waterwalkcheck to 0 endifelse if ( "Player"->GetEffect sEffectWaterWalking ) set waterwalkcheck to 1 elseif ( player->GetWaterWalking ) set waterwalkcheck to 1 endif if ( waterwalkcheck ) cast "_MCA_companion_waterwalk" player addspell "_MCA_companion_waterwalk" endifendifif ( flyCheck ) if ( "Player"->GetEffect sEffectLevitate == 0 ) removespell "_MCA_companion_levitate" ; SetFlying 0 set flyCheck to 0 endif set myz to ( Player->GetPos Z ) set myz to ( myz + 16 ) SetPos z myz returnelseif ( "Player"->GetEffect sEffectLevitate ) cast "_MCA_companion_levitate" player addspell "_MCA_companion_levitate" set flyCheck to 1endifif ( i1 ) ; warpelse returnendif; if ( myx < 800 ) ; set i1 to 0 ; interior, warp always; endifif ( i1 ) ; warp unseen set x1 to ( player->GetPos X ) set y1 to ( player->GetPos Y ) set myz to ( player->GetAngle Z ) set myx to GetPos X set myy to GetPos Y set myx to ( myx - x1 ) set myy to ( myy - y1 ) if ( myy >= 0 ) set z1 to myy else set z1 to ( 0 - myy ) endif if ( z1 < 0.0001 ) return endif set z1 to ( myx / myy ) if ( myx > 0 ) if ( myy > 0 ) if ( z1 > 1 ) if ( myz < -45 ) set i1 to 0 endif else if ( myz < -90 ) set i1 to 0 endif if ( myz > 135 ) set i1 to 0 endif endif else if ( z1 < -1 ) if ( myz < 0 ) if ( myz > -135 ) set i1 to 0 endif endif else if ( myz < 45 ) if ( myz > -90 ) set i1 to 0 endif endif endif endif else if ( myy > 0 ) if ( z1 < -1 ) if ( myz > 45 ) set i1 to 0 endif else if ( myz > 90 ) set i1 to 0 endif if ( myz < -135 ) set i1 to 0 endif endif else if ( z1 > 1 ) if ( myz > 0 ) if ( myz < 135 ) set i1 to 0 endif endif else if ( myz > -35 ) if ( myz < 90 ) set i1 to 0 endif endif endif endif endifendifif ( i1 ) ; player is looking at me, skip warping returnendifAIWander 0 0 0 0 0 ; avoid warping in aifollow modeset myz to ( Player->GetPos X )set myx to GetPos Xset myy to GetPos Yset myx to ( ( myx * 0.125 ) + ( myz * 0.875 ) )set myz to ( Player->GetPos Y )set myy to ( ( myy * 0.125 ) + ( myz * 0.875 ) )set myz to ( Player->GetPos Z )set myz to ( myz + 16 )set timer to 3 ; about 0.3 sec before next aifollowSetPos z myzSetPos x myxSetPos y myyend[EDIT]added a setalarm 0
begin ab01gCompCorpseScriptshort statefloat x1float y1float z1if ( state == 0 ) MessageBox "You kneel at your companion remains, gathering proper things before burying the corpse..." if ( GetInterior ) else set x1 to GetPos X set y1 to GetPos Y set z1 to GetPos Z player->PlaceItem "ex_nord_rock_01" x1 y1 z1 0 endif set state to 1endifif ( MenuMode ); wait for inventory to close returnendifif ( GetDisabled ) set state to 0 stopscript ab01gCompCorpseScript setdelete 1 returnendifdisableend