Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

target specific

carlos Sachertorte
Registered User
Join date: 14 Sep 2005
Posts: 5
08-02-2006 08:23
Im needng a script that on my command will kill who it has been told to kill eg. /2kill carlos

I know sl's limitations in llSetDamage (i need an object to hit the Avatar) so i tried llSetposition(i) where I is the target av but it didnt work, any suggestions?
Cherokee Darling
Registered User
Join date: 14 Jun 2006
Posts: 8
/target kill>
08-02-2006 08:45
I would dearly love to have a script like that :D Hope someone comes up with it.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-02-2006 10:18
It needs to be physical movement to fire the collision to fire the llSetDamage I think. llMoveToTarget maybe?
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
carlos Sachertorte
Registered User
Join date: 14 Sep 2005
Posts: 5
could try that
08-02-2006 10:27
That might work:D but i dont want the bot that i am using to move to the target, so i would need a prim to rez either at the target or to go to the target, both of which i dont know how to do

Any more suggestions?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-02-2006 11:52
Response to the voice command should be to set the target's name and execute an 'llSensor()'. Unless you want the user to have to use the exact case-sensitive name you must use an empty name ("";) on the sensor and do the filtering logic yourself. Note that if you DO filter the sensor by name, the logic would likely be simpler because you can eliminate use of (some?) global variables (and the sensor itself might have a better chance of finding the target; there is a limit to the number of targets a sensor can return, but I'm not sure if that is enforced before or after the filter).

The sensor event should rez an object with 'llRezObject()' as close to the target as possible. The rezzed object can either be rezzed with a good velocity and be a dumb projectile, or can be told the key of the target by means of a chat from the parent and then do targetting of its own (with its own sensor).
carlos Sachertorte
Registered User
Join date: 14 Sep 2005
Posts: 5
Help?
08-02-2006 12:17
ok im not understanding this at all, i have no idea how to script it, could sombody help me script it and they could sell it themselves please
carlos Sachertorte
Registered User
Join date: 14 Sep 2005
Posts: 5
08-02-2006 12:32
If i put in a script for a sensor to run for the av, then once it finds the av, the bot looks at its target and fires.

Would that work? If it needs any improvment please add
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-02-2006 14:45
Try something like this. I haven't compiled it, so it could need some fixes. Just consider it pseudo-code:
CODE
integer CHANNEL = 15;  // or whatever

string KILL_CMD = "kill ";

float KILL_RANGE = 96.0;
float KILL_ARC = PI;

string REZ_OBJECT_NAME = "bullet";
float REZ_SPEED = 200.0;
float OPTIMAL_DIST_FROM_TARGET = 0.5; // Rez no closer than this.
float MAX_REZ_DIST = 9.6; // Don't want it to fail at 10.0 due to rounding.

string gPartialName;

...

informTargetNotFound()
{
llOwnerSay("Couldn't find target with partial name '" + gPartialName +
"' within range.");
}

...

on_rez(integer startParam)
{
llListen(CHANNEL, "", llGetOwner(), "");
}

listen(integer channel, string name, key id, string message)
{
if (llSubStringIndex(message, KILL_CMD) != 0)
{
return;
}

gPartialName = llGetSubString(message, llStringLength(KILL_CMD), -1);
if (gPartialName == "")
{
llOwnerSay("Use: /" + (integer)CHANNEL + " " + KILL_CMD + "<name>");
return;
}

// May want to keep case for smarter filtering...eh.
gPartialName = llToLower(gPartialName);

llSensor("", NULL_KEY, AGENT, KILL_RANGE, KILL_ARC);
}

no_sensor()
{
informTargetNotFound();
}

sensor(integer numDetected)
{
integer index;
integer foundTarget = FALSE;
for (index = 0; !foundTarget && index < numDetected; ++index)
{
// Again, smarter filtering?

string detectedName = llToLower(llDetectedName(index));
if (llSubStringIndex(detectedName, gPartialName) == 0)
{
foundTarget = TRUE;
}
}
--index; // Correct for last increment since I don't want to use a jump.

if (!foundTarget)
{
informTargetNotFound();
return;
}

// Ready to fire. I'll leave it up to you to enhance the dumb logic.

vector myPos = llGetPos();
vector targetPos = llDetectedPos(index);
vector relativePos = targetPos - myPos;
vector direction = llVecNorm(relativepos);
float targetDist = llVecMag(relativePos);
float optimalDist = targetDist - OPTIMAL_DIST_FROM_TARGET;

vector rezPos;
if (optimalDist < 0)
{
// Too close. Just use a point half-way between.
rezPos = (myPos + targetPos) / 2.0;
} else if (optimalDist <= MAX_REZ_DIST)
{
rezPos = myPos + optimalDist * direction;
} else
{
rezPos = myPos + MAX_REZ_DIST * direction;
}

vector bulletX = direction;
vector bulletY = llVecNorm(<0, 0, 1.0> % bulletX);
vector bulletZ = bulletX % bulletY;

llRezObject(
REZ_OBJECT_NAME,
rezPos,
REZ_SPEED * direction,
llAxesToRot(bulletX, bulletY, bulletZ,
0);
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-02-2006 14:51
Oh. This doesn't cover the, "bot looks at the target," part. For that, you'll have to have the sensor start a rotation and possibly wait for the rotation to complete before firing the shot. See:

You may also have to augment with more sensor calls and more complicated sensor logic if it takes a while to turn and you want to both fire AFTER the turn and compensate for the time it takes.
carlos Sachertorte
Registered User
Join date: 14 Sep 2005
Posts: 5
08-08-2006 15:15
:confused: ok im seriously crap at scripting and fixing scripts :(
Could sombody write up a completed and checked script for me, they can sell and ill pay them when i get some spare l$