Jump to content

need some rather advanced help with 1 specific problem


angelwraith

Recommended Posts

this code is intended to refwalk activators and then upon determining if they are in that list it should highlight them...

 

this works for all traps.. problem is it randomly fires the script for a few activators that are NOT in the list..

and heres the really really confusing part.. 2 identical activators in the world sitting literally right next to each other may get treated differently..

 

the script ive provided is the only thing i have working with activators and shaders and also after implementing that small section of code is when i started to notice this behavior.

 

btw the formlist SUBmastertraplist is one that i made and the only thing on it is traps.

which means that somehow the game is reading that these plants, campfires, and workbenches as being in that list.. which they are not.

 

also this is weird but sometimes this only happens at distance, if you walk right up the the plant it stops emitting the wrong shader...

 

if i take out this code, traps wont light up but neither will random activators so i know it has something to do with what ive provided here.

 

im starting to think this may be a game error and not a modder error... but if you see that i am wrong please enlighten me as this is holding up my next release and is bugging the hell out of me.

 

 

this is all beyond me at this point.. hopefully it isnt beyond you...thx for your help.

 

	; Activator shaders
set creatureREFcount to GetNumRefs 21 1
set creatureREF to GetFirstRef 21 1
	if (creatureREF.GetDistance player < 5000 ) && ( creatureREF.IsInList SUBmastertraplist )
		creatureREF.PMS SUBtrapSHADER 1
	endif
label 7
if creatureREFcount > 0
	set creatureREF to GetNextRef
	if (creatureREF.GetDistance player < 5000 ) && ( creatureREF.IsInList SUBmastertraplist )
		creatureREF.PMS SUBtrapSHADER 1
	endif
	set creatureREFcount to creatureREFcount - 1
	goto 7
endif

 

 

 

http://i1134.photobucket.com/albums/m602/Matthew_Franks/ScreenShot60.jpg?t=1305474230

http://i1134.photobucket.com/albums/m602/Matthew_Franks/ScreenShot59.jpg?t=1305473897

Edited by angelwraith
Link to comment
Share on other sites

I haven't had much luck using IsInList in a script. I've been using it just in conditions for perks and such. When I want to check if a reference is in a list, I get the base object and use ListGetFormIndex.

 

 

 ; Activator shaders

set creatureREF to GetFirstRef 21 1

Label 7
if (creatureREF)
	set rcreatureBase to creatureREF.GetBaseObject
	set iFormIndex to ListGetFormIndex SUBmastertraplist rcreatureBase
	if (creatureREF.GetDistance player < 5000 ) && ( iFormIndex > -1 )
		creatureREF.PMS SUBtrapSHADER 1
	endif
	set creatureREF to Pencil01
	set creatureREF to GetNextRef
	Goto 7
endif

Link to comment
Share on other sites

I haven't had much luck using IsInList in a script. I've been using it just in conditions for perks and such. When I want to check if a reference is in a list, I get the base object and use ListGetFormIndex.

 

 

 ; Activator shaders

set creatureREF to GetFirstRef 21 1

Label 7
if (creatureREF)
	set rcreatureBase to creatureREF.GetBaseObject
	set iFormIndex to ListGetFormIndex SUBmastertraplist rcreatureBase
	if (creatureREF.GetDistance player < 5000 ) && ( iFormIndex > -1 )
		creatureREF.PMS SUBtrapSHADER 1
	endif
	set creatureREF to Pencil01
	set creatureREF to GetNextRef
	Goto 7
endif

 

 

that looks solid and ill give it a go, however im having another issue with a very similar script that refwalks actors then applies conditionals on them to decide whether or not to fire on them.. and on 1 guys machine they never work and on mine they work fine. again stumped.

 

	set killdistance to ( SUBskillcostREF.skillcost / 65 )
set killdistance to 3000 - ( killdistance * 2500 )
set creatureREFcount to GetNumRefs 200 2
set creatureREF to GetFirstRef 200 2
if ( creatureREF.GetShouldAttack player > 0 || creatureREF.GetCombatTarget == player || creatureREF.GetFactionRelation player == 1 || ( creatureREF.GetFactionRelation player == 0 && creatureREF.GetAV Aggression >= 2 ))
	if creatureREF.GetDistance player < killdistance && creatureREF.GetDead == 0 
		creatureREF.KillActor Player 1 5
		playsound FXExplosionGrenadeEMPLow
	endif
endif


label 5
if creatureREFcount > 0
	set creatureREF to GetNextRef
	if ( creatureREF.GetShouldAttack player > 0 || creatureREF.GetCombatTarget == player || creatureREF.GetFactionRelation player == 1 || ( creatureREF.GetFactionRelation player == 0 && creatureREF.GetAV Aggression >= 2 ))
		if creatureREF.GetDistance player < killdistance && creatureREF.GetDead == 0 
			creatureREF.KillActor Player 1 5
			playsound FXExplosionGrenadeEMPLow
		endif
	endif
	set creatureREFcount to creatureREFcount - 1
	goto 5
endif

 

 

off to try your method, thanks a ton. Was hoping to hear from someone like you on this.

 

 

BTW i like the elimination of the redundancy in that script, dont know why i ever did it any other way.. now to go back and fix em all. however i dont think i can simplify it that far.. because i am not actually ever removing any of the references so if creatureREF will always return true thus getting the script stuck in the goto loop...

unless getnextref runs through a finite an unchanging list 1 time and actually returns a null for getnextref at some point. But if getnextref loops through all available references and changes with whats there this would cause an infinite loop

 

 

 

 

 

*EDIT*

 

 

 

just tried it.. still returns things not in that list. i had a plant activator light up and the klaxon speaker at black mountain light up... def not in that list. the script works (and cleaner with the redundancy fix thx to you) it just doesn't fix the problem at hand.. im basically where i started.

Edited by angelwraith
Link to comment
Share on other sites

GetNextRef always returns zero when it has gone through all the refs in the cell (s). So you can use creatureRef as a conditional to exit the loop.

 

I'm baffled as to why ListGetFormIndex doesn't appear to be working - rcreaturebase is a Ref variable and iFormIndex is a short, right? The function is supposed to return -1 when the object is not in the list. You can use printc to see what is going on.

; Activator shaders

   	set creatureREF to GetFirstRef 21 1
   	
   	Label 7
   	if (creatureREF)
           	set rcreatureBase to creatureREF.GetBaseObject
           	set iFormIndex to ListGetFormIndex SUBmastertraplist rcreatureBase
			printc "Base %i %n  index %.0f", rcreatureBase, rcreatureBase, iFormIndex
           	if (creatureREF.GetDistance player < 5000 ) && ( iFormIndex > -1 )
                   	creatureREF.PMS SUBtrapSHADER 1
           	endif
           	set creatureREF to Pencil01
           	set creatureREF to GetNextRef
           	Goto 7
   	endif

 

In the second script, you should always check to make sure creatureREF is non zero before calling a function on it or the script could halt, or even CTD.

Link to comment
Share on other sites

As far as I know, for some form types, listGetFormIndex will not work to test if an element is in a list. I'm pretty sure it's the case for references, it might even happen for anything that's not an item or something alike. I don't know if that's really a problem for whatever you're testing with, but at least be aware of the possibility.

An alternative is to use listRemoveForm, which will return the removed object (if it was removed, 0 otherwise), or use manually iterate through the list and compare each element yourself.

Edited by schlangster
Link to comment
Share on other sites

GetNextRef always returns zero when it has gone through all the refs in the cell (s). So you can use creatureRef as a conditional to exit the loop.

 

I'm baffled as to why ListGetFormIndex doesn't appear to be working - rcreaturebase is a Ref variable and iFormIndex is a short, right? The function is supposed to return -1 when the object is not in the list. You can use printc to see what is going on.

; Activator shaders

   	set creatureREF to GetFirstRef 21 1
   	
   	Label 7
   	if (creatureREF)
           	set rcreatureBase to creatureREF.GetBaseObject
           	set iFormIndex to ListGetFormIndex SUBmastertraplist rcreatureBase
			printc "Base %i %n  index %.0f", rcreatureBase, rcreatureBase, iFormIndex
           	if (creatureREF.GetDistance player < 5000 ) && ( iFormIndex > -1 )
                   	creatureREF.PMS SUBtrapSHADER 1
           	endif
           	set creatureREF to Pencil01
           	set creatureREF to GetNextRef
           	Goto 7
   	endif

 

In the second script, you should always check to make sure creatureREF is non zero before calling a function on it or the script could halt, or even CTD.

 

thats just it, it IS working like in the pictures above it is working for all the traps, however in some cases 2 identical activators are treated as if they're different.. again see the pictures.. in both those pictures 1 plant is highlighted for some reason i dont understand while the others are fine.... dont get it.

 

didnt realize it was a finite list.. will use that now and again thanks for that.

just like i said it doesnt really change anything.. it still acts exactly as it did before working for 99.9% of what i need it to, just randomly for some reason beyond me its skipping the conditionals totally and applying the shader regardless of whether or not it fits the conditionals like the second script just ignoring the conditionals.

Link to comment
Share on other sites

As far as I know, for some form types, listGetFormIndex will not work to test if an element is in a list. I'm pretty sure it's the case for references, it might even happen for anything that's not an item or something alike. I don't know if that's really a problem for whatever you're testing with, but at least be aware of the possibility.

An alternative is to use listRemoveForm, which will return the removed object (if it was removed, 0 otherwise), or use manually iterate through the list and compare each element yourself.

 

if the same is the case for isinlist maybe..

 

but the big deal here is what you can see in the pictures.

 

it does work sometimes.. but other identical activators directly next to it randomly get positives on all the conditionals

 

THEY ARE IDENTICAL

either work or dont!! dont work most of the time but sometime mess up... its driving me nuts.

Link to comment
Share on other sites

Well have you tested with the script rickerhk posted, or with your initial version?

 

Besides the redundant part, your version was missing the

set creatureREF to Pencil01

set creatureREF to GetNextRef

, which is necessary or otherwise getNextRef can be buggy.

Link to comment
Share on other sites

As far as I know, for some form types, listGetFormIndex will not work to test if an element is in a list. I'm pretty sure it's the case for references, it might even happen for anything that's not an item or something alike. I don't know if that's really a problem for whatever you're testing with, but at least be aware of the possibility.

An alternative is to use listRemoveForm, which will return the removed object (if it was removed, 0 otherwise), or use manually iterate through the list and compare each element yourself.

 

Come to think of it, I've only ever used listGetFormIndex on lists of items, so that may very well be the case.

Link to comment
Share on other sites

i did use his script, and like i said above it does exactly the same thing that mine did. albeit a lot more tidy.

getnextref was already in there and just had to be relocated as a part of eliminating the redundancy.

and as far as the pencil part goes. i did not add that in there as i have used this script in many other places and i haven't got and issues from it ever.

but in the fashion of chasing down every possible avenue i did just add it.. and upon loading the game up again immediately was greeted with a activator lighting up thats not in that list.

 

i kinda already said this but the script works to do what its supposed to do.

 

it highlights all the traps and 99.9% of activators are ignored.. as they should be.. but its that 1 in 1000 thats driving me nuts.. cause a buffalo gourd seed is not a mine.

 

but please believe me when i say that the script is itself works.. (there are screens to prove it) its just that random 1 in 1000 case that the conditions that control the situation are not being adhered to.

 

but both scripts work, mine and his, identically.. with the same random bug.

 

 

please go back and look at the pictures above.. and notice that: its working yay the activators are not lighting up... but wait whats this? there is 1 out of a bunch of 5 that is being treated differently and for some reason satisfying the condition to check if its in that list and then coloring it cause it thinks it is... its not. This is the problem. Why in a scenario where there are 4 identical activators right next to each other the returns can come back differently for whether or not its in this particular list.

 

 

 

*EDIT*

HEY HEY HEY!!!

 

upon going back and changing the other scripts to reflect the optimizations in this one the bug seems to be gone.

 

 

i think you fixed it.. but like i said it was rare before so well see.. THANKS A TON!!!

Edited by angelwraith
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...