Potentially Complicated Script
#1
Posté 10 février 2012 - 10:08
Upon using a placeable, the PC sits down to rest and all enemies (either on the module or in the area, whatever is easier) are respawned exactly where they were when they initially spawned (on module load). On use this also starts a conversation, but I can do that bit of scripting myself. I've spent two days trying to script this to no avail, and I would immensely appreciate any help that could be given. The only tag I can provide is that of the placeable: bonfire. I don't even have all the enemies made yet, but if a tag would make this scripting easier I have one enemy with the tag: SnowedGhoul.
If possible and if it doesn't cause any crashes I would appreciate it if the script was done to respawn all creatures on the module. But like I said, if it's too troublesome it can be done by area.
Again, it would be a HUGE help as I can't really move forward in creating this module unless I have this script working. But to any who may attempt it, take your time and my appreciation will be no less.
#2
Posté 10 février 2012 - 10:23
#3
Posté 10 février 2012 - 10:26
On spawn you'll want to store the creature object on it that you last spawned there, so it can be ported back into place if still present, or remade if not. The new creature object would then be stored. It'd only take about 10 lines of script to do the whole module under that system.
I'm heading out for a bit now, but I'll write something up in a couple hours when I get back if you're curious how that would be scripted.
#4
Posté 10 février 2012 - 11:05
Failed.Bard wrote...
Set up waypoints at each spawn location, all with the same tag, that have the creature ResRef on them that you want to spawn at that point.
On spawn you'll want to store the creature object on it that you last spawned there, so it can be ported back into place if still present, or remade if not. The new creature object would then be stored. It'd only take about 10 lines of script to do the whole module under that system.
I'm heading out for a bit now, but I'll write something up in a couple hours when I get back if you're curious how that would be scripted.
Whether you manually put the creatures into the toolset and create waypoints at their start location or you put waypoints into the toolset and create creatures at that those locations is just a matter of preference.
If you want this to work only in specified areas your respawn script will look something like this:
(Note for the module only approach use the Module for oArea)
void RespawnCreatures(object oArea)
{
object oCreature;
string sResRef;
location lLoc;
int nCount = GetLocalInt(oArea, "RespawnNumber");
string sCount;
while(nCount--)
{
sCount = IntToString(nCount + 1);
oCreature = GetLocalObject(oArea, "RespawnCreature" + sCount);
if(GetIsObjectValid(oCreature)) DestroyObject(oCreature);
sResRef = GetLocalString(oArea, "RespawnResRef" + sCount);
lLoc = GetLocation(GetLocalObject(oArea, "RespawnLocation" + sCount));
oCreature = CreateObject(OBJECT_TYPE_CREATURE, sResRef, lLoc);
SetLocalObject(oArea, "RespawnCreature" + sCount, oCreature);
}
}
Edit: Note that I used a waypoint to trigger lLoc, when I could have also used GetLocalLocation(), this is more for if you like a waypoint method more than a non-waypoint.
Modifié par WhiZard, 10 février 2012 - 11:21 .
#5
Posté 10 février 2012 - 11:29
Failed.Bard wrote...
I'm heading out for a bit now, but I'll write something up in a couple hours when I get back if you're curious how that would be scripted.
That would be awesome if you could, since I've had so much trouble with this script I feel like I've become actually worse at scripting (honestly, didn't think that was possible). But like I said, I've spent two days on this so I can wait as long as it would take you to throw a script together. Take your time, and thanks again for helping me and my crappy scripting abilities.
#6
Posté 10 février 2012 - 11:32
WhiZard wrote...
Failed.Bard wrote...
Set up waypoints at each spawn location, all with the same tag, that have the creature ResRef on them that you want to spawn at that point.
On spawn you'll want to store the creature object on it that you last spawned there, so it can be ported back into place if still present, or remade if not. The new creature object would then be stored. It'd only take about 10 lines of script to do the whole module under that system.
I'm heading out for a bit now, but I'll write something up in a couple hours when I get back if you're curious how that would be scripted.
Whether you manually put the creatures into the toolset and create waypoints at their start location or you put waypoints into the toolset and create creatures at that those locations is just a matter of preference.
If you want this to work only in specified areas your respawn script will look something like this:
(Note for the module only approach use the Module for oArea.
Edit: Note that I used a waypoint to trigger lLoc, when I could have also used GetLocalLocation(), this is more for if you like a waypoint method more than a non-waypoint.
I'll test is out as soon as possible, and if Failed.Bard throws a script together I'll see which one of yours is more convenient for this module. Regardless, I think I can put this script to use for certain miniboss characters to only spawn when a certain area's placeable is used. Thanks for this.
#7
Posté 11 février 2012 - 12:02
Junnest wrote...
I'll test is out as soon as possible, and if Failed.Bard throws a script together I'll see which one of yours is more convenient for this module. Regardless, I think I can put this script to use for certain miniboss characters to only spawn when a certain area's placeable is used. Thanks for this.![]()
The best scripting option is based on what specifically you want to accomplish. My way is based off of servers needing areas to respawn, and not wanting to put in a bunch of waypoints with resrefs stored in the variables, especially if they want to swap creatures. Failed Bard will give you a shorter script but one that is based on placing, naming and inserting resrefs into all locations; a simple copy and paste if all creatures are the same.
#8
Posté 11 février 2012 - 12:34
// Added the object type check so you can execute the script on one of the specific
// waypoints you want to respawn.
// Example use: ExecuteScript ("respawn", GetWaypointByTag ("WP_GOBLIN_CAVES"));
// This script can be used for both initial spawning and respawning.
void main()
{
object oWP, oCreature;
string sTag;
int i;
if (GetObjectType (OBJECT_SELF) == OBJECT_TYPE_WAYPOINT)
{
sTag = GetTag (OBJECT_SELF);
}
else sTag = "WP_GENERIC_SPAWN_TAG_HERE";
while (GetIsObjectValid (oWP = GetObjectByTag (sTag, i++)))
{
oCreature = GetLocalObject (oWP, "CREATURE");
if (GetIsObjectValid (oCreature)) DestroyObject (oCreature);
oCreature = CreateObject (OBJECT_TYPE_CREATURE, GetLocalString (oWP, "RESREF"), GetLocation (oWP));
SetLocalObject (oWP, "CREATURE", oCreature);
}
}
#9
Posté 11 février 2012 - 07:07
As for the scripts themselves, I just have one short/quick question for the each of you if you have the time to answer (and I hope it's just my sleep deprived mind that wants to ask since the answers to these questions should be quite obvious). For your script, WhiZard, would that be placed on the OnUse for the placeable since the locations are already defined by the waypoints? And Failed.Bard, I would need a version of that script per creature, correct? And that script would be placed?... I'm not even going to make an attempt at guessing as to not further embarrass myself. Haha.
#10
Posté 11 février 2012 - 08:29
Junnest wrote...
So it looks like now I just have to see how long it would really take to implement Failed.Bard's script per creature compared to yours, WhiZard, and see how the time consumption weighs with the necessity to have the script work module-wide. I'm about to knock out, so I'll test these both as soon as I wake up tomorrow and I'll get back to you. Thank you both very much.
As for the scripts themselves, I just have one short/quick question for the each of you if you have the time to answer (and I hope it's just my sleep deprived mind that wants to ask since the answers to these questions should be quite obvious). For your script, WhiZard, would that be placed on the OnUse for the placeable since the locations are already defined by the waypoints? And Failed.Bard, I would need a version of that script per creature, correct? And that script would be placed?... I'm not even going to make an attempt at guessing as to not further embarrass myself. Haha.
You'd need a version of the waypoint per creature, not of the script. If you use it just for global spawning and respawning, based on a single spawn waypoint tag, then it would go in the OnModuleLoad and OnPlayerRest scripts.
Just have the module execute the script instead of a waypoint. Eg: ExecuteScript ("respawn", GetModule() );
To make up a spawning point, you'd have to do this:
- Edit - Copy a standard waypoint
- Name it for the creature type in question (Let's say... Goblin Archer)
- Set the tag to the one you're using for all the spawn points
- Set the RESREF string variable on the waypoint (for a goblin archer... nw_goblinb)
Then just place the waypoint where you want to creature to spawn, including the orientation you want. You can add as many as you want, likely you won't have to worry about possible TMI errors unless you get more than a thousand waypoints.
Hope that helps explain it.
#11
Posté 11 février 2012 - 04:36
First I copy/pasted your script into the OnModuleLoad and OnPlayerRest of the module, and just in case threw the "ExecuteScript ("respawn", GetModule() );" in front of each, and renamed the "WP_GENERIC_SPAWN_TAG_HERE" to "WP_CSPAWN". I made and placed a waypoint, named it "Snowed Ghoul (weaponless)" and edited the tag to "WP_CSPAWN". Then for the variable, this is where some confusion came in (if I didn't make a mistake already, I certainly made one here)...
As I mentioned, I am not great with variables so expect some pretty dumb errors here. The first variable I set was "snowedghoul001, string, 0". The test didn't work obviously, so I set it to "snowedghoul001, string, 1", which I doubt would have worked as it didn't. Lastly I threw in "WP_CSPAWN, string, snowedghoul001" but that hadn't worked either.
Sorry to have you coming back and explaining all of this to me, as I'm sure you've provided me more than enough of the information I should need to get this script working. I'm just that bad at them.
#12
Posté 11 février 2012 - 06:01
All I'm trying to accomplish is having the PC sit down to rest, whether it's ForceRest with a sit down animation or the actual rest animation (doesn't matter), and give the PC a full 100% recovery so I am trying to include the spell greater restoration, and accomplish all of this regardless of enemy status (they could even be attacking the PC at the time for all I care). Though the latter portion doesn't matter all that much, I just for some reason can't get a sit-down-and-rest script to compile properly.
#13
Posté 12 février 2012 - 12:57
Junnest wrote...
Ah, okay. Right now it isn't working fully but I am least of all educated in the workings of variables as I've only used the same pattern over and over again to forge quests, so I'm assuming I wrote the variable in wrong on the waypoint. I'll tell you everything I did anyway just in case I made any other mistakes, which is actually pretty likely.
First I copy/pasted your script into the OnModuleLoad and OnPlayerRest of the module, and just in case threw the "ExecuteScript ("respawn", GetModule() );" in front of each, and renamed the "WP_GENERIC_SPAWN_TAG_HERE" to "WP_CSPAWN". I made and placed a waypoint, named it "Snowed Ghoul (weaponless)" and edited the tag to "WP_CSPAWN". Then for the variable, this is where some confusion came in (if I didn't make a mistake already, I certainly made one here)...
As I mentioned, I am not great with variables so expect some pretty dumb errors here. The first variable I set was "snowedghoul001, string, 0". The test didn't work obviously, so I set it to "snowedghoul001, string, 1", which I doubt would have worked as it didn't. Lastly I threw in "WP_CSPAWN, string, snowedghoul001" but that hadn't worked either.
Sorry to have you coming back and explaining all of this to me, as I'm sure you've provided me more than enough of the information I should need to get this script working. I'm just that bad at them.
This is what you'd need to put in for the variable, based on that creature resref you're trying.
RESREF, string, snowedghoul001
It looks like you did the rest of it properly, based on what you posted.
Modifié par Failed.Bard, 12 février 2012 - 12:57 .
#14
Posté 12 février 2012 - 01:02
Junnest wrote...
One thing I wanted to quickly add, as I've just discovered. I've put ten or so scripts in this module and was saving the OnUse placeable script to cause the PC to rest for last since I imagined that would be the easiest to implement. I guess I'm having bad luck because it's turned out far more annoying than I thought based on my scripting abilities, though I feel it really is simple and I'm just bad at this.
All I'm trying to accomplish is having the PC sit down to rest, whether it's ForceRest with a sit down animation or the actual rest animation (doesn't matter), and give the PC a full 100% recovery so I am trying to include the spell greater restoration, and accomplish all of this regardless of enemy status (they could even be attacking the PC at the time for all I care). Though the latter portion doesn't matter all that much, I just for some reason can't get a sit-down-and-rest script to compile properly.
I don't know a way to bypass the default rest check that bioware uses, while still using the rest key. For my mod I ended up adding a rest tool to player tool 1 to get around that, since in my system you only have to be out of sight of an enemy to start resting.
I'm not sure why you'd want to allow a full healing instant rest in combat, but you'd likely have to move it to a seperate tool or feat as well to accomplish it.
#15
Posté 12 février 2012 - 01:40
As for resting: I don't mind using the default rest check, rather it's that I just can't compile a script properly that consists of an placeable triggering the PC to rest OnUse. This is what I have, and the current error I'm receiving is an "invalid declaration type" on the first bracket.
void ActionRest(int bCreatureToEnemyLineOfSightCheck = TRUE);
{
object oPC = GetLastUsedBy();
ActionCastSpellAtObject(SPELL_GREATER_RESTORATION, oPC, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
ActionStartConversation(oPC, "", TRUE, FALSE);
}
#16
Posté 12 février 2012 - 01:41
Modifié par Junnest, 12 février 2012 - 01:42 .
#17
Posté 12 février 2012 - 02:29
void main()
{
object oPC = GetLastOpenedBy();
AssignCommand(oPC,ClearAllActions());
AssignCommand(oPC,ActionRest(TRUE));
}
#18
Posté 12 février 2012 - 02:34
I mine as well keep this topic around in case I run into any more issues, but I think that's all the scripting I should need help with for the remainder of this module. A big thanks to all three of your for all your assistance, I sincerely appreciate you taking time out of your day to help me.





Retour en haut






