main local.origin local.smoketime: if(local.smoketime == NIL) { level.jointsmoketime = 9999 } if(local.smoketime != NIL) { level.jointsmoketime = local.smoketime } local.player = parm.other local.trigger = spawn trigger_use targetname "joint_trigger" local.trigger.origin = local.origin + ( 0 0 30 ) local.trigger setsize ( -30 -30 -20 ) ( 30 30 50 ) local.trigger model "items/cigarette.tik" local.trigger.angles = ( 0 90 -45 ) local.trigger.scale = 5 local.trigger setthread do_random local.trigger show exec global/flickerrotate.scr joint_trigger ( 0.65 0.8 0.2 ) 125 20 20 20 end do_random: self nottriggerable local.player = parm.other if(local.player.inuse) { local.player iprint "Cannot use. You are holding something already." wait 1 self triggerable end } else { if(level.jointdropped != 1) { $joint_trigger message ("*** You found a nice and fresh fat blunt! Spark it up bro! ***") } else if(level.jointdropped == 1) { $joint_trigger message ("*** You found a partially smoked fat blunt, but who cares! Spark it up bro! ***") } local.player.inuse = 1 local.player give "items/papers.tik" local.player thread doit self.origin } self triggerable end doit local.origin: if(level.jointdropped != 1) { self stufftext "say *** I just lit a fat blunt, and I'm getting super high! ***" } else if(level.jointdropped == 1) { self stufftext "say *** I just found and lit someone's half-smoked blunt, and I'm getting pretty high still! ***" } local.number = randomint 999999999 self attachmodel models/items/cigarette.tik "Bip01 Head" 1.75 ("cig_1" + local.number) 1 -1 -1 -1 -1 ( 4 7 -3 ) self attachmodel models/emitters/inferno.tik "Bip01 Head" .2 ("cig_2" + local.number) 1 -1 -1 -1 -1 ( 4 7 -3 ) //self attachmodel models/emitters/fancyfire.tik "Bip01 Head" .2 ("cig_3" + local.number) 1 -1 -1 -1 -1 ( 4 7 -3 ) self attachmodel models/emitters/breath_emitter.tik "Bip01 Head" 1.5 ("cig_4" + local.number) 1 -1 -1 -1 -1 ( 4 7 -3 ) self attachmodel models/emitters/breath_emitter.tik "Bip01 Head" 1.5 ("cig_5" + local.number) 1 -1 -1 -1 -1 ( 4 7 -3 ) local.static = spawn script_model local.static model "items/cigarette.tik" local.static.scale = 0.001 local.static.origin = self.origin local.static notsolid local.static light (randomfloat 20 / 100.00 + 0.65) (randomfloat 20 / 100.00 + 0.8) (randomfloat 20 / 100.00 + 0.2) 400 //.75 1 .3 400 local.static glue self local.static show //huddraw_alpha 104 0 //huddraw_virtualsize 104 1 //huddraw_alpha 104 .8 //huddraw_font 104 "verdana-12" //huddraw_color 104 .5 .25 0 //huddraw_rect 104 -200 222 200 14 //huddraw_string 104 "Weed Blunt: Lighting Up" $"joint_trigger" nottriggerable waitframe $"joint_trigger" remove // need to waitframe before removing trigger, otherwise trigger "message" will not work. $("cig_1" + local.number).angles = ( 0 180 20 ) $("cig_2" + local.number).angles = ( 0 180 20 ) //$("cig_3" + local.number).angles = ( 0 180 20 ) $("cig_4" + local.number).angles = ( 0 180 20 ) $("cig_5" + local.number).angles = ( 0 180 20 ) self thread smokeweed420 //huddraw_string 104 "Weed Blunt: Smoking" if(level.jointdropped != 1) { self iprint ("Yes, that is real weed you're smoking right now.") } else if(level.jointdropped == 1) { self iprint ("You're such a fiend for lighting that blunt up again...") } local.result = self waitthread scan_player level.jointsmoketime if(local.result != left) { self.inuse = 0 $("cig_1" + local.number) remove $("cig_2" + local.number) remove $("cig_3" + local.number) remove $("cig_4" + local.number) remove $("cig_5" + local.number) remove self stufftext "say *** No! I dropped my fat blunt! ***" //huddraw_string 104 "Weed Blunt: Dropped" self stopsound local.static unglue local.static remove level.jointdropped = 1 // never = 0 again; jointdropped = 1 after the first joint is found, after each map loads. local.originold = local.origin + ( 0 0 -30 ) if(level.jointdropped_useheld != 1) { if(level.joint_went2spectator != 1) { wait 0.5 } // drops joint onto ground instantly if player goes into spectator (so player doesn't fly into walls) // waiting 0.5 seconds allows a player's dead body to finish falling before running "main". //huddraw_string 104 "" // if the player is in midair and goes to spectator, the trigger will be stuck in the air, if(level.joint_went2spectator == 1) // this respawns the trigger at the origin it was last picked up at (hopefully on the ground). { // when map loads, players can still change teams without dying, so that case applies here too. level.joint_went2spectator = 0 goto main local.originold } goto main self.origin // using "goto" here immediately ends "doit" script and runs "main" as a new thread. } if(level.jointdropped_useheld == 1) { thread main self.origin // using "thread" here allows joint to be dropped faster. also allows "doit" code to finish. level.jointdropped_useheld = 0 //wait 0.5 //huddraw_string 104 "" } } end scan_player local.time: local.result = ok local.team = self.dmteam local.count = 0 self thread instructions while(1) { if(self == NULL) { local.result = left end local.result } else { if(self.dmteam != local.team || !isalive self || self.dmteam == spectator) { if(self.dmteam == spectator || isalive self) { level.joint_went2spectator = 1 } end local.result } if(self.dmteam == local.team && isalive self && self.dmteam != spectator) { local.count++ if((local.count / 10) >= local.time) { end local.result } } local.smoketimer = 0 while(self.useheld == 1 && self.dmteam == local.team && isalive self) { local.random = randomint(3) if(local.smoketimer == 10) { if(local.random == 0) { self playsound sparkup1 } if(local.random == 1) { self playsound sparkup2 } if(local.random == 2) { self playsound sparkup3 } } if(local.smoketimer == 20) { if(local.random == 0) { self playsound sparkup1 } if(local.random == 1) { self playsound sparkup2 } if(local.random == 2) { self playsound sparkup3 } } if(local.smoketimer >= 50) { if(local.random == 0) { self playsound sparkup1 } if(local.random == 1) { self playsound sparkup2 } if(local.random == 2) { self playsound sparkup3 } self iprint ("You dropped the blunt by holding the USE key for 5 seconds.") level.jointdropped_useheld = 1 end local.result } local.smoketimer++ wait 0.1 } } wait 0.1 } end instructions: // separate the "wait 3" from the rest of the scan_player thread. wait 3 if($joint_trigger == NULL) { self iprint ("Hold USE for 1 or 2 seconds to smoke blunt. Hold USE for 5 seconds to drop it.") } end // NIL is for values, variables, strings. NULL is for entities, objects, targetnames. smokeweed420: // make the smoking sounds if(isalive self && self != NULL && self.dmteam != spectator) { local.random1 = randomint(3) if(local.random1 == 0) { self playsound sparkup1 } if(local.random1 == 1) { self playsound sparkup2 } if(local.random1 == 2) { self playsound sparkup3 } } wait 1.5 if(isalive self && self != NULL && self.dmteam != spectator) { local.random = randomint(3) if(local.random == 0) { self playsound sparkup1 } if(local.random == 1) { self playsound sparkup2 } if(local.random == 2) { self playsound sparkup3 } } end