TTLG|Thief|Bioshock|System Shock|Deus Ex|Mobile
Results 1 to 8 of 8

Thread: Figuring out the flashbomb script

  1. #1
    Member
    Registered: Feb 2016

    Figuring out the flashbomb script

    I'm trying to set up a system where an AI hit with a certain projectile will be stunned as if they've been blinded by a flash bomb. I've tried a few things (NVWatchMe, TrapMotion) but I think the best way would be to use a squirrel script. I want to figure out how the FlashBomb script actually handles the stunning but Telliamed's documentation doesn't go into any detail and all I've been able to figure out using NVSpy is that the AI receives a "Stun" message at the start of being blinded and "Unstun" at the end. Those messages don't do anything on their own though so I need some more information.

  2. #2
    DromEd Archmage
    Registered: Nov 2010
    Location: Returned to the eternal labor
    Hmmm... If I was you, I'll also try to spy the potential metaproperties AIs could get when they are in the area covered by the flashbomb. We know that the area is defined by the "lightbright" stimulus sent by the flash.
    Who knows ? It's hard to guess how some complex scripts are working since they could use hard coded stuff.

    Anyway, try at least to check if there are changes with Metaprop first, then Links. It could be related to the Stun and Unstun messages.

    At worst, since you want your object to stun an enemy, I'm sure you could redo it. Just doing that your projectile is sending a special stimulus and your AIs will have a script in their properties that will react to this projectile by losing their "senses" (setting hearing and vision attributes to Null) for a specific delay, playing an animation with the "Puppet" service that manages animations.

  3. #3
    Member
    Registered: Feb 2016
    I opened up a save with a stunned enemy and it doesn't look like there are any metaproperties or links involved.

  4. #4
    DromEd Archmage
    Registered: Nov 2010
    Location: Returned to the eternal labor
    Ok, and you said that such message do nothing if sent to Ais in any other situation ?
    I fear then that Stun and Unstun should be related to hard coded stuff then.

    The question now is, what allow these messages to work ? Is it the flash or the stim ? I guess you might try to seach this way by removing to the flashbomb it flash first and then it stim and check what messages are send or not.
    You could find out something interesting.

  5. #5
    Member
    Registered: Feb 2016
    I don't think the lightbright stim or renderflash are related to the stun effect. You can put the flashbomb script on a broadhead without any other modification and it will stun AI who are looking when it hits a surface (the reason i can't just do that is I need only the AI who's hit to be blinded.) I think if I can find out what else the script does when it sends Stun I can just replicate that with a script that's activated by a stim.

  6. #6
    Member
    Registered: Jan 2001
    Location: Formby, NW England
    Creating 'world flash' is an engine function which Squirrel can call. I think the AIs' reactions are hardcoded but it doesn't include alertness. I think that's caused by the sound of the flashbomb colliding with the nearby surface.

  7. #7
    Member
    Registered: Apr 2011
    The default flashbomb's flash effect is done by the DrkPowerups.TriggerWorldFlash() function. The rest of the builtin FlashBomb script is just dealing with physics so it knows when it hits something.

    Here's a quick recreation of the FlashBomb script in Squirrel. You should be able to adapt it to suit your projectile, if you need different behaviour than the the FlashBomb script.

    Code:
    class SquirrelFlashBomb extends SqRootScript {
    
        function OnBeginScript() {
            // Ask to be notified when I collide with anything
            Physics.SubscribeMsg(self, ePhysScriptMsgType.kCollisionMsg);
        }
    
        function OnEndScript() {
            // Clean up: make sure I won't be notified anymore.
            Physics.UnsubscribeMsg(self, ePhysScriptMsgType.kCollisionMsg);
        }
    
        function OnPhysCollision() {
            // Trigger a flash from myself. The TriggerWorldFlash() function needs
            // a RenderFlash link from me to the flash archetype, and it will play
            // a sound with my class tags and the "Activate" tag, if there is one.
            // (Note that the default schemas don't have an Activate sound for
            // WeaponType FlashBomb; the sound that gets played when a flashbomb
            // hits something is its Death sound, because see below.)
            DrkPowerups.TriggerWorldFlash(self);
    
            // Tell the physics system to slay me as a result of this collision.
            Reply(ePhysMessageResult.kPM_Slay);
        }
    }
    On the other hand, if you want to replicate the way the flashbomb stuns an AI without the flash, then I'm not sure it's possible with a script. The TriggerWorldFlash() function tells the AI stun controller to take over the AI for a certain time (some calculation based on how directly the AI was looking at the flash) with the "Blinded 0, Stalled 0" motion tags.

    When the stun controller takes over, it basically clears the AI's goals, sends the "Stun" message, loops a motion with those tags, and then when the time is up, sends the "Unstun" message and returns control back to the normal AI behaviours.

    You might be able to use AI.ClearGoals() and set the AI_MotTags property yourself, and use a timer to clear the motion tags again, but I really don't know if that would work properly. You might end up with the AI trying to do its normal behaviours with a stunned animation or something bizarre. You'd have to experiment.


    Edit: this would be a really good new feature to request for NewDark. Stunning _is_ exposed to scripts in SS2, via ShockAI.Stun(), IsStunned(), and UnStun(), just not in thief! But all the AI code for being stunned is the same. It should be straightforward for Le Corbeau to add these same functions to Thief's script interface.
    Last edited by vfig; 25th Aug 2018 at 16:11.

  8. #8
    Member
    Registered: Feb 2016
    Thanks for the info! I'll see if I can make something work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •