Jump to content

Remenbering Avatar Keys Inside Scripts


TailBlue
 Share

You are about to reply to a thread that has been inactive for 1125 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Ive scripted a small missile system that uses a hud to send a selected avatar key using llRegionSay to a mech. There is a relay script inside the mech that listens and sends the avatar key to the mechs linkset and that in return is picked up by the script that rezzes the small missile. The script that rezzes the missile sends the avatar key to region using llRegionSay. It all works like it should but my issue comes when I fire the missile a second time. The missile rezzing script doesn't remember the avatar key to send it to the region again so the missile can lock on to same avatar or object.

My question is how can I get the missile rezzing script to remember the avatar key every time I click fire from my hud until I issues a reset command which resets the script?

Few things ive considered was inside of my hud sending the avatar key every time i click fire or maybe putting my missile rezzing script on a looping timer. I think the best way to go about this is to either A have the hud send the command and avatar key every time I click fire or somehow have the missile rezzing script itself member the avatar key.

Im using a string to send the commands and the avatar key.

Thank you

Link to comment
Share on other sites

my 2 cents. If I were to code something like this the sequence of events would go as follows:

- the Rezzor script receives a target key from the user (or HUD) and stores it in a global variable(there are various ways of doing this some of which are more user-friendly than others, I'll skip over the details because I think you already have this down.) presumably the rezzor will refuse to rez missiles before this.

-the Rezzor script receives a command to fire a missile. (again, details depend on implementation)

-the Rezzor script opens a listener on a random channel, (and stores the handle of that listener as a global variable) and rezzes the missile with that channel as its rez parameter.

- the missile script opens a listener on the channel it gets from its rez parameter, and sends a message on that channel.

-the Rezzor script receives the message from the missile script, and replies with the key of the target the missile is supposed to fire at. it then removes the listener.

-the Missile script receives the key from the Rezzor and fires itself at the target, deleting itself after impact or after some amount of time (guardin against the case in which the target cannot be found)

  • Like 1
Link to comment
Share on other sites

3 hours ago, TailBlue said:

I think the best way to go about this is to either A have the hud send the command and avatar key every time I click fire or somehow have the missile rezzing script itself member the avatar key

given that you said somehow, then suggest that you go with A: Send the key every time. Is a whole lot simpler

target an avatar - press fire (send command + key). Target them again - press fire. Target another avatar - press fire. And so on

 

when the missiles are not target trackers/followers, then can be simpler again

 the HUD doesn't need to pass the avatar key. It only needs to pass the target avatar's position

llRegionSay(mech_channel, "command:" + (string)llGetPos(target_avatar_key));

on receiving message, the mech can rez the missile and chuck it at the target position

 

Link to comment
Share on other sites

Hmm, that has me wondering if the 32 bits of the rez parameter is enough to encode a local position offset with reasonable precision. . .

EDIT: 10 bits each for X, Y, Z Euler angles could give you slightly better than 1 degree accuracy, if you wanted to use a direction to fire in rather than a position. could be made more accurate if you only allow the missile to fire in a 90 degree cone.

Edited by Quistessa
Link to comment
Share on other sites

10 hours ago, Quistessa said:

Hmm, that has me wondering if the 32 bits of the rez parameter is enough to encode a local position offset with reasonable precision. . .

 a conversation about packing a vector into a integer for this purpose is here

 

Edited by Mollymews
link
  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1125 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...