Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @name TeleCheese
- @persist Props:array Target:entity Focus:vector X
- if(first()|dupefinished()){
- runOnTick(1)
- X = 0
- findIncludePlayerProps(owner())
- }
- elseif(changed(first())|changed(dupefinished())){
- entity():setMaterial("models/wireframe")
- entity():setColor(vec4(25,25,255,255))
- }
- else{
- findByClass("prop_physics")
- Props = array()
- foreach(EI,Ent:entity = findToArray()){
- if(!Ent:isFrozen()){
- Ent:setMass(5)
- Props:pushEntity(Ent)
- }
- else{
- Ent:setColor(vec(255))
- Ent:setMaterial("")
- }
- }
- X += 1
- if(X%20 == 1){
- foreach(EI,Ent:entity = Props){
- Ent:setColor(vec(180,25,25))
- Ent:setMaterial("models/debug/debugwhite")
- Ent:setAlpha(255)
- }
- }
- if(changed(owner():isFlashlightOn())){
- if(owner():isFlashlightOn()){
- Focus = owner():aimPos()
- Dist = array()
- foreach(PI,Ply:entity = players()){
- if(Ply != owner() & Ply:isAlive()){
- Dist[PI,number] = Ply:shootPos():distance(Focus)
- }
- else{
- Dist[PI,number] = 200000
- }
- }
- if(Dist:min() <= 1000){
- Target = players()[Dist:minIndex(),entity]
- }
- else{
- Target = noentity()
- }
- }
- }
- else{
- foreach(EI,Ent:entity = Props){
- if(owner():isFlashlightOn()){
- if(Target:isValid()){
- if(Target:isAlive()){
- Dir = Target:shootPos() - Ent:pos()
- }
- else{
- Target = noentity()
- }
- }
- else{
- Dir = Focus - Ent:pos()
- }
- Ent:setMass(200000000)
- Ent:applyForce((Dir * 500)*Ent:mass())
- }
- else{
- Ent:setMass(4)
- Dir = (owner():pos() + vec(sin(curtime()*50+360*(EI/Props:count()))*(30*Props:count()),cos(curtime()*50+360*(EI/Props:count()))*(30*Props:count()),150))-Ent:pos()
- Ent:applyForce((Dir*2 - Ent:vel()*0.1)*Ent:mass())
- }
- Ent:applyTorque((-Ent:angVelVector())*Ent:inertia())
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment