LarryG on 17/9/2014 at 14:05
I'm looking for a simple way to emit a random choice from several possibles. I know I can set up several emitters, one per possible item, and use an NVRelayTrap to randomly select one of them to fire off, but that seems awfully ... ugly ... is there no simpler way?
R Soul on 17/9/2014 at 15:49
You could try using NVRandomPropertyTrap.
Design note: NVRandomPropertyTrapProperty="cfgtweqemit"; NVRandomPropertyTrapSubProperty="Emit what"; NVRandomPropertyTrapMin=1; NVRandomPropertyTrapMax=7; NVRandomPropertyTrapPrefix="Item"
In the hierarchy, name your archetypes Item1, Item2... Item 7. Then you just need one EmitterTrap.
It looks like the script goes on the same object as the property to be modified, so you will need a custom [scriptname]On parameter too.
LarryG on 17/9/2014 at 16:52
Quote Posted by R Soul
You could try using NVRandomPropertyTrap.
Design note: NVRandomPropertyTrapProperty="cfgtweqemit"; NVRandomPropertyTrapSubProperty="Emit what"; NVRandomPropertyTrapMin=1; NVRandomPropertyTrapMax=7; NVRandomPropertyTrapPrefix="Item"
In the hierarchy, name your archetypes Item1, Item2... Item 7. Then you just need one EmitterTrap.
I'll try that and report back.
Quote Posted by R Soul
It looks like the script goes on the same object as the property to be modified, so you will need a custom [scriptname]On parameter too.
Yeah. It's a trap not a trigger, so there is no way to target another object. You mean something like NVRandomPropertyTrapOn="PickEmit".
I may also try an NVRelayTrap which sends a custom stim to the emitter which randomly varies, and have individual receptrons for setting the property. That may work too if the prop is set before the "TurnOn" gets to the emitter.
john9818a on 17/9/2014 at 19:59
Does it have to be random or can it be sequencial? I know I'm grasping at straws but I recall the red spider could alternate between shooting webs and zaps. I'm not home or else I would post correct references but its worth looking at.
Btw can more than one object name be placed on an emittertrap?
Yandros on 17/9/2014 at 20:40
AI using different spells/ranged attacks is just a matter of multiple AIProjectile links, and doesn't use emitters.
The Watcher on 17/9/2014 at 21:13
Off the top of my head, something vaguely like this'd probably do the job, done as part of a timer handler (the LaunchProjectile 4th and 5th arguments probably need tweaking):
Code:
SService<IPhysSrv> phys_srv(g_pScriptManager);
std::vector<TargetObj> *archetype = get_target_objects("&Weighted", msg);
if(archetype.size()) {
object fired;
phys_srv -> LaunchProjectile(fired, ObjId(), archetype.front().obj_id, 1.0, 10, vel_vec);
}
That'd pick a weighted scriptparam-linked archetype and fire a concrete instance of it.
LarryG on 17/9/2014 at 21:31
Cool. Add it to TWScripts?
The Watcher on 17/9/2014 at 22:19
Sure, may as well. I'm replacing the handling of int/float/time/bool variables and the way they can pull from qvars right now, but once I've done that and added the optional shrink for the fireshadow stuff, I can do a, say, TWTrapEmit or something.
LarryG on 18/9/2014 at 00:22
:thumb:
Thanks. I wait with breath fully bated ...