
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://kb.speeddemosarchive.com/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://kb.speeddemosarchive.com/index.php?action=history&amp;feed=atom&amp;title=Thief_2%2FSource_Code</id>
		<title>Thief 2/Source Code - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://kb.speeddemosarchive.com/index.php?action=history&amp;feed=atom&amp;title=Thief_2%2FSource_Code"/>
		<link rel="alternate" type="text/html" href="https://kb.speeddemosarchive.com/index.php?title=Thief_2/Source_Code&amp;action=history"/>
		<updated>2026-04-04T13:25:37Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.9</generator>

	<entry>
		<id>https://kb.speeddemosarchive.com/index.php?title=Thief_2/Source_Code&amp;diff=40241&amp;oldid=prev</id>
		<title>LotBlind: Created page with &quot;[https://kb.speeddemosarchive.com/Thief_2:_The_Metal_Age Return to Main Page]  = Potions =  == Slow-fall ==     /* Potion's effect is to reduce gravity on the imbiber to 50%....&quot;</title>
		<link rel="alternate" type="text/html" href="https://kb.speeddemosarchive.com/index.php?title=Thief_2/Source_Code&amp;diff=40241&amp;oldid=prev"/>
				<updated>2015-12-07T18:11:32Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;[https://kb.speeddemosarchive.com/Thief_2:_The_Metal_Age Return to Main Page]  = Potions =  == Slow-fall ==     /* Potion&amp;#039;s effect is to reduce gravity on the imbiber to 50%....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[https://kb.speeddemosarchive.com/Thief_2:_The_Metal_Age Return to Main Page]&lt;br /&gt;
&lt;br /&gt;
= Potions =&lt;br /&gt;
&lt;br /&gt;
== Slow-fall ==&lt;br /&gt;
&lt;br /&gt;
   /* Potion's effect is to reduce gravity on the imbiber to 50%.&lt;br /&gt;
   Also reduces movement speed by 50%, keeping jump distance about&lt;br /&gt;
   the same.  Only supported for player-character imbiber.&lt;br /&gt;
   */&lt;br /&gt;
  BEGIN_SCRIPT(LoGravPotion,TimedPotion)&lt;br /&gt;
  METHODS:&lt;br /&gt;
   METHOD void PotionEffect(object imbiber, boolean start)&lt;br /&gt;
   {&lt;br /&gt;
      if(!Object.InheritsFrom(imbiber,Object.Named(&amp;quot;Avatar&amp;quot;)))&lt;br /&gt;
         return;&lt;br /&gt;
      if(start)&lt;br /&gt;
      {&lt;br /&gt;
         vector vel;&lt;br /&gt;
&lt;br /&gt;
         // Arrest downward velocity by 50%.  If you'd been at 50%&lt;br /&gt;
         // gravity all along, you'd actually only be at 30% less&lt;br /&gt;
         // velocity at the same depth (a factory of 1/root(2)).&lt;br /&gt;
         // This will then tend to encourage use of the potion in&lt;br /&gt;
         // mid-fall, which sounds like fun. -TJS&lt;br /&gt;
         Physics.GetVelocity(imbiber,vel);&lt;br /&gt;
         if(vel.z&amp;lt;0) vel.z/=2;&lt;br /&gt;
         Physics.SetVelocity(imbiber,vel);&lt;br /&gt;
&lt;br /&gt;
         DrkInv.AddSpeedControl(&amp;quot;LoGrav&amp;quot;,0.5,1.0);&lt;br /&gt;
         Physics.SetGravity(imbiber,0.50);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         Physics.SetGravity(imbiber,1.00);&lt;br /&gt;
         DrkInv.RemoveSpeedControl(&amp;quot;LoGrav&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
  END_SCRIPT(LoGravPotion)&lt;br /&gt;
&lt;br /&gt;
= Movement =&lt;br /&gt;
&lt;br /&gt;
== Setting Velocity ==&lt;br /&gt;
&lt;br /&gt;
This is what causes drinking slow-fall potions to free you from being stuck.&lt;br /&gt;
&lt;br /&gt;
  STDMETHOD(SetVelocity)(object obj, const vector ref vel)&lt;br /&gt;
  {&lt;br /&gt;
   // Setting velocities from scripts wants to be initially clear from the&lt;br /&gt;
   // effects of friction, so we break all contacts.  &lt;br /&gt;
   cPhysModel *pModel = g_PhysModels.GetActive(obj);&lt;br /&gt;
   if (pModel)&lt;br /&gt;
   {&lt;br /&gt;
      for (int i=0; i&amp;lt;pModel-&amp;gt;NumSubModels(); i++)&lt;br /&gt;
      {&lt;br /&gt;
         pModel-&amp;gt;DestroyAllTerrainContacts(i);&lt;br /&gt;
         DestroyAllObjectContacts(obj, i, pModel);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   PhysSetVelocity(obj, (mxs_vector*)&amp;amp;vel);&lt;br /&gt;
   return S_OK;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Calling DestroyAllTerrainContacts also calls another method that makes you fall off any ropes.&lt;br /&gt;
&lt;br /&gt;
= Mission-specific =&lt;br /&gt;
&lt;br /&gt;
== Mission 6 Key Location ==&lt;br /&gt;
&lt;br /&gt;
The mission source code basically takes a random number (and RNG seed is based on system uptime in miliseconds):&lt;br /&gt;
Code (MISS6.SCR):&lt;br /&gt;
&lt;br /&gt;
  #define KEYPATHS 9&lt;br /&gt;
  [...]&lt;br /&gt;
  SetData(&amp;quot;PathNumber&amp;quot;,Data.RandInt(1,KEYPATHS)); //which key we're using.&lt;br /&gt;
  [...]&lt;br /&gt;
  SetupLocation();&lt;br /&gt;
  //setup the location, if we are the starting&lt;br /&gt;
  //point.  This allows all sorts of wholesome&lt;br /&gt;
  //linky goodness.&lt;br /&gt;
&lt;br /&gt;
There is also a game config cheat parameter to fix the key location to a specific one.&lt;/div&gt;</summary>
		<author><name>LotBlind</name></author>	</entry>

	</feed>