Here's a couple of E2s that I made and that I thought could be usefull,
Feel free to use or pass on, If you have any questions on these or just some E2 advice contact me;
[email]Lemmingz95@Gmail.com[/email]
Includes :
[list]
[*]Npc control,
[*]Hunter killer drone,
[*]Lift/Drag simulator
[/list]
[B]Lift / Drag Simulator[/B]
An E2 that once welded to a prop simulates lift and drag using modern lift equation ( Sort of )
[list]
[*]To change the amount of lift generated change the angle of the wings.
[*]Works Best Using A Cuboid or Triangle.
[*]Works similarly to [post=29001731]XXXmag's[/post] code but neater and eliminates the bug where wings at vertical pitch would slam into the ground.
[/list]
[code]
@name Aerofoil
@inputs
@outputs Wing_Speed Wing_Area Wing_Pitch Wing_Brake:vector Coefficient Drag:vector Lift:vector Wing_Area_T
@model models/cheeze/beta/white_button.mdl
@persist Wing:entity
interval(10)
if(first() | duped()) {
print("Expression by Lemmingz.")
}
entity():setColor(225,175,50)
Wing =entity():isWeldedTo()
Wing_x=toUnit("m", Wing:boxSize():x())
Wing_y=toUnit("m", Wing:boxSize():y())
Wing_z=toUnit("m", Wing:boxSize():z())
Wing_Forward=Wing:forward()
Wing_Speed=toUnit("m/s", entity():vel():length())
Wing_Pitch=abs(Wing:angles():pitch())
Wing_Area=((sin(Wing_Pitch)*Wing_x)*Wing_y) + ((sin(90-Wing_Pitch)*Wing_z)*Wing_y)
Wing_Area_T=(Wing_x*Wing_y)
Wing_Vel=Wing:vel()
Drag = -Wing_Vel * Wing_Area
Coefficient = 2 * pi() * (((-abs(Wing:angles():pitch())+180)) * 0.0174532925)
Lift = Wing:up() * vec( 0 , 0 , (Coefficient * 1.225 * (Wing_Speed*10) * (Wing_Area) * 0.5 ))
Wing:applyForce(Drag)
Wing:applyForce(Lift)
[/code]
[B]Npc Control[/B]
[list]
[*]Stick the E2 anywhere and spawn up to four Npcs
[*]To change the Npc controlled substitute "Npc_metropolice" for another string eg "npc_fastzombie"
[*]In passive mode the controlled Npcs will follow you, when mouse one is pressed they become aggressive, moving to your aim position and attacking any other player.
[*][B]*BUG*[/B] - move to far from the Npcs and they will cease following you, would be good if anyone can sort that.
[/list]
[code]
@name NpcControl
@inputs
@outputs
@persist NPC:entity
if(first() | duped()) {
print("Expression by Lemmingz.")
}
interval(10)
Owner = owner()
OwnerPos = Owner:pos()
TargetPos = Owner:aimPos()
if(Owner:keyAttack1()) {
Kill=1
} else {Kill=0}
findByClass("npc_metropolice")
NPC = findResult(1)
NPC1 = findResult(2)
NPC2 = findResult(3)
NPC3 = findResult(4)
NPC:npcRelationship(Owner,"like",800)
NPC1:npcRelationship(Owner,"like",800)
NPC2:npcRelationship(Owner,"like",800)
NPC3:npcRelationship(Owner,"like",800)
if (Kill) {
NPC:setColor(250,250,0)
NPC1:setColor(250,250,0)
NPC2:setColor(250,250,0)
NPC3:setColor(250,250,0)
NPC:npcRelationship("player","hate",900)
NPC1:npcRelationship("player","hate",900)
NPC2:npcRelationship("player","hate",900)
NPC3:npcRelationship("player","hate",900)
interval(1000)
Pos=OwnerPos
DPos = NPC:pos() - TargetPos
WalkPos = TargetPos + DPos:normalized()*100
if (DPos:length()>120) {NPC:npcGoRun(WalkPos)} else {NPC:npcStop()}
DPos1 = NPC1:pos() - TargetPos
WalkPos1 = TargetPos + DPos1:normalized()*100
if (DPos1:length()>120) {NPC1:npcGoRun(WalkPos1)} else {NPC1:npcStop()}
DPos2 = NPC2:pos() - TargetPos
WalkPos2 = TargetPos + DPos2:normalized()*100
if (DPos2:length()>120) {NPC2:npcGoRun(WalkPos2)} else {NPC2:npcStop()}
DPos3 = NPC3:pos() - TargetPos
WalkPos3 = TargetPos + DPos3:normalized()*100
if (DPos1:length()>120) {NPC3:npcGoRun(WalkPos3)} else {NPC3:npcStop()}
} else {
interval(1000)
NPC:setColor(0,250,250)
NPC1:setColor(0,250,250)
NPC2:setColor(0,250,250)
NPC3:setColor(0,250,250)
NPC:npcRelationship("player","neutral",900)
NPC1:npcRelationship("player","neutral",900)
NPC2:npcRelationship("player","neutral",900)
NPC3:npcRelationship("player","neutral",900)
Pos=OwnerPos
DPos = NPC:pos() - OwnerPos
WalkPos = OwnerPos + DPos:normalized()*100
if (DPos:length()>120) {NPC:npcGoRun(WalkPos)} else {NPC:npcStop()}
DPos1 = NPC1:pos() - OwnerPos
WalkPos1 = OwnerPos + DPos1:normalized()*100
if (DPos1:length()>120) {NPC1:npcGoRun(WalkPos1)} else {NPC1:npcStop()}
DPos2 = NPC2:pos() - OwnerPos
WalkPos2 = OwnerPos + DPos2:normalized()*100
if (DPos2:length()>120) {NPC2:npcGoRun(WalkPos2)} else {NPC2:npcStop()}
DPos3 = NPC3:pos() - OwnerPos
WalkPos3 = OwnerPos + DPos3:normalized()*100
if (DPos3:length()>120) {NPC3:npcGoRun(WalkPos3)} else {NPC3:npcStop()}
}
[/code]
[B]Hunter Killer Drone[/B]
[list]
[*]Stick the E2 to a prop, no lighter than a PHX 4x4 ( Else the stabilisation spazzes out), and spawn a target finder with maximum range, target players and targets to track : 1
Wire the Targ input to the target finder entity output.
Spawn a saw-blade and make it a wire prop-spawner then weld it to the centre-bottom or the prop that the chip is welded to.
wire the spawn input of the prop-spawner to the Fire output of the chip
Release upon your hapless victims!
[*]To change the prop fired (eg. to an explosive barrel) substitute the sawblade path, In the missile section (findByModel("[B]models/props_junk/sawblade001a.mdl[/B]") for the for another prop.
[/list]
Features :
[list]
[*]Auto stabilization
[*]Props are flung with apply force to preserve user anonymity.
[*]Crushes players who attempt to jump atop it
[*][B]WARNING TO MINGES[/B] This chip has a rather high Op count so it will very probably be removed by an admin, also is incredibly annoying to builders so will probably get you kicked/banned, [B] You Have Been Warned! [/B]
[/list]
[code]
@name Drone_e2
@inputs Targ:entity
@outputs Ent_Gyro:angle Height_Diff Forward Backward Up_Var Dn_Var PosM:vector TargetM:entity FwM:vector Target2M:entity Fw2M:vector Fire Fire_count
@persist Weld:entity Diff_A:vector Diff_B:vector
if(first() | duped()) {
print("Expression by Lemmingz.")
}
runOnTick(1)
# Declaring Variables
Ent = entity():isWeldedTo()
Ent_Gyro = -Ent:angles()*1000
Target=Targ
# Colouring
Ent:setAlpha(0)
entity():setAlpha(0)
#Gyroscopic stabilization
Ent:applyAngForce((Ent_Gyro + $Ent_Gyro*5):setYaw(0) * (Ent:mass()))
# Turning
Ent_Bearing = Ent:bearing(Target:pos())
if(Ent_Bearing>1) {T_Left=0 , T_Right=1 , Fire=0} elseif (Ent_Bearing<-1) {T_Left=1 , T_Right=0 , Fire=0} else {T_Left=0 , T_Right=0 , Fire=1}
if(Ent_Bearing>1) {Vel_Brake=0} elseif (Ent_Bearing<-1) {Vel_Brake=0} else {Vel_Brake=1}
if(Ent_Bearing>15) {Vel_Brake_I=0} elseif (Ent_Bearing<-15) {Vel_Brake_I=0} else {Vel_Brake_I=1}
# Defining Movement variables
FW =(((Target:shootPos()-Ent:pos())*2-Ent:vel())*Ent:mass())
BK = -Ent:forward() * (Ent:mass()) *20
if(T_Left == 1) {Ent:applyAngForce(Ent:angles():setYaw(40) * (Ent:mass()) *100)}
if(T_Right == 1) {Ent:applyAngForce(Ent:angles():setYaw(-40) * (Ent:mass()) *100)}
if(Forward == 1) {Ent:applyForce(FW)}
if(Backward == 1) {Ent:applyForce(BK)}
if(Height_Diff>40) {Dn_Var=1} else {Dn_Var=0}
if(Dn_Var==1) {UP= -Ent:up() * (Ent:mass()) *50} else {UP=Ent:up() * (Ent:mass()) *20}
if(Dn_Var!=1) {if(Ent:pos():z()-50<Target:pos():z()) {Ent:applyForce(UP) , Up_Var=1} else {Up_Var=0}} else {Up_Var=1}
# Velocity brake
if(Vel_Brake==1) {
Ent_angvel = -Ent:angVel() * (Ent:mass() * 100)
Ent:applyAngForce(Ent_angvel)}
# Velocity brake I
if(Vel_Brake_I==1) {
Ent_angvel = -Ent:angVel() * (Ent:mass() * 55)
Ent:applyAngForce(Ent_angvel)}
# Velocity brake II
Ent_angvel_II=Ent:angVel()
if(Ent_angvel_II:yaw()>200) {
Ent_angvel = -Ent:angVel() * (Ent:mass() * 75)
Ent:applyAngForce(Ent_angvel)}
if(Ent_angvel_II:yaw()<-200) {
Ent_angvel = -Ent:angVel() * (Ent:mass() * 75)
You should be able to govern the npcs with an array, thus eliminating the four npc limit, and simplifying the code in general. Just a little advice
Sorry, you need to Log In to post a reply to this thread.