i'm making a mod to make companions available to players for advancing in factions (and eventually to add some nifty functions to being the head of any given faction.) at first, i was going to write a script that allows the player to make any faction member he outranks a tribunal style companion. after this did not work out that well (and after noticing that most faction members would not make ideal companions) i decided that i'd make respawning generic companions available based on rank.
my thought is that i should have the same script handle all of a faction's companions, by attaching the script to each companion NPC. i plan on introducing persistent elements to these companions, so i wrote a global "keepvars" script. i want all companions for a faction to use the same timer variables, so i included timer scripts to my global keepvars script.
i'm using a variable within the local script and dialog to ensure the companion shares and follows (or doesent) according to my stipulations.
for testing purposes, i'm only working with the fighters guild, and only adding the first tier companion to balmora's guildhall. i am only working with the main game and expansions in my data files.
my current scripts look like this-
keepvars:
begin 1rak_gvats ;global variable and timer systemshort Rlocaldayspassedshort Rcurrentdayshort gfighterupdateshort RkeepVarsshort Rupdatefsvif ( Rupdatefsv == 0 ) ; update fighter minion if ( scriptrunning 1rak_fighter_minion == 0 ) ;here's the problem set 1rak_fighter_minion.keepvars to 1 ;local doonce variable, also broken startscript 1rak_fighter_minion set Rupdatefsv to 1 ;global doonce for keepvar endifendifif ( RcurrentDay != Day ) ;whenever Day changes set RcurrentDay to Day ;(presumably increasing)… set RlocaldaysPassed to RlocaldaysPassed + 1 ;add one to the counterendifstopscript 1rak_gvatsend
and main companion script:
Begin 1rak_fighter_minionshort companion ;companion sharefloat minimumprofit ;underlings get grumpy without a paycheckshort rak_fighter ;0= no companion, 1=accompnied, 2=wait till respawn, 3=deadshort isdeadshort raktimershort raktimerDshort keepvarsif ( keepvars == 1 ) ;keepvars snippit set keepvars to 0 stopscript 1rak_fighter_minion returnendifif ( menumode == 1 ) ;dont run the script in menus returnendifif ( gethealth < 1 ) ;checking if dead set isdead to 1 set rak_fighter to 3 set raktimerD to 1endifif ( ondeath == 1 ) ;checking if dead set isdead to 1 set rak_fighter to 3 set raktimerD to 1endifif ( rak_fighter == 0 ) ;first time script is run, sets this to enable the companion. set rak_fighter to 1 ;values >1 will result in a respawn in 3 (or more) dayselseif ( rak_fighter == 1 ) if ( player->getpcrank, "fighters guild" > 2 ) ;only if you outrank the npc by 3 addtopic "travel together" ;will you get companion topic endif if ( minimumprofit < 0 ) ;no profits set rak_fighter to 4 set companion to 0 ;no companion aiwander 0 0 0 0 0 0 0 0 0 0 0 0 ;he stays in place set raktimer to 1 endifelseif ( rak_fighter == 2 ) set companion to 0 ;no companion set raktimer to 1endifif ( rak_fighter > 1 ) if ( 1rak_gvats.Rlocaldayspassed >= 3 ) ;calls global variable if ( isdead == 1 ) ;only ressurect when dead resurrect set isdead to 0 endif PositionCell, 545, -383, 378, 0, "Balmora, guild of fighters" ; move back to spawnpoint set rak_fighter to 1 endifendifif ( raktimer == 1 ) set 1rak_gvats.Rlocaldayspassed to 0 ;resets global timer set raktimer to 0elseif ( raktimerD == 1 ) ;resets global timer with death penalty set 1rak_gvats.Rlocaldayspassed to -3 set raktimerD to 0endifend
at this point, the major problem (in 1rak_gvats) is that when i try to save these scripts, the editor complains that it cannot find variable or function, in reference to me checking if "rak_fighter_minion" is running. adding quotation marks around the script name fixes this (note, it's not looking for 1rak_ just rak_) but then it complains that it cannot find the variable keepvars. this puzzles me, because in any number of scripting tutorials list the script as just how i wrote it.
so, any clue as to what i'm doing wrong here?