GetIsDay Question
![Zephirius](https://forums.beamdog.com/uploads/userpics/KEYH4THWCWVZ/n6VV98LH2SN2M.gif)
Trying to spawn a critter when entering an area, only if it is day time. I'm not seeing my spawn. When entering the game the clock is automatically set to 13:00 hours - daytime. Still no spawn.
Looked on the lexicon but didn't see anything informative...
Thanks for any help.
Looked on the lexicon but didn't see anything informative...
Thanks for any help.
void main() { object oPC = GetEnteringObject(); if (GetIsPC(oPC)) return; location lLoc = GetLocation(GetWaypointByTag("ZUG_ZUG_LOC")); if (GetIsDay()) { CreateObject(OBJECT_TYPE_CREATURE, "bullywug004", lLoc); } }
Post edited by Zephirius on
0
Comments
NESS is one I have used for quite sometime:
https://neverwintervault.org/project/nwn1/script/neshkes-extendable-spawning-system-ness-v813
You are returning when it is the PC that is detected. Removing the 'return;' and instead adding a '{}' pair gives -
which, assuming everything else is correct, should work.
TR
The simplest fix is to set a flag (local int) on the area when the creature spawns. If that's set, don't spawn another one.
A more robust fix (which only needs coding once per module) is
Triggers can also check the "loading saved game" flag, leaving it to the area to clear it (triggers fire first).
Occasionally, there may be OnEnter actions that are required for both loads and normal entry - for example, scripted tweaks to sound / lighting. Do those before checking the flag, obviously.
This is for SP - multiplayer might need a more sophisticated solution.
Yep, I missed the !
The actors:
Character 1. Strong Zug-Zug - impossible for a 1st level character to topple
Character 2. Weak & Poisoned Zug-Zug
Intententions for my really bad scripting...
Only Spawn Strong Zug-Zug at night. If Strong Zug-Zug is poisoned only spawn weak Zug-Zug during day time. That's it.
As it stands, the behavior of my code results in Strong Zug-Zug spawning during the day except when poisoned. What doesn't happen is weak Zug-Zug spawning in after Strong Zug-Zug is poisoned...
Good Morning to all...
Try this in order to match your description -
One little thing. In C based languages like NwScript 1 == TRUE when used in an if() statement so there is no need to check for a local int being equal to one in that circumstance.
TR
Anyhow, thanks for the awsome help TarotRedhand and Proleric for the pointers...
I'm gonna try to iron this script out. I think by now, ya'll know that is a dicey proposistion!
Code I'm using right now...
Okee dokee. I throw in the proverbial towel! I'm tapping the mat! I'm crying uncle. I'm just crying...
P.S. I used Lilac Soul's script generator for most of the script...
SetLocalInt(oPC, "weak_zugzug", 1);
Then to call it - else if ( GetIsDay() && GetLocalInt(oPC, "weak_zugzug"))
Don't know if that's correct?
And let me know if the re-ordering of your code works.
TR
Yeah, I tried the code, but got the same result. No spawn of the weak version. Also, I'm waiting until 9 am before I even attempt to enter the cave - just to be sure it was day time. Wasn't exactly sure when day began. Although I would imagine arround 6 or 7.
I've also triple checked the ResRefs and tags...
Look in the module properties under the Advanced tab. It is defined in there.
Experimenting in toolset (I have an idea). I may be sometime...
TR
BTW, is it your intention that the PC only gets one chance to kill Zug Zug? That they can only enter the cave, with a chance of killing Zug Zug, once even if they do so at night? If not I can create a work around that let's the PC enter more than once.
TR
Yeah. I was trying for multiple chances.
From the actions taken tab -
Now onto the problem with the above code. You are assuming that the very first item in the PCs inventory is going to be the poison. This is not necessarily the case. Try the following version of your code with a little bit of editing.
TR
Tried to no avail. I'll tear apart every script in the mod. Thankfully I'm just starting this one and the number of scripts is small. Even smaller yet would be the number of scripts germaine to the intended outcome.
Thanks again TarotRedhand.
I'll check back soon...
I had a qestion about the revised script above. When you use "while" are you creating a "loop", and that's why there is a "break" at the end? If not does it fry your game in an endless loop...
The reason I ask is, when I've tried to use "while" before I always crash my game with code. I'm assuming it was because I didn't and don't know, how and when to "tie the knot" of the loop...?
I don't know if that makes a bit of sense...?
I explain all about loops (and other things) in the tutorial I wrote - "TR's Basics - Decisions". It's a 36 page pdf booklet that is extensively illustrated (eg loads of piccies). Give it a try. If you do get it, I highly recomend you use a dedicated pdf reading program as I went to the trouble of including bookmarks to make finding what you want easier.
TR
I looked at all of my scripts (all said and done about 20) and couldn't find anything that would cause any mayhem with the spawn that I could discern...
Gonna pass a little time and start making my 2x2 mod in lesson #1 of your tutorial...
Hope this helps.
TR
Would the fact that this script is being triggered as an area OnEnter script and not just a generic trigger have anything to do with weak ZUg-Zug not spawning? I wouldn't think so...?