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

Thread: Finding the location of a stim source

  1. #1
    Registered: Apr 2011

    Finding the location of a stim source

    in my fm i wanted to spawn a particle effect when receiving a stim, and configure it so that the particles run between the object that had the stim source and the one receiving it. the particle effect handling is straightforward; the problem is that a stim sent to scripts does not seem to have any way of identifying which object the stim originated from.

    when receiving a [StimName]Stimulus message, the message “from” parameter is zero, since the message is sent by the act/react system, not the originating object. the message’s “source” parameter is a link id, being the link to the stim archetype. Edit: the rest of this paragraph is complete nonsense: however, in the common case where the stim source is attached to an archetype or metaprop, this link is from that archetype or metaprop, and not from the concrete object actually producing the stim. am i missing something obvious?

    Edit: no, the link is from the concrete object. past me is a drongo

    i have a workaround for now that suffices, but its a bit messy and would not suit any stim that would result in damage. what i do is, the receptron is set to Poke Object, with the target set to the stim source and the agent set to “Me”, and “use stim” enabled. this results in the object producing the stim receiving a Damage message, with intensity zero and the stim archetype as the damage source, and the concrete object with the receptron as the culprit. so i can handle that in script, and so obtain the postions of both objects for my particle effects. but is there a cleaner way to so this?
    Last edited by vfig; 26th Nov 2023 at 14:34.

  2. #2
    Registered: Jan 2001
    Location: 27430 Cells
    Would you mind uploading a demo mision/cow to show your setup?
    I just tried it with a mine exploding underneath a table, and a simple script was able to report the location of the concrete object (though in this case the object doesn't exist for very long, and the mine expolosion produces two firestims).

    (edit updated to set a timer and use object data to prevent the same collision causing more than one response (e.g. from a collision object and radius object))
    class GetStimObjLocation extends SqRootScript
    	function OnMessage()
    		local messageCheck = message().message;
    			local linkID = message().source;
    			local stimLink = sLink(linkID);
    			local from = stimLink.From(); //concrete object
    			local locVect = Object.Position(from);
    	function CreateNewObject(objLocation)
    		if(!IsDataSet("StimObjectCreated")) //One shot limit
    			local newObject = Object.Create("Purse");
    			Object.Teleport(newObject, objLocation, vector());
    			SetData("StimObjectCreated", 1);
    			SetOneShotTimer("ClearStimObjectTimer", 0.5);
    	function OnTimer()
    		if (message().name == "ClearStimObjectTimer")
    Last edited by R Soul; 26th Nov 2023 at 11:18.

  3. #3
    Registered: Apr 2011
    i am blind, arent i? i wrote that up after wrestling with this problem for a whole afternoon. but you are right—i was quite wrong in my conclusion. the link does indeed come from the concrete object with the stimulus on it. i have no idea now what the code was i had that had led me down the garden path. i mustve had the wrong link or something. who knows what?

    well that is good news. the universe makes a little more sense again. i can delete a hacky workaround. this makes me happy! thanks for looking into it.

Posting Permissions

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