I am currently diving into scripting (quests, primarily) and I have run across some problems. I do have some C/C++ (and others) background and I am in need of some general guidance
I have been working on a "scan for NPC_type in current cell" (I have the basics down.)
First OBSE Question:
I am attempting to do a scan and place all the detected NPC_of_type (this example is same faction) into an array for later (next loop through) usage.
How does one go about this?
i.e.
scn MyScan
short faction
short refCounter
short counter
short tempCounter
ref tempNPC
array_var refNPC
short range ; a set distance from player. Changeable via quest level.
begin gamemode
let refNPC := ar_contruct Array
let refCounter:= GetNumRefs 35 1 1
let tempCounter := refCounter
let tempNPC := Getfirstref 35 1 1
if (tempNPC.faction == player.SameFaction) && (tempNPC.GetDistance Player <range)
let refNPC [counter] := tempNPC
let counter +=1
let tempCounter -=1
endif
while (refCounter !=0)
let tempNPC := Getnextref
if (tempNPC.faction == player.SameFaction) && (tempNPC.GetDistance Player <range) ;NPC in same faction and in "range"
let refNPC [counter] := tempNPC
let counter +=1
let refCounter -=1
endif
loop
end
I know I did not set "range", but it is not part of the problem.Second OBSE question: Do I need to create multiple arrays for each cell I am in or will a single array set work? (Bad phrasing, I am sorry.)
Question 3: If used in a "quest script", will the "time cost" (fps hits) be too costly? (Should I move it to a callable script instead and use an "Onload" detection or some other trigger?)
Question 4: Am I even in the right ballpark (implementation-wise?)
Thank you for all the help, advice.
(Note: Once the "quest" is complete, I know I should delete the arrays and null out the other variables. Or should I?)



Sign In
Create Account

Back to top









