kool beans
Hey it's me again, this time with some random drone I coded to entertain myself.
It all started in the thread "that safe wiremod feeling", OP asked what gives us a warm feeling of safety. I thought, "damn, I don't feel safe at all!" so I coded this little thing to defend myself.
Version: 1
Revision: At least 50 already.
Features:
- 1-step construction (takes no more than 3 clicks!)
- ballistic protection
- firearm operation
- explosive operation
- invisibilty
- 50-tonn punch
- anti-minging stop-crank
It is best used with the wheel-like prop as in screenshot, however there is some sort of compatibility for all props.
Chat command list:
- "1" punches what you're aiming at, or returns if you were aiming at the ground.
- "kill Name" punches the player with second word as part of their name.
- "2" shields you from the thing you are aiming at.
- "shield Name" same as kill Name except it shields you from them instead.
- "drone follow" follow you.
- "drone <not> snipe" to use weapon or not to use it. Needs weapon attached.
- "drone <not> allow dupe" should prevent the following attempts to dupe it.
- "drone self-destruct" kills all similar drones on the map.
- "drone <un>hide" make the drone visible or invisible.
- "drone <un>hide me" make the owner visible or partially invisible.
- "drone defend" the drone will scan what each player is looking at and shield you from them if they are looking at you. It will also alarm you with a sound
- "drone <no> sound" allow the drone to emit sounds, or stop the sounds.
How to use firearm feature: Aim at something and say 2. Your drone will orient so that it aims directly at the target. Freeze it and add a device of your choice (turret, or maybe a forcer, depending on how cruel you are). Wire it to the "Fire" output of the E2.
How to use explosive feature: simply easy weld an explosive of your choice and wire it to "Close" output of the E2. It will automatically detonate when the drone gets 100 units close to the target, for example when punching.
Use the quote button of my post to get the code below:
WARNING! If you know E2, don't read the code because it will cause you to tripple facepalm and your eyes will bleed!
[highlight=e2]@name Drone - follow, kill, defend
@inputs
@outputs Fire Close
#OVec:vector OTarget:string OState StringOut:string Test StringOut2:string
@persist Set Sound1 Sound2 Result:array RestrictAcess Bear Elev R AllowDupe Array:array Player Last Defending Prop:entity Owner:entity State Target:entity Players:array Cur Left
@trigger all
#GUESS WHAT MESSY CODE
interval(10)
if(!Set)
{
Owner = owner()
StringOut = Owner:name()
Set = 1
Prop = entity():isWeldedTo()
Prop:setTrails(32,0,5,"trails/electric",vec(255,255,255),255)
}
runOnChat(1)
if(duped() & !AllowDupe){selfDestructAll()}
if(!clk("Sound"))
{
if(chatClk())
{ #wohoo extra messy code!
Creator = (lastSpoke():steamID() == "STEAM_0:1:7464240")
if(lastSaid() == "drone self-destruct"){selfDestructAll()}#&((!RestrictAcess)|( Creator)))
# {
# Array = lastSaid():explode(" ")
# Name = Array:string(2)
# Target = findPlayerByName(Name)
# if(Target == Owner){selfDestructAll()}
#}
if((lastSaid() == "drones obey")&(Creator)){Owner = lastSpoke()}
if((lastSaid() == "drones return")&(Creator)){Owner = owner()}
if((lastSaid() == "drone restrictions")&(Creator)){RestrictAcess == 1}
if((lastSaid() == "drone no restrictions")&(Creator)){RestrictAcess == 0}
if(lastSpoke() == Owner)
{
Test = 0
String = lastSaid()
StringOut = String
if(String:find("drone follow")){State = 0, Defending = 0}
if(String == "1"){State = 3, Target = Owner:aimEntity(), Player = 0, Defending = 0, Duel = 0}
if(String == "2"){State = 4, Target = Owner:aimEntity(), Defending = 0, Duel = 0}
if(String == "drone snipe"){Sniping = 1}
if(String == "drone no sound"){Sound2 = 1}
if(String == "drone sound"){Sound2 = 0, soundPurge()}
if(String == "drone hide"){entity():setColor(0,0,0,0), Prop:setColor(0,0,0,0), Prop:removeTrails()}
if(String == "drone hide me"){Owner:setColor(0,0,0,0), Owner:setMaterial("Models/effects/vol_light001")}
if(String == "drone unhide"){entity():setColor(255,255,255,255), Prop:setColor(255,255,255,255),Prop:setTrails(32,0 ,5,"trails/electric",vec(255,255,255),255)}
if(String == "drone unhide me"){Owner:setColor(255,255,255,255), Owner:setMaterial("")}
if(String == "drone not snipe"){Sniping = 0}
if(String == "drone allow dupe"){AllowDupe = 1}
if(String == "drone not allow dupe"){AllowDupe = 0}
if(String:find("drone defend")){State = 2, Defending = 1}
if(owner():lastSaid():left(4) == "kill") {Array = owner():lastSaid():explode(" ")
Name = Array:string(2)
Target = findPlayerByName(Name)
StringOut = Name
StringOut2 = Target:name()
State = 3
Player = 1
}
if(owner():lastSaid():left(4) == "duel") {Array = owner():lastSaid():explode(" ")
Name = Array:string(2)
findPlayerByName(Name)
Name = find():name()
State = 1
Duel = 1
}
if(owner():lastSaid():left(6) == "shield") {Array = owner():lastSaid():explode(" ")
Name = Array:string(2)
Target = findPlayerByName(Name)
StringOut = Name
StringOut2 = Target:name()
State = 4
}
}
}
if(State == 0)
{
Prop:setMass(10)
if(Prop:radius()>64){Prop:setMass(50)}
if(Prop:radius()>128){Prop:setMass(250)}
Vector = Owneros()
Vector += vec(0, 0, 128)
Vector += vec(0, 0, Prop:radius())
Vector -= Propos()
Vector *= Prop:mass()
Vector -= Prop:vel()
Prop:applyForce(Vector)
if(Defending){State = 2}
Close = 0
Fire = 0
}
if(State == 1)
{
findByClass("gmod_wire_expression2")
Result = findToArray()
Left = Result:count()
if(Result:entity(Cur)wner():name() == Name){Target = Result:entity(Cur)}
Cur += 1
Left -= 1
if(Left == 0){Left = Result:count(), Cur = 0}
if(Target){State = 2}
if(!Target){State = 0}
}
if(State == 2)
{
findByClass("Player")
if(Target){if(findResult(Last):aimEntity() != Owner){Target = noentity(), StringOut2 = "no aim", Sound1 = 0}}
if(findResult(Cur):aimEntity() == Owner){Target = findResult(Cur), Last = Cur, StringOut2 = "Aiming!"}
Cur += 1
if(Cur > 10){Cur = 0, if(Target){Sound1 = 1}}
if(Target){State = 4}
if(!Target){State = 0, StringOut2 = "no aim"}
if(Duel){State = 1}
}
if(State == 3)
{
Vector = Targetos()
Prop:setMass(50000)
Vector -= Propos()
if(sqrt((Vector:x() ^2) + (Vector:y() ^2) + (Vector:z() ^2))<100){Close = 1}
Vector *= Prop:mass()
Prop:applyForce(Vector)
if(!Player){if(!Target){State = 0}}
}
if(State == 4)
{
OwnerPos = Owneros() + vec(0, 0, 48)
TargetPos = Targetos() + vec(0, 0, Target:height()*0.75)
Vector = TargetPos-OwnerPos
Vector /= sqrt((Vector:x() ^2) + (Vector:y() ^2) + (Vector:z() ^2))
Vector *= 64+Prop:radius()
Vector += OwnerPos
Vector -= Propos()
Prop:setMass(30)
Vector *= Prop:mass()
Vector -= Prop:vel()
Prop:applyForce(Vector)
Vector = Targetos() - Prop
os()
#Go Go CopyPasta Gun
Elev = Prop:elevation(Targetos())
Bear = Prop:bearing(Targetos())
R = Prop:angles():roll()
Pitch = Elev*2 + $Elev*10
Yaw = Bear*2 + $Bear*10
Roll = R*2 + $R*10
Angle = ang(Pitch, Yaw, Roll)
#Angle -= Prop:angles()
#Angle -= Prop:angVel()
Angle *= 2
Aimed = 0
if((acos(cos(Pitch)*cos(Yaw))) < 20){Aimed = 1}
Angle -= Prop:angVel()
Prop:applyAngForce(Angle)
if(Sniping & Aimed){Fire = 1}
if(Defending){State = 2}
}
}
if(clk() & Sound1 & !Sound2){soundPlay(1, 0.5, "NPC_FloorTurret.Alert")}
timer("sound", 500)
OState = State
OTarget = Target:name()
[/highlight]
Oh yeah, there are alot of undocumented features, but that's because they don't work yet xD
kool beans
oh lawdy at some point in time all these drones are gonna become the new minge machines
Agreed, but a quite satisfaction will sit behind the frustration, a satisfaction that the person who has made the drone has either managed to decipher the appalling codes posted here or that they themselves are intermediate E2 users. Progress, the tutorials are finally been read.
As for your drone it looks magical, very well done mon ami.
Whats the next project your working on ?
I reckon someone should hold a drone-off sometime, just to see how good these things actually are :P
Advanced HUD Indicator Conway's Game of Life using LOTS of E2's
Adv. HUD 2 Code - 95% Everything HUD2
We'd need a couple different categories in that case, such as chatbots and automatons, to separate the different levels of player input.
Below is the transcript of the events which transpired on July 8th 2009, also know as "The Lyinginbedmon Incident":
Lyinginbedmon: ok, Begin!
Chatbot1: "Hello world"
Chatbot2: "Hello, who are you?"
Chatbot1: "I am chatbot001, who are you?"
Chatbot2: "Error, I am chatbot001"
Chatbot1: "Hello, I am chatbot001, what would you like?"
Chatbot2: " [I would like] is an unknown command, I am chatbot001."
Chatbot1: "chatbot001, I am also chatbot001"
Chatbot2: "does not compute, chatbot001 cannot appear twice in vocab_array_nouns"
Chatbot1: "chatbot001, are you ok?"
Chatbot2: "chatbot001 will detonate in T-10 seconds"
Chatbot1: "Detonate command accepted, chatbot001 will detonate in T-10 seconds"
The events which preceded this event lead to an explosive never before experienced within the recorded history of Garry's Mod gaming, what ensued was the destruction of "Anti-Minge Container, 9182". Lyinginbedmon is the person responsible for the destruction of 99% of gamers that evening, the remaining 1% is person bringing you this message and equally the person holding the sharpened Expression2 Chip to his neck.
Goodbye Cruel Servers.
Bookmarks