Difference between revisions of "TurnsToSeconds"

From NWN Lexicon
Jump to: navigation, search
(Created page with " =TurnsToSeconds(int)= Convert turns into seconds. float  TurnsToSeconds(      int  nTurns ); ====Parameters==== ''nTurns'' ...")
 
Line 7: Line 7:
 
Convert turns into seconds.
 
Convert turns into seconds.
  
 +
<nwscript>
 
  [[float | float ]] TurnsToSeconds(
 
  [[float | float ]] TurnsToSeconds(
 
      [[int | int ]] nTurns
 
      [[int | int ]] nTurns
 
  );
 
  );
 +
</nwscript>
  
 
====Parameters====
 
====Parameters====
Line 37: Line 39:
 
====Example====
 
====Example====
  
<font color="#007f00">// Simple custom spell cast by an NPC.  The spell should last 1 turn per level of the caster.
+
<nwscript>
  </font>
+
// Simple custom spell cast by an NPC.  The spell should last 1 turn per level of the caster.
  <font color="#0000ff">void</font> main(){
+
   
     <font color="#0000ff">int</font> nDurationOfSpell = GetCasterLevel(<font color="#0000ff">OBJECT_SELF</font>);
+
  void main(){
     <font color="#0000ff">effect</font> eBonusToApply = EffectAttackIncrease(<font color="#7f007f">1</font>);
+
     int nDurationOfSpell = GetCasterLevel(OBJECT_SELF);
     <font color="#0000ff">object</font> oTargetOfSpell = GetSpellTargetObject();
+
     effect eBonusToApply = EffectAttackIncrease(1);
 +
     object oTargetOfSpell = GetSpellTargetObject();
 
     ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBonusToApply, oTargetOfSpell, TurnsToSeconds(nDurationOfSpell));
 
     ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBonusToApply, oTargetOfSpell, TurnsToSeconds(nDurationOfSpell));
 
  }
 
  }
 +
</nwscript>
  
 
====See Also====
 
====See Also====

Revision as of 21:03, 25 August 2012



TurnsToSeconds(int)

Convert turns into seconds.

 [[float | float ]] TurnsToSeconds(
     [[int | int ]] nTurns
 );

Parameters

nTurns

The number of turns to convert into seconds.


Description

Returns the value of nTurns converted into seconds. A single turn is always 60 seconds.

This value never changes due to the game clock - it is real time.



Remarks

Great way to apply a turn-based effect to an object when ApplyEffectToObject expects seconds instead of turns. Used mostly for spell effects in the game.

Note that a turn, in the P&P D&D books, is what we call a round (6 second) in NwN. Do not get confused if it says "2 turns", which means 12 seconds, not 120.


Version

1.62

Example

 // Simple custom spell cast by an NPC.  The spell should last 1 turn per level of the caster.
 
 void main(){
     int nDurationOfSpell = GetCasterLevel(OBJECT_SELF);
     effect eBonusToApply = EffectAttackIncrease(1);
     object oTargetOfSpell = GetSpellTargetObject();
     ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBonusToApply, oTargetOfSpell, TurnsToSeconds(nDurationOfSpell));
 }

See Also

functions: 

RoundsToSeconds



 author: Charles Feduke, editor: Jasperre, additional contributor(s): John Shuell, Kirk McDonald