Difference between revisions of "Talk:OBSE Wish List"
Jump to navigation
Jump to search
no edit summary
imported>DragoonWraith (→Dejaside's Binary Examples: defense of the binary operations) |
imported>GreyWanderer |
||
Line 38: | Line 38: | ||
:::Anyway, Dejaside's idea was that these functions would be very easy to create for the OBSE developers, and combinations of them could be more useful than a simple GetObjectType function - for example, an ingredient with Restore Health is both edible and an ingredient - GetObjectType would only return one of these pieces of information, while having these binary tests would allow you to determine both. | :::Anyway, Dejaside's idea was that these functions would be very easy to create for the OBSE developers, and combinations of them could be more useful than a simple GetObjectType function - for example, an ingredient with Restore Health is both edible and an ingredient - GetObjectType would only return one of these pieces of information, while having these binary tests would allow you to determine both. | ||
==CellScan== | |||
This is to discuss the different approaches taken by former Script Extenders to realise a "Cell Scan". | |||
MWSE did it that way: it used three different functions to chose from three different items lists (I suppose these were pre-defined by the game): | |||
*'''FirstNPC''' - to select the NPC/Creature list | |||
*'''FirstStatic''' - to select the Statics list | |||
*'''FirstItem''' - to select the list containing other items in a cell | |||
All these returned the first ref on the list. | |||
Then, there was '''NextRef''' which took a reference (like the ones returned by the commands above or this very command) as a parameter and returned the next ref after the one specified. Refs could be encoded in long type variables and used in a similar manner as in Oblivion (imho better, one could actualy access variables on the refs). | |||
Afaik MWE could only search for NPCs/Creatures which it calls "Livings" so the command was named '''NextLiving'''. MWE remembered the last encountered ref automatically. It returned a "-1" value (to a remote variable) if the scan is through. '''ClearLiving''' was used to reset the search to the first item on the list.<br> | |||
[there was also a third command needed to succeed, but this is of no interest here] | |||
Now, I think the question whether such a function is necessary is redundant. Mandatory though is the question '''how this should work'''. Personally, I like the MWSE approach a bit more, but it showed to be slower (though cdcooley said this was because it wasn't optimized; I can't tell). | |||
Then, there is the concept used in the OBSE for Inventory Scan. Iterate using a number instead of a reference. | |||
===[[User:GreyWanderer|Grey]]'s proposal=== | |||
I was about to propose a mix of MWSE and MWE approaches. One command to actually select a list (or item type) to scan and one command to actually iterate through the list: | |||
====''CellScan [short_integer]''==== | |||
Takes a mandatory integer as a parameter. Returns the current state set in the parameter, and "-1" if none. | |||
0 should be "all" ?<br> | |||
1 should be NPCs/Creatures<br> | |||
2-... should be additional lists / types of items | |||
====''NextRef [optional: ref]''==== | |||
This returns the next reference after the currently selected (or the first on the list if none). Returns "-1" if there is no "next" reference. | |||
The optional parameter is to shorten the time needed to do the scan if we know two references are near each other. "-1" as a parameter resets to the beginning of the list. | |||
====example:==== (simple, runs only once) | |||
<pre> | |||
scn ExampleQuestScript | |||
ref tempref ; takes the output of NextRef to work with the object | |||
short damage ; only needed for this very example, in which we do a dnd-like "fortitude save" | |||
CellScan 1 ; search for NPCs/Creatures | |||
while done == 0 | |||
if nextref == -1 | |||
set done to -1 ; we only want to loop once | |||
else | |||
set tempref to NextRef | |||
if tempref.getav health <= 5 && tempref.GetDead != 1 | |||
set damage to ( GetRandomPercent - tempref.getav endurance ) / 10 | |||
if damage > 0 | |||
tempref.modav health damage | |||
endif | |||
endif | |||
endif | |||
endwhile | |||
StopQuest ExampleQuest | |||
</pre> | |||
I'll try to find a better example that uses all of the possibilities, but this should work for now. --[[User:GreyWanderer|Grey]] 15:50, 3 August 2006 (EDT) |