Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need Help with this exploding script.....

Shayna Korobase
Registered User
Join date: 8 May 2007
Posts: 454
12-24-2008 10:39
I have a script here that causes things to explode. What I need it to do is NOT ask me perms and also to explode when I shoot it with bullets. If anyone can help me it would be most appreciated. Thanks.




integer CHANNEL = 7;
string COMMAND = "collapse";
integer OWNER_ONLY = TRUE;

// Exploding Objects script, by Dale Innis
// Do with this what you will, no rights reserved
// See https://wiki.secondlife.com/wiki/ExplodingObjects for instructions and notes

integer lh = 0;

init() {
llListenRemove(lh);
key who = NULL_KEY;
if (OWNER_ONLY) who = llGetOwner();
lh = llListen(CHANNEL,"",who,COMMAND);
llOwnerSay("To cause collapse, say '"+COMMAND+"' on channel "+(string)CHANNEL);
llRequestPermissions(llGetOwner(),PERMISSION_CHANGE_LINKS);
}

default {
// usual faffing about
state_entry() {
init();
}
on_rez(integer x) {
llResetScript();
}
changed(integer change) {
if (change & CHANGED_OWNER) llResetScript();
}
// the part that actually does something interesting
listen(integer c,string name,key id,string msg) {
llSetStatus(STATUS_PHYSICS,TRUE);
llSetPrimitiveParams([PRIM_TEMP_ON_REZ,TRUE]);
llBreakAllLinks();
}
// faffing about with permissions
run_time_permissions(integer perms) {
if (!(perms & PERMISSION_CHANGE_LINKS)) {
llOwnerSay("Well, the collapsing stuff isn't going to work, then!";);
}
}
}
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
12-24-2008 11:21
There are two ways around this.
This first to to remove the llResetScript from the on_rez event. That way it will only ask you the first time you create the object and will not ask anymore for the copies you make.

The second is to put the parts into one of the prims and put a die script into the parts. You then have the prim rez the exploding parts. Not the same effect as the first solution but may be used if the object is small and not noticeable.
Below is a copy of the break script that I found in a target dummy that might be useful to you.

CODE

float health = 100;
// Particle Script 0.3
// Created by Ama Omega
// 10-10-2003

// Mask Flags - set to TRUE to enable
integer glow = FALSE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = TRUE; // Particles effected by wind
integer followSource = FALSE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_EXPLODE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "";

// Particle paramaters
float age = 1; // Life of each particle
float maxSpeed = 10; // Max speed each particle is spit out at
float minSpeed = 2; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 1; // Start alpha (transparency) value
float endAlpha = 1; // End alpha (transparency) value
vector startColor = <.5,0,0>; // Start color of particles <R,G,B>
vector endColor = <.3,0,0>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <4,4,4>; // Start size of particles
vector endSize = <.035,.035,.035>; // End size of particles (if interpSize == TRUE)
vector push = <0.0,0.0,-5>; // Force pushed on particles

// System paramaters
float rate = .1; // How fast (rate) to emit particles
float radius = .5; // Radius to emit particles for BURST pattern
integer count = 30; // How many particles to emit per BURST
float outerAngle = 7.0; // Outer angle for all ANGLE patterns
float innerAngle = 2.5; // Inner angle for all ANGLE patterns
vector omega = <14,14,14>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles

// Script variables
integer flags;

updateParticles()
{
flags = 0;
if (target == "owner") target = llGetOwner();
if (target == "self") target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}
default
{
state_entry()
{
llParticleSystem([]);
llSetTimerEvent(1);
llSetStatus(STATUS_DIE_AT_EDGE,TRUE);
}
timer()
{
llSetText((string)((integer)health) + " Health",<1,1,1>,1);
}
collision_start(integer times)
{
age = .5;
life = .2;
startSize = <.1,.1,.1>;
updateParticles();
integer randSound = (integer)llFrand(2.99);
if(randSound == 0)
{
llTriggerSound("righthand", 1);
}
if(randSound == 1)
{
llTriggerSound("lefthand", 1);
}
if(randSound == 2)
{
llTriggerSound("kick", 1);
}
float damage = llVecMag(llDetectedVel(0))+llVecMag(llGetVel());
health = health - damage;
if(health<=0)
{
age = 1;
life = 5;
startSize = <4,4,4>;
llTriggerSound("swordhit", 1);
updateParticles();
llSetAlpha(1,ALL_SIDES);
llRezObject("Bone Chip",llGetPos() + <.5,-.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Tendon strips",llGetPos() + <-.5,.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Heart",llGetPos() + <-.5,-.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Liver, Kidney",llGetPos() + <0,-.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Unrecognizable flesh",llGetPos() + <-.5,-.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Stomach",llGetPos() + <-.5,0,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone",llGetPos() + <.5,-.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Large Intestines",llGetPos() + <.5,0,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone",llGetPos() + <-.5,0,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Unrecognizable flesh",llGetPos() + <.5,.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Tendon strips",llGetPos() + <.5,.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone",llGetPos() + <0,0,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone Chip",llGetPos() + <.5,0,0>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone Chip",llGetPos() + <.5,0,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llDie();
}
}
land_collision_start(vector where)
{
age = .5;
life = .2;
startSize = <.1,.1,.1>;
updateParticles();
integer randSound = (integer)llFrand(2.99);
if(randSound == 0)
{
llTriggerSound("righthand", 1);
}
if(randSound == 1)
{
llTriggerSound("lefthand", 1);
}
if(randSound == 2)
{
llTriggerSound("kick", 1);
}
float damage = llVecMag(llGetVel());
health = health - damage;
if(health<=0)
{
age = 1;
life = 5;
startSize = <4,4,4>;
llTriggerSound("swordhit", 1);
updateParticles();
llSetAlpha(1,ALL_SIDES);
llRezObject("Bone Chip",llGetPos() + <.5,-.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Tendon strips",llGetPos() + <-.5,.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Heart",llGetPos() + <-.5,-.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Liver, Kidney",llGetPos() + <0,-.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Unrecognizable flesh",llGetPos() + <-.5,-.5,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Stomach",llGetPos() + <-.5,0,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone",llGetPos() + <.5,-.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Large Intestines",llGetPos() + <.5,0,-.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone",llGetPos() + <-.5,0,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Unrecognizable flesh",llGetPos() + <.5,.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Tendon strips",llGetPos() + <.5,.5,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone",llGetPos() + <0,0,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone Chip",llGetPos() + <.5,0,0>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llRezObject("Bone Chip",llGetPos() + <.5,0,.5>,<llFrand(6) - 3,llFrand(6) - 3,5>,<0,0,0,0>,1);
llDie();
}
}
}
Shayna Korobase
Registered User
Join date: 8 May 2007
Posts: 454
12-24-2008 23:32
Thatwas perfect for what I needed thank you :-)