Jump to content

Photo

Scripting problem


  • Please log in to reply
18 replies to this topic

#1
Patzifist

Patzifist

    Newbie

  • Members
  • Pip
  • 13 posts

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 0
label 1
If 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 1
endif
 
set counterbase to 0
set NPCref to GetFirstRef 200 3 0
label 2
If 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 2
endif

 

---------------- [some code, including spawning enemies] ----------------

 

set counter to 0
set NPCref to GetFirstRef 200 3 0
label 3
If 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 3
endif
 
if counter == counterbase ; check if every NPC exept companions are dead
___ ; do stuff
endif
 
-----------------------------------------------------------------------------------------------------------------
 
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 by Patzifist, 20 July 2014 - 12:41 PM.


#2
Fallout2AM

Fallout2AM

    Enthusiast

  • Members
  • PipPip
  • 228 posts

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
        endif

Hope it helps



#3
Patzifist

Patzifist

    Newbie

  • Members
  • Pip
  • 13 posts

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.



#4
Fallout2AM

Fallout2AM

    Enthusiast

  • Members
  • PipPip
  • 228 posts

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.



#5
Patzifist

Patzifist

    Newbie

  • Members
  • Pip
  • 13 posts

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.



#6
Fallout2AM

Fallout2AM

    Enthusiast

  • Members
  • PipPip
  • 228 posts

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.



#7
Patzifist

Patzifist

    Newbie

  • Members
  • Pip
  • 13 posts

 


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.



#8
Fallout2AM

Fallout2AM

    Enthusiast

  • Members
  • PipPip
  • 228 posts

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.



#9
Patzifist

Patzifist

    Newbie

  • Members
  • Pip
  • 13 posts

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? :)



#10
JJ2198

JJ2198

    Regular

  • Members
  • PipPip
  • 73 posts

You can learn about it here: http://geck.bethsoft...=PrintToConsole






Page loaded in: 1.047 seconds