Stacks, arrays, or Loops in scripts?

Post » Fri May 06, 2011 8:13 pm

I need to do a database and/or for/next type setup to lower the number of lines for a massive script. Is it even possible?

Here is what I'm doing:

I need to take every single perk in vanilla and have a script (and subscripts with tokens for the 'ability' perks) and remove them from a player.

This will allow me to strip, for example, a level 25 player down to the same state as a level one character (its for a rebuilder).

The problem is, there are massive numbers of perks, and a script containing a player.removeperk blah blah line for each perk would be humongous.

What I was thinking was seeing if there is a way to do a for/next setup to pull all perks in numerical order such as:

FOR x = 00aee217 to (00aee217+)

player.removeperk x

NEXT

Im not sure if there even IS a for/next in either new Vegas OR NVSE, is there?

Please guys, this is driving me batty.
User avatar
Ilona Neumann
 
Posts: 3308
Joined: Sat Aug 19, 2006 3:30 am

Post » Sat May 07, 2011 6:11 am

This could be a start:

1. Create a form list
2. Select all perks and drag them into the list so they are added
3. Have a script like

set i to 0set n to listGetCount YourPerkListLabel 1if i < n	set perk to listGetNthForm YourPerkList i	player.removePerk perk	set i to i + 1	goto 1endif

User avatar
Lyd
 
Posts: 3335
Joined: Sat Aug 26, 2006 2:56 pm

Post » Sat May 07, 2011 8:21 am

This could be a start:

1. Create a form list
2. Select all perks and drag them into the list so they are added
3. Have a script like

set i to 0set n to listGetCount YourPerkListLabel 1if i < n	set perk to listGetNthForm YourPerkList i	player.removePerk perk	set i to i + 1	goto 1endif





Thanks, man..thats a definate help!

A couple of things though...there is a notation on the GECK pages for player.removeperk that says that 'ability' perks will crash the game unless you drop a token into the players inventory, run a separate script from the token to remove the perk/ability.

Any idea which perks qualify as 'ability' perks? Nothing comes to mind here...
User avatar
joeK
 
Posts: 3370
Joined: Tue Jul 10, 2007 10:22 am

Post » Sat May 07, 2011 2:08 am

I didn't think loops were even possible, that is good to know. The formlist is an excellent way to deal with *vanilla* perks. Suppose a mod has added some perks. The rebuilder should remove those also. Is there a way to get a list of perks which were added afterwards? A "real" API would allow us to iterate object types, even ones which were added by other modders.

I have a related concern for the pulse gun effect on power armor. If you trace down the pulse gun effect, you see that there are three different places (pulse grenade, zap glove, and pulse gun) where the effect occurs if the target is wearing t51 power armor OR t45 armor OR BOS t51 armor OR BOS t51 armor. For my mod, I have locally converted this to a formlist. But there are lots of mods which add a power armor type. So I'd love to be able to iterate all the power armors in the game, to catch cases where a target with power armor modded in after my mod, would still get the pulse gun effect.

Any way to iterate like this?
User avatar
Brooks Hardison
 
Posts: 3410
Joined: Fri Sep 07, 2007 3:14 am

Post » Sat May 07, 2011 12:03 pm

If I'm following you correctly, yes.

A form list is just a list of formID's, and since every object in the game, and quest, and perk, et al, has a formID, you should be able to drag and drop them into a new leveled list or formlist.
User avatar
Emma
 
Posts: 3287
Joined: Mon Aug 28, 2006 12:51 am

Post » Sat May 07, 2011 4:13 am

I did not explain my question well. I am creating mod A, let's say this is the rebuilder application in the OP. In mod A, I create a formlist which lists all the base game perks, and I use the above loop to remove them all. That is fine. Now some other person is working on mod B, which adds some new perks. Suppose a player is using both mod A and mod B. The rebuilder fails to remove the perks defined in mod B, which is the wrong result. Modder A had no way to know about B's perks, and modder B had no such formlist to update.

If there were a function that allowed iterating "all perks", then modder A would not create any formlist, instead he would write code to remove each perk. Modder B does not have to do anything special; and the player will see the "correct" behavior when using both mods together.

Does anybody know whether this type of iteration or collection is available?
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm

Post » Sat May 07, 2011 3:07 am

Would a GetFirstRef/GetNextRef loop for type 86 (perks) iterate through all the player's perks?
User avatar
Rhiannon Jones
 
Posts: 3423
Joined: Thu Sep 21, 2006 3:18 pm

Post » Sat May 07, 2011 8:15 am

That sounds interesting, but it requires the script extender. I have not looked into that because it requires players to install that and allow steam community mode.
User avatar
Javaun Thompson
 
Posts: 3397
Joined: Fri Sep 21, 2007 10:28 am

Post » Sat May 07, 2011 10:43 am

Getrefs would probably induce an infinite loop, so i dont think that would work, if it didnt infa loop, it would probably crash.

As to getting mod based perks, no...they would have to know my master mods formlist and add theirs to it, i think

What is needed is for a modder who makes perks to make a listing, including FormID, of ALL their perks, and earmark which are ABILITY adding perks as well.

Then the original modder has to create an adjunct .esp to handle removing the new ones.

I'm already planning on trying to do this for the added perk pack that adds 75 or so perks.
User avatar
Damned_Queen
 
Posts: 3425
Joined: Fri Apr 20, 2007 5:18 pm

Post » Sat May 07, 2011 10:03 am

As to getting mod based perks, no...they would have to know my master mods formlist and add theirs to it, i think


This is a "chicken and egg" problem, isn't it? Your mod, by itself, cannot know the names of the other mod's perks. Their mod, by itself, cannot know the name of your formlist. If they add their perks to their own formlist, you cannot know the name of that. If there are N different mods which add perks, you would need N^2 different copies of your mod, which contained different combinations of the other mods' perks. There is no general solution apart from iteration.
User avatar
Joe Bonney
 
Posts: 3466
Joined: Tue Jul 17, 2007 12:00 pm

Post » Fri May 06, 2011 9:23 pm

Thanks, man..thats a definate help!

A couple of things though...there is a notation on the GECK pages for player.removeperk that says that 'ability' perks will crash the game unless you drop a token into the players inventory, run a separate script from the token to remove the perk/ability.

Any idea which perks qualify as 'ability' perks? Nothing comes to mind here...

Well, I dont know about that. An ability perk would be a perk that adds an ability :) Double-click any perk and you'll notice the option.

I've just created a bunch of perks that add ability and i didnt encounter any problems so far when removing them.

Would a GetFirstRef/GetNextRef loop for type 86 (perks) iterate through all the player's perks?


No, those functions iterate over references in cells, so for type 86 this wouldnt make sense.

That sounds interesting, but it requires the script extender. I have not looked into that because it requires players to install that and allow steam community mode.


The first snippet I posted requires NVSE as well. You can do some pseudo-loops without NVSE, but you cant get form list elements at a specific index if i remember correctly.

This is a "chicken and egg" problem, isn't it? Your mod, by itself, cannot know the names of the other mod's perks. Their mod, by itself, cannot know the name of your formlist. If they add their perks to their own formlist, you cannot know the name of that. If there are N different mods which add perks, you would need N^2 different copies of your mod, which contained different combinations of the other mods' perks. There is no general solution apart from iteration.


Yes thats a bit of a problem. You need your mod which adds the list, and for every mod you want to support you need a patch with the mod itself and the retrainer as masters. But you wont need multiple combinations. If you add the additional perks by modifying the formlist record, the user will have to create a merged patch which will combine all entries from different patches + the original list. Or you can use script functions to add the items at runtime, which will remove the need for a merged patch.

Also theres the possibility of re-purposing an existing formid in the NV master and use it for your list, but I think that svcks :)
User avatar
Laura Hicks
 
Posts: 3395
Joined: Wed Jun 06, 2007 9:21 am

Post » Sat May 07, 2011 5:32 am

Well, I dont know about that. An ability perk would be a perk that adds an ability :) Double-click any perk and you'll notice the option.

I've just created a bunch of perks that add ability and i didnt encounter any problems so far when removing them.


Made also a test, removing abilty perks do not crash the game for me.


The first snippet I posted requires NVSE as well. You can do some pseudo-loops without NVSE, but you cant get form list elements at a specific index if i remember correctly.


Right, this function is added by NVSE and not available without it.

Yes thats a bit of a problem. You need your mod which adds the list, and for every mod you want to support you need a patch with the mod itself and the retrainer as masters. But you wont need multiple combinations. If you add the additional perks by modifying the formlist record, the user will have to create a merged patch which will combine all entries from different patches + the original list. Or you can use script functions to add the items at runtime, which will remove the need for a merged patch.

Also theres the possibility of re-purposing an existing formid in the NV master and use it for your list, but I think that svcks :)


The basic perk list can be expanded by adding the new forms to it with this function: http://geck.gamesas.com/index.php/AddFormToFormList
User avatar
barbara belmonte
 
Posts: 3528
Joined: Fri Apr 06, 2007 6:12 pm

Post » Sat May 07, 2011 8:57 am

I dunno guys...maybe you are removing the perk but not the ability then?

HERE is what the new vegas wiki has to say...lets discuss it:

Notes

* Using RemovePerk in an Effect Script on a perk that has an "ability" type Perk Entry defined will crash Fallout 3, so long as it has an ability specified. Instead, use AddItem to add a scripted token that removes the perk via RemovePerk and then calls RemoveMe:

ref rContainer
Begin OnAdd
set rContainer to GetContainer
rContainer.RemovePerk MyPerk
RemoveMe
End

Since it specifically mentions FO3, do you think this was 'fixed' in New Vegas perhaps?

Or would it be a good idea to still fire a scripted token into their inv?
User avatar
Lady Shocka
 
Posts: 3452
Joined: Mon Aug 21, 2006 10:59 pm

Post » Sat May 07, 2011 7:07 am

Well, you could just run the whole perk removal script on a token and not have to worry about that particular issue.
User avatar
Kelsey Anna Farley
 
Posts: 3433
Joined: Fri Jun 30, 2006 10:33 pm

Post » Sat May 07, 2011 7:52 am

Just as I thought, the script isnt accepting the LABEL 1 line. Anyone got any ideas?
User avatar
Ymani Hood
 
Posts: 3514
Joined: Fri Oct 26, 2007 3:22 am

Post » Sat May 07, 2011 10:39 am

It was mentioned later in the thread that some of the syntax in that examle requires nvse. Are you using that?
User avatar
Bellismydesi
 
Posts: 3360
Joined: Sun Jun 18, 2006 7:25 am

Post » Sat May 07, 2011 6:39 am

yeah. check the 'script wont compile thread'.

Moderator can you close this thread because of the other one being used? thanks
User avatar
Chrissie Pillinger
 
Posts: 3464
Joined: Fri Jun 16, 2006 3:26 am


Return to Fallout: New Vegas