Jump to content

Come laugh at the noob trying to script :)


nate12357

Recommended Posts

Couldn't he do a ref walking script?

 

I don't even know if SKSE has the necessary functions to refwalk in skyrim but you would need to get the number of enemies within a certain distance. You could fill a formlist dynamically with these npc refs including their levels. then you could sort the formlist by distance from the player. alternatively you could apply some basic statistical inference, add up the levels of all the npc's and divide by the number of npcs. if player.getlevel() < (AverageNPCLevel-2) ring the bell.

 

 

There's a number of ways to get all the NPCs in an area. With SKSE this is the most straight-forward:

Cell currentCell    ;represents the cell, however you set it

int totalRefs = currentCell.GetNumRefs(43)    ;gets all the references of form type 43 (npc)
int i = 0    ;the iterator
while i<totalRefs
    ObjectReference target = GetNthRef(i)
    ...    ;do stuff here with the target
    i+=1
endWhile

This will iterate through all NPC's in the cell, allowing you to sequentially operate on them however you like. It can be attached to the cell or you can attach it elsewhere and get the cell some other way (property, event, etc.).

 

Another way is to have an invisible magic effect on the player that has a large area that "marks" all nearby actors for use in a script. This has some limitations but can be useful in certain cases.

Link to comment
Share on other sites

 

Couldn't he do a ref walking script?

 

I don't even know if SKSE has the necessary functions to refwalk in skyrim but you would need to get the number of enemies within a certain distance. You could fill a formlist dynamically with these npc refs including their levels. then you could sort the formlist by distance from the player. alternatively you could apply some basic statistical inference, add up the levels of all the npc's and divide by the number of npcs. if player.getlevel() < (AverageNPCLevel-2) ring the bell.

 

 

There's a number of ways to get all the NPCs in an area. With SKSE this is the most straight-forward:

Cell currentCell    ;represents the cell, however you set it

int totalRefs = currentCell.GetNumRefs(43)    ;gets all the references of form type 43 (npc)
int i = 0    ;the iterator
while i<totalRefs
    ObjectReference target = GetNthRef(i)
    ...    ;do stuff here with the target
    i+=1
endWhile

This will iterate through all NPC's in the cell, allowing you to sequentially operate on them however you like. It can be attached to the cell or you can attach it elsewhere and get the cell some other way (property, event, etc.).

 

Another way is to have an invisible magic effect on the player that has a large area that "marks" all nearby actors for use in a script. This has some limitations but can be useful in certain cases.

 

@ the OP. I would do this and fill in the part where dalsio wrote "... ;do stuff here with the target" with something like

 



Cell currentCell ;represents the cell, however you set it

Event OnCellLoad()
int totalRefs = currentCell.GetNumRefs(43) ;gets all the references of form type 43 (npc)
int AvgNPCLevel=0
int i = 0 ;the iterator
while i<totalRefs
ObjectReference target = GetNthRef(i)
AvgNPCLevel+=AvgNPVLevel+target.GetLevel()
i+=1
endWhile

AvgNPCLevel=AvgNPCLevel/totalRefs
if (AvgNPCLevel-2)>playerRef
  ;insert command to play a sound PlaySFX(SoundMarkerForm, 1.0)
endif
EndEvent

still new to scripting myself.

 

How to play a sound.http://www.creationkit.com/index.php?title=Play_-_Sound&redirect=no

Link to comment
Share on other sites

I'm not sure the "zones" have levels or dungeons. Most this game reacts off your current level.

There's many vanilla dungeons that do not level with the player. Plus there are mods that specifically de-level the enemies to make it more like Morrowind or other RPG's and many mods that add dungeons have fixed or limited-range leveled enemies.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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