+ 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
    67

    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.

  2. #2
    billywitchdoctor.com Schilcote will become famous soon enough Schilcote's Avatar
    Join Date
    Jan 2009
    Location
    There.
    Posts
    2,045

    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...


    [19:16:47]Client "rcdraco" spawned in server
    [19:17:10]rcdraco: hamburgertime
    [19:18:04]rcdraco was killed by worldspawn
    [19:21:50]Dropped "rcdraco" from server

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

    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.

  4. #4
    Wirererer adeeda is on a distinguished road adeeda's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    110

    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
    67

    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
    Lurker Maxaxle is on a distinguished road Maxaxle's Avatar
    Join Date
    Sep 2009
    Posts
    189

    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
    No u

    Divran is a jewel in the rough Divran is a jewel in the rough Divran is a jewel in the rough Divran is a jewel in the rough Divran's Avatar
    Join Date
    Jul 2008
    Location
    Sweden
    Posts
    2,455

    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) | SVN Tutorial | EGP v3
    MY SVN LINK:
    Code:
    http://divranspack.googlecode.com/svn/trunk/%20divranspack/
    


    Thanks for clicking, everyone!
    http://www.minerwars.com/?aid=927
    But if I get even more clicks, I get the full game, so keep at it!

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

    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
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots