LarryG on 7/6/2013 at 15:50
Great! So will you include TWFireShadowEcology and TWFireShadowFlee in your next release of TWScripts? I can help debug these ...
qolelis on 7/6/2013 at 22:17
Quote Posted by LarryG
@ qolelis: Please post your Lua scripts when you have them such that you want to share.
I'm pretty busy right now trying to get a small sidemission out this Summer, but if you remind me later, I can share my scripts (if my problem with lgscript and New Dark's FM loader gets sorted you might find them in the mission zip when that gets released if not posted here). It's nothing super-advanced and they aren't exactly generalized, so be warned.
Quote Posted by LarryG
When LGScript was announced I went out an bought a programming with Lua book. Way back when, I was a professional software engineer (Fortran and IBM assembler (BAL) and later on some O-O), all self taught from manuals, but I couldn't figure out how to get LGScript working for Thief from the docs. So I really would appreciate having some working examples to look at.
A big help to me is having all available services and messages referenced at
The Dromesday Book:
(
http://dromed.whoopdedo.org/lgscript/services)
(
http://dromed.whoopdedo.org/lgscript/messages)
LarryG on 7/6/2013 at 22:52
Quote Posted by The Watcher
Looking at his code, (
https://github.com/whoopdedo/publicscripts/blob/master/T2Scripts.cpp#L1259) AttemptSpawn() first checks whether a Firer link exists (1262-1266), if it doesn't the remaining code in that function will try to spawn a new AI and set up a time delayed message ((
https://github.com/whoopdedo/publicscripts/blob/master/T2Scripts.cpp#L1279) 1279) which results in (
https://github.com/whoopdedo/publicscripts/blob/master/T2Scripts.cpp#L1251) MakeFirer() being called (via OnTimer) after 100 milliseconds. (I
guess that the delay there is necessary to ensure that the game has finished creating and setting up the AI before any attempt is made to create a link to it, but I find it a bit puzzling since Teleport can be called on it, surely a link can be added...)
My first-stab guess is that the problem may be down to a race condition: if AttemptSpawn() is called twice, and the second call happens within that 100ms or so window between the first call setting up the timed message and the timed message firing to add the Firer link, the Firer link will not have been created before the second call passes its check for the existence of a Firer link. Basically, if calls to AttemptSpawn() can possibly happen with less that approximately 100ms between calls, the mutual exclusion behaviour provided by the Firer link will not work, so you could potentially get more than two spawns at a time depending on the tweq firing rate.
Without the source for the old T1/TG gen.osm, we probably won't know how LGS did it originally, but the first approach I'd probably try is to see if that Firer link could be added immediately in AttemptSpawn(). If it couldn't, I'd probably try adding in a "bSafeToSpawn" member variable, initialised to true, and then do if(!bSafeToSpawn || bFirer) for the link existence check, immediately set bSafeToSpawn = false after that, and only set it back to true after the Firer link has been established in MakeFirer().
I just remembered that Telliamed posted this, wbw:
Quote Posted by Telliamed
Well, that was annoying. Seems that emitted AI don't get the
Firer link like they're supposed to. Or rather, they do but it disappears in some mysterious way that I can't track because it doesn't fire the listener callback! So I have to resort to manually adding the link.
Might be a clue about why the
Firer link isn't always there?
Edit: A
Thought: what about right after you test for the
Firer link and find none, the first thing you do is add a
Firer link from the TWFireShadowEcology host object to itself. That way if there is a flicker causing another Fireshadow attempt, there will already be a link. Then you create the AI, then the
Firer link from the AI to the host object, and finally delete the
Firer link from the host object to itself.Shouldn't that eliminate any timing issues? Or will creating a link take too many ms, allowing a 2nd spawning? If so, isn't there some way to set/clear a flag in a persistent space and test that instead?
LarryG on 9/6/2013 at 06:37
This is my demo mission for the FireShadowEcology and FireShadowFlee scripts in Public script-t2 (v2.2). [EDIT: updated to remove experimental / debug setup]
1. Press the red button to turn on the Fireshadow emitter.
2. Rather than add a Fireshadow.bin & .cal to the zip, I just used Garrett.bin as a proxy.
3. FireShadowEcology can spawn any type of critter. Just hook up a CD link to the archetype. I used a FireShadow archetype I created based on the one in TG. This was just to document the setup in TG.
4. The FireshadowSpawnPoint archetype is also based on the one in TG. The only difference worth mentioning is that the FireShadowEcology script in TG is hardwired to the Fireshadow archetype, while the one in Public script-t2 uses a CD link to an AI archetype to know what to spawn. This makes it much more useful.
5. A Fireshadow should never be spawned when you are looking at where the emitter is located because of how the Tweq > Flicker state is defined in the concrete spawner. This seems to work OK.
6. The FireShadowFlee script also seems to work OK, except for having the AI remaining hostile after slain. In TG the FireShadowFlee script makes the Fireshadow non-hostile when slain. There is nothing more annoying than having slain the d----d thing and it still attacks you, and at super speed! This needs fixing, or someone needs to teach me how to get the bloody thing to be non-hostile when it is slain. EDIT: I think what the FireShadowFlee script needs to do is to remove all AIAttack, AIAwareness, AITarget, and AIInvest links from the AI when slain. That should make the AI docile when speeded up.
7. In the past I saw the FireShadowEcology script spawn multiple AIs. This may have been my fault in not following the TG setup closely enough. That was over a year ago, and I don't remember anymore. So far, in all my limited testing of the demo mission, the FireShadowEcology script has been behaving itself.
8. Please post any problems you encounter with either FireShadowFlee or FireShadowEcology. And many thanks to Telliamed for these scripts!
[ATTACH]1697[/ATTACH]