Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Set damage script

Dalek Thor
Registered User
Join date: 12 Jul 2008
Posts: 1
07-14-2008 09:38
Hey people,

I'm creating a simple combat system but do not want it to affect the owner..

I used the basic script from the wiki and adapted a few of my own code.

For the life of me i cant see why im getting syntax errors...

Anyway, heres the code :-)

//Simple autokiller bullet:
//When it rezzed it scans for the closest person,
//Moves to their location and kills them. (Because
//It collides with them)
default {

state_entry()
{
llSetAlpha(0,ALL_SIDES);
}
on_rez(integer i)
{
if(AGENT == llGetOwner())
{
llSetDamage(0);
}
}
else
{
llSetTimerEvent(10.0);
llSetDamage(100);
llSensor("", "", AGENT, PI, 1.0);
}
timer()
{
llDie();
}
sensor(integer num) {
for(num = 100;--num; )
llSetPos(llDetectedPos(0));
}
}
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
07-14-2008 09:47
I think your problem is here:

sensor(integer num) {
for(num = 100;--num; )
llSetPos(llDetectedPos(0));
}


First, the sensor only returns the first 16 objects/AVs it detected... Thus 100 is too big anyway...

Guess your loop needs to look like this:

while(num > 0){
num--;
llSetPos(llDetectedPos(num));
}
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
07-14-2008 11:16
llSetDamage can only be set in state_entry() and only once