Difference between revisions of "Talk:Summon Object"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Chaosregen
(Created page with "Hey everyone. I'm using this code here to summon a trunk to me however is there a way to modify it to summon 2 trunks instead of 1 IE 2 different trunks and separate them from ea...")
 
imported>DragoonWraith
Line 1: Line 1:
Hey everyone. I'm using this code here to summon a trunk to me however is there a way to modify it to summon 2 trunks instead of 1 IE 2 different trunks and separate them from each other.????
Hey everyone. I'm using this code here to summon a trunk to me however is there a way to modify it to summon 2 trunks instead of 1 IE 2 different trunks and separate them from each other.????
:Sure. First you need two trunks, both of which are persistent references, and you need to give them ReferenceIDs. This tutorial has only one named <tt>wrSleepBedRef</tt>; I'll assume you have two named <tt>wrSleepBedRef1</tt> and <tt>wrSleepBedRef2</tt> respectively.
:Next, you need to separate them from each other a bit. This code uses a numerical approximation method for [[sin]] and [[cos]], which I think is... kind of ridiculous, personally. I recommend that you just use [[:Category:Oblivion Script Extender|OBSE]] for those functions; it's much simple and will give you better performance.
:You don't ''have to'' though; point is, instead of using <tt>player.GetAngle Z</tt> for your angle (that you find the cos and sin of; note the differences between [[GetAngle]] and normal mathematical angle notation), you should use, say, <tt>player.GetAngle Z + 15</tt> and <tt>player.GetAngle Z - 15</tt> for your two trunks.
:With OBSE, this is easy:
Begin ScriptEffectStart
  wrSleepBedRef1.disable
  wrSleepBedRef2.disable
End
Begin _ScriptEffectFinish ; the _ before ScriptEffectFinish enables the compiler override
  let angle1 := player.GetAngle Z - 15
  if ( angle1 < 90 ) ; this code comes from [[GetAngle]]
    let angle1 := 90 - angle1
  else
    let angle1 := 450 - angle1
  endif
  wrSleepBedRef1.MoveTo player
  wrSleepBedRef1.SetPos X (player.GetPos X + (cos angle1)) ; the compiler override
  wrSleepBedRef1.SetPos Y (player.GetPos Y + (sin angle1)) ; allows these to work
  wrSleepBedRef1.SetPos Z (player.GetPos Z + 55) ; assuming the tutorial's right about the offset
  wrSleepBedRef1.SetAngle X 0
  wrSleepBedRef1.SetAngle Y 0
  wrSleepBedRef1.SetAngle Z (player.GetAngle Z + 75) ; 75 = 90-15
  let angle2 := player.GetAngle Z + 15
  ; copy everything for wrSleepBedRef1 and apply it to wrSleepBedRef2, switching angle1 for angle2
End
:Like I said, you can continue to use the non-OBSE method described in the article; you'll just need to go through that entire process of determining the since and cosine for each angle.
:I hope that helps!
:[[User:DragoonWraith|<span style="font-family: Oblivion; size=2;">D</span>ragoon <span style="font-family: Oblivion; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion; size=2;">TALK</span>]] 10:42, 9 June 2011 (EDT)

Revision as of 09:42, 9 June 2011

Hey everyone. I'm using this code here to summon a trunk to me however is there a way to modify it to summon 2 trunks instead of 1 IE 2 different trunks and separate them from each other.????

Sure. First you need two trunks, both of which are persistent references, and you need to give them ReferenceIDs. This tutorial has only one named wrSleepBedRef; I'll assume you have two named wrSleepBedRef1 and wrSleepBedRef2 respectively.
Next, you need to separate them from each other a bit. This code uses a numerical approximation method for sin and cos, which I think is... kind of ridiculous, personally. I recommend that you just use OBSE for those functions; it's much simple and will give you better performance.
You don't have to though; point is, instead of using player.GetAngle Z for your angle (that you find the cos and sin of; note the differences between GetAngle and normal mathematical angle notation), you should use, say, player.GetAngle Z + 15 and player.GetAngle Z - 15 for your two trunks.
With OBSE, this is easy:
Begin ScriptEffectStart

  wrSleepBedRef1.disable
  wrSleepBedRef2.disable

End

Begin _ScriptEffectFinish ; the _ before ScriptEffectFinish enables the compiler override

  let angle1 := player.GetAngle Z - 15
  if ( angle1 < 90 ) ; this code comes from GetAngle
    let angle1 := 90 - angle1
  else
    let angle1 := 450 - angle1
  endif

  wrSleepBedRef1.MoveTo player
  wrSleepBedRef1.SetPos X (player.GetPos X + (cos angle1)) ; the compiler override
  wrSleepBedRef1.SetPos Y (player.GetPos Y + (sin angle1)) ; allows these to work
  wrSleepBedRef1.SetPos Z (player.GetPos Z + 55) ; assuming the tutorial's right about the offset

  wrSleepBedRef1.SetAngle X 0
  wrSleepBedRef1.SetAngle Y 0
  wrSleepBedRef1.SetAngle Z (player.GetAngle Z + 75) ; 75 = 90-15

  let angle2 := player.GetAngle Z + 15
  ; copy everything for wrSleepBedRef1 and apply it to wrSleepBedRef2, switching angle1 for angle2
End
Like I said, you can continue to use the non-OBSE method described in the article; you'll just need to go through that entire process of determining the since and cosine for each angle.
I hope that helps!
Dragoon Wraith TALK 10:42, 9 June 2011 (EDT)