New scripting function: GetCellID

Feedback on past, current, and future development.
Post Reply
User avatar
NatalieN
Posts: 43
Joined: 30 Nov 2015, 21:32

New scripting function: GetCellID

Post by NatalieN »

I'm proposing a new scripting function, GetCellID. It would behave like the various GetStat functions, in that requires an explicit reference, and accepts no additional arguments. GetCellID would return the cell id of the first instance of the referenced object.

An alternative, probably easier to implement function would be GetPCCellID. As GetCellID, but the reference is implicitly the player. It looks to me like OpenMW's implementation of GetPCCell, (implemented in cellextensions.cpp) already does everything that would be required. A copy, paste, and some tweaks would probably be enough to get it implemented. vmformat.txt would also need to be updated.

The special cases that I can think of would be when objects are deleted, disabled, or never actually placed in game. I'm not sure how they should be handled, but I don't believe they would ever arise if the GetPCCellID vice the more generic GetCellID was implemented.

Scripting Enhancement Thread for reference.
User avatar
DestinedToDie
Posts: 1181
Joined: 29 Jun 2015, 09:08

Re: New scripting function: GetCellID

Post by DestinedToDie »

Did you happen to read my post? viewtopic.php?f=3&t=3232&p=36173#p36173

Anyway I wouldn't mind this function. Not seeing how it would support scripting, but at least I'd know where the I am on the pathgrid. But what are the other uses? To my imagination GetPCCell (checks if PC is in a certain cell, returns True or False) is enough to script the events.
User avatar
sjek
Posts: 442
Joined: 22 Nov 2014, 10:51

Re: New scripting function: GetCellID

Post by sjek »

getcellID could be used with some system which stores or search trought instances of object and would be as a way to pick one in sadrith mora and other in tel mora telling npc's to activate ancients relics and player itself need to go stop them or get a companion for it. otherwise all are teleported to another dimension like dwemers in those cells .p

then of course rescue mission but right of the bat one

+ amulets, calling generic imperial guards or so. getcellid could also be used then conjuction with cell checking for worldspaces and such.

other would be to make soltheim hircine make the hunt begin and you as a werewolf need to get npc's to certain cells

then there's the change to get regorius arhcmage to finally reveal where dwemers disappeared. good use for sneaking skills

also for weather scripts if you want to make guick or radual change with distance calculation in specific cell while region is set / scripted differently

as a function ?

edit: as a feature. main part is that..... that getpccell xD

would returning a spring work, could be compared against list of cells or one, extending without sacrificing base functionality
User avatar
NatalieN
Posts: 43
Joined: 30 Nov 2015, 21:32

Re: New scripting function: GetCellID

Post by NatalieN »

DestinedToDie wrote:Anyway I wouldn't mind this function. Not seeing how it would support scripting, but at least I'd know where the I am on the pathgrid. But what are the other uses? To my imagination GetPCCell (checks if PC is in a certain cell, returns True or False) is enough to script the events.
It would be very useful to specify CellIDs when the modder can have no idea in advance what the CellID should be. For instance, I want the player to be able to tell an NPC to "meet back here" but I have no idea where the player wants to meet. The script that I want to work would be something like:

First, Player leads the NPC to their location of choice, then triggers a script like:
Set MarkX to GetPos (x)
Set MarkY to GetPos (y)
Set MarkZ to GetPos (z)
Set MarkCellID to GetPCCCell

Later, when you want the NPC to go back to that location, you can run something like:

NPC-> PositionCell, MarkX, MarkY, MarkZ, MarkCellID

In this way, you can use PositionCell to position the NPC in any possible cell, even ones's that don't exist in your Mod.

Another possible use might be having something happen in a cell where something else has already happened, but we can't know in advance what that cell is. For instance, in the below, I know I want the player to be haunted if she sleeps in a cell where an NPC died, but I don't know what cell the NPC will die in.:

NPC-> if ondeath == 1
set DeathCell to GetCellId

Later, if the player tries to sleep in that cell,

If GetPCCell = DeathCell
If Player sleeping
placeatpc Ghost
wakePC

It could also be used with items. Say I want something to happen in a cell where a PC drops a certain item:

Item has a script like:
If OnPCDrop == 1
set ItemLocation to GetCellID

Later, we can run something like:
NPC-> If GetCellID == ItemLocation
Forcegreeting "I'm sure you dropped it somewhere around here."
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: New scripting function: GetCellID

Post by Chris »

The CellID is a string, isn't it? That would be a big problem since there's no way to store a string variable, and it would probably need some not-insignificant changes to the VM to do so.
User avatar
sjek
Posts: 442
Joined: 22 Nov 2014, 10:51

Re: New scripting function: GetCellID

Post by sjek »

First, Player leads the NPC to their location of choice, then triggers a script like:
Set MarkX to GetPos (x)
Set MarkY to GetPos (y)
Set MarkZ to GetPos (z)
Set MarkCellID to GetPCCCell

Later, when you want the NPC to go back to that location, you can run something like:

NPC-> PositionCell, MarkX, MarkY, MarkZ, MarkCellID
i think that would be possible also with springs. something like

Code: Select all

set markxyz to getpos mark{X,Y,Z}       
;list, or with differents for getting individual at different times or some 

set [markcell] to player->getcellid     
;as getpccell would need extension to return cell without definition ?
NPC-> PositionCell, MarkX, MarkY, MarkZ, {markcell}
Spoiler: Show
NPC-> if ondeath == 1
set DeathCell to GetCellId
same could be used for that as to reduce the needed functions basically.

Code: Select all

if npc->ondeath==1
set DeathCell to npc->getcellid   
;this makes also possible setting other conditions with ands and ors. 
went kinda syntax checking but refer a clear way to tell what exactly some part of the code do there being possibility for multiple ones on front
The CellID is a string, isn't it? That would be a big problem since there's no way to store a string variable, and it would probably need some not-insignificant changes to the VM to do so.
that's kinda problem then. what about variable saving or as custom globals or gmst's althought that would be glutterous. other available way is to place dummy object in that cell on runtime and trigger the event from checking for that.

then again:
comparing
NPC-> if ondeath == 1
and
if npc->ondeath==1

1. checks defined inside npc reference if ondeath is 1 and 2. same but on the general level possibly trought all npc's (type definitions) or would they be the same on the code level?
then again 1. on that note is the same as defining if ondeath==1 on npc's script going into possibility of defining local commands from global script..... uses for lightly different referencing function?
Chris
Posts: 1626
Joined: 04 Sep 2011, 08:33

Re: New scripting function: GetCellID

Post by Chris »

I had a thought, for being able to handle IDs like this with comparatively uninvasive changes. IIRC, referenceable objects are defined using a string in the esm/p data, but they get an integer index when loaded into the engine. So my thinking is that there's a new REFID script type which is effectively a 32- or 64-bit integer at runtime (whichever size the index is). Normal math operations don't work on it, but it can be used for comparisons, explicit references, and certain function parameters.

To handle savegames, the REFID can be converted from the integer ID to the string ID when saving, and converted from the string ID to integer ID when loading. This ensures the REFID consistently points to the same referenceable even if the mod list changes (if the referenceable is for a mod that was removed, or if the referenceable type changes, this can be detected when loading the save game, a warning issued, and the REFID nulled out).
Post Reply