Script performance question (Cipscis?)

Post » Fri Feb 26, 2010 5:45 am

This line of code:

if Followers7.MalcolmBG == 1 && (PhalanxMalcolm2REF.GetEquipped PhPBG || PhalanxMalcolm2REF.GetEquipped PhFPBG || PhalanxMalcolm2REF.getequipped PhDLC03PBG)


Is the executable going to check every single formlist (PhPBG, PhFPBG, PhDLC03PBG) under all circumstances, or will it stop at the first formlist check if, say, the match for getequipped is found in the first formlist check?

Question is moreso meant for the likes of Cipscis because he has his ways of actually knowing this stuff and finding it out if he doesn't (he can even test and determine it based upon the results) - - theoretical guessing isn't what I'm lookin for.

I know its possible to split this up but it's in a spot in my code that's already embedded in elseif, I'd sooner not if I do not have to. And in this particular script there is, as always, a total length consideration. I'm hoping to keep things short (and this is hella short).
User avatar
Richard Dixon
 
Posts: 3461
Joined: Thu Jun 07, 2007 1:29 pm

Post » Fri Feb 26, 2010 5:15 am

Yes, each instance of http://geck.gamesas.com/index.php/GetEquipped will be evaluated every time the code reaches that point. The script compiler does very little optimisation when it comes to expressions, so it doesn't know that, for example, if a expression consists of multiple smaller expressions linked via a logical or operator ("||") that having one of the smaller expressions evaluate to 1 is enough for the entire expression to evaluate to 1.

When form lists are used in code, they basically work as a way to condense expressions that would otherwise use many logical or operators. I don't know if http://geck.gamesas.com/index.php/GetEquipped (for example) will return 1 as soon as it finds an item in a form list that is equipped or if it will check every item, but it shouldn't be too difficult to test.

Cipscis
User avatar
Robyn Lena
 
Posts: 3338
Joined: Mon Jan 01, 2007 6:17 am

Post » Thu Feb 25, 2010 8:42 pm

Yes, each instance of http://geck.gamesas.com/index.php/GetEquipped will be evaluated every time the code reaches that point. The script compiler does very little optimisation when it comes to expressions, so it doesn't know that, for example, if a expression consists of multiple smaller expressions linked via a logical or operator ("||") that having one of the smaller expressions evaluate to 1 is enough for the entire expression to evaluate to 1.

When form lists are used in code, they basically work as a way to condense expressions that would otherwise use many logical or operators. I don't know if http://geck.gamesas.com/index.php/GetEquipped (for example) will return 1 as soon as it finds an item in a form list that is equipped or if it will check every item, but it shouldn't be too difficult to test.

Cipscis


Thank you Cipscis!!!

* throws up*

I was hoping you'd say it wasn't so.
User avatar
Kelly Upshall
 
Posts: 3475
Joined: Sat Oct 28, 2006 6:26 pm

Post » Thu Feb 25, 2010 8:42 pm

When form lists are used in code, they basically work as a way to condense expressions that would otherwise use many logical or operators. I don't know if http://geck.gamesas.com/index.php/GetEquipped (for example) will return 1 as soon as it finds an item in a form list that is equipped or if it will check every item, but it shouldn't be too difficult to test.


BTW, this part, I don't need to know. I must use formlists for this application, it's key.
User avatar
DAVId MArtInez
 
Posts: 3410
Joined: Fri Aug 10, 2007 1:16 am

Post » Thu Feb 25, 2010 8:17 pm

Thank you Cipscis!!!

* throws up*

I was hoping you'd say it wasn't so.

Easy enough to optimise, though :)

short DoActionif Followers7.MalcolmBG == 1   if PhalanxMalcolm2REF.GetEquipped PhPBG	  set DoAction to 1   elseif PhalanxMalcolm2REF.GetEquipped PhFPBG	  set DoAction to 1   elseif PhalanxMalcolm2REF.getequipped PhDLC03PBG	  set DoAction to 1   endif   if DoAction	; do whatever   endifendif

Then just put the list tests in order most likely to be true down to least likely.

Sorry if this was already blindingly obvious to you :).
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Thu Feb 25, 2010 6:37 pm

Easy enough to optimise, though :)

Then just put the list tests in order most likely to be true down to least likely.

Sorry if this was already blindingly obvious to you :).


Thx but yeah, it is already known. I have piles of blocks that look like this. It just svcks to have to spell out OR every darn time.

This will be fun. The working line is:

if Followers7.MalcolmEW && PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList || Followers7.MalcolmBG && (PhalanxMalcolm2REF.GetEquipped PhPBG || PhalanxMalcolm2REF.GetEquipped PhFPBG || PhalanxMalcolm2REF.getequipped PhDLC03PBG)


Here is how I believe the entire code block optimizes, including what comes after it.

if Followers7.MalcolmEW	if PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList		set fix to 1	endifendifif fixelse	if Followers7.MalcolmBG		if PhalanxMalcolm2REF.GetEquipped PhPBG			set fix to 1		elseif PhalanxMalcolm2REF.GetEquipped PhFPBG			set fix to 1		elseif PhalanxMalcolm2REF.getequipped PhDLC03PBG			set fix to 1		endif	endifendifif fix	set fix to 0	if NoCoverCS	else		PhalanxMalcolm2REF.SetCombatStyle FollowersCombatStyleNoCover		set NoCoverCS to 1	endifelse	if NoCoverCS		set NoCoverCS to 0		if PhalanxMalcolm2REF.CombatStyleMelee			PhalanxMalcolm2REF.SetCombatStyle FollowersCombatStyleMelee		else			PhalanxMalcolm2REF.SetCombatStyle FollowersCombatStyleRanged		endif	endifendif


bleh. all cause the OR operator has it's head up its ass!!!! =p
User avatar
Manuel rivera
 
Posts: 3395
Joined: Mon Sep 10, 2007 4:12 pm

Post » Thu Feb 25, 2010 11:42 pm

Like I said before, it'd probably be easier to use more form lists. Instead of lists of "elseif" statements all executing the same code, just make a form list of the form lists that you want to check, and check against that.

Cipscis
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Thu Feb 25, 2010 6:19 pm

Like I said before, it'd probably be easier to use more form lists. Instead of lists of "elseif" statements all executing the same code, just make a form list of the form lists that you want to check, and check against that.

Cipscis


I see what you mean...

Does it actually uhhhh, work? Like, you're sure?

Edit: Well, I'll give it a try, and use a messagebox to make it clear if its getting the data right.
User avatar
Jessica Colville
 
Posts: 3349
Joined: Wed Oct 18, 2006 6:53 pm

Post » Fri Feb 26, 2010 3:00 am

	set fix to 0	if Followers7.MalcolmEW		if PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList			set fix to 1		endif	endif
Could be replaced with
	Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList

User avatar
Monika
 
Posts: 3469
Joined: Wed Jan 10, 2007 7:50 pm

Post » Fri Feb 26, 2010 8:31 am

	set fix to 0	if Followers7.MalcolmEW		if PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList			set fix to 1		endif	endif
Could be replaced with
	Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList


Seriously? Boy does that look weird, but alright!
User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm

Post » Fri Feb 26, 2010 2:00 am

	set fix to 0	if Followers7.MalcolmEW		if PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList			set fix to 1		endif	endif
Could be replaced with
	Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList


So here is what I will test.



set fix to 0if Followers7.MalcolmEW	Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCListendifif fixelse	if Followers7.MalcolmBG		set fix to PhalanxMalcolm2REF.getequipped PhalanxMegaPBG	endifendif

User avatar
Cccurly
 
Posts: 3381
Joined: Mon Apr 09, 2007 8:18 pm

Post » Thu Feb 25, 2010 11:37 pm

Seriously? Boy does that look weird, but alright!
It works. I just double checked the below...
	Set Test to Player.GetEquipped Vault101ApparelFLST	If TEST; Player is wearing a form in FLST		Player.AddItem F 1000	Else		Player.Kill Player 1	EndIf
...and it was caps after caps until I took off all my Vault 101 gear, then a head explosion. To invert it (Cipscis style)...
	Set Test to (Player.GetEquipped Vault101ApparelFLST == 0)	If TEST; Player is not wearing a form in FLST		Player.AddItem F 1000	Else		Player.Kill Player 1	EndIf

User avatar
sarah simon-rogaume
 
Posts: 3383
Joined: Thu Mar 15, 2007 4:41 am

Post » Thu Feb 25, 2010 4:31 pm

My code block is failing, actually. I'll work out what's up with it.
User avatar
Lucie H
 
Posts: 3276
Joined: Tue Mar 13, 2007 11:46 pm

Post » Thu Feb 25, 2010 8:43 pm

So here is what I will test.



;set fix to 0	if Followers7.MalcolmEW		Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList	elseif (Followers7.MalcolmBG != Fix)		set fix to PhalanxMalcolm2REF.getequipped PhalanxMegaPBG	endif

or
;set fix to 0	if Followers7.MalcolmEW		Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList	end	if (Followers7.MalcolmBG != Fix); ((Followers7.MalcolmBG == 1 && FIX == 0) || (Followers7.MalcolmBG == 0 && FIX == 1))		set fix to PhalanxMalcolm2REF.getequipped PhalanxMegaPBG	endif
???
User avatar
Carlos Rojas
 
Posts: 3391
Joined: Thu Aug 16, 2007 11:19 am

Post » Fri Feb 26, 2010 3:46 am

My code block is failing, actually. I'll work out what's up with it.


Using one mega-formlist (PhalanxMegaPBG) and placing all 3 of the other formlists into it, and running the comparison against that, is failing to catch a match, for me.

I do not know if it means anything but, my formlists are a bit dynamic. Two of the formlists are empty within Phalanx-MainFollowerModule. It is Phalanx-BrokenSteelCompatibility.esp (which has both MainFollowerModule and BrokenSteel.esm as masters) which overwrites the contents of PhDLC03PBG, adding the correct DLC weapons to it (such as the Slow-Burn Flamer, which is what the follower is equipping during this test). I'm not saying this is happening but, if the contents of the formlists are being stored at compile time, that would cause what I'm seeing. That list is empty from the perspective of a standalone MainFollowerModule.
User avatar
Rachyroo
 
Posts: 3415
Joined: Tue Jun 20, 2006 11:23 pm

Post » Thu Feb 25, 2010 8:03 pm

Still fails, but its on the formlist check, I am sure of it.


if Followers7.MalcolmEW	Set Fix to PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCListelseif (Followers7.MalcolmBG != Fix)	set fix to PhalanxMalcolm2REF.getequipped PhalanxMegaPBGendifif fixshowmessage genericdebugmsg...etc


Malcolm's in a DLC03 flamer and the line never hits.

This code spams the messagebox for fix==1

set fix to 0if Followers7.MalcolmEW	if PhalanxMalcolm2REF.GetEquipped PhalanxDLC03TCList		set fix to 1	endifendifif fixelse	if Followers7.MalcolmBG		if PhalanxMalcolm2REF.GetEquipped PhPBG			set fix to 1		elseif PhalanxMalcolm2REF.GetEquipped PhFPBG			set fix to 1		elseif PhalanxMalcolm2REF.getequipped PhDLC03PBG			set fix to 1		endif	endifendif

User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Thu Feb 25, 2010 10:14 pm

Well. this is cute.

I cannot use this anyway, now that I see it working in-game. Check it out.

When I switch the combat style, it causes the follower to re-evaluate his choice of weapons. He always picks the highest DPS one first AND ACTUALLY EQUIPS IT. Only after equipping it and thinking about it for a second does he succesfully answer the range/splash damage question, and will then switch back off of it if he thinks the flamer is a bad idea.

One point of what I am doing is that the follower is being allowed to keep his flamer fuel, and gets to choose if he wants to use the flamer or another weapon (potentially refusing to use the flamer for either range or splash damage reasons). So, here's what happens 50% of the time.

Follower equips 44magnum on the basis of not being close enough to the target for the flamer to be good or on the basis of splash damage concerns. My system sees this and switches him to a combat style that tells him to use cover. Then, he re-evaluates, and switches weapons to the flamer (highest DPS). My system sees this and swaps his combat style to not use cover. He re-evaluates, re-equips the flamer again. Then, he in the end decides against using the flamer, and switches back to the 44. Then, my system sees that, and switches his combat style to use cover. Then he re-evaluates and goes back onto the flamer.

And it cycles... and very little weapon firing is happening.

And, there's other glitches that happen along the way, which other scripts catch, and cause yet another re-evaluation just for the hell of it.

Edit: I'm desperately in need of a getcombatstyle function. And yes FOSE has it and the regular compiler does not, and yes I'm trying to think of another way to do what I need. :(
User avatar
brian adkins
 
Posts: 3452
Joined: Mon Oct 01, 2007 8:51 am


Return to Fallout 3