The script should overlook the owner...
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-25-2005 07:34
Hi I'm having this problem and its anoying me! Its the last thing i need to do to complete my item and it just work work, but it wont no matter how i script it! Ahr... frustrations... Theres a whole lot of scripting behind this as you probably can see. The first part (wich is not shown) is a particle system (eltee statoskys particle engine 1.0) but thats beside the point. The problem is the IF in the sensor part, i tried to make it overlook the owner, but no matter how hard i try it still... doesnt... work... float force_amount = 1000.0; default { state_entry() { llPreloadSound("explosion_2"); setParticles(); llSetTimerEvent(5); llTriggerSound("explosion_2",1); llSensorRepeat("", NULL_KEY, AGENT, 7, PI*2, .2); } sensor(integer num_detected) { vector pos = llGetPos(); rotation rot = llGetRot(); vector direction = llRot2Up(rot); string owner = llGetOwner(); if ((llDetectedType(0) && AGENT) || ( llDetectedName(0) == owner)) llSetDamage(40.0); llPushObject(llDetectedKey(0), force_amount*llRot2Up(llGetRot()), ZERO_VECTOR, FALSE); llPushObject(llDetectedKey(0), force_amount*llRot2Up(llGetRot()), ZERO_VECTOR, FALSE); llPushObject(llDetectedKey(0), force_amount*llRot2Up(llGetRot()), ZERO_VECTOR, FALSE); } timer() { llDie(); } }
I'd appreciate any help what so ever cause I'm really stuck.
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-25-2005 07:37
You are trying to compare the detected agent's name with the owner's key. Key != name, use llDetectedKey(0) instead  Also, you don't need to check again for type AGENT, the sensor already filters it.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-25-2005 08:00
Right... key id; string owner = llGetOwnerKey(id);
if (llDetectedKey(0) == owner) llSetDamage(40.0); llPushObject(llDetectedKey(0), force_amount*llRot2Up(llGetRot()), ZERO_VECTOR,
FALSE);
this is closer right? Or should I use != ?
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-25-2005 08:07
I guess you're making a bomb of some sort, so definitely use "if (llDetectedKey(0) == llGetOwner())"  You don't want to get A/R'ed, right ?  In your code, you declare a variable called "id", which holds no value. Then you call llGetOwnerKey with this non-value, so you get nothing in return. Then you compare this nothing with the first detected key, which will always be false no matter what. Why ?
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-25-2005 08:30
Simple, im a ScriptIdiot  i do what i can, bi normaly never use owner settings so.... im not really good at it  wich is why im stuck now Dx fiddling with it... wont.. work. And yes, im using it for a ring of protection, and right now its a ring of selfdestruction wich is stupid xD
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-25-2005 08:59
if ((llDetectedKey(0) == llGetOwner())) llSetDamage(40.0); llPushObject(llDetectedKey(0), force_amount*llRot2Up(llGetRot()), ZERO_VECTOR, FALSE);
ok,i still need to do something about the push though right? Cause it doesnt work.... i still get pushed.
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-25-2005 10:09
Well, yes, that's the point actually. This script pushes the closest AV if it's the owner. Also, llSetDamage is only useful for objects that are intended to collide with someone over an unsafe area. It's useless here I think.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
|
10-25-2005 10:13
This is what I understand your code do:
- when someone comes by, the script push her - if it is the owner then in addition the script set itself to 40 damage
Damage only occurs when the object containing the script collides with someone, so it may be pointless in your case since you push the person (toward or out of the object's direction??)
What are you trying to achieve with this script? It may help us.
_____________________
Vincit omnia Chaos From: Flugelhorn McHenry Anyway, ignore me, just listen to the cow
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-25-2005 10:33
i know the damage works, it just have to set damage, tested that. but i have no idea on how to do the push...
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-25-2005 10:37
If you use llSetDamage, then the object just deals the damage and dies with NO further action upon collision.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-25-2005 11:04
I got a mine script that uses a sensor, it deals damage without colliding. Ill take it out for now... but, what should i do about the llPush() ? i can see why the if ahs to be changed, but i dont know what to do with the push (although i can see it is wrong).
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
total LSL newbie but......
10-25-2005 13:33
My understanding of your script is that it will detect any AV's within 7m The first ( = closest?) AV is then pushed. In addition to this if the AV is the owner it will also inflict damage. I would have thought that the code should have been restructured something more like float force_amount = 1000.0; key id; key tgt; string owner;
default { state_entry() { llPreloadSound("explosion_2"); setParticles(); llSetTimerEvent(5); llTriggerSound("explosion_2",1); llSensorRepeat("", NULL_KEY, AGENT, 7, PI*2, .2); id = llGetOwner(); }
sensor(integer num_detected) { vector pos = llGetPos(); rotation rot = llGetRot(); vector direction = force_amount * llRot2Up(rot);
for(i=0;i<num_detected;i++) {
tgt = llDetectedKey(i); if( tgt != id ) { llSetDamage(40.0); llPushObject(tgt, direction , ZERO_VECTOR, FALSE); } } } timer() { llDie(); } }
I'm guessing that the script is attached to a munition launched from a delivery system with a 5 second fuel / burn time and you are using the sensor as a simple proximity fuse. I think the llPushObject automatically degrades the push based on physical distance from the pushing object, but should the damage also be degraded by range (assuming its a concusion wave effect)
|
|
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
|
10-26-2005 02:16
How can an object deals damage if it never collide the target?
_____________________
Vincit omnia Chaos From: Flugelhorn McHenry Anyway, ignore me, just listen to the cow
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-26-2005 02:23
It can't 
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-26-2005 07:18
From: Newgate Ludd My understanding of your script is that it will detect any AV's within 7m The first ( = closest?) AV is then pushed. In addition to this if the AV is the owner it will also inflict damage. I would have thought that the code should have been restructured something more like float force_amount = 1000.0; key id; key tgt; string owner;
default { state_entry() { llPreloadSound("explosion_2"); setParticles(); llSetTimerEvent(5); llTriggerSound("explosion_2",1); llSensorRepeat("", NULL_KEY, AGENT, 7, PI*2, .2); id = llGetOwner(); }
sensor(integer num_detected) { vector pos = llGetPos(); rotation rot = llGetRot(); vector direction = force_amount * llRot2Up(rot);
for(i=0;i<num_detected;i++) {
tgt = llDetectedKey(i); if( tgt != id ) { llSetDamage(40.0); llPushObject(tgt, direction , ZERO_VECTOR, FALSE); } } } timer() { llDie(); } }
I'm guessing that the script is attached to a munition launched from a delivery system with a 5 second fuel / burn time and you are using the sensor as a simple proximity fuse. I think the llPushObject automatically degrades the push based on physical distance from the pushing object, but should the damage also be degraded by range (assuming its a concusion wave effect) It doesnt work, it gives me an error that, i, is not a name thats defined within scope. I tried to work around that, but... as you can hear i have no idea that that i is... The script is supposed to do this: Push ALL AV's except the owner. Thats all  It it really nesecarry to make the script so complicated just to overlook the owner?
|
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
10-26-2005 07:51
No, just use if (llDetectedKey(0) == llGetOwner()) return;
It's making it do what you want it to do that is proving complicated.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-26-2005 12:18
But the problem is how to fix the push comand, i really have a hard time doing that.
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
10-26-2005 12:46
From: Jesrad Seraph No, just use if (llDetectedKey(0) == llGetOwner()) return;
It's making it do what you want it to do that is proving complicated. Whatif there's more than one agent in range? sensor(integer num_detected) { integer i; // VERY IMPORTANT IF YOU WANT TO WRITE A LOOP integer n = -1; // When he's not -1, you found a patsy
// For each detected agent, until you find one that isn't you... for(i = 0; i < num_detected && n == -1; i++) if(llDetectedKey(i) != llGetOwner()) // if it's not you ... n = i; // remember who it is
if(n == -1) return; // No patsies in range, abort mission!
// Now you have a patsy, do the dirty deed to llDetectedFoo(n)... // ... }
Also, I don't think you can llSetDamage() here. See how it's llSetDamage(damage), not llSetDamage(damage, i)? You can only llSetDamage() in a collision event where the target is whatever you hit... Plus, you can't llSetDamage() in a loop, because the object will llDie() the first time it fires.
|
|
Online Doesburg
absurd hero
Join date: 6 Jul 2005
Posts: 53
|
10-26-2005 16:28
From: Eirinn Overdrive But the problem is how to fix the push comand, i really have a hard time doing that. This might be trivial, but are you sure your force_amount variable is large enough, especially considering that the resulting force will be much weaker the farther away the pushed object is from the pushing object?
_____________________
"The evil that is in the world almost always comes of ignorance, and good intentions may do as much harm as malevolence if they lack understanding." - Albert Camus
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
10-27-2005 06:32
From: Argent Stonecutter Whatif there's more than one agent in range? sensor(integer num_detected) { integer i; // VERY IMPORTANT IF YOU WANT TO WRITE A LOOP integer n = -1; // When he's not -1, you found a patsy
// For each detected agent, until you find one that isn't you... for(i = 0; i < num_detected && n == -1; i++) if(llDetectedKey(i) != llGetOwner()) // if it's not you ... n = i; // remember who it is
if(n == -1) return; // No patsies in range, abort mission!
// Now you have a patsy, do the dirty deed to llDetectedFoo(n)... // ... }
Also, I don't think you can llSetDamage() here. See how it's llSetDamage(damage), not llSetDamage(damage, i)? You can only llSetDamage() in a collision event where the target is whatever you hit... Plus, you can't llSetDamage() in a loop, because the object will llDie() the first time it fires. it still pushes me, the push part needs to be redone, any idea how to do that? EDIT!!!!!: it seems like it overlooks me if im the only one present!
|
|
Eirinn Overdrive
Woodland Guide
Join date: 27 Jul 2005
Posts: 19
|
Finished Script
10-27-2005 08:44
Ok i met Argent Stonecutter ingame and he corrected and simplified the whole thing. It now works as it should. Here is the script: float force_amount = 1000.0; default { state_entry() { llPreloadSound("explosion_2"); setParticles(); llSetTimerEvent(5); llTriggerSound("explosion_2",1); llSensorRepeat("", NULL_KEY, AGENT, 7, PI*2, .2); } sensor(integer num_detected) { vector pos = llGetPos(); integer i; // VERY IMPORTANT IF YOU WANT TO WRITE A LOOP // For each detected agent (0 .. num_detected-1)... for(i = 0; i < num_detected; i++) { if(llDetectedKey(i) != llGetOwner()) // if it's not you ... { llPushObject( llDetectedKey(i), force_amount* (<0,0,1> + llVecNorm(llDetectedPos(i) - pos)), ZERO_VECTOR, FALSE); } } } timer() { llDie(); } }
|