User:Allen Kerensky/Myriad Lite Preview 5/Myriad Compatible Trap
From OpenSimulator
< User:Allen Kerensky | Myriad Lite Preview 5(Redirected from User:Allen Kerensky:Myriad Lite Preview 5:Myriad Compatible Trap)
Contents |
Myriad Compatible Trap
This Myriad Compatible Trap script, when used in a prim, causes Myriad damage and does other things, if avatar touches or collides with it.
It is normally used by the region owner or builders to add the element of risk to players walking or flying around in a sim RP game environment.
Instructions
- Choose a location for the trap to exist within your sim/region game environment.
- Edit a prim to the size and area desired for your trap.
- In the prim contents, add a sound file you desire to be played when the trap interacts with a player.
- In the prim contents, add the script: Myriad Compatible Trap v0.5.1c.
- Edit the script in the prim:
- change the SOUNDNAME: (default = "zap") to the exact name of the sound you added. Alternatively, you may rename the sound to "zap".
- change the TRAPNAME: (default = "BIG TRAP") to your desired name for your new trap.
- change the MYRIADTRAPNAME: (default = "TRAP1") to your desired Myriad RP Event name for your new trap
- change the COLLISIONMESSAGE (default = "tried to trap you! ") message directly sent to the avatar at the time of interaction with the trap.
- change the MYRIADMESSAGE (default = "tried to trap ") message sent via Myriad RP Event
- change the HOVERTEXT: (default "TRAP") to your desired warning floating text above your new trap. (no text = " ")
- change the HTEXTALPHA alpha of hovertext: (default = 0.5) (opaque = 1.0) (transparent = 0.0)
- change the PUSHPOWER vector direction/power (default = <200,200,200>) to push the avi away at the time of interaction with the trap. <x,y,z>
- Place the trap in the position desired for interaction with avatars.
- For full interaction with the trap, the avatar must wear a Myriad compatible HUD and Meter.
- Note! The trap will not damage its owner, so please test the trap using an alt avatar, or a volunteer.
Tips
- To turn any existing object into a trap: Make the trap prim a cylinder or sphere, place it at the same position as the existing object, but make the trap prim slightly larger diameter. Then make the trap prim 100% transparent.
- The push power should be just enough push in a good direction to cause the avatar to be pushed away when they walk or fly into it. However, it can also orbit the avatar if too much Z axis power is set.
Myriad_Compatible_Trap-v0.5.4-20120202.lsl
// Myriad_Compatible_Trap-v0.5.4-20120202.lsl // Myriad Compatible Trap script (c)2012 LANI GLOBAL SYSTEMS and Allen Kerensky // Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported // This trap causes Myriad damage if avatar touches or collides with it. // The Myriad RPG System was designed, written, and illustrated by Ashok Desai // Myriad RPG licensed under the Creative Commons Attribution 2.0 UK: England and Wales // http://creativecommons.org/licenses/by/2.0/uk/ // Myriad Lite software Copyright (c) 2011 by Allen Kerensky (OSG/SL) // Baroun's Adventure Machine Copyright (c) 2008-2011 by Baroun Tardis (SL) // Myriad Lite and Baroun's Adventure Machine licensed under the // Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported // http://creativecommons.org/licenses/by-nc-sa/3.0/ // Myriad config below this line //========================== integer MINDAMAGE = 1; // minimum allowed trap damage integer MAXDAMAGE = 5; // maximum allowed trap damage integer DAMAGE = 2; // default how much damage do you want this weapon to cause? can be overriden on rez! string CHAN_PREFIX = "0x"; // used to convert key to hexadecimal channel number string DIV = "|"; // divider between parts of Myriad API messages integer CHANMYRIAD = -999; // channel to send Myriad RP events to string MYRIADTRAPNAME = "TRAP1"; //name of the trap string TOUCHMESSAGE = "do not touch this!"; // touch damage message sent to avi via IM direct string COLLISIONMESSAGE = "tried to trap you!"; //collision damage message sent to avi via IM direct string MYRIADMESSAGE = "tried to trap"; //RP attempted damage message sent via Myriad hud string SOUNDNAME = "zap"; // name of the sound to play when trap springs string HOVERTEXT = "TRAP"; //floating text vector HTEXTCOLOR = <1,0.0,0>; // <R,G,B> color of the hovertext float HTEXTALPHA = 0.5; //alpha level of the hovertext vector PUSHPOWER = <200,200,200>; // vector to push the damaged avi away ATTACK(key victim,string victimname,string attackmessage) { llPlaySound(SOUNDNAME, 1.0); // play sound if touched llPushObject(victim,PUSHPOWER, ZERO_VECTOR, FALSE); // push avatar away if touch llInstantMessage(victim," sorry "+llDetectedName(0)+ ", "+attackmessage); //tell avi something // calculate the dynamic channel of who/what we hit integer dynchan = (integer)(CHAN_PREFIX+llGetSubString((string)llGetOwner(),0,6)); // owner of trap becomes attacker llRegionSay(dynchan,"CLOSECOMBAT"+DIV+(string)DAMAGE+DIV+(string)victim+DIV+(string)llGetOwner()+DIV+llGetObjectName()); //myriad damage regionsay llRegionSay(CHANMYRIAD,"RPEVENT"+DIV+MYRIADTRAPNAME+" "+MYRIADMESSAGE+" "+victimname+"!"); //myriad rp event regionsay } default { on_rez(integer rez_damage) { if ( rez_damage >= MINDAMAGE && rez_damage <= MAXDAMAGE ) { DAMAGE = rez_damage; // allow rez param to override scripted in damage } llSetStatus(STATUS_PHANTOM, TRUE); // toggle phantom status llSleep(0.2); // sleep for a moment to give toggle a chance to settle llSetStatus(STATUS_PHANTOM, FALSE); // make sure trap is not phantom } state_entry() { llSetText(HOVERTEXT,HTEXTCOLOR,HTEXTALPHA); // set the hovertext llSetSitText("--"); // set the sit text llSetTouchText("BAD"); // set the touch text } touch_start(integer total_number) { while (total_number--) { // loop through all people who touched, not just first this frame ATTACK(llDetectedKey(total_number),llDetectedName(total_number),TOUCHMESSAGE); } } collision_start(integer total_number) { while (total_number--) { // loop through all people who touched, not just first this frame ATTACK(llDetectedKey(total_number),llDetectedName(total_number),COLLISIONMESSAGE); } } }