+ Reply to Thread
Results 1 to 8 of 8

Thread: Automobile Bomb Detonator

  1. #1
    Wire Amateur Jasongamer1 is on a distinguished road Jasongamer1's Avatar
    Join Date
    Aug 2009
    Location
    Nashville, Tennessee
    Posts
    37

    Post Automobile Bomb Detonator

    Here is yet another code im releasing. You spawn an E2 chip (with the code in it) on a vehicle, then wire output:detonate to a wire explosive. It is setup so when you say "!arm" it is armed, and "!disarm" disarms it. when its armed, if any player enters the vehicle, it is ready. It detonates once that player leaves the vehicle.
    I actually made this about a week ago:
    Code:
    @name Automobile Bomb
    @outputs Detonate
    @persist [Driver]:entity [Armed Detonate Ready]
    
    if(first()|duped())
    {
      runOnChat(1)
    
      hint("Made by Jasongamer1",5)
    
      if(!(toString(entity():isWeldedTo()):find("Vehicle")) & changed(toString(entity():isWeldedTo())))
      {
          hint("ERROR: Chip must be spawned somewhere on a vehicle.",5)
          entity():setColor(vec(255,0,0)) 
          selfDestruct()
      }
      else
      {
        Vehicle=entity():isWeldedTo()
        
        Detonate=0
        Ready=0
    
        hint("Say !Arm to arm the bomb, and !Disarm to disarm it.",10)
        hint("Make sure that you wire the bomb up to an explosive!",10)
    
        holoCreate(1000,entity():pos(),vec(0.24,0.24,0.24),entity():angles())
        holoParent(1000,entity())
        holoModel(1000,"hqicosphere2")
        holoColor(1000,vec(0,0,0))
      }
    }
    
    if(Vehicle!=noentity())
    {
      if(chatClk(owner()))
      {
        if(owner():lastSaid():lower():sub(0,1)=="-")
        { 
          hideChat(1)
    
          if(owner():lastSaid():lower():explode(" ")[1,string] == "-arm")
          {Armed=1, hint("Car bomb is now armed",10), Ready=0}
    
          if(owner():lastSaid():lower():explode(" ")[1,string] == "-disarm")
          {Armed=0, hint("Car bomb is now disarmed",10), Ready=0}
        }
        else{hideChat(0)}
      }
    
      if(Armed)
      { 
        interval(200)
    
        if(Armed&$Armed){holoColor(1000, vec(255,255,0))}
    
        if(Vehicle:driver()&changed(Vehicle:driver()))
        {	
          interval(20)
    
          Driver = Vehicle:driver()
          hint("Driver in vehicle, ready to detonate when driver leaves vehicle!",20)
          Ready=1
        }
    
        if(Ready & Driver:health()>0)
        {
          holoColor(1000, vec(255,0,0))
    
          if(Driver==noentity() & changed(Driver))
          {
            hint("Driver left vehicle, Detonating now!",8)
            Detonate = 1
            Ready = 0
            Detonate = 0
          }
        }
      }
      elseif(!Armed)
      {
        if(!Armed&$Armed)
        {
          holoColor(1000, vec(0,0,0))
        }
        interval(0)
      }
    }
    
    Last edited by Jasongamer1; 02-10-2010 at 08:52 PM.
    Need faster internet? Hijack an alien ship, play gmod on their computer using their internet.

  2. #2
    Wire Sofaking Schilcote will become famous soon enough Schilcote's Avatar
    Join Date
    Jan 2009
    Location
    There.
    Posts
    1,196

    Default Re: Automobile Bomb Detonator

    Nice, but essentially useless since you can't spawn E2s on other player's props. You should probably use that command that gives all the entities that are in the contraption that the E2 is welded to (E2 is welded to A, which is welded to B, which is welded to C and D, you get all of them), so you aren't limited to spawning extremely conspicuous E2 chips on the one part of the vehicle the driver is guaranteed to be looking at.

    I'm going to be checking the back of my seat every time I get in my cars now...


    Well this monster dosen't look to hard to defeOshit

  3. #3
    Wire Amateur Jasongamer1 is on a distinguished road Jasongamer1's Avatar
    Join Date
    Aug 2009
    Location
    Nashville, Tennessee
    Posts
    37

    Default Re: Automobile Bomb Detonator

    I actually got my steam account back now! I immediately went to see how this worked. I did make and post this with no steam account, editing it for two hours with Notepad++ and using my knowledge of Expression2 did not help, because I had a plentiful amount of corrections to make when I returned to Garrys mod. I apologize for those who tried using this code, it was wrong for me to post it without testing it first.

    I realy have a few problems, and I should have posted it in the wiremod help forum, not contraptions & saves. While its here, I would like to note some issues that I would like to get some aid with:
    1) it doesnt display chat commands and I cannot see why. It looks like it would work just fine to me.
    2) It will reach the "ready" stage, but it will not detonate, completely defeating the purpose of the E2.
    Need faster internet? Hijack an alien ship, play gmod on their computer using their internet.

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

    Default Re: Automobile Bomb Detonator

    I looked over the "ready" part, and saw this:

    Code:
    if(Ready & Driver:health()>0)
        {
          holoColor(1000, vec(255,0,0))
    
          if(Driver==noentity() & changed(Driver))
          {
            hint("Driver left vehicle, Detonating now!",8)
            Detonate = 1
            Ready = 0
            Detonate = 0
          }
        }
    
    You have, inside "if Driver:health()>0", an "if(Driver==noentity())"
    This will never be true, because if the health of the driver is there, then the driver will be there. Instead, you need to use a persisted variable "Health" and set Health = Driver:health() after you check if the driver is there. On the next execution,if the previously found Health is > 0 and if the driver is gone (if(Driver==noentity)) then you detonate.

    Edit: I might as well post a quick re-do. Put @persist Health at the top of the code, obviously.
    Code:
    if(Ready & Health>0)
        {
          holoColor(1000, vec(255,0,0))
    
          if(Driver==noentity() & changed(Driver))
          {
            hint("Driver left vehicle, Detonating now!",8)
            Detonate = 1
            Ready = 0
            Detonate = 0
          }
        else
          {
            Health = Driver:health()
          }
        }
    
    Last edited by adeeda; 02-10-2010 at 09:13 PM.
    Anne drew Andrew and Drew, and Druanne drew Anne, Drew, Andrew, and Ru.
    AnDrEw in-game.

  5. #5
    Wire Amateur Jasongamer1 is on a distinguished road Jasongamer1's Avatar
    Join Date
    Aug 2009
    Location
    Nashville, Tennessee
    Posts
    37

    Default Re: Automobile Bomb Detonator

    Thank you adeeda, I guess i shoulda used a persistent variable for health/alive...

    UPDATED VERSION:
    Code:
    @name Automobile Bomb
    @outputs Detonate
    @persist [Driver]:entity [Armed Detonate Ready Alive]
    
    if(first()|duped())
    {
      runOnChat(1)
    
      hint("Made by Jasongamer1",5)
    
      if(!(toString(entity():isWeldedTo()):find("Vehicle")) & changed(toString(entity():isWeldedTo())))
      {
          hint("ERROR: Chip must be spawned somewhere on a vehicle.",5)
          entity():setColor(vec(255,0,0)) 
          selfDestruct()
      }
      else
      {
        Vehicle=entity():isWeldedTo()
        
        Detonate=0
        Ready=0
    
        hint("Say !Arm to arm the bomb, and !Disarm to disarm it.",10)
        hint("Make sure that you wire the bomb up to an explosive!",10)
    
        holoCreate(1000,entity():pos(),vec(0.24,0.24,0.24),entity():angles())
        holoParent(1000,entity())
        holoModel(1000,"hqicosphere2")
        holoColor(1000,vec(0,0,0))
      }
    }
    
    if(Vehicle!=noentity())
    {
      if(chatClk(owner()))
      {
        if(owner():lastSaid():lower():sub(0,1)=="-")
        { 
          hideChat(1)
    
          if(owner():lastSaid():lower():explode(" ")[1,string] == "-arm")
          {Armed=1, hint("Car bomb is now armed",10), Ready=0}
    
          if(owner():lastSaid():lower():explode(" ")[1,string] == "-disarm")
          {Armed=0, hint("Car bomb is now disarmed",10), Ready=0}
        }
        else{hideChat(0)}
      }
    
      if(Armed)
      { 
        interval(200)
    
        if(Armed&$Armed){holoColor(1000, vec(255,255,0))}
    
        if(Vehicle:driver()&changed(Vehicle:driver()))
        {	
          interval(20)
    
          Driver = Vehicle:driver()
          hint("Driver in vehicle, ready to detonate when driver leaves vehicle!",20)
          Alive=Driver:isAlive()
          Ready=1
        }
    
        if(Ready&Alive)
        {
          holoColor(1000, vec(255,0,0))
    
          if(Driver==noentity() & changed(Driver))
          {
            hint("Driver left vehicle, Detonating now!",8)
            Detonate = 1
            Ready = 0
            Detonate = 0
          }
        else
          {
            Alive=Driver:isAlive()
          }
        }
      }
      elseif(!Armed)
      {
        if(!Armed&$Armed)
        {
          holoColor(1000, vec(0,0,0))
        }
        interval(0)
      }
    }
    

  6. #6
    Wirererer Maxaxle is on a distinguished road Maxaxle's Avatar
    Join Date
    Sep 2009
    Posts
    157

    Default Re: Automobile Bomb Detonator

    Finally, a good security system! But really, you could slap that on your own car, in a secret place, and remove it when not needed!
    Still very clueless about code in general.
    92% of teens have moved onto rap. If you are part of the 8% that still listen to real music, copy and paste this into your signature.

  7. #7
    Wire Sofaking
    Divran will become famous soon enough Divran will become famous soon enough Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    1,256

    Default Re: Automobile Bomb Detonator

    You should make it run on an Adv Pod Controller's "Active" output to save ops.

    Here's a simple one:
    Code:
    @inputs Active
    @outputs Detonate Armed
    if (first()|duped()) {
        runOnChat(1)
    }
    
    if (chatClk(owner())) {
        if (lastSaid() == ".arm") {Armed = 1}
        elseif (lastSaid() == ".disarm") {Armed = 0}
    }
    
    if (~Active & !Active & Armed) then {Detonate = 1}
    
    PewPew (New GCombat): http://www.wiremod.com/forum/wiremod...w-gcombat.html
    SVN TUTORIAL: http://www.facepunch.com/showthread.php?t=688324
    E2 THREAD: http://www.wiremod.com/forum/custom-...ns-thread.html
    MY SVN LINK:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    

  8. #8
    Wire Noob Sycoslicer is on a distinguished road Sycoslicer's Avatar
    Join Date
    Jul 2009
    Location
    Hell
    Posts
    5

    Default Re: Automobile Bomb Detonator

    If you die in the vehicle while it's armed does it explode? Because I think it'd be neat if you could put that on your own vehicle, arm it, and if somebody kills you while your in it it explodes. Idk, it might be like some sort of terrorist bomb on RP servers that have E2. Just an idea, if it doesn't it's still cool.

+ Reply to 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