Patzifist Posted July 19, 2014 Share Posted July 19, 2014 (edited) Hello, I'm having some problems with the following script parts (given variables: 'short counterbase', 'short counter'and 'ref NPCref'): ----------------------------------------------------------------------------------------------------------------- set NPCref to GetFirstRef 200 3 0label 1If NPCref != 0___if NPCref.GetDisabled == 0 && NPCref.GetDead == 0______NPCref.kill ; kill NPCs around___endif___if NPCref.GetDead == 1______NPCref.disable ; disable dead corpses___endif___set NPCref to Pencil01___set NPCref to GetNextRef___Goto 1endif set counterbase to 0set NPCref to GetFirstRef 200 3 0label 2If NPCref != 0___if NPCref.GetDisabled == 0 && NPCref.GetDead == 0______set counterbase to counterbase + 1 ; count enemies still around___endif___set NPCref to Pencil01___set NPCref to GetNextRef___Goto 2endif ---------------- [some code, including spawning enemies] ---------------- set counter to 0set NPCref to GetFirstRef 200 3 0label 3If NPCref != 0___if NPCref.GetDisabled == 0 && NPCref.GetDead == 0______set counter to counter + 1 ; count NPCs around___endif___set NPCref to Pencil01___set NPCref to GetNextRef___Goto 3endif if counter == counterbase ; check if every NPC exept companions are dead___ ; do stuffendif ----------------------------------------------------------------------------------------------------------------- In the beginning of the script i want to kill every NPC around (exept companions because I don't play hardcore), and after that I want to store the amount of NPCs still around (-> companions) to 'counterbase'.Later in my script i use the condition 'if counter == counterbase'; so some code should only be running if nothing else than companions is near the player.Unfortunately this last part doesn't work and I just can't find ount why, so it seems like there are enemies close by when there aren't.I also tried stuff like 'GetPlayerTeammateCount' which didn't help at all, so I'm pretty stuck right now. I don't expect somebody do to find the problem because it seems like a bug to me, but this is my last hope. Crying,Patzifist Edited July 20, 2014 by Patzifist Link to comment Share on other sites More sharing options...
Fallout2AM Posted July 20, 2014 Share Posted July 20, 2014 There's something in the scanner. I don't get how it goes out from the first loop. For your reference, this is the default scanner I use. Let My_Counter := 0 ; This sets a counter that will increases everytime I scan an actor ... Let Number_of_Ref to GetNumRefs 42 1 1 ; This sets how many actors are present in 9 cells label 1 if (Number_of_Ref < 1) Let Scanned_Ref := GetFirstRef 42 1 1 ; if it's the first time, scan the first actor else Let Scanned_Ref := GetNextRef ; if it's not, scan the next actor endif Let My_Counter += 1 ; increases the counter ; do some code ... if My_Counter < Number_of_Ref ; if the counter didn't reach the number of references present in 9 cells, go back goto 1 ; else ... ; If it did, do something else endifHope it helps Link to comment Share on other sites More sharing options...
Patzifist Posted July 20, 2014 Author Share Posted July 20, 2014 There's something in the scanner. I don't get how it goes out from the first loop.The loop will stop as soon as NPCref equals 0; so if GetNextRef returns 0 the scan is done. I will try your code as soon as I can, but I don't think that's the issue. Strangely my code works sometimes and sometimes it doesn't, that's what freaks me out the most. Link to comment Share on other sites More sharing options...
Fallout2AM Posted July 20, 2014 Share Posted July 20, 2014 I completely missed that line.The only things I can think about are - does 200 include every actor, even those for leveled list? I don't know. And - the scan breaks under some circumstances. I have this issue on a mod, I solved increasing the delay time but it's not a reliable solution in my opinion.But excluding whatever problem there could be in the script, I just wanted to add (for what it counts :) ) that in al lthe scanners I did the result was fine, scanning all the references and not skipping some, personally I would feel confortable in not thinking about a bug on the scanners. Link to comment Share on other sites More sharing options...
Patzifist Posted July 20, 2014 Author Share Posted July 20, 2014 The only things I can think about are - does 200 include every actor, even those for leveled list? I don't know.I assume so. I made a mod which marks every NPC in range so I can see them through walls and objects with the exact same scan code, and yet I didn't notice any not-marked actors. The only things I can think about are - does 200 include every actor, even those for leveled list? I don't know. And - the scan breaks under some circumstances. I have this issue on a mod, I solved increasing the delay time but it's not a reliable solution in my opinion.The scan code is in a 'GameMode' block so the scan is done in every frame; so even when one scan progress would break there would be another one right after. I'm still very confused that my script works sometimes and sometimes it doesn't. I just don't get how this can happen. Link to comment Share on other sites More sharing options...
Fallout2AM Posted July 20, 2014 Share Posted July 20, 2014 The scan code is in a 'GameMode' block so the scan is done in every frame; so even when one scan progress would break there would be another one right after. If it can help, it's not the behaviour I noticed in my case. If the scanner was breaking, not finishing its cycle, it wouldn't have scanned anymore until I was reloading the savegame. Link to comment Share on other sites More sharing options...
Patzifist Posted July 20, 2014 Author Share Posted July 20, 2014 The scan code is in a 'GameMode' block so the scan is done in every frame; so even when one scan progress would break there would be another one right after. If it can help, it's not the behaviour I noticed in my case. If the scanner was breaking, not finishing its cycle, it wouldn't have scanned anymore until I was reloading the savegame. Yeah right, when my script doesn't work I have to load a savegame as well; I meant if one scan would return something wrong whyever there would be another scan right after. So do you have any advice now why this code doesn't work? I'm, like, completely stuck right now. Link to comment Share on other sites More sharing options...
Fallout2AM Posted July 21, 2014 Share Posted July 21, 2014 I just noticed you wrote "the scan is done in every frame". Are you using a spell / object script maybe? I'm not sure you can scan with depth 3 in a single frame concerning the different situations that can happen ingame, different modded installations etc. I find that riskful, I would use a quest with default delay. If the issue happens "randomly", you should print stuff in console, so that you can see exactly where it stops and what value have the variables, that's the only way I track down an issue when it's hard to find it. Link to comment Share on other sites More sharing options...
Patzifist Posted July 21, 2014 Author Share Posted July 21, 2014 I just noticed you wrote "the scan is done in every frame". Are you using a spell / object script maybe? I'm not sure you can scan with depth 3 in a single frame concerning the different situations that can happen ingame, different modded installations etc. I find that riskful, I would use a quest with default delay. If the issue happens "randomly", you should print stuff in console, so that you can see exactly where it stops and what value have the variables, that's the only way I track down an issue when it's hard to find it.Oh, now that looks encouraging :) I created a quest which is activated through a terminal; and this quest starts a script with a 'GameMode' block. The scan is located in this block, also a condition which stops the quest.Also I think printing out variables would be a good idea, but up to now I didn't even know this is possible. Could you tell me how this is done? :) Link to comment Share on other sites More sharing options...
JJ2198 Posted July 21, 2014 Share Posted July 21, 2014 You can learn about it here: http://geck.bethsoft.com/index.php?title=PrintToConsole Link to comment Share on other sites More sharing options...
Recommended Posts