EXP2: NPC_Avatar

Hello!
I want to present my project in exp2 chip!

It can do:

  1. Move NPC with WASD buttons
  2. Walk and Run
  3. Rotate with your mouse
  4. By pressing “R” give weapon to NPC
  5. Attack other NPC’s and players

And I want to hear you ideas how use this chip.:slight_smile:


@name NPC_avatar
@inputs Control:wirelink
@outputs Pos:vector Ang:angle NPCpar:entity
@persist NPC:entity Target:entity V:vector Flag Go
@trigger none

runOnTick(1)

if(first()){
    holoCreate(1) #need to set view
    Flag = 1 #need to set camera
}

X = -owner():eye():x()*100
Y = owner():eye():y()*100

if(!NPC){
    R = ranger(500) #need to find NPC
    holoPos(1,entity():toWorld(vec(Y,X,0)))
    holoAlpha(1,255)
}else{
    holoAlpha(1,0)
}

if(R:entity() & !NPC & R:entity():isNPC()){
    hint("NPC set",10)
    NPC = R:entity()
    hint(toString(NPC),5)
    NPC:npcRelationship(owner(),"like",1)
}

if(NPC){    
    Ang = owner():eyeAngles()
    
    if(Flag){
        timer("SetCam",200)
        Flag = 0
    }
    if(Control:number("Active") & clk("SetCam")){
        Height = NPC:height()
        Pos = NPC:toWorld(vec(-40,0,Height+10)) #Fixed
    }

    if(Control:number("Active")){NPCpar = NPC}else{NPCpar = entity()}
    
    NPC:npcFace(entity():toWorld(vec(Y,X,0))) #facing NPC. If you will have problems with this part of code tell me, I'll explain.
    
    V = vec(0,0,0)
    if(Control:number("W")){
        V += vec(150,0,0)
    }elseif(Control:number("S")){
        V += vec(-150,0,0)
    }
    
    if(Control:number("A")){
        V += vec(0,150,0)
    }elseif(Control:number("D")){
        V += vec(0,-150,0)
    }
    
    if(Control:number("W") | Control:number("A") | Control:number("S") | Control:number("D")){
        if(Go == 0 | Go > 3){timer("Go",50)}else{timer("Go",400)} #There is some bug with movement in far distanse from chip.. This fix it.
        if(clk("Go")){ 
            if(Control:number("Shift")){
                NPC:npcGoRun(NPC:toWorld(V))
                    Go++
            }else{
                NPC:npcGoWalk(NPC:toWorld(V))
                    Go++
            }
        }
    }elseif(Control:number("Mouse1")){ #Attack NPC
        timer("Attack",1000)
        if(clk("Attack")){
            hint("Fire",3) 
            findInSphere(NPC:pos(),1000)
            findClipToClass("npc_*")
            findClipFromModel(NPC:model())
            Target = findClosest(NPC:pos())
            if(Target){
                hint("FIND!"+toString(Target),3)
                NPC:npcRelationship(Target,"hate",1)
            }
        }
    }elseif(Control:number("Mouse2")){ #Attack players
        timer("Attack2",1000)
        if(clk("Attack2")){
            hint("Fire",3) 
            findInSphere(NPC:pos(),1000)
            findClipToClass("player")
            findClipFromName(owner():name())
            Target = findClosest(NPC:pos())
            if(Target){
                hint("FIND!"+toString(Target),3)
                NPC:npcRelationship(Target,"hate",1)
            }
        }
    }elseif(Control:number("R")){ #Give SMG
        NPC:npcGiveWeapon()    
    }elseif(Control:number("Alt")){ #Say sound file..)
        NPC:soundPlay(1,5,"vo/Breencast/br_tofreeman02.wav")
    }else{
        NPC:npcGoRun(NPC:pos())
        Go = 0
    }
}

if(!Control:number("Active")){
    Flag = 1
}


Fill free with edit and add new =)

P.S. Oh… I have forgotten to tell… For this chip you need a chear, adv. pod controller on it and a cam controller.

  1. Spawn chear and AdvPod on it, plate, E2 and CC on it.
    1.1) Rotate plate! The cube must be in front of you and in front of plate.
  2. Create wirelink between E2 and adv.pod
  3. Wire CC pos, angle and parent to chip.
  4. Wire CC Active to AdvPod active
  5. Spawn NPC on chip (it use ranger to set NPC)
  6. Have fun =)

P.S. Hello from Russia! And sorry for my English

p fucking cool man

Saw this on wiremod.com. Not really much of a contraption but still awesome!

really fucking awesome :buddy:

There is a bed position version on the wiremod forums. It is useful for Avatar machines, I made one from bathtubs.

Reminds me of that surrogates movie, Now if only you could control where they shoot.

Omfg epic!

This part of code for bed position:


@name NPC_avatar
@inputs Control:wirelink
@outputs Pos:vector Ang:angle NPCpar:entity
@persist NPC:entity Target:entity V:vector Flag Go
@trigger none

runOnTick(1)

if(first()){
    holoCreate(1) #need to set view
    Flag = 1 #need to set camera
}

X = -owner():eye():x()*100
Y = owner():eye():y()*100
Z = owner():eye():z()*100

if(!NPC){
    R = ranger(500) #need to find NPC
    #holoPos(1,entity():toWorld(vec(Y,X,0)))
    holoPos(1,entity():toWorld(vec(Y,Z,0)))
    holoAlpha(1,255)
}else{
    holoAlpha(1,0)
}

if(R:entity() & !NPC & R:entity():isNPC()){
    hint("NPC set",10)
    NPC = R:entity()
    hint(toString(NPC),5)
    NPC:npcRelationship(owner(),"like",1)
}

if(NPC){    
    #Ang = owner():eyeAngles() #Comment this if pod is upright
    
    if(Flag){
        timer("SetCam",200)
        Flag = 0
    }
    if(Control:number("Active") & clk("SetCam") | Control:number("Space")){
        Height = NPC:height()
        Pos = NPC:toWorld(vec(-40,0,Height+10)) #Fixed
    }
    
    if(Control:number("Active")){NPCpar = NPC}else{NPCpar = entity()}
    
    #NPC:npcFace(entity():toWorld(vec(Y,X,Z))) #facing NPC. If you will have problems with this part of code tell me, I'll explain.
    NPC:npcFace(entity():toWorld(vec(Y,Z,0))) #Facing if pod is upright
    Ang = NPC:eyeAngles() + ang(X,0,0) #Cam rotation if pod is upright


Holy crap, this is awesome.

Imagine all the possibilities if someone would use this in a machinima.

that looks great! does it /can you make it work with manhacks and city scanners?

Stalkeer from wiremod.com done this and share with me. Ask him for code and if he give it, be free to add here)