+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 13

Thread: Laser Tag

  1. #1
    Wire Amateur adeeda is on a distinguished road adeeda's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    86

    Default Laser Tag

    Hello there, fellow wiremodders. I've been holding on to this for a while now, trying to motivate myself to take a video and some pictures. I present....

    Laser Tag


    I've created a full laser tag system with holograms, that works off of a single chip. It takes the form of a button, that players on the server can "press."

    How to Play:
    Upon pressing the "button," each participant receives a simple green hologram for a gun, with a red laser and a red bar representing their health. Using a pistol-ish weapon is preferable, because you can see the health bar normally. Press your Use key to shoot your laser. There are nifty pew pew sounds, as well as activation/deactivation sounds. When you get hit, your gun is deactivated and turns black for a few seconds. What happens when you run out of health depends on the options, but you will lose your laser gun and must obtain it again.

    Create your own map:
    The "button" (It's really just an E2) is all that's needed to play. This makes it ideal for use in various, player-made laser tag courses. Simply create a bunch of props to hide behind, and you've got an instant laser tag game! I've added other options that are, well, optional. My example, the advanced dupe attached, has both of them. Two Door outputs for controlling a two-doored entryway (They output 1 for when they are active. D1 is the outer door, D2 the inner door), and Text/Background outputs for a text screen. There are also options at the beginning of the code, for maximum number of players (technical limit is 12), deactivation time when hit, and what to do when someone runs out of health (ULX slay or psay, or just say, or a custom command).

    gm_flatgrass0002.jpggm_flatgrass0000.jpg

    I strongly recommend creating your own, cooler arenas, because mine really does suck gameplay-wise. Post them here for extra credit.

    My attached example laser tag arena requires PHX, and the Unofficial Wire Addon for its no-collide doors. (Noobs, put the advanced dupe file titled "laser tag final.txt" into C:\Program Files\Steam\steamapps\yoursteamnamehere\garrysmod\ garrysmod\data\adv_duplicator)

    Here's the code. (Noobs: either copy&paste this into an empty text file in the following location, or download "laser_tag_e2.txt" to the following location: C:\Program Files\Steam\steamapps\yoursteamnamehere\garrysmod\ garrysmod\data\Expression2)
    Also, what's up with the weird code boxes being very long?
    Code:
    @name Laser Tag! Press E!
    @outputs D1 D2 Text:string
    @persist [Players Ingame Inuse UOn Health HoloN Timeout TextA]:array
    @persist Max OMax N Slay T Say PSay TOut [CustomCommand CustomMessage]:string
    @model models/dav0r/buttons/button.mdl
    
    #INSTRUCTIONS#
    #Simply place this at the entrance to your arena, and press E on it.
    #You can see your health better if you use a toolgun or pistol.
    #OPTIONAL: Create two no-collide doors with the wire nocollide tool for best effect.
    #(D1 goes to the outer door, D2 goes to the inner door.)
    #OPTIONAL: Wire a text screen's "String" input to "Text" to display a welcoming message to players.
    
    if(first() | duped()) {
        
        #################-----OPTIONS-----###################
        
        #Max Players - Cannot exceed 12
        Max = 12
        
        #Time-out Time: (seconds)
        TOut = 3
        
        #Choose what to do when someone runs out of health
        #(Pick only one)
        Slay = 0 #ULX
        PSay = 0 #ULX
        Say = 1
        
        #Custom command will be CustomCommand+'Loser's name'+CustomMessage
        CustomCommand = "" #Enter a console command here.
        CustomMessage = "" #Enter a message here.
        
        
        #####################################################
        
        timer("players",1000)
        timer("text",1000)
        runOnTick(1)
        N=D1=T=1
        if(Max>12) {Max=12}
        if(Max>7) {M=7, OMax=1} else {M=Max}
        
        for(I=1,M) {
            holoCreate(I)
            holoAlpha(I,0)
            holoAng(I,ang(0,0,0))
        }
        for(I=Max+1,Max+M) {
            holoCreate(I)
            holoAlpha(I,0)
            holoModel(I,"hqcylinder")
            holoScaleUnits(I,vec(7,7,14))
            holoAng(I,ang(0,90,90))
            holoParent(I,I-Max)
        }
        for(I=Max*2+1,Max*2+M) {
            holoCreate(I)
            holoAlpha(I,0)
            holoModel(I,"hqcylinder")
            holoScaleUnits(I,vec(0.4,0.4,300))
            holoColor(I,vec(255,0,0))
            holoPos(I,holoEntity(I-Max):pos()+holoEntity(I-Max):up()*150)
            holoAng(I,ang(0,90,90))
            holoParent(I,I-Max*2)
        }
        for(I=Max*3+1,Max*3+M) {
            holoCreate(I)
            holoAlpha(I,0)
            holoColor(I,vec(255,0,0))
            holoScaleUnits(I,vec(0.5,0.5,10))
            holoAng(I,ang(0,90,90))
            holoPos(I,holoEntity(I-Max*2):pos()-holoEntity(I-Max*2):right()*3.1)
            holoParent(I,I-Max*3)
        }
        
        T=1
        TextA[T,string] = "Welcome to Laser Tag! Made by AnDrEw.",T++
        TextA[T,string] = "Press the Button to join in the fun!",T++
        TextA[T,string] = "Press E to fire your laser gun.",T++
        TextA[T,string] = "You have 10 health, indicated by the red bar.",T++
        hint("Laser Tag made by AnDrEw :D",7)    
        TextA[T,string] = "If you are hit, you get 5 seconds of safety.",T++
        TextA[T,string] = "When you lose, find some way to exit or suicide.",T++
        TextA[T,string] = "Enter the entrance one at a time.",T++
        TextA[T,string] = "I recommend toolgun or pistol for best results"
        T=1
    
    }
    if(OMax & holoCanCreate()) {
        for(I=8,Max) {
            holoCreate(I)
            holoAlpha(I,0)
            holoAng(I,ang(0,0,0))
        }
        for(I=Max+8,Max*2) {
            holoCreate(I)
            holoAlpha(I,0)
            holoModel(I,"hqcylinder")
            holoScaleUnits(I,vec(7,7,14))
            holoAng(I,ang(0,0,0))
            holoParent(I,I-Max)
        }
        for(I=Max*2+8,Max*3) {
            holoCreate(I)
            holoAlpha(I,0)
            holoModel(I,"hqcylinder")
            holoScaleUnits(I,vec(0.4,0.4,300))
            holoColor(I,vec(255,0,0))
            holoPos(I,holoEntity(I-Max):pos()+holoEntity(I-Max):up()*150)
            holoAng(I,ang(0,0,0))
            holoParent(I,I-Max*2)
        }
        for(I=Max*3+8,Max*4) {
            holoCreate(I)
            holoAlpha(I,0)
            holoColor(I,vec(255,0,0))
            holoScaleUnits(I,vec(0.5,0.5,10))
            holoAng(I,ang(0,90,90))
            holoPos(I,holoEntity(I-Max*2):pos()-holoEntity(I-Max*2):right()*3.1)
            holoParent(I,I-Max*3)
        }
    }
    for(I=1,Players:count()) {
        Player = Players[I,entity]
        if(Player:keyUse() & Player:aimEntity()==entity() & N<Max & !Ingame[I,number]) {
            N++
            Ingame[I,number]=1
            UOn[I,number]=1
            Health[I,number]=10
            D1=0
            D2=1
            stoptimer("close")
            timer("close",2000)
            for(J=1,Max) {
                if(!Inuse[J,number]) {
                    Inuse[J,number]=1
                    HoloN[I,number]=J
                    break
                }
            }
            holoScaleUnits(J+Max*3,vec(0.5,0.5,Health[I,number]))
            holoAng(J,Player:attachmentAng("anim_attachment_RH"))
            holoPos(J,Player:attachmentPos("anim_attachment_RH"))
            holoColor(J+Max,vec(0,255,0))
            holoAlpha(J+Max,255)
            holoAlpha(J+Max*3,255)
        }
    
        if(Ingame[I,number]) {
            J = HoloN[I,number]
            Eye=(Player:aimPos()-holoEntity(J):pos())
            holoAng(J,Eye:toAngle())
            holoPos(J,Player:attachmentPos("anim_attachment_RH"))
            if(Player:keyUse() & !UOn[I,number] & !Timeout[I,number]) {
                if(Player:aimEntity()==entity()) {
                    D1=0
                    D2=1
                    stoptimer("close")
                    timer("close",2000)
                }
                UOn[I,number]=1
                holoAlpha(J+Max*2,255)
                holoEntity(J+Max):soundPlay(J+Max,0,"buttons/blip1.wav")
                soundPitch(J+Max,200)
                rangerFilter(Player)
                R=rangerOffset(1000,holoEntity(J+Max):pos(),holoEntity(J+Max):up())
                if(R:hit()) {
                    for(K=1,Players:count()) {
                        L = HoloN[K,number]
                        if(R:entity()==Players[K,entity] & Ingame[K,number] & !Timeout[K,number]) {
                            Health[K,number] = Health[K,number]-1
                            if(Health[K,number]==0) {
                                Ingame[K,number]=0
                                HoloN[K,number]=0
                                Inuse[L,number]=0
                                N--
                                if(Slay) {concmd("ulx slay "+Players[K,entity]:name())}
                                elseif(PSay) {concmd("ulx psay "+Players[K,entity]:name()+" You have run out of health. Please either exit or suicide.")}
                                elseif(Say) {concmd("say "+Players[K,entity]:name()+", you have run out of health. Please either exit or suicide.")}
                                elseif(CustomCommand) {concmd(CustomCommand+Players[K,entity]:name()+CustomMessage)}
                                holoAlpha(L+Max,0)
                                holoAlpha(L+Max*2,0)
                                holoAlpha(L+Max*3,0)
                            } else {
                                holoScaleUnits(L+Max*3,vec(0.5,0.5,Health[K,number]))
                                holoColor(L+Max,vec(0,0,0))
                                Timeout[K,number]=1
                                soundStop(L)
                                holoEntity(L):soundPlay(L,0,"items/suitchargeno1.wav")
                                timer("timein"+K,TOut*1000)
                            }
                            break
                        }
                    }
                    holoScaleUnits(J+Max*2,vec(0.4,0.4,min(R:distance(),500)))
                    holoPos(J+Max*2,holoEntity(J+Max):pos()+holoEntity(J+Max):up()*min(R:distance()/2,250))
                } else {
                    holoScaleUnits(HoloN[I,number]+Max*2,vec(0.4,0.4,500))
                    holoPos(J+Max*2,holoEntity(J+Max):pos()+holoEntity(J+Max):up()*250)
                }
                timer("off"+I,100)
            } elseif (!Player:keyUse() & UOn[I,number]) {
                UOn[I,number]=0
                soundStop(J+Max)
            }
            if(!Player:isAlive()) {
                Ingame[I,number]=0
                HoloN[I,number]=0
                Inuse[J,number]=0
                N--
                holoAlpha(J+Max,0)
                holoAlpha(J+Max*2,0)
                holoAlpha(J+Max*3,0)
            }
        }
        if(clk("off"+I)) {holoAlpha(HoloN[I,number]+Max*2,0)}
        if(clk("timein"+I)) {
            holoColor(HoloN[I,number]+Max,vec(0,255,0))
            Timeout[I,number]=0
            soundStop(HoloN[I,number])
            holoEntity(HoloN[I,number]):soundPlay(HoloN[I,number],0,"items/suitchargeok1.wav")
        }
    }
    if(clk("text")) {
        if(N>=Max) {
            Text = "Max Players Reached, please wait!"
        } else {
            Text = TextA[T,string]
            T++
            if(T>TextA:count()) {T=1}
        }
        timer("text",2000)
    }
    if(clk("close")) {
        D1=1
        D2=0
    }
    if(clk("players")) {
        timer("players",30000)
        findByClass("player")
        Players = findToArray()
    }
    
    Attached Files
    Last edited by adeeda; 4 Weeks Ago at 03:03 PM.
    Anne drew Andrew and Drew, and Druanne drew Anne, Drew, Andrew, and Ru.
    AnDrEw in-game.

  2. #2
    Wirererer somone77 is on a distinguished road somone77's Avatar
    Join Date
    Jun 2008
    Location
    <Smart ass location>
    Posts
    176

    Default Re: Laser Tag

    This looks very interesting. I may check this out if I get a chance.


    90% of people on the internet put dumb statistics like this in their signatures. If you are one of the 10% that don't, DO NOT put this in your signature.

    Black Phoenix: That's not vegetables, that's someones tits cancer
    Grammar Nazi alert. Please point out any grammar errors I make, then, I can prove you wrong.

    http://somone77.is-a-geek.net

  3. #3
    Wirererer Blaylock1988 is on a distinguished road Blaylock1988's Avatar
    Join Date
    Apr 2009
    Location
    North Carolina
    Posts
    211

    Default Re: Laser Tag

    Looks really good, I would suggest parenting the green gun to the player's hands or eyes though so it does not lag behind as much.

  4. #4
    Wire Amateur adeeda is on a distinguished road adeeda's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    86

    Default Re: Laser Tag

    Quote Originally Posted by Blaylock1988 View Post
    Looks really good, I would suggest parenting the green gun to the player's hands or eyes though so it does not lag behind as much.
    I've struggled with making a decision on this. Originally, it was parented, and the laser shot straight out of the gun, so it was amazingly inaccurate. Now nothing is parented, the gun moves with you and aims where your aimpos is (and the laser goes straight). I could parent the gun, but unparent the laser from the gun and move it so it fires at an angle from the gun, but I originally decided not to do that because of the sometimes-large disparities between your eye angle and what your hands look like to other players. If enough people want it, I can do it.
    Anne drew Andrew and Drew, and Druanne drew Anne, Drew, Andrew, and Ru.
    AnDrEw in-game.

  5. #5
    Wire Noob holy knife is on a distinguished road holy knife's Avatar
    Join Date
    Feb 2010
    Posts
    29

    Default Re: Laser Tag

    Wow very interesting and creative. I've seen it before though, but this ones better the other person didnt finish.

  6. #6
    Wire Sofaking mattwd0526 is on a distinguished road mattwd0526's Avatar
    Join Date
    Apr 2009
    Location
    findPlayerByName( "mattwd0526" ):pos()
    Posts
    735

    Default Re: Laser Tag

    You should definitely parent the guns, they lag behind the player far too much. People are used to strange shooting angles in garrysmod.

  7. #7
    Wire Noob Jake_a_j is on a distinguished road Jake_a_j's Avatar
    Join Date
    Dec 2009
    Posts
    2

    Default Re: Laser Tag

    Great E2. Loved playing around with it after I showed it to some friends on a server I frequent.

  8. #8
    Wirererer Blaylock1988 is on a distinguished road Blaylock1988's Avatar
    Join Date
    Apr 2009
    Location
    North Carolina
    Posts
    211

    Default Re: Laser Tag

    You can still move (rotate) a parented hologram. You said that it shot straight out of the gun and was inaccurate, you could just adjust the gun to point to the aimPos() from the hand.

  9. #9
    Wire Amateur zinen is on a distinguished road zinen's Avatar
    Join Date
    Jun 2007
    Location
    DK
    Posts
    45

    Default Re: Laser Tag

    Nice contraption really like lasertag (real world too). But i have seen this before I'm afraid it had rank system, team play and upgradeable weapon. Just saying this to give you some ideas to make it THE best one I've ever seen .
    The weapon upgrades like... reduced cooldown on shots, larger damage and also a cloak ability.

    If you can fly too, say Weeeee

  10. #10
    Wirererer Tayg0 is on a distinguished road Tayg0's Avatar
    Join Date
    Aug 2008
    Posts
    142

    Default Re: Laser Tag

    Was very fun playing this with you Andrew, GJ.

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts