Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!
Spartan gunner
@name Spartan Gunner by Starkkz @inputs Seat:entity TargetFaction TargetCore TargetExclude:array TargetOwner TargetOwnerProps DisableFire @persist Anim:string LAnim:string @persist Pose:string LPose:string PoseAng LPoseAng @persist AIModel:string AIName:string AIColor:vector @persist FactionPlayers:array @persist Bot:entity Chip:entity @persist Moving TargetPosition:vector TargetAngle:angle @persist FallVelocity @persist UpdatingTarget TargetUpdated UpdateI LowestHeading:array @persist Targets:array @outputs Fire AimPos:vector Target:entity if (first()){ #Model of your AI AIModel = "models/voxelzero/player/voxelspartan.mdl" #Name of your AI AIName = "Spartan Gunner by Starkkz" #The color of your AI AIColor = vec(50, 50, 25) #Enable light effect AILight = 0 #Enable material effect AIMaterial = 0 Chip = entity() timer("updateFactionPlayers", 1) timer("updateTargetList", 1) timer("updateTarget", 1) timer("update", 1) function say(Text:string){ local Players = players() foreach (I, Player:entity = Players){ Player:plyPrintSimpleColor(AIName+": "+Text, AIColor) } } function entity coreEntity(){ if (Seat:isValid()){return Seat} local Core = Chip:getCoreEnt() return Core:isValid() ? Core : Chip } function parentAI(){ if (Seat:isValid()){ holoPos(1, Seat:pos()) holoAng(1, Seat:toWorld(ang(0, 90, 0))) holoParent(1, Seat) }else{ holoPos(1, Chip:pos()) holoParent(1, Chip) } } function deparentAI(){ holoUnparent(1) } function updateFactionPlayers(){ if (!TargetFaction){ FactionPlayers = array() local Players = players() local OwnerFaction = owner():getFaction() if (OwnerFaction != "Civilian"){ foreach (I, Player:entity = Players){ if (Player:getFaction() == OwnerFaction){ FactionPlayers:pushEntity(Player) } } } } timer("updateFactionPlayers", 5000) } function updateTargetList(){ local Owner = owner() findClearWhiteList() findClearBlackList() findExcludeEntities(TargetExclude) if (!TargetFaction){ findExcludeEntities(FactionPlayers) foreach (I, Player:entity = FactionPlayers){ findExcludePlayerProps(Player) } } if (!TargetOwner){findExcludePlayer(Owner)} if (!TargetOwnerProps){findExcludePlayerProps(Owner)} if (TargetCore){findIncludeClass("ship_core")} findIncludeClass("player") findInSphere(Bot:pos(), 9999999999999999999) Targets = findToArray() timer("updateTargetList", 5000) } function updateTarget(){ if (UpdatingTarget){ while (perf()){ if (UpdateI <= Targets:count()){ local Entity = Targets[UpdateI, entity] UpdateI = UpdateI + 1 if (Entity:isValid() & Entity:lsName() == "Space"){ local HeadingLength = vec(-Bot:heading(Entity:pos())):length() if (!LowestHeading[1, entity]:isValid() | HeadingLength < LowestHeading[2, normal]){ LowestHeading = array(Entity, HeadingLength) } } }else{ Target = LowestHeading[1, entity] LowestHeading = array() UpdateI = 0 timer("updateTarget", 1000) exit() } } }else{ UpdatingTarget = 1 TargetUpdated = 0 } timer("updateTarget", 1) } function update(){ if (Target:isValid() & coreEntity():lsName() == "Space" & Target:lsName() == "Space"){ Fire = !DisableFire AimPos = Target:pos() }else{ Fire = 0 AimPos = vec() } timer("update", 150) } function updateAI(){ local ParentEntity = Bot:parent() if (!ParentEntity:isValid()){ local BotPosition = Bot:pos() local MovementHeading = -heading(BotPosition, ang(), TargetPosition):setPitch(0) local RotationVector = MovementHeading:forward() local MiddlePosition = BotPosition + vec(0, 0, 48) local TempTargetPosition = TargetPosition:setZ(BotPosition:z()) local ForwardPosition = MiddlePosition + RotationVector * 20 local R = rangerOffsetHull(ForwardPosition, ForwardPosition, vec(20, 20, 10)) local R2 = rangerOffset(50, BotPosition + vec(0, 0, 30), vec(0, 0, -1)) if (R:hit() & TargetPosition != vec()){ Anim = "act_idle" Pose = "" PoseAng = 0 }elseif (R2:hit()){ local Distance = BotPosition:distance(TempTargetPosition) if (Distance > 300 & TargetPosition != vec()){ Anim = "run_all" Pose = "move_yaw" PoseAng = Bot:toLocal(MovementHeading):yaw() holoPos(1, R2:pos() + RotationVector * 25) }elseif (Distance > 40 & TargetPosition != vec()){ Anim = "walk_all" Pose = "move_yaw" PoseAng = Bot:toLocal(MovementHeading):yaw() holoPos(1, R2:pos() + RotationVector * 9) }else{ Anim = "act_hl2mp_idle_passive" Pose = "" PoseAng = 0 } }else{ Anim = "act_jump" Pose = "" PoseAng = 0 FallVelocity = FallVelocity ? FallVelocity + 5 : 10 local R3 = rangerOffset(FallVelocity, BotPosition, vec(0, 0, -1)) if (R3:hit()){ FallVelocity = 0 holoPos(1, R3:pos()) }else{ holoPos(1, BotPosition - vec(0, 0, 1) * FallVelocity) } } holoAng(1, ang(0, TargetAngle:yaw(), 0)) }else{ if (ParentEntity:isVehicle()){ Anim = "act_hl2mp_sit_passive" Pose = "" PoseAng = 0 }else{ Anim = "act_hl2mp_idle_passive" Pose = "" PoseAng = 0 } } if (LAnim != Anim){ LAnim = Anim holoAnim(1, Anim) } if (LPose != Pose | LPoseAng != PoseAng){ LPose = Pose LPoseAng = PoseAng holoSetPose(1, Pose, PoseAng) } timer("updateAI", 100) } Bot = holoCreate(1) holoModel(1, AIModel) if (AIMaterial){ holoMaterial(1, "models/wireframe") } holoColor(1, AIColor) if (AILight){ lightCreate(1) lightColor(1, AIColor) lightParent(1, Bot) } parentAI() updateAI() setName(AIName) }elseif (~Seat){ reset() }else{ ClkName = clkName() if (ClkName:length() > 0){ClkName()} }Simply a Spartan gunner made in E2, it targets automatically and fires while in space. I just would like to note that I made this for server #2.
Comments
we're not doing this AI/VI thing again are we
"I want you to show this world what it means to fear the sky."
... but are they ACTUALLY AI?
"I want you to show this world what it means to fear the sky."
Lλmbdλ: donations for coding the space future of diaspora :>
Get your extra long EVE trial here!