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

Thread: Advanced Landmine, Expression 2

  1. #1
    Wire Sofaking singilli is on a distinguished road singilli's Avatar
    Join Date
    Jun 2007
    Location
    Garðabær, Iceland
    Posts
    505

    Post Advanced Landmine (and ChatMine as of request)

    [ame="http://www.youtube.com/watch?v=zysvYraOZfw"]YouTube - Enginn's tutorial #2 - Advanced landmine (E2)[/ame]

    Now includes ChatMine at bottom as requested.

    Whenever you pick up the prop the e2 was spawned on it will not explode, when it comes to a stop it will arm that part of the explosive again.


    Advanced Landmine:

    Part 1 - Building the contraption

    1. First spawn a PHX 1x1 plate, freeze it.

    2. Place a wired "Button" onto the plate toggled with Value on: 1 and Value off: 0, it is under Wire - I/O.

    3. Place an "Explosive" and make sure the trigger value is at 1 other options are up to you, it is under Wire - Physics.


    Part 2 - The expression 2

    e2 Code:
    1. @name Advanced Landmine
    2. @inputs Button
    3. @outputs Detonate
    4. @persist Plate:vector True
    5.  
    6. #Whenever you update the Epression it won't explode
    7. if (first()) {Plate=entity():pos()}
    8. #Makes it run every game tick or 10 milliseconds, this way it won't be affected by lag
    9. runOnTick(1)
    10.  
    11. #If player holds the entity the Expression is welded to the explosive can't explode
    12. if (entity():isWeldedTo():isPlayerHolding()) {True=0}
    13.  
    14. #Gets the position of the expression as a vector
    15. Plate=entity():pos()
    16. #If True equal 0 and the plate has stopped moving True is set to 1 again and that part of the explosive gets armed
    17. if (True==0&$Plate==vec(0,0,0)) {True=1}
    18. #If the delta of the plate is not 0/if it has moved, the button is 1 and True is 1 Detonate is 1 else Detonate is 0
    19. if ($Plate&Button&True) {Detonate=1}
    20. #Self explanatory
    21. else {Detonate=0}

    Copy and paste the code and place the expression

    Part 3 - Wiring it all up


    1. Wire the "Button" input of the expression to the "Button".

    2. Wire the Explosives "Detonate" to the "Detonate" output of the expression.

    Part 4 - Better understanding of the expression used


    Line 1:
    e2 Code:
    1. if (first()) {Plate=entity():pos()}

    If it's the first run of the expression it will get the vector position of the Plate so it doesn't blow it when you update it.

    Line 2:
    e2 Code:
    1. runOnTick(1)
    Makes it run every 10 millisecond.


    Line 3:
    e2 Code:
    1. if (entity():isWeldedTo():isPlayerHolding()) {True=0}
    If you hold the entity the expression is welded to with the physgun, it will make the variable True equal to 0. If True is 0 the explosive can't explode.


    Line 4:
    e2 Code:
    1. Plate=entity():pos()

    Updates the position of the expression


    Line 5:
    e2 Code:
    1. if (True==0&$Plate==vec(0,0,0)) {True=1}
    If the variable True is equal to 0 and the Delta of the vector of the plate is 0/the Plate variable is not moving. It makes the True variable 1 and thus arming that part of the bomb.


    Line 6:
    e2 Code:
    1. if ($Plate&Button&True) {Detonate=1}

    If the Delta of the expression is changing/the expresion is moving and the Button is equal to 1 and True is equal to 1 Detonate = 1.


    Line 7:
    e2 Code:
    1. else {Detonate=0}
    If one of the variables at line 6 is not equal to 1, Detonate is equal to 0.

    -------------------------------------------------------------------------------------------------------

    ChatMine:

    Part 1 - Building the contraption

    1. First spawn a PHX 1x1 plate, freeze it.

    2. Place an "Explosive" and make sure the trigger value is at 1 other options are up to you, it is under Wire - Physics.


    Part 2 - The expression 2

    e2 Code:
    1. @name Chatmine
    2. @inputs Button
    3. @outputs Detonate
    4. @persist Plate:vector True ChatActivate
    5.  
    6. #Whenever you update the Epression it won't explode
    7. if (first()) {Plate=entity():pos()}
    8. #Makes it run every game tick or 10 milliseconds, this way it won't be affected by lag
    9. runOnTick(1)
    10.  
    11. #Saves the last thing the owner said as the variable Arg
    12. Arg=owner():lastSaid()
    13. #If you say /act it will activate the mine
    14. if (Arg=="/act") {Chat=1}
    15. #Else if you say /deact it will deactivate the mine
    16. elseif (Arg=="/deact") {Chat=0}
    17.  
    18. #If player holds the entity the Expression is welded to the explosive can't explode
    19. if (entity():isWeldedTo():isPlayerHolding()) {True=0}
    20.  
    21. #Gets the position of the expression as a vector
    22. Plate=entity():pos()
    23. #If True equal 0 and the plate has stopped moving True is set to 1 again and the explosive gets armed
    24. if (True==0&$Plate==vec(0,0,0)) {True=1}
    25. #If the delta of the plate is not 0/if it has moved, the button is 1 and True is 1 Detonate is 1 else Detonate is 0
    26. if ($Plate&Chat&True) {Detonate=1}
    27. #Self explanatory
    28. else {Detonate=0}

    Copy and paste the code and place the expression


    Part 3 - Wiring it up

    1. Wire the Explosives "Detonate" to the "Detonate" output of the expression.


    Part 4 - Better understanding of the expression used

    Line 1 (changed):
    e2 Code:
    1. Arg=owner():lastSaid()
    Makes the variable Arg become the last thing you said and is saved as a string.


    Line 2 (changed):
    e2 Code:
    1. if (Arg=="/act") {Chat=1}
    If the variable Arg is equal to that you said "/act" Chat is equal to 1.


    Line 3 (changed):
    e2 Code:
    1. elseif (Arg=="/deact") {Chat=0}
    Else if the variable Arg is equal to "/deact" Chat is equal to 0.

    Do note that I just threw this code in and it's very inefficient, ask for help if you want to know how to make it more efficient.
    Last edited by singilli; 07-04-2009 at 08:38 AM.

  2. #2
    Wire Sofaking singilli is on a distinguished road singilli's Avatar
    Join Date
    Jun 2007
    Location
    Garðabær, Iceland
    Posts
    505

    Default Re: Advanced Landmine, Expression 2

    Part 4 updated!

  3. #3
    Wire Sofaking singilli is on a distinguished road singilli's Avatar
    Join Date
    Jun 2007
    Location
    Garðabær, Iceland
    Posts
    505

    Default Re: Advanced Landmine, Expression 2

    bumpity bump

  4. #4
    Wire Sofaking Wizard of Ass has a spectacular aura about Wizard of Ass has a spectacular aura about Wizard of Ass's Avatar
    Join Date
    May 2009
    Location
    Germany Bremerhaven
    Posts
    1,068

    Default Re: Advanced Landmine, Expression 2

    Instead of the button you could use a chatController... and why you don't apply the phx plate model to the explosive?

  5. #5
    Wire Sofaking singilli is on a distinguished road singilli's Avatar
    Join Date
    Jun 2007
    Location
    Garðabær, Iceland
    Posts
    505

    Default Re: Advanced Landmine, Expression 2

    I know, I'm going into chat controllers later on. And what is the second thing you are talking about?

  6. #6
    B0B
    B0B is offline
    Wirererer B0B will become famous soon enough B0B's Avatar
    Join Date
    Jul 2007
    Location
    Osdorf(SH) not in Hamburg!!!
    Posts
    178

    Default Re: Advanced Landmine, Expression 2

    You should change the model of the e2 (wire_expression2_model [modelpath]) or the model of the explosive so that you don't need an extra prop.

    And please don't use chat commands... or everyone will know if you activate the mine.

    But anyway: Nice Landmine I like the idea to be able to pick it up
    Any spelling or grammar mistake is just to amuse you and may be kept by the finder


  7. #7
    Drone Madman
    Lyinginbedmon has a spectacular aura about Lyinginbedmon has a spectacular aura about Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,652

    Default Re: Advanced Landmine, Expression 2

    You could use a chat command to arm it though, and then perhaps E:aimEntity() and E:keyUse() to deactivate it.

  8. #8
    B0B
    B0B is offline
    Wirererer B0B will become famous soon enough B0B's Avatar
    Join Date
    Jul 2007
    Location
    Osdorf(SH) not in Hamburg!!!
    Posts
    178

    Default Re: Advanced Landmine, Expression 2

    Why want everyone to use chat commands? they are ******* ****.
    I suggest to do it like Lying said but activate it with it too and use hints for status.
    Any spelling or grammar mistake is just to amuse you and may be kept by the finder


  9. #9
    Drone Madman
    Lyinginbedmon has a spectacular aura about Lyinginbedmon has a spectacular aura about Lyinginbedmon's Avatar
    Join Date
    Mar 2009
    Location
    England
    Posts
    2,652

    Default Re: Advanced Landmine, Expression 2

    Using chat commands however would allow them to activate them all simultaneously. Using my idea for both activation and deactivation would be very time consuming when laying a field of mines.

  10. #10
    Wire Sofaking singilli is on a distinguished road singilli's Avatar
    Join Date
    Jun 2007
    Location
    Garðabær, Iceland
    Posts
    505

    Default Re: Advanced Landmine, Expression 2

    e2 Code:
    1. @name Chatmine
    2. @inputs Button
    3. @outputs Detonate
    4. @persist Plate:vector True ChatActivate
    5.  
    6. #Whenever you update the Epression it won't explode
    7. if (first()) {Plate=entity():pos()}
    8. #Makes it run every game tick or 10 milliseconds, this way it won't be affected by lag
    9. runOnTick(1)
    10.  
    11. #Saves the last thing the owner said as the variable Arg
    12. Arg=owner():lastSaid()
    13. #If you say /act it will activate the mine
    14. if (Arg=="/act") {Chat=1}
    15. #Else if you say /deact it will deactivate the mine
    16. elseif (Arg=="/deact") {Chat=0}
    17.  
    18. #If player holds the entity the Expression is welded to the explosive can't explode
    19. if (entity():isWeldedTo():isPlayerHolding()) {True=0}
    20.  
    21. #Gets the position of the expression as a vector
    22. Plate=entity():pos()
    23. #If True equal 0 and the plate has stopped moving True is set to 1 again and the explosive gets armed
    24. if (True==0&$Plate==vec(0,0,0)) {True=1}
    25. #If the delta of the plate is not 0/if it has moved, the button is 1 and True is 1 Detonate is 1 else Detonate is 0
    26. if ($Plate&Chat&True) {Detonate=1}
    27. #Self explanatory
    28. else {Detonate=0}

    Someone asked for code with chatcommands. Here it is. That is nothing special it doesn't include any super hard commands just your very basic Chatmine as I like to call it.

    Added to top post
    Last edited by singilli; 06-29-2009 at 12:44 PM.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Basic Landmine, Regular Gates and E2
    By singilli in forum Wiremod Tutorials
    Replies: 16
    Last Post: 07-03-2009, 07:32 PM
  2. advanced Smoother in expression 2
    By Skyjets in forum Technical Support
    Replies: 2
    Last Post: 05-20-2009, 01:31 PM
  3. Replies: 2
    Last Post: 04-16-2009, 10:32 PM
  4. Advanced Dupe and Expression 2 problems
    By tnecromancer in forum Technical Support
    Replies: 1
    Last Post: 02-05-2009, 05:31 AM

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