Jump to content

Looking for a simple rez random object script ... and maybe slighly more complex rezing script.


Sorina Garrigus
 Share

You are about to reply to a thread that has been inactive for 647 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I am making a zombie RPG shooting escape room area (Escape Zombie City).  I am looking for a simple rez script that when someone clicks it rezes one of the random items in the box. Basically loot boxes being clicked and rezing ammo med packs and maybe a zombie surprise now and then.

The more complex version, though still simple for an average scripter rather than the google fu franken scripting type like myself ... is the same random rezing but I want the ability to adjust the probability of any given item for being rezed. Additionally I might want to have flavor text put out with the rezes in this more complex version. I am trying to put as much story and RPG flavor into Escape Zombie City as I can with the tools I have available. I can pay some small fee if this is more complex than I am thinking it might be. 

Link to comment
Share on other sites

weighting the probabilities isn't too hard, although it requires a bit of setup in the script (or in a notecard, but notecard reading is too complicated IMO for a forum example)

list probabilities = 
[ 5,10,10,25,50 // must add to 100% or more. (if >100%, the last probability will effectively be truncated to the remainder)
];
list items =
[ "A","B","C","D","E" // must be present in object inventory.
];
list flavor =
[ "This is thing A",
  "This is thing B",
  "This is thing C",
  "This is thing D",
  "This is thing E" // no final ','
];
default 
{  state_entry()
   {  if(llListStatistics(LIST_STAT_SUM,probabilities)<100.0)
      {   llSay(0,"Error: probabilities do not add to 100%");
      }
   }
   touch_start(integer n)
   {  integer roll = (integer)llFrand(100.0);
      float sum;
      integer index = -1;
      while(sum<roll)
      {  sum+=llList2Float(probabilities,++index);
      }
      llRezAtRoot(llList2String(items,index),llGetPos()+<0,0,1>,<0,0,0>,llGetRot(),0);
      llSay(0,llList2String(flavor,index));
   }
}

 

Edited by Quistess Alpha
Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

weighting the probabilities isn't too hard, although it requires a bit of setup in the script (or in a notecard, but notecard reading is too complicated IMO for a forum example)

list probabilities = 
[ 5,10,10,25,50 // must add to 100% or more. (if >100%, the last probability will effectively be truncated to the remainder)
];
list items =
[ "A","B","C","D","E" // must be present in object inventory.
];
list flavor =
[ "This is thing A",
  "This is thing B",
  "This is thing C",
  "This is thing D",
  "This is thing E" // no final ','
];
default 
{  state_entry()
   {  if(llListStatistics(LIST_STAT_SUM,probabilities)<100.0)
      {   llSay(0,"Error: probabilities do not add to 100%");
      }
   }
   touch_start(integer n)
   {  integer roll = (integer)llFrand(100.0);
      integer sum;
      integer index = -1;
      while(sum<roll)
      {  sum+=llList2Float(probabilities,++index);
      }
      llRezAtRoot(llList2String(items,index),llGetPos+<0,0,1>,<0,0,0>,llGetRot(),0);
      llSay(0,llList2String(flavor,index);
   }
}

 

I think it's close. I think the last line needed an extra close parenthesis as giving a syntax error at that spot so I added it and it got past that error

.but I am getting an "(36,53) : Error : Named not defined within scope" right after the llGetPos and before the +   This is what I got

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

list probabilities = 
[ 3,3,3,3,3,3,3,3,3,3,10,10,20,15,10,5 // must add to 100% or more. (if >100%, the last probability will effectively be truncated to the remainder)
];
list items =
[ "Grim-monster","Grim-monster 1","Grim-monster 2","Grim-monster 3","Grim-monster 4","Grim-monster 5","Grim-monster 6","Grim-monster 7","Grim-monster 8","Grim-monster 9","Item.Pickup-Armor Pack 2.40 MESH","Item.Pickup-Cure syringe 2.401","Pickup-GCS Ammo Box 2.40 Mesh","Pickup-GCS Ammo Box 2.40 Mesh 1","Pickup-Health Pack 2.40 Mesh","Pickup-Health Pack 2.40 Mesh 1" // must be present in object inventory.
];
list flavor =
[ "Who put that thing in there!",
  "I thought this crate smelled",
  "Zombie in a box ... great",
  "Not what I was expecting",
  "Nope nope get back in that box!",
  "Pretty sure this wasn't marked zombie storage",
  "Why ... just why?",
  "Hey bub ... were you sitting on some ammo perchance?",
  "Zombie? eh?",
  "Armor! This will keep the bitting to a minimum!",
  "Meds in a pointy thing ... nice",
  "A bit more ammo ... can't have too much of that",
  "Double the ammo double the fun",
  "Meds! This helps",
  "Just found someone's stash of meds ... nice" // no final ','
];
default 
{  state_entry()
   {  if(llListStatistics(LIST_STAT_SUM,probabilities)<100.0)
      {   llSay(0,"Error: probabilities do not add to 100%");
      }
   }
   touch_start(integer n)
   {  integer roll = (integer)llFrand(100.0);
      integer sum;
      integer index = -1;
      while(sum<roll)
      {  sum+=llList2Float(probabilities,++index);
      }
      llRezAtRoot(llList2String(items,index),llGetPos+<0,0,1>,<0,0,0>,llGetRot(),0);
      llSay(0,llList2String(flavor,index));
   }

1 hour ago, Quistess Alpha said:

 

 

Edited by Sorina Garrigus
Link to comment
Share on other sites

16 minutes ago, Sorina Garrigus said:

"(36,53) : Error : Named not defined within scope"

Ahh yup, llGetPos(); is a function and needs empty parentheses to hold its non-existant arguments : llGetPos(); fixed and added the missing parenthesis to my original post.

Link to comment
Share on other sites

9 hours ago, Quistess Alpha said:

Ahh yup, llGetPos(); is a function and needs empty parentheses to hold its non-existant arguments : llGetPos(); fixed and added the missing parenthesis to my original post.

(34,49 off the my modifed script) or (24,49 going off of your original

ERROR : Type mismatch right after the ++index)

My googlefu only comes up with the following 

ERROR : Type mismatch

You must name the .x .y .z .s components of a vector or rotation that you're assigning, you can't assign them all at once from a list, for instance:

Link to comment
Share on other sites

21 minutes ago, Sorina Garrigus said:

Type mismatch

It's nice to be reminded that things that are "Obvious" to me aren't obvious to most. I forgot that LSL auto-typecasts integers to floats, but not always visa versa.

change the type of sum to a float and it will actually compile this time (I just went inworld and checked, also edited my first post retroactively)

"float sum;" instead of "integer sum;" on line 31 or so of yours.

Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

It's nice to be reminded that things that are "Obvious" to me aren't obvious to most. I forgot that LSL auto-typecasts integers to floats, but not always visa versa.

change the type of sum to a float and it will actually compile this time (I just went inworld and checked, also edited my first post retroactively)

"float sum;" instead of "integer sum;" on line 31 or so of yours.

My programing knowledge is literally BASIC and crude spaghetti code at that and that was decades ago. It's working now! I can put in sleep and script reset commands pretty easily for the rest of it. Thanks again!!!

let me know if I owe you something. A Mole moderator moved this from the scripting discussion to employment section for some reason. I guess because I said I was willing to pay if someone had help for the more complex version of what I was trying to script. 

Though I might try to hire people to make games for me down the road. 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 647 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...