Difference between revisions of "TurnsToSeconds"

From NWN Lexicon
Jump to: navigation, search
 
Line 8: Line 8:
  
 
<nwscript>
 
<nwscript>
[[float | float ]] TurnsToSeconds(
+
float TurnsToSeconds(
    [[int | int ]] nTurns
+
    int nTurns
);
+
);
 
</nwscript>
 
</nwscript>
  
Line 40: Line 40:
  
 
<nwscript>
 
<nwscript>
// Simple custom spell cast by an NPC.  The spell should last 1 turn per level of the caster.
+
// Simple custom spell cast by an NPC.  The spell should last 1 turn per level of the caster.
+
 
void main(){
+
void main(){
    int nDurationOfSpell = GetCasterLevel(OBJECT_SELF);
+
    int nDurationOfSpell = GetCasterLevel(OBJECT_SELF);
    effect eBonusToApply = EffectAttackIncrease(1);
+
    effect eBonusToApply = EffectAttackIncrease(1);
    object oTargetOfSpell = GetSpellTargetObject();
+
    object oTargetOfSpell = GetSpellTargetObject();
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBonusToApply, oTargetOfSpell, TurnsToSeconds(nDurationOfSpell));
+
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBonusToApply, oTargetOfSpell, TurnsToSeconds(nDurationOfSpell));
}
+
}
 
</nwscript>
 
</nwscript>
  

Latest revision as of 00:51, 26 August 2012



TurnsToSeconds(int)

Convert turns into seconds.

float TurnsToSeconds(
    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