Calling Sparkey Spawner via Script?

Is it possible to call a sparkey spawner case from a script? Example, conversation choice that calls a case # from the sparkey_enc script.

I’m trying to create an object with a conversation that can spawn a large number of mobs/groups. Would be great if I can just call a case from the sparkey_enc to do this.

You could set the sparky variable you need on the NPC (or whatever object is having the conversation) and write a script for the Action:

#include "sparky_inc"
voide main()
{
object oPC = GetPCSpeaker();
object oArea = OBJECT_SELF;
SetLocalString(oArea, "encounter_01", "v2, always, 100, copy, zoo, zoo_merchant_m, genstore, 
1, wp: POST_genstore, 1, 0, 1");//or whatever you need
int iSparkyPartyLvls = GetFactionAverageLevel(oPC) * (GetNumberPartyMembers(oPC) - 1);
SetLocalInt(oArea, "iSparkyPartyLvls", iSparkyPartyLvls);
SpawnEncounters(oArea);
}

This is lifted from a script I use that calls sparky from a trigger, but instead this is the speaking NPC.
Now, I realize you may want a different action depending on the conversation choice. You can set the variable in the same script. I will edit the above to show that.

This is awesome. Thank you Mannast! BTW thank you for the base module you created! I’m not great w/ code, but for some reason I’m addicted to getting things working in my nwn module that no one will ever see or play lol.

Would the first method you discussed only allow for 10 encounters? enc01 through enc10 per the predefined variables on the NPC?

Per the updated code, I could just make an individual script per “summon” that I want to happen from the conversation? Is that the idea? Just modify the encounter line per the script.

To better put what I’m trying to do. A simple arena like that from the ‘pretty good character creator’ module, that I can select a goblin or balor from a conversation selection. In which whatever is selected gets spawned into the room at the set wp. I’ll need to figure out how to prevent drops/exp from these mobs, but I can sort that out later.

1 Like

Sparky goes up to 99 encounters, I think
“encounter_” 01-99 - but you would define the encounter in the individual scripts and just call the one encounter set in the script.

"v2, always, 100, creature, <resref>, <amount>, <location>, <offset>, <random walk>, <continue>"

and change the information in the scripts. I admit, there may be an easier way to do this, but this workaround is what came to mind.

This is related to the previous posts, as I’m just starting to work on this part again. Should the following work? Currently it doesn’t spawn anything for me. Even if I comment out one of the encounter lines. This script is called from a npc conversation choice. abt_minotaur & art_hmerc are the resref and tags for both custom creatures i’m trying to spawn in 5 of each in a pve arena setting.

#include "sparky_inc"

void main()
{
object oPC = GetPCSpeaker();
object oArea = OBJECT_SELF;
SetLocalString(oArea, "cp25_01", "v2, always, 100, creature, abt_minotaur, 5, wp: arena_blue, 1, 0, 1");
SetLocalString(oArea, "cp25_02", "v2, always, 100, creature, art_hmerc, 5, wp: arena_red, 1, 0, 1");
SpawnEncounters(oArea);
}

I have sparkey_enter and sparkey_exit set on the area’s events. Not sure if those are even needed for a script to call an encounter on the fly like this.

Additionally, I’m also trying to figure out if I can create a table/list of 30 encounters, and to have it only pull 5 randomly from that table. So each time this spawn is called it pulls 5 encounters randomly from the list of 30.

Last question if you know - Anytime I set a spawn with Sparkey’s that uses a waypoint, it won’t allow me to include a second encounter with a different waypoint - form the same encounter. Like the code I listed above. Is that just how Sparkey’s works?

You need to name the variables “encounter_##” for the spawn to get called

SetLocalString(oArea, "encounter_01", "v2, always, 100, creature, abt_minotaur, 5, wp: arena_blue, 1, 0, 1");
SetLocalString(oArea, "encounter_02", "v2, always, 100, creature, art_hmerc, 5, wp: arena_red, 1, 0, 1");

Makes sense… and it crashes my module - Progress!!

1 Like

I remove these two lines from what you sent me originally:

int iSparkyPartyLvls = GetFactionAverageLevel(oPC) * (GetNumberPartyMembers(oPC) - 1);
SetLocalInt(oArea, "iSparkyPartyLvls", iSparkyPartyLvls);

If I leave these in, the script doesn’t compile because of the first row (ERROR: UNKNOWN STATE IN COMPILER). If I comment these two out it crashes the module when it kicks off the spawn script. If I save it anyways, and try it - nothing spawns. I assume these two lines are needed but the int is looking for something else?

Edit: Redo-ing some testing. I merged something into the sparkey_inc script like 9 months back and that is maybe my issue.

Yeah I’m not sure why it’s crashing my module. Sparky_inc is restored with the default script.
Played around with the script but I’m running into the same thing regardless.

NPC had a conversation.
oPC gets a “Start Arena” conversation option
“Start Arena” has script set on ‘Actions Taken’
That script is as follows:

#include "sparky_inc"

void main()
{
object oPC = GetPCSpeaker();
object oArea = OBJECT_SELF;
SetLocalString(oArea, "encounter_01", "v2, always, 100, creature, abt_minotaur, 5, wp: arena_blue, 1, 0, 1");
SetLocalString(oArea, "encounter_02", "v2, always, 100, creature, art_hmerc, 5, wp: arena_red, 1, 0, 1");
int iSparkyPartyLvls = GetFactionAverageLevel(oPC) * (GetNumberPartyMembers(oPC) - 1);
SetLocalInt(oArea, "iSparkyPartyLvls", iSparkyPartyLvls);
SpawnEncounters(oArea);
}

arena_red and arena_blue waypoints exist in the same area.

I moved the waypoints to where my PC can walk just to be sure the “pit” I had them in was not out of bounds or something. Even though I could spawn in creatures with DM enabled in said pit. It didn’t have any impact and still crashes.

I’ll keep testing different things.

Not an expert on the subject, but this is a convo (OBJECT_SELF = the NPC), so shouldn’t

be (judging by the “area” context)

object oArea = GetArea(OBJECT_SELF);

?

I adjusted it to your suggestion which in my mind makes sense.

object oArea = GetArea(OBJECT_SELF);

No longer crashes! Still not getting the spawning. I think it’s identifying the area correctly now when called but running into a wall somewhere else.

Ah ha! It was getting stuck on object oPC = GetPCSpeaker(); It’s working with the following:

#include "sparky_inc"

void main()
{
//object oPC = GetPCSpeaker();
object oArea = GetArea(OBJECT_SELF);
SetLocalString(oArea, "encounter_01", "v2, always, 100, creature, abt_minotaur, 5, wp: arena_blue, 1, 0, 1");
SetLocalString(oArea, "encounter_02", "v2, always, 100, creature, art_hmerc, 5, wp: arena_red, 1, 0, 1");
//int iSparkyPartyLvls = GetFactionAverageLevel(oPC) * (GetNumberPartyMembers(oPC) - 1);
//SetLocalInt(oArea, "iSparkyPartyLvls", iSparkyPartyLvls);
SpawnEncounters(oArea);
}

This also answered another question of mine above that it can indeed spawn seperate encounters at different waypoints. Something I’ve had a hard time getting working with tables or groups for sparkys.

Now… to add a betting system, have the NPC monitor the creatures with art_ abt_ in their tag to determine what team wins (is alive) and announce it. And then clear the remaining winning team creatures so the event can be triggered again. Also pay out to the players that bet on the winning team.

Should be easy right?

Edit: Also… can a script call another script from a list at random? If I created 50 scripts for these arena encounters, could one script be set to pick and run one of them at random? Trying to figure out a good way to make it feel random, and not often would you see the same encounters in the arena.