![]() |
#include "nw_i0_generic"
location lTarget; object oSpawn; object oTarget; void main() { object oPC = GetLastOpenedBy(); if (!GetIsPC(oPC)) return; int nInt; nInt=GetLocalInt(OBJECT_SELF, "openme"); if (nInt == 0) { oTarget = oPC; lTarget = GetLocation(oTarget); oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "rb_gnollboss_01", lTarget); oTarget = oSpawn; SetIsTemporaryEnemy(oPC, oTarget); AssignCommand(oTarget, ActionAttack(oPC)); AssignCommand(oTarget, DetermineCombatRound(oPC)); SetLocalInt(OBJECT_SELF, "openme", 1); } } This script will spawn the creature, no problem. The problem was, until I added the int openme, it would continuosly spawn the creature when you used the placeable. However, I have a lot of placeables with the same script, and it locks out the other spawns. If I clear the int OnDeath, then a player could, and most probably would, farm one placeable for all it's worth. Adding a DoOnce thing would put me right where I am now, and my placeables must have the same resref for my spawn script. Edit again: As listed this script will spawn a creature beside the PC, which then attacks the PC. It will only fire once, and now works on the other similar objects in the area. The same script will fix the multiple zombies spawning in the catacombs in my module as well. [ 02-08-2007, 12:33 PM: Message edited by: robertthebard ] |
Have you considered a DoOnce thing stored on the container? For example,
SetLocalInt(oPC, "openme", 1); becomes SetLocalInt(OBJECT_SELF, "openme", 1); in which case each container only fires the spawnscript once no matter which PC opens it. Alternatively, change it to something like SetLocalInt(OBJECT_SELF, "openme"+GetName(oPC), 1); which results in each container spawn-in firing only once for every PC (or log-in, or cd key, or race, or ...). Another option is changing the script to work with a variable stored on the container instead of the resref (you'd use something as GetLocalString(oContainer,"SpawnCode") instead of GetResRef(oContainer)). If the problem lies more in that a bashed container is replaced with a new one, thus providing infinite spawns, you might assign players logging into your module a unique number, use that instead of the PC name to identify who already opened the container, and change the OnDeath script to transfer all openme# variables up to the highest one the module has handed out to the new container which is yet to spawn. A bit more work, but so long as it is the death script spawning the new chests it will work to keep track of who opened what. |
:D I changed the check for, and the setting of the variable to OBJECT_SELF, since the script is on each version of the placeable, and tested it that way, and it works great now. The PC won't be able to farm the containers, which is good. When the PC leaves the area, all containers with this script attached will be destroyed, and replaced when another PC enters, so the variable will be back to 0, allowing the scripts to fire again.
|
All times are GMT -4. The time now is 05:13 PM. |
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
©2024 Ironworks Gaming & ©2024 The Great Escape Studios TM - All Rights Reserved