Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Plugin: Snapshot #1307

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

Daztek
Copy link
Member

@Daztek Daztek commented Mar 24, 2021

WIP~

A bunch of cool functions to create object snapshot lists with optional filters.

Example: Get all clerics with at last 12 strength in a Shape/Area/Module

struct NWNX_Snapshot_Filter strFilter1;
strFilter1.nType = NWNX_SNAPSHOT_FILTER_TYPE_CREATURESTATS;
strFilter1.nSubtype = NWNX_SNAPSHOT_FILTER_SUBTYPE_CREATURESTATS_ABILITY;
strFilter1.nComparison = NWNX_SNAPSHOT_COMPARISON_GREATER_THAN_OR_EQUALS;
strFilter1.nParam1 = ABILITY_STRENGTH;
strFilter1.nParam2 = 12;
NWNX_Snapshot_AddFilter(nSnapshotID, strFilter1);

struct NWNX_Snapshot_Filter strFilter2;
strFilter2.nType = NWNX_SNAPSHOT_FILTER_TYPE_CREATURESTATS;
strFilter2.nSubtype = NWNX_SNAPSHOT_FILTER_SUBTYPE_CREATURESTATS_HAS_CLASS;
strFilter2.nParam1 = CLASS_TYPE_CLERIC;
NWNX_Snapshot_AddFilter(nSnapshotID, strFilter2);        

// Pick one
int nSize = NWNX_Snapshot_CreateAreaShapeSnapshot(SHAPE_SPHERE, 10.0f, locTarget, bLineOfSight, nObjectFilter, vOrigin, nSnapshotID);
int nSize = NWNX_Snapshot_CreateAreaSnapshot(oArea, nObjectFilter, nSnapshotID);
int nSize = NWNX_Snapshot_CreateModuleSnapshot(nObjectFilter, nSnapshotID);        
       
// Sort by nearest to oPlayer
NWNX_Snapshot_SortSnapshotByDistance(oPlayer, nSnapshotID);

int nIndex;
for (nIndex = 0; nIndex < nSize; nIndex++)
{          
    object oObject = NWNX_Snapshot_GetObjectFromSnapshot(nIndex, nSnapshotID);   
    
    // Do stuff.
}

@Daztek Daztek force-pushed the plugin-snapshot branch 2 times, most recently from acad0c4 to 0d0c335 Compare March 25, 2021 09:45
@mtijanic mtijanic changed the title Plugin: Snapshot [WIP] Plugin: Snapshot Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant