I managed to get a working code. Well, partially.
When the counter reaches zero and below, no more firespells can be cast, yeiy
The next problem I try to solve is to get the value of the integer from the spellhook to the counter, because the spellhook also should be able to influence the counter.
I try to do that by setting the integer on the area, and reading it out in the counter script, then update it, then put the new value in the area integer again.
The following code I have adjusted: the spellhooking script can alter the area intneger, but something goes wrong in the count down. It isnt counting down. BTW 20 is the starting number, when I use 19 as starting number, the number appearing is 0, because TimeLimit is still empty in the beginning. The counting down isnt working then either. I guess all the swapping of integers make something go wrong.
countdown. I have tried changing oPC to oObject, didnt change anything.
Code: Select all
void Countdown( int nTimeLimit, object oObject = OBJECT_INVALID);
void main()
{
object oPC = GetEnteringObject();
Countdown( 20, oPC);
FloatingTextStringOnCreature("The air is stale, and old.", oPC);
}
// ** FUNCTION DEFINITIONS ** //
void Countdown( int nTimeLimit, object oObject = OBJECT_INVALID)
{
object oPC = GetEnteringObject();
object oArea;
oArea=GetArea( oObject );
if(nTimeLimit == 20){
SetLocalInt( GetArea( oPC ), "TimeLimit", nTimeLimit );
}
nTimeLimit = GetLocalInt( oArea, "TimeLimit" );
DelayCommand( 1.0, Countdown( --nTimeLimit, oObject));
SetLocalInt( GetArea( oPC ), "TimeLimit", nTimeLimit );
FloatingTextStringOnCreature( IntToString( nTimeLimit), oObject);
}
one without object oPC, just to be sure
Code: Select all
void Countdown( int nTimeLimit, object oObject = OBJECT_INVALID)
{
object oArea;
oArea=GetArea( oObject );
//if you start, make sure something is in Timelimit
if(nTimeLimit == 20){
SetLocalInt( GetArea( oObject ), "TimeLimit", nTimeLimit );
}
//get the int from TimeLimit, put it in nTimeLimit
nTimeLimit = GetLocalInt( oArea, "TimeLimit" );
//change nTimeLimit
DelayCommand( 1.0, Countdown( --nTimeLimit, oObject));
//put the new nTimeLimit back in TimeLimit
SetLocalInt( GetArea( oObject ), "TimeLimit", nTimeLimit );
FloatingTextStringOnCreature( IntToString( nTimeLimit), oObject);
also, the counter continues below zero...gotta stop that.
the spellhook:
Code: Select all
#include "x2_inc_switches"
void main()
{
int nSpell=GetSpellId();
int nSpellDC=GetSpellSaveDC();
int nCastLevel=GetCasterLevel(OBJECT_SELF);
int nTimer;
object oObject = OBJECT_INVALID;
object oTarget;
object oArea;
effect eEffect;
switch (nSpell)
{
case SPELL_FIREBALL:
case SPELL_FIRE_STORM:
case SPELL_FIREBRAND:
case SPELL_FLAME_WEAPON:
case SPELL_FLAME_LASH:
case SPELL_FLAME_STRIKE:
case SPELL_DARKFIRE:
case SPELL_WALL_OF_FIRE:
case SPELL_SHADES_FIREBALL:
case SPELL_METEOR_SWARM:
case SPELL_FLARE:
case SPELL_ELEMENTAL_SHIELD:
case SPELL_DELAYED_BLAST_FIREBALL:
oArea = GetArea(OBJECT_SELF);
nTimer = GetLocalInt( oArea, "TimeLimit" );
SendMessageToPC( OBJECT_SELF, "TimeLimit is " + IntToString( nTimer) +
" from object " + ObjectToString( oArea ) );
if (nTimer>=0 && GetTag(oArea) == "Lichlairdeepbelow")
{
nTimer = nTimer-10;
FloatingTextStringOnCreature( IntToString( nTimer), oObject);
SetLocalInt( GetArea( OBJECT_SELF ), "TimeLimit", nTimer );
}
if (nTimer<=0)
{
SetModuleOverrideSpellScriptFinished();
SendMessageToPC(OBJECT_SELF, "Due to the lack of air, the fire fizzles right away");
//break;
}
}}