Shield Spawn
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-17-2005 19:39
Does anyone have the script for the shields which rez an object when someone comes too fast at you? Such as the ones which res circular curved objects 'around' the user on the side that the person is coming at them at.
=D (If that made sense =P) Any help is appreciated =D.
Thanks
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-17-2005 22:13
I know someone knows =P. ^.^ Sensors, velocity, distance.. =D LoL
|
|
Ghordon Farina
Script Poet
Join date: 1 Nov 2005
Posts: 126
|
12-17-2005 22:26
I don't have a script offhand, but that would be a fun thing to attempt.
It's not super high on my list, but I'd like to see someone do it.
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-18-2005 16:27
O.o I tried, I failed. LoL I got up to llRezObject and could REZ the object, but not int he direction the person was coming, and only if they came withen 3 meters of me at ANY speed, because it was under a sensor
|
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
12-18-2005 16:32
I'm not familiar with shields at all...and don't even do attachments...but...
...what about llLookAt?
...yes, you will have to use a sensor...no way around that...
_____________________
--AeonVox--Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-18-2005 17:10
True, I will need to, but I can't get it so if they come fast, it makes the shield. mErr, llLookAt, I tried that before for something else, and I remember it didn't work out well. LoL Does anyone happen to have an example script of llLookAt, or once again, a shield like this? =P
|
|
SpankMe Pinkerton
Registered User
Join date: 13 Feb 2005
Posts: 158
|
12-18-2005 18:29
This is quite doable. You will first need a sensor repeat of course (please remember these can add substantial server script load if you are not careful with them). Next, you can determine the absolute velocity of the person/object using llVecMag(llDetectedVel(i)). The simplest thing would be to rez a bubble right around you. If you want it to rez between you and the object, you will have to do a little math using your position and the detected objects position. If the detected object is in a different sim, this gets a bit harder.
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-18-2005 22:30
Thanks =D How exactly would I use llLookAt? Didn't work when I tried =(  If it's possible, can you post a script using it? =D (Psst! Or even make the shield! Hint Hint lol  )
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-19-2005 05:48
Basically, this sort of thing is much like a turret, except instead of rezzing a physical bullet in the direction of the target, it's rezzing a non-physical shield. I have some turret scripts, I might give this a go later when I get home.
Note that when you're calculating the speed you can't just use llVecMag(llDetectedVel(f)) > speedLimit - you have to work out its speed in your direction, which involves taking the dot product of its relative velocity to you (remember you might be moving too) and the vector of the path between the two of you. I did this for a text radar on Saturday so I've got the code around.
If you're actually thinking of using this in practice for personal protection, it won't work completely; there are phantom bullets that get through these things. I don't know how they work but I can take a guess. And a slow invisible bullet could creep up on you as well.
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-19-2005 09:21
Would be great if you could post that script =D
Mainly want to build it because it would look really cool to use =P. Protection would be good, although not perfect, but I"m fine with that, as I don't ever hang out in Battle Sims. Would be awesome if someone could get the line code for the llRez so it's in the directino they're coming from, and the llVecMag part =P
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-19-2005 14:17
I'm having a bit of trouble making one that's fast enough. With a flat directional shield or a globe I can stop things moving at 30 m/s, which is the default for the Linden revolver script... but 100m/s, neither is rezzed quickly enough to stop a bullet fired from 20-30m, even scanning every 0.05s (which is rather antisocial in a busy sim). Here's the script so far: float gSpeedLimit = 20.0;
default { state_entry() { llSay(0, "Scanning..."); llSensorRepeat("", NULL_KEY, 14, 96.0, 2*PI, 0.05); }
sensor(integer n) { integer no_shield = TRUE; integer f; vector myPos = llGetPos(); vector myVel = llGetVel(); for (f=0; ((f<n) && no_shield); f++) { vector a = llDetectedVel(f) - myVel; vector b = myPos - llDetectedPos(f); float magB = llVecMag(b); if (magB == 0) magB = 1; // avoid division by zero errors float towardsSpeed = ((a.x * b.x) + (a.y * b.y) + (a.z * b.z)) / magB; if (towardsSpeed > gSpeedLimit) { // directional shield start vector towards = llVecNorm(llDetectedPos(f) - myPos); vector left = <-towards.y, towards.x, 0>; vector top = <-(towards.z * towards.x), -(towards.z * towards.y), (towards.x * towards.x + towards.y * towards.y)>; rotation rot = llAxes2Rot(towards, left, top); llRezObject("shield", myPos + towards * 2, <0,0,0>, rot, 3); // directional shield end // globe shield start // llRezObject("globe", myPos, <0,0,0>, ZERO_ROTATION, 3); // globe shield end llPlaySound("2d429055-68ec-f3f4-d123-e2eb05198de0", 1.0); llOwnerSay(llDetectedName(f) + " incoming at " + (string)llRound(towardsSpeed) + " - countermeasures activated"); no_shield = FALSE; } } if (!no_shield) llSleep(3.0); }
collision_start(integer n) { llOwnerSay("Hit by " + llDetectedName(0)); } }
Probably some vector geometry and efficiency issues there - first draft.... Oh, the "shield" object is a block with 2x2m Y and Z size, and 0.5m X size. The script points the forward X axis towards the object.
|
|
Prometheus Deckard
Registered User
Join date: 24 May 2005
Posts: 23
|
12-19-2005 22:06
Worked like a charm =D. If anyone makes it better. Post, post, post, and mroe post! =P
Thanks for the script =D
|
|
Gangster Borkotron
Registered User
Join date: 7 Sep 2008
Posts: 2
|
Error
10-22-2008 20:36
am getting a error on it dont know why everything look rite
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-22-2008 21:50
From: Prometheus Deckard How exactly would I use llLookAt? Didn't work when I tried =( BTW, you aren't going to want to use llLookAt() for something like this. You'll want to rez the shield so that it is in place immediately. Waiting for a llLookAt() to take effect, and waiting for a script in the rezzed object to initialize and be able to take action, is probably going to take more time than you want. It's worth a little computation time in the rezzing script, as was done in the script above. With Mono you can probably do PLENTY of math without it affecting this noticeably in any case.
|