Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer HEALTH = 200;
- // Set this to the total health. The maximum point-
- // blank cannon shot will deal 30 damage which will be
- // deduced from the total health.
- //integer statusChan1 = -51069;
- integer wallOne;
- //integer chanOne = -135790;
- integer tChan = -135790;
- //integer chanOneTalk = -456987;
- vector scale;
- integer flipSwitch = FALSE;
- float delay = 0.2;
- float age; // Life of each particle
- float maxSpeed; // Max speed each particle is spit out at
- float minSpeed; // Min speed each particle is spit out at
- string texture; // Texture used for particles, default used if blank
- float startAlpha; // Start alpha (transparency) value
- float endAlpha; // End alpha (transparency) value
- vector startColor; // Start color of particles <R,G,B>
- vector endColor; // End color of particles <R,G,B> (if interpColor == TRUE)
- vector startSize; // Start size of particles
- vector endSize; // End size of particles (if interpSize == TRUE)
- vector push; // Force pushed on particles
- // System paramaters
- float rate; // How fast (rate) to emit particles
- float radius; // Radius to emit particles for BURST pattern
- integer count; // How many particles to emit per BURST
- float outerAngle; // Outer angle for all ANGLE patterns
- float innerAngle; // Inner angle for all ANGLE patterns
- vector omega; // Rotation of ANGLE patterns around the source
- float life; // Life in seconds for the system to make particles
- // MASK FLAGS: set to "TRUE" to enable
- integer glow;
- integer bounce; // Make particles bounce on Z plane of objects
- integer interpColor; // Color - from start value to end value
- integer interpSize; // Size - from start value to end value
- integer wind; // Particles effected by wind
- integer followSource; // Particles follow the source
- integer followVel; // 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;
- integer flags;
- // 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;
- // --->> first is a user defined function to create the particle display.
- StartSmoke()
- {
- scale = llGetScale();
- age = 15;
- maxSpeed = 0.01;
- minSpeed = 0.0;
- texture = "";
- startAlpha = 1.0;
- endAlpha = 0.0;
- startColor = <1.0,1.0,1.0>;
- endColor = <0,0,0>;
- startSize = scale/2;
- endSize = scale;
- push = <0.0,0.0,0.9>;
- rate = 0.05;
- radius = scale.x/2;
- count = 6;
- outerAngle = 1.0; // 0.1;
- innerAngle = 1.0; //0.65;
- omega = <0,0,100.0>;
- life = 0;
- //---->>>> This first part is where you make choices in how your particles will appear.
- // MASK FLAGS: set to "TRUE" to enable
- glow = TRUE;
- bounce = TRUE;
- interpColor = TRUE;
- interpSize = TRUE;
- wind = TRUE;
- followSource = FALSE;
- followVel = TRUE;
- // 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
- 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;
- //--->> This is the part where your choices are assembled into machine readable code.
- //--->> You don't have to change anything from here down.
- 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
- ]);
- }
- StartFire()
- {
- scale = llGetScale();
- age = 1.0;
- maxSpeed = 0.01;
- minSpeed = 3.0;
- texture = "";
- startAlpha = 0.8;
- endAlpha = 0.0;
- startColor = <1.0,1.0,0.0>;
- endColor = <1,0,0>;
- startSize = scale/2;
- endSize = scale;
- push = <0.0,0.0,15>;
- rate = 0.01;
- radius = scale.x/2;
- count = 2;
- outerAngle = 0.1;
- innerAngle = 180;//2;
- omega = <0,0,0>;
- life = 0;
- //---->>>> This first part is where you make choices in how your particles will appear.
- // MASK FLAGS: set to "TRUE" to enable
- glow = TRUE;
- bounce = TRUE;
- interpColor = TRUE;
- interpSize = TRUE;
- wind = TRUE;
- followSource = FALSE;
- followVel = TRUE;
- // 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
- 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;
- //--->> This is the part where your choices are assembled into machine readable code.
- //--->> You don't have to change anything from here down.
- 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
- ]);
- }
- //////////////////////////////////////////////////////////
- // INTERNALS //
- //////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////
- // Wizardry and Steamworks (c) 2013, GPLv3 //
- //////////////////////////////////////////////////////////
- string progress(integer percent, integer length, list symbols) {
- percent /= (integer)((float)100.0/(length));
- string p = llList2String(symbols,0);
- integer itra = 0;
- do {
- if(itra>percent-1) p += llList2String(symbols,2);
- else p += llList2String(symbols,1);
- } while(++itra<length);
- return p + llList2String(symbols,3);
- }
- //////////////////////////////////////////////////////////
- // Wizardry and Steamworks (c) 2013, GPLv3 //
- //////////////////////////////////////////////////////////
- vector wasPercentToGradient(float percent, string rgb) {
- if(llStringLength(rgb) != 2) {
- llSay(DEBUG_CHANNEL, "Assert failed, rgb parameter must consist of a pair of either r, g, or b.");
- return ZERO_VECTOR;
- }
- string a = llGetSubString(rgb, 0, 0);
- string b = llGetSubString(rgb, 1, 1);
- list col = [ "r", "g", "b" ];
- integer ax = llListFindList(col, (list)a);
- integer bx = llListFindList(col, (list)b);
- if(ax == -1 || bx == -1) {
- llSay(DEBUG_CHANNEL, "Asset failed, rgb parameters must contain either r, g, or b letters.");
- return ZERO_VECTOR;
- }
- col = llListReplaceList(col, (list)((100-percent)/100), ax, ax);
- col = llListReplaceList(col, (list)(percent/100), bx, bx);
- return 2*<llList2Float(col, 0), llList2Float(col, 1), llList2Float(col, 2)>;
- }
- float h;
- listenOne()
- {
- wallOne = llListen(tChan, "wall controller 1", "", "");
- }
- default
- {
- state_entry()
- {
- llCollisionFilter("Cannonball","",TRUE);
- listenOne();
- llParticleSystem([]);
- h = HEALTH;
- llSetText("Health: " + progress((integer)(h/HEALTH*100), 10, ["[", "█", "░", "]"]), wasPercentToGradient((integer)(h/HEALTH*100), "rg"), 1.0);
- }
- listen(integer channel, string name, key id, string msg)
- {
- if(msg=="status")
- {
- //llSleep(0.1);
- llShout(0, (string)h);
- llRegionSay(tChan, (string)h);
- }
- else if(msg=="cleanup")
- {
- //llDie();
- //llRegionSay(chanOneTalk, "block is dead");
- llShout(0, "Cleaning up");
- state dead;
- }
- else
- {
- //llShout(0, "some message was received.");
- }
- }
- collision_start(integer num)
- {
- h -= llVecMag(llDetectedVel(0));
- llSetText("Health: " + progress((integer)(h/HEALTH*100), 10, ["[", "█", "░", "]"]), wasPercentToGradient((integer)(h/HEALTH*100), "rg"), 1.0);
- llSetTimerEvent(delay);
- if((h/HEALTH*100) <= 95 && (h/HEALTH*100) >= 50)
- {
- StartSmoke();
- llSleep(10.0/(h/HEALTH*100));
- llParticleSystem([]);
- }
- if(h <= 0)
- {
- state dead;
- }
- //llShout(0, (string)h + " " + (string)HEALTH + " " + (string)(h/HEALTH*100));
- }
- timer()
- {
- //llShout(0, "Timer is on");
- if((h/HEALTH*100) <= 50 && (h/HEALTH*100) >= 25)
- {
- StartSmoke();
- }
- else if((h/HEALTH*100) <= 25)
- {
- flipSwitch =! flipSwitch;
- delay = 1.0;
- if(flipSwitch)
- {
- StartSmoke();
- }
- else if(!flipSwitch)
- {
- StartFire();
- }
- }
- else
- {
- llParticleSystem([]);
- }
- }
- }
- state dead
- {
- state_entry()
- {
- llSetText("☠", <1,0,0>, 1.0);
- llSleep(1.0);
- // llDie();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement