What is the best companion script?

Post » Fri May 27, 2011 11:57 pm

I've using for my companion mod the Grumpy one + Jac's modifications (change cell fix).

This one:

begin 1runs_comp3Scriptfloat axfloat ayfloat bxfloat byfloat bzfloat cxfloat cyfloat czfloat t1float t2float t3float t4float coDistfloat coDist2float playzfloat timerfloat sheatheTimerfloat moveTimerfloat h_checkshort doOnceshort doOnce2short combatDoneshort weapUseshort combatCheckshort soundPlayedshort flyCheckshort wwCheckshort oneTimeMoveshort compMoveshort c_moveshort warpshort c_marksmanshort c_speedshort c_athleticsshort companionshort nohelloshort noLoreshort countershort addOnceshort p_Checkshort oldcellif ( MenuMode == 1 )  if ( GetPCSleep == 0 )    return  endifendifif ( weapUse == 1 )  if ( Player->GetWeaponType <= 8 )    setmarksman 0  elseif ( weapUse == 1 )  if ( Player->GetWeaponType >= 9 )    setmarksman 200  endif  endifendifif ( combatCheck == 1 )  set sheathetimer to sheatheTimer + GetSecondsPassed  if ( GetSoundPlaying, "Weapon Swish" == 1 )    set sheatheTimer to 0    return  elseif ( GetSoundPlaying, crossbowShoot == 1 )    set sheatheTimer to 0    return  elseif ( GetSoundPlaying, bowShoot == 1 )    set sheatheTimer to 0    return  elseif ( sheatheTimer > 4 )  if ( GetSoundPlaying "Weapon Swish" == 0 )    set sheatheTimer to 0    set soundPlayed to 1  elseif ( sheatheTimer > 4 )  if ( GetSoundPlaying "crossbowShoot" == 0 )    set sheatheTimer to 0    set soundPlayed to 1  elseif ( sheatheTimer > 4 )  if ( GetSoundPlaying "bowShoot" == 0 )    set sheatheTimer to 0    set soundPlayed to 1  endif  endif  endif  endifendifif ( soundPlayed == 1 )  equip "silver dagger"  removeitem "silver dagger" 1;  messagebox "Working"  set soundPlayed to 0  set combatCheck to 0  set combatDone to 1endifif ( combatDone == 1 )    set timer to timer + GetSecondsPassed  if ( timer > 6 )    set timer to 0    set combatDone to 0    set warp to 0  endifendif  if ( GetCurrentAIPackage == 3 )  if ( GetPCSleep == 1 )    StartScript 1runs_compLevel  endif  if ( GetPCSneaking == 1 )    ForceSneak  elseif ( GetPCSneaking == 0 )    ClearForceSneak  endif  if ( Player->GetEffect sEffectLevitate == 1 )  if ( flyCheck == 0 )    cast 1gr_comp2_lev_bog player    addspell 1gr_comp2_lev    set flyCheck to 1  endif  endif  if ( Player->GetEffect sEffectLevitate == 0 )  if ( flyCheck == 1 )    removespell 1gr_comp2_lev    set flyCheck to 0  endif  endif  if ( Player->GetEffect sEffectWaterWalking == 1 )  if ( wwCheck == 0 )    cast 1gr_comp2_ww_bog player    addspell 1gr_comp2_ww    set wwCheck to 1  endif  endif  if ( Player->GetEffect sEffectWaterWalking == 0 )  if ( wwCheck == 1 )    removespell 1gr_comp2_ww    set wwCheck to 0  endif  endif  if ( flyCheck == 1 )  if ( GetWeaponDrawn == 0 )    set playz to ( Player->GetPos z )    SetPos z playz  elseif ( flyCheck == 1 )  if ( GetCurrentAIPackage != 3 )  if ( GetWeaponDrawn == 0 )    set playz to ( GetPos z )    SetPos z playz  endif  endif  endif  endif  if ( GetWeaponDrawn == 1 )  if ( flyCheck == 0 )    set combatCheck to 1    set timer to 0    set warp to 1    return  elseif ( GetWeaponDrawn == 1 )  if ( flyCheck == 1 )    set combatDone to 1    set timer to 0    set warp to 1    return  endif  endif  endif  set ax to ( Player->GetPos x )  set ay to ( Player->GetPos y )  if ( doOnce == 0 )    set bx to ( Player->GetPos x )    set by to ( Player->GetPos y )    set bz to ( Player->GetPos z )    set doOnce to 1  endif  set t1 to ( ax - bx )  set t1 to ( t1 * t1 )  set t2 to ( ay - by )  set t2 to ( t2 * t2 )  set t1 to ( t1 + t2 )  set coDist to ( GetSquareRoot, t1 )  if ( coDist > 360 )    set doOnce to 0  endif  if ( coDist > 180 )  if ( doOnce2 == 0 )    set cx to ( Player->GetPos x )    set cy to ( Player->GetPos y )    set cz to ( Player->GetPos z )    set doOnce2 to 1  endif  endif  set t3 to ( ax - cx )  set t3 to ( t3 * t3 )  set t4 to ( ay - cy )  set t4 to ( t4 * t4 )  set t3 to ( t3 + t4 )  set coDist2 to ( GetSquareRoot, t3 )  if ( coDist2 > 360 )    set doOnce2 to 0  endif  if ( warp == 0 )  if ( coDist > 350 )  if ( GetDistance Player > 680 )    SetPos x bx    SetPos y by    SetPos z bz    AiFollow Player 0 0 0 0  elseif ( warp == 0 )  if ( coDist2 > 350 )  if ( GetDistance Player > 680 )    SetPos x cx    SetPos y cy    SetPos z cz    AiFollow Player 0 0 0 0  endif  endif  endif  endif  endifendif;IF ADDITIONS ARE DESIRED, PLEASE ADD THEM BELOW HERE...if ( GetCurrentAIPackage == 3 )  if ( compMove == 1 )  if ( c_move == 0 )  if ( GetDistance Player < 70 )    AIWander 300 0 0 0 0    set c_move to 1  endif  endif  endifendifif ( c_move == 1 )  if ( GetDistance Player > 100 )    AIFollow Player 0 0 0 0  set c_move to 0  endifendifif ( oneTimeMove == 1 )  set moveTimer to moveTimer + GetSecondsPassed  if ( moveTimer > 4 )    set moveTimer to 0    AiFollow Player 0 0 0 0    set oneTimeMove to 0  endifendif; to allow my companion to not stand on me when we went through load;doors and to help prevent her from dying if we levitated through a load doorif ( CellChanged == 0 )   if ( GetInterior == 1 )   set oldcell to 1 ;sets oldcell to interior cell   else         set oldcell to 0 ;sets oldcell to exterior cell      endif   endif      if ( CellChanged == 1 )   if ( flyCheck == 1 )        if ( GetInterior == 1 )      AiWander 256 0 0 0      set warp to 0      set moveTimer to 0      set oneTimeMove to 3   elseif ( oldcell == 1 )      AiWander 256 0 0 0      set warp to 0      set moveTimer to 0      set oneTimeMove to 3   endif   endifendif      if ( CellChanged == 1 )      if ( oneTimeMove == 0 )         if ( GetInterior == 1 )            set oneTimeMove to 2            AIWander 300 0 0 0 0              set moveTimer to 0         elseif ( oldcell == 1 )            set oneTimeMove to 2            AIWander 300 0 0 0 0            set moveTimer to 0         endif      endif   endifendif   if ( oneTimeMove == 3 )      set moveTimer to moveTimer + GetSecondsPassed         if ( moveTimer > 5.0 )            set oneTimeMove to 0            set warp to 0         endif   endif   if ( oneTimeMove == 2 )       set moveTimer to moveTimer + GetSecondsPassed       if ( moveTimer > 2.25 )            set moveTimer to 0            AiFollow Player 0 0 0 0            set oneTimeMove to 0       endif   endif ;AND ABOVE HERE.;ADDITIONS CAN ALSO BE ADDED TO THIS FOLLOWING SECTION, BUT BEWARE OF THE COUNTER.;Counter can pooch some functions if they need to be checked every frame.if ( counter < 20 )  set counter to counter + 1  returnendifset counter to 0if ( GetCurrentAIPackage == 3 )  if ( GetDistance Player < 300 )    setSpeed 15    setAthletics 15  elseif ( GetDistance Player > 300 )    set c_speed to ( ( Player->GetSpeed ) * 2.25 )    set c_athletics to ( ( Player->GetAthletics ) * 2.25 )    setSpeed  c_speed    setAthletics c_athletics  endif  if ( GetItemCount p_restore_health_b >= 1 )    set p_Check to 1  elseif ( GetItemCount p_restore_health_c >= 1 )    set p_Check to 1  elseif ( GetItemCount p_restore_health_e >= 1 )    set p_Check to 1  elseif ( GetItemCount p_restore_health_q >= 1 )    set p_Check to 1  elseif ( GetItemCount p_restore_health_s >= 1 )    set p_Check to 1  else    set p_Check to 0  endifendifif ( GetCurrentAIPackage != 3 )  setspeed 40endif;ADD ADDITIONAL TOPICS IN THIS SECTION IF REQUIRED.if ( addOnce == 0 )  AddTopic "Lamia La Loca"  AddTopic "-Combatir"  AddTopic "-Seguirme"  AddTopic "-Otros"  StartScript 1runs_compLevel  set companion to 1  set addOnce to 1endifend


Plus the default Grumpy leveling script.

Any suggestion to improve it?
User avatar
Kyra
 
Posts: 3365
Joined: Mon Jan 29, 2007 8:24 am

Post » Sat May 28, 2011 1:31 am

I think there is a extra endif...
if ( CellChanged == 1 )	if ( oneTimeMove == 0 )		if ( GetInterior == 1 )			set oneTimeMove to 2			AIWander 300 0 0 0 0			set moveTimer to 0		elseif ( oldcell == 1 )			set oneTimeMove to 2			AIWander 300 0 0 0 0			set moveTimer to 0		endif	endifendif;endif ; extra endif commented

User avatar
Rachie Stout
 
Posts: 3480
Joined: Sun Jun 25, 2006 2:19 pm

Post » Sat May 28, 2011 9:57 am

You can remove the getSquareRoot by squaring the numbers it is compared with. But I doubt it will do anything much (noticeable) to the speed.

Optimizations because "it might be faster" at the cost of readability are very rarely worth it imho.
User avatar
Jenna Fields
 
Posts: 3396
Joined: Mon Dec 11, 2006 11:36 am

Post » Sat May 28, 2011 10:10 am

Melian made the change cell fix for me and she should be credited for it. :) As for improving it, I've never had any issues with it and I've received very few reports of Jasmine going missing. For that, I included a way to have her meet you at her house, but any specific place would work. Most other companion mods I've run across also have a similar feature so it's a game engine issue and not something that can be fixed via scripting that I know of.
User avatar
Dawn Farrell
 
Posts: 3522
Joined: Thu Aug 23, 2007 9:02 am

Post » Fri May 27, 2011 7:21 pm

Melian made the change cell fix for me and she should be credited for it. :) As for improving it, I've never had any issues with it and I've received very few reports of Jasmine going missing. For that, I included a way to have her meet you at her house, but any specific place would work. Most other companion mods I've run across also have a similar feature so it's a game engine issue and not something that can be fixed via scripting that I know of.


How can implement that?
User avatar
Jason Wolf
 
Posts: 3390
Joined: Sun Jun 17, 2007 7:30 am

Post » Sat May 28, 2011 12:26 am

If you have my Jasmine mod, look for the topic "Where's Jasmine" to get the scripting for it. I don't have the CS installed, so I can't get that information for you. Basically what I did was move her to predefined coordinates, which I got from dropping an object in front of her house, copying the X, Y, & Z axis coordinates, and then deleting the object. I used those coordinates in a script that moves her to them. I think I also disabled and enabled her to clear up any issues with moving her.
User avatar
brian adkins
 
Posts: 3452
Joined: Mon Oct 01, 2007 8:51 am

Post » Sat May 28, 2011 1:58 am

If you have my Jasmine mod, look for the topic "Where's Jasmine" to get the scripting for it. I don't have the CS installed, so I can't get that information for you. Basically what I did was move her to predefined coordinates, which I got from dropping an object in front of her house, copying the X, Y, & Z axis coordinates, and then deleting the object. I used those coordinates in a script that moves her to them. I think I also disabled and enabled her to clear up any issues with moving her.


Thanks works like a charm.

But now I'm afraid because of reading another post in this forum. Is it my script affected by the 72 hour?????!!!!!!!!!!!

:toughninja:
User avatar
sexy zara
 
Posts: 3268
Joined: Wed Nov 01, 2006 7:53 am

Post » Sat May 28, 2011 1:32 am

Thanks works like a charm.

But now I'm afraid because of reading another post in this forum. Is it my script affected by the 72 hour?????!!!!!!!!!!!

:toughninja:

only if you dont at least enter the cell where this companion is located. any information stored in global variables (or a MWSE txt file) is also preserved.
User avatar
Haley Merkley
 
Posts: 3356
Joined: Sat Jan 13, 2007 12:53 pm


Return to III - Morrowind