FN_SERVER_NAME<-"server_FN"
FN_TIMER_NAME<-"timer_FN"
FN_TARGET_NAME<-"FN_target"
FN_PROP_NAME<-"FN_prop"
try{if(FN_P_C>0){}}catch(e){FN_P_C<-0}
FN_MODEL_PATH<-"models/fortnite/"
FN_MODEL_PATH_ARR<-["stairs","floor-ceiling","wall"]
FN_MAX_LEN<-190
FN_HEALTH<-3
FN_GUNS<-"knife"
function FN_CreateServer(s=null){
if(Entities.FindByName(null,FN_SERVER_NAME)==null){
s=Entities.CreateByClassname("point_servercommand");
SetKeyValue(s,"targetname",FN_SERVER_NAME)
SetKeyValue(s,"classname","soundent")
}
}
function FN_CreateTimer(t=null){
if(Entities.FindByName(null,FN_TIMER_NAME)==null){
t=Entities.CreateByClassname("logic_timer");
SetKeyValue(t,"targetname",FN_TIMER_NAME)
SetKeyValue(t,"classname","soundent")
SetKeyValue(t,"RefireTime",0.01)
ent_fire(t,"addoutput","OnTimer "+FN_SERVER_NAME+":command:script FN_Cheack()::")
ent_fire(t,"Enable")
}
}
function FN_RegPlayers(p=null,scope=null){
while((p=Entities.FindByClassname(p,"player"))!=null)
if(p.GetName()==""){
FN_P_C++;
SetKeyValue(p,"targetname","player_"+FN_P_C)
p.ValidateScriptScope()
scope=p.GetScriptScope()
scope.prop<-FN_CreateProp()
scope.game_ui<-FN_CreateGameUI(p)
scope.forward<-Vector(0,0,0)
scope.access<-false
scope.spawned<-false
scope.obj<-FN_CreateObject(0)
scope.model_num<-0
scope.place<-function(s=null){
s=self.GetScriptScope();
if(WeaponInHand(self)&&s.access){
FN_CreateObjectServer()
s.spawned<-true
}
}
scope.activate<-function(s=null){
s=self.GetScriptScope();
ent_fire(s.game_ui,"activate","",0,self,self)
SetKeyValue(s.game_ui,"spawnflags",0)
}
scope.changemodel<-function(s=null){
s=self.GetScriptScope()
s.model_num+=1
if(s.model_num>=3)s.model_num=0
FN_CreateObject(s.model_num,s.obj)
}
}
}
function FN_CreateGameUI(p,ui=null){
ui=Entities.CreateByClassname("game_ui")
SetKeyValue(ui,"FieldOfView",-1.0)
SetKeyValue(ui,"classname","soundent")
ent_fire(ui,"addoutput","PressedAttack !activator:runscriptcode:place():0.01:")
ent_fire(ui,"addoutput","PressedAttack2 !activator:runscriptcode:changemodel():0.01:")
ent_fire(ui,"activate","",0,p,p)
return ui
}
function FN_CreateObject(num=0,obj=null){
if(obj==null) obj=Entities.CreateByClassname("prop_dynamic")
obj.PrecacheModel(FN_MODEL_PATH+FN_MODEL_PATH_ARR[num]+".mdl")
obj.SetModel(FN_MODEL_PATH+FN_MODEL_PATH_ARR[num]+".mdl")
obj.SetForwardVector(Vector(0,0,0))
SetKeyValue(obj,"rendermode",1)
SetKeyValue(obj,"classname","soundent")
ent_fire(obj,"alpha","170")
ent_fire(obj,"disablecollision")
SetKeyValue(obj,"rendercolor","0 255 0")
return obj
}
function FN_ObjectPlace(p,obj=null,num=null){
num=p.GetScriptScope().model_num
obj.PrecacheModel(FN_MODEL_PATH+FN_MODEL_PATH_ARR[num]+".mdl")
obj.SetModel(FN_MODEL_PATH+FN_MODEL_PATH_ARR[num]+".mdl")
obj.SetOrigin(p.GetScriptScope().obj.GetOrigin())
ent_fire(obj,"sethealth",""+FN_HEALTH)
ent_fire(obj,"addoutput","OnTakeDamage !self:removehealth:1::")
obj.SetForwardVector(p.GetScriptScope().obj.GetForwardVector())
}
function WeaponInHand(player,g=null){
while((g=Entities.FindByClassname(g,"predicted_viewmodel"))!=null){
if(g.GetMoveParent()==player){
if(g.GetModelName().find(FN_GUNS)>=0)return true
}
}
return false
}
function FN_Cheack(p=null,scope=null){
FN_RegPlayers()
while((p=Entities.FindByClassname(p,"player"))!=null){
scope=p.GetScriptScope();
if(p.GetName()!="" && WeaponInHand(p)) {
FN_Trace(p)
}else{
ent_fire(scope.obj,"disabledraw")
}
}
}
function FN_CreateObjectServer(){
SendToConsole("prop_dynamic_create fortnite/stairs.mdl")
}
function FN_FindObjectSpawned(p,obj=null){
while((obj=Entities.FindByClassname(obj,"*"))!=null){
obj.ValidateScriptScope()
if(obj.GetModelName()=="models/fortnite/stairs.mdl" && !("finded" in obj.GetScriptScope())){
FN_ObjectPlace(p,obj)
obj.GetScriptScope().finded<-true
p.GetScriptScope().spawned<-false;
}
}
}
function FN_Trace(p,scope=null,vec1=null,len=null,forward=null,angles=null,point=null,target=null,spawn=null){
scope=p.GetScriptScope();
forward=scope.prop.GetForwardVector()
angles=scope.prop.GetAngles()
vec1=p.EyePosition()
if(vec1.x%128<=-64)vec1.x=vec1.x-vec1.x%128-128
if(vec1.x%128>=64)vec1.x=vec1.x-vec1.x%128+128
if(vec1.y%128<=-64)vec1.y=vec1.y-vec1.y%128-128
if(vec1.y%128>=64)vec1.y=vec1.y-vec1.y%128+128
if(p.GetOrigin().z<=0)vec1.z-=97
vec1.x=vec1.x-vec1.x%128
vec1.y=vec1.y-vec1.y%128
vec1.z=vec1.z-vec1.z%97
point=Vector(0,0,0)
//DebugDrawBox(vec1, Vector(-10,-10,-10), Vector(10,10,10), 255, 0,0, 255, 0.1)
if(abs(angles.y)>=45&&abs(angles.y)<=135){
scope.obj.SetForwardVector(Vector(0,forward.y,0))
} else scope.obj.SetForwardVector(Vector(forward.x,0,0))
if(angles.y<45&&angles.y>-45)point=Vector(128,0,0)
if(angles.y>45&&angles.y<135)point=Vector(0,128,0)
if(angles.y>135||angles.y<(-135)) point=Vector(-128,0,0)
if(angles.y>(-135)&&angles.y<(-45))point=Vector(0,-128,0)
if(scope.model_num!=2){
if(angles.y<(-18)&&angles.y>-70)point=Vector(128,-128,0)
if(angles.y>18&&angles.y<70)point=Vector(128,128,0)
if(angles.y>108&&angles.y<160)point=Vector(-128,128,0)
if(angles.y>(-162)&&angles.y<(-109))point=Vector(-128,-128,0)
}
if(angles.x>45)point.z-=97
if(angles.x<(-45))point.z+=97
point=point+vec1
len=point-p.EyePosition()
len=len.Length2D()
if(scope.model_num==2){
angles=scope.obj.GetAngles()
if(angles.y==0) point.x-=64
if(angles.y==90) point.y-=64
if(angles.y==180) point.x+=64
if(angles.y==270) point.y+=64
}
//DebugDrawLine(vec1,point,125,125,255,false,2)
spawn=true
while((target=Entities.FindByClassname(target,"*")) != null){
if(target.GetModelName()==scope.obj.GetModelName()){
if(point.x==target.GetOrigin().x&&point.y==target.GetOrigin().y&&point.z==target.GetOrigin().z){
if(target!=scope.obj){
spawn=false
break}}}
}
if(spawn&&len<=FN_MAX_LEN){
ent_fire(scope.obj,"enabledraw")
scope.access=true
scope.obj.SetOrigin(point)
if(scope.spawned) FN_FindObjectSpawned(p)
}else {
scope.access=false
ent_fire(scope.obj,"disabledraw")
}
}
function FN_CreateProp(prop=null,logic=null,target=null){
prop=Entities.CreateByClassname("prop_dynamic_override")
SetKeyValue(prop,"targetname",FN_PROP_NAME+FN_P_C)
SetKeyValue(prop,"rendermode",1)
SetKeyValue(prop,"classname","soundent")
prop.SetModel("models/weapons/w_snip_awp_mag.mdl")
logic=Entities.CreateByClassname("logic_measure_movement");
SetKeyValue(logic,"MeasureType",1)
SetKeyValue(logic,"classname","soundent")
ent_fire(logic,"settargetscale","1000")
ent_fire(logic,"setmeasurereference",FN_TARGET_NAME+FN_P_C)
ent_fire(logic,"settargetreference",FN_TARGET_NAME+FN_P_C)
ent_fire(logic,"setmeasuretarget","player_"+FN_P_C)
ent_fire(logic,"settarget",FN_PROP_NAME+FN_P_C)
ent_fire(logic,"Enable")
target=Entities.CreateByClassname("info_target");
SetKeyValue(target,"targetname",FN_TARGET_NAME+FN_P_C)
SetKeyValue(target,"classname","soundent")
return prop;
}
function ent_fire(target,action,value="",delay=0,activator=null,caller=null){
switch(typeof target){
case "string":{{EntFire(target,action,value,delay,activator)}{break}}
case "instance":{{EntFireByHandle(target,action,value,delay,activator,caller)}{break}}
}
}
function SetKeyValue(handle,key,value){
switch(typeof value){
case "float":{{handle.__KeyValueFromFloat(key,value)}{break}}
case "integer":{{handle.__KeyValueFromInt(key,value)}{break}}
case "string":{{handle.__KeyValueFromString(key,value)}{break}}
case "Vector":{{handle.__KeyValueFromVector(key,value)}{break}}
}
}
function FN_Start(){
FN_CreateServer()
FN_CreateTimer()
}
FN_Start()