So, ive been making this for a while, and i cant seem to find anything else to add, so im just going to release it, there will be a v2 if i find anything i should add, and ill update the code here if i have minor fixes.
Wonderball is a expression 2 "pet", although its more of a sort of animal thing.
To put it in simple terms, its a ball with a top hat that rolls around, and has various abilities.
The only thing you need here is base wiremod svn (i think)
Features:
*randomly wanders around, and when i say randomly, i mean i have like 4 different ways that its random, based on how often, strong, and in what direction he pushes.
*sounds, it makes random sounds, of a rollermine, turn them off in the very first "if(first())" line, they are easily found.(im to lazy to make chat commands)
*runs on a battery, it runs on a battery, that is recharged by it rolling back to the plug.(when the battery reaches 0%, he will "die", which means he sits there not moving for a few minutes, and then gets a charge of like 20%, just to keep them from dying completely)
*hiding, i made this on an rp server (postnukerp), and if you turn the option on, he will hide from other players and certain props if they get close enough, this means (runs back to the charger, goes invisable, stops making sounds)
*Personality, this part is kind of dumb, but the ball changes random materials, and the name is different every time (it was going to have a mood system, where you could piss it off by throwing shit at it, or keeping it away from the charger, etc[maybe v2]), it also randomly looks around, based on his monocle.
*mini version (changed the code around, the mini version has a tinyer top hat, and is a smaller ball)
Instructions:
*spawn a plug (search "plug" in the q menu)
*spawn a wonderball, and unfreeze it
*if after 10-20 seconds his skin doesnt change, refresh the e2
Images:





heres the code for the wonderball
Code:
@name WonderBall Battery:Unknown
@inputs Avoid:entity
@outputs Battery Charging NoPlayer E:entity
@persist [V2 V]:vector [Players Sounds Mats Bros Plugs Names]:array
@persist [Name Mat]:string [Charger Player]:entity
@persist R ColR ColB Power SUPERRANDOM Face Hide ROB Low HighTail Percent Sound Dead NeedCharge
@model models/hunter/misc/sphere075x075.mdl
interval(100)
runOnChat(1)
E=entity()
#changing critical values
if(first())
{
Hide=0#allow it to hide
ROB=1#Run on battery?
Sound=1#Play sounds?
HighTail=20#speed to return to the charger upon battery drain
}
#brim- set the hat and monacle pos
holoPos(2,E:pos()+vec(0,0,15))
#face me you top hat!
if(Face&Battery>=1)
{
holoAng(2,ang(7,E:angles():yaw(),0))
holoAng(3,ang(7,E:angles():yaw(),0))
holoAng(4,ang(7,E:angles():yaw(),0))
}
#is i charging?
if(changed(Charging)&Charging)
{
holoColor(6,vec(0,255,0))
}
elseif(changed(Charging)&!Charging)
{
holoColor(6,vec(255,0,0))
}
elseif(changed(NeedCharge)&NeedCharge)
{
holoColor(6,vec(250,160,0))
}
#clamping battery
if(Battery>=100){Battery=100}
if(!ROB){Battery=100}
if(Battery<=0){Battery=0}
#Shut down sound/red
if(changed(Battery)&Battery<=0&!first()){
Dead=1
soundPlay(3,0,"ambient/energy/powerdown2.wav")
print(+Name+": "+owner():name()+", how could you let me die!")
print(+Name+": Dont worry, ill get a burst of juice from the sun in about 3 minutes")
E:setMass(50000)
timer("revive",180000)
}
elseif(changed(Battery)&Battery>0)
{
Dead=0
}
#give it a burst of juice after 5 minutes of being dead, just so they dont all die
if((clk("revive")|changed(Dead)&!Dead)&!first())
{
print(+Name+": Im back, and starting a new life!")
soundPlay(5,0,"ambient/explosions/citadel_end_explosion1.wav")
E:setMass(35)
Battery=30
}
#Lets you change the battery %
if(chatClk(owner()))
{
if(owner():lastSaid():explode(" "):string(1) == "/bat")
{
Percent=owner():lastSaid():explode(" "):string(2):toNumber()
}
}
if(changed(Percent)&!first()){Battery=Percent,print("Battery set to "+Percent+"%.")}
#Getting the color for the battery ring
if(changed(Battery)){setName("WonderBall: "+Name+" (Battery:"+round(Battery)+"%)")}
if(changed(Battery)&Battery >= 100){ColR = 0,ColB=255}
if(changed(Battery)&Battery >= 75&Battery<100){ColR = 90,ColB=230}
if(changed(Battery)&Battery >= 50&Battery<75){ColR = 150,ColB=100}
if(changed(Battery)&Battery >= 25&Battery<50){ColR = 230,ColB=90}
if(changed(Battery)&Battery >= 0&Battery<25){ColR = 255,ColB=0}
if(changed(Battery)&Battery <=1){ColR=0,BolB=0}
if(changed(ColR)|changed(ColB)){holoColor(4, vec(ColR,ColB,0))} #Setting that color
if(first())
{
Sounds=array(
"npc/roller/mine/rmine_blip1.wav",
"npc/roller/mine/rmine_blip3.wav",
"npc/roller/mine/rmine_chirp_quest1.wav",
"npc/roller/mine/rmine_taunt1.wav",
"npc/roller/mine/rmine_taunt2.wav",
"npc/roller/mine/rmine_tossed1.wav")
Mats=array(
"models/props_wasteland/metal_tram001a",
"models/props_wasteland/rockcliff04a",
"models/props_pipes/pipeset_metal",
"models/props_foliage/oak_tree01",
"models/props_canal/metalwall005b",
"models/props_debris/plasterwall021a",
"models/props_debris/building_template012d")
Names=array(
"Steve Staller",
"Bill Baller",
"Willy Wander",
"Reed Roller",
"Sally Slider",
"Jenny Jumpin",
"Cherry Chargin",
"Chucky Charger",
"Marry Monacle",
"Terry TopHat",
"Richard RedRing",
"Gillbert GreenRing",
"Tommy Model/Tree",
"Sarah Stopping",
"Bob Breaking",
"Randy Rollermine")
#Grabbin chargers.
findByModel("models/props_lab/tpplugholder_single.mdl")
Plugs=findToArray()
#brim
holoCreate(2)
holoModel(2,"hqcylinder2")
holoScale(2,vec(3,3,0.08))
holoAng(2,ang(7,0,0))
holoColor(2,vec(0,0,0))
#top
holoCreate(3)
holoModel(3,"hqcylinder2")
holoScale(3,vec(1.8,1.8,2.5))
holoColor(3,vec(20,20,20))
holoAng(3,ang(7,0,0))
holoParent(3,2)
#white thing
holoCreate(4)
holoModel(4,"hqcylinder2")
holoScale(4,vec(1.9,1.9,0.2))
holoPos(4,E:pos()+vec(0,0,5))
holoAng(4,ang(7,0,0))
holoMaterial(4,"models/debug/debug_white")
holoParent(4,2)
#monical!!!
holoCreate(5)
holoModel(5,"hqcylinder2")
holoScale(5,vec(0.6,0.6,0.2))
holoAng(5,ang(90,55,0))
holoPos(5,E:pos()+(holoEntity(2):forward()*20)+(holoEntity(2):right()*-9)-vec(0,0,10))
holoAlpha(5,200)
holoParent(5,2)
#indicator
holoCreate(6)
holoPos(6,E:pos()+vec(0,0,15))
holoModel(6,"sphere")
holoScale(6,vec(0.3,0.3,0.3))
holoColor(6,vec(255,0,0))
holoParent(6,2)
#Give it a name!
Name=Names:string(randint(0,Names:count()))
setName("WonderBall: "+"'"+Name)
R=10 #how far it travels, i think
Power=5 #initial power
NoPlayer=1 #no players around
Battery=randint(20,100) #set battery
Charging=0 #im not charging
Face=0 #you got no face,(top hat pointing)
Dead=0 # well derp
NeedCharge=0
Low=20
print(+Name+": "+"My battery started at "+Battery+"%.")
#oh the timers!
timer("move",1000)
timer("moarPower",1000)
timer("NewDist",randint(1000,random(2000,10000)))
timer("SR",randint(10000,30000))
timer("sound",randint(1000,5000))
timer("search",500)
timer("face",1000)
timer("Mat",5000)
timer("link",4000)
}
if(clk("link"))
{
if(Plugs:count()>0)
{
Charger=Plugs[1,entity]
print(+Name+": I found a charger!")
}
else
{
Charger=E
print(+Name+": I can't find a charger!")
print(+Name+": If i dont find a charger, ill die!")
}
}
if(clk("face"))
{
Face=1
# E:propFreeze(0)
}
if(clk("Mat")|changed(owner():lastSaid())&owner():lastSaid()=="/mat")
{
#set a random material}
Mat=Mats:string(randint(0,Mats:count()))
E:setMaterial(Mat)
}
#Search for players
if(clk("search"))
{
timer("search",5000)
findExcludeEntity(owner())
findExcludeEntities(Bros)
findIncludeModel("models/props_phx/games/chess/black_knight.mdl")
findIncludeClass("Player")
findInSphere(E:pos(),500)
Players=findToArray()
}
#Adding people to the "allow see" list
if ( chatClk( owner() ) )
{
LS = lastSaid():explode(" ")
Command = LS[1,string]:lower()
if ( Command == "/add" )
{
Bro = findPlayerByName( LS[2,string] )
Bros:pushEntity(Bro)
print(+Name+": You know, i think ill open up to "+Bro:name())
hideChat(1)
}
else
{
hideChat(0)
}
}
if(changed(Players:count())&Players:count()>=1&Hide)
{
print(+Name+": Theres someone here!")
print(+Name+": Ill be hiding by the charger.")
}
#the effects of a unwanted visitor
if(Players:count()>=1&Hide)
{
NoPlayer=0
holoAlpha(1,0)
holoAlpha(2,0)
holoAlpha(3,0)
holoAlpha(4,0)
holoAlpha(5,0)
E:setAlpha(0)
Charger:setAlpha(0)
V2=(Charger:pos()-E:pos())+vec(0,0,10)
E:applyForce(V2+$V2*10)
soundStop(1)
}
else
{
NoPlayer=1
holoAlpha(1,255)
holoAlpha(2,255)
holoAlpha(3,255)
holoAlpha(4,255)
holoAlpha(5,200)
E:setAlpha(255)
Charger:setAlpha(255)
timer("sound",randint(1000,5000))
}
#code for avoid object
if(Avoid&E:pos():distance(Avoid:pos())<100)
{
V=(E:pos()-Avoid:pos())*100
timer("NewDist",100)
}
#goto the charger!
if(((Battery<=Low&Battery>=1)|(Charging&Battery<=90))&Charger)
{
NeedCharge=1
V=(Charger:pos()-E:pos())*HighTail
}
elseif((Battery>=Low&Battery>0)&Charger)
{
NeedCharge=0
Charging=0
V=randvec(-R,R)*Power*3
}
#add the juice
if(E:pos():distance(Charger:pos())<=100)
{
Charging=1
Battery+=0.2
}
else
{
Charging=0
}
#the sounds
soundPitch(1,Battery)
if(clk("sound")&NoPlayer&Battery>=0.2&Sound)
{
Battery-=0.5
soundPlay(1,0,Sounds:string(randint(0,Sounds:count())))
timer("sound",randint(2000,5000))
}
if(changed(Sound)&Sound){timer("sound",100)}
#Super random
if(clk("SR")&Battery>=10&NoPlayer)
{
Battery--
SUPERRANDOM=randint(0,10)
timer("SR",randint(10000,30000))
}
#find a new distance to go
if(clk("NewDist")&Battery>=1)
{
Low=randint(40,60)
timer("NewDist",randint(1000,5000))
R=random(20,50)+SUPERRANDOM
}
#A extra power boost
if(clk("moarPower")&Battery>=10&NoPlayer)
{
timer("moarPower",randint(5000,10000))
Power=randint(10,60)
}
#the final push!
if(clk("move")&Battery>=2)
{
Battery-=0.8
timer("move",randint(1000,5000))
E:applyForce(V+$V*2)
}
and the mini wonderball:
Code:
@name WonderBall
@inputs Avoid:entity
@outputs Battery Charging NoPlayer E:entity
@persist [V2 V]:vector [Players Sounds Mats Bros Plugs Names]:array [Name Mat]:string [Charger Player]:entity
@persist R ColR ColB Power SUPERRANDOM Face Hide ROB Low HighTail Percent Sound Dead NeedCharge
@model models/hunter/misc/sphere025x025.mdl
interval(100)
runOnChat(1)
E=entity()
#changing critical values
if(first())
{
Hide=0#allow it to hide
ROB=1#Run on battery?
Sound=1#Make sound?
HighTail=35#speed to return to the charger upon battery drain
}
#brim- set the hat and monacle pos
holoPos(2,E:pos()+vec(0,0,5))
#face me you top hat!
if(Face&Battery>=1)
{
holoAng(2,ang(3,E:angles():yaw(),0))
holoAng(3,ang(3,E:angles():yaw(),0))
holoAng(4,ang(3,E:angles():yaw(),0))
}
#is i charging?
if(changed(Charging)&Charging)
{
holoColor(6,vec(0,255,0))
}
elseif(changed(Charging)&!Charging)
{
holoColor(6,vec(255,0,0))
}
elseif(changed(NeedCharge)&NeedCharge )
{
holoColor(6,vec(250,160,0))
}
#clamping battery
if(Battery>=100){Battery=100}
if(Battery<=0){Battery=0}
if(!ROB){Battery=100}
#Shut down sound/red
if(changed(Battery)&Battery<=0&!first()){
Dead=1
soundPlay(3,0,"ambient/energy/powerdown2.wav")
print(+Name+": "+owner():name()+", how could you let me die!")
print(+Name+": Dont worry, ill get a burst of juice from the sun in about 3 minutes")
E:setMass(50000)
timer("revive",180000)
}
elseif(changed(Battery)&Battery>0)
{
Dead=0
}
#give it a burst of juice after 5 minutes of being dead, just so they dont all die
if((clk("revive")|changed(Dead)&!Dead)&!first())
{
print(+Name+": Im back, and starting a new life!")
soundPlay(5,0,"ambient/explosions/citadel_end_explosion1.wav")
E:setMass(150)
Battery=30
}
#Lets you change the battery %
if(chatClk(owner()))
{
if(owner():lastSaid():explode(" "):string(1) == "/bat")
{
Percent=owner():lastSaid():explode(" "):string(2):toNumber()
}
}
if(changed(Percent)&!first()){Battery=Percent,print("Battery set to "+Percent+"%.")}
#Getting the color for the battery ring
if(changed(Battery)){setName("WonderBall: "+Name+" (Battery:"+round(Battery)+"%)")}
if(changed(Battery)&Battery >= 100){ColR = 0,ColB=255}
if(changed(Battery)&Battery >= 75&Battery<100){ColR = 90,ColB=230}
if(changed(Battery)&Battery >= 50&Battery<75){ColR = 150,ColB=100}
if(changed(Battery)&Battery >= 25&Battery<50){ColR = 230,ColB=90}
if(changed(Battery)&Battery >= 0&Battery<25){ColR = 255,ColB=0}
if(changed(Battery)&Battery <=1){ColR=0,BolB=0}
holoColor(4, vec(ColR,ColB,0)) #Setting that color
if(first())
{
Sounds=array(
"npc/roller/mine/rmine_blip1.wav",
"npc/roller/mine/rmine_blip3.wav",
"npc/roller/mine/rmine_chirp_quest1.wav",
"npc/roller/mine/rmine_taunt1.wav",
"npc/roller/mine/rmine_taunt2.wav",
"npc/roller/mine/rmine_tossed1.wav")
Mats=array(
"models/props_wasteland/metal_tram001a",
"models/props_wasteland/rockcliff04a",
"models/props_pipes/pipeset_metal",
"models/props_foliage/oak_tree01",
"models/props_canal/metalwall005b",
"models/props_debris/plasterwall021a",
"models/props_debris/building_template012d")
Names=array(
"Steve Staller",
"Bill Baller",
"Willy Wander",
"Reed Roller",
"Sally Slider",
"Jenny Jumpin",
"Cherry Chargin",
"Chucky Charger",
"Marry Monacle",
"Terry TopHat",
"Richard RedRing",
"Gillbert GreenRing",
"Tommy Model/Tree",
"Sarah Stopping",
"Bob Breaking",
"Randy Rollermine")
findByModel("models/props_lab/tpplugholder_single.mdl")
Plugs=findToArray()
#brim
holoCreate(2)
holoModel(2,"cylinder")
holoScale(2,vec(1,1,0.06))
holoAng(2,ang(7,0,0))
holoColor(2,vec(0,0,0))
#top
holoCreate(3)
holoModel(3,"cylinder")
holoScale(3,vec(0.6,0.6,0.7))
holoColor(3,vec(20,20,20))
holoAng(3,ang(7,0,0))
holoParent(3,2)
#white thing
holoCreate(4)
holoModel(4,"cylinder")
holoScale(4,vec(0.65,0.65,0.08))
holoPos(4,E:pos()+vec(0,0,1.3))
holoAng(4,ang(7,0,0))
holoMaterial(4,"models/debug/debug_white")
holoParent(4,2)
#monical!!!
holoCreate(5)
holoModel(5,"cylinder")
holoScale(5,vec(0.3,0.3,0.1))
holoAng(5,ang(90,55,0))
holoPos(5,E:pos()+(holoEntity(2):forward()*7)+(holoEntity(2):right()*-5)-vec(0,0,3))
holoAlpha(5,200)
holoParent(5,2)
#indicator
holoCreate(6)
holoPos(6,E:pos()+vec(0,0,4))
holoModel(6,"sphere")
holoScale(6,vec(0.2,0.2,0.2))
holoColor(6,vec(255,0,0))
holoParent(6,2)
#Give it a name!
Name=Names:string(randint(0,Names:count()))
setName("Wonderball "+Name)
R=10 #how far it travels, i think
Power=5 #initial power
NoPlayer=1 #no players around
Battery=randint(20,100) #set battery
Charging=0 #im not charging
Face=0 #you got no face,(top hat pointing)
Dead=0#well, derp
NeedCharge=0
Low=20
print(+Name+": "+"My battery started at "+Battery+"%.")
E:setMass(150)
#oh the timers!
timer("move",1000)
timer("moarPower",1000)
timer("NewDist",randint(1000,3000))
timer("SR",randint(10000,30000))
timer("sound",randint(1000,5000))
timer("search",500)
timer("face",1000)
timer("Mat",5000)
timer("link",4000)
}
if(clk("link"))
{
if(Plugs:count()>0)
{
Charger=Plugs[1,entity]
print(+Name+": I found a charger!")
}
else
{
Charger=E
print(+Name+": I can't find a charger!")
print(+Name+": If i dont find a charger, ill die!")
}
}
if(clk("face"))
{
Face=1
# E:propFreeze(0)
}
if(clk("Mat")|changed(owner():lastSaid())&owner():lastSaid()=="/mat")
{
#set a random material}
Mat=Mats:string(randint(0,Mats:count()))
E:setMaterial(Mat)
}
#Search for players
if(clk("search"))
{
timer("search",5000)
findExcludeEntity(owner())
findExcludeEntities(Bros)
findIncludeModel("models/props_phx/games/chess/black_knight.mdl")
findIncludeClass("Player")
findInSphere(E:pos(),500)
Players=findToArray()
}
#Adding people to the "allow see" list
if ( chatClk( owner() ) )
{
LS = lastSaid():explode(" ")
Command = LS[1,string]:lower()
if ( Command == "/add" )
{
Bro = findPlayerByName( LS[2,string] )
Bros:pushEntity(Bro)
print(+Name+": You know, i think ill open up to "+Bro:name())
hideChat(1)
}
else
{
hideChat(0)
}
}
if(changed(Players:count())&Players:count()>=1&Hide)
{
print(+Name+": Theres someone here!")
print(+Name+": Ill be hiding by the charger.")
}
#the effects of a unwanted visitor
if(Players:count()>=1&Hide)
{
print(+Name+": Theres someone here!")
print(+Name+": Ill be hiding by the charger.")
NoPlayer=0
holoAlpha(1,0)
holoAlpha(2,0)
holoAlpha(3,0)
holoAlpha(4,0)
holoAlpha(5,0)
E:setAlpha(0)
Charger:setAlpha(0)
V2=(Charger:pos()-E:pos())+vec(0,0,10)
E:applyForce(V2+$V2*10)
soundStop(1)
}
else
{
NoPlayer=1
holoAlpha(1,255)
holoAlpha(2,255)
holoAlpha(3,255)
holoAlpha(4,255)
holoAlpha(5,200)
E:setAlpha(255)
Charger:setAlpha(255)
timer("sound",randint(1000,5000))
}
#code for avoid object
if(Avoid&E:pos():distance(Avoid:pos())<100)
{
V=(E:pos()-Avoid:pos())*100
timer("NewDist",100)
}
#goto the charger!
if((Battery<=Low&Battery>=1|(Charging&Battery<=90))&Charger)
{
NeedCharge=1
V=(Charger:pos()-E:pos())*HighTail*4
}
elseif((Battery>=Low&Battery>0)&Charger)
{
NeedCharge=0
Charging=0
V=randvec(-R,R)*Power*8
}
#add the juice
if(E:pos():distance(Charger:pos())<=70)
{
Charging=1
Battery+=0.2
}
else
{
Charging=0
}
#the sounds
soundPitch(1,Battery)
if(clk("sound")&NoPlayer&Battery>=0.2&Sound)
{
Battery-=0.5
soundPlay(1,0,Sounds:string(randint(0,Sounds:count())))
timer("sound",randint(1000,5000))
}
if(changed(Sound)&Sound){timer("sound",100)}
#Super random
if(clk("SR")&Battery>=10&NoPlayer)
{
Battery--
SUPERRANDOM=randint(0,20)
timer("SR",randint(10000,30000))
}
#find a new distance to go
if(clk("NewDist")&Battery>=1)
{
Low=randint(30,60)
timer("NewDist",randint(1000,5000))
R=random(20,50)+SUPERRANDOM
}
#A extra power boost
if(clk("moarPower")&Battery>=10&NoPlayer)
{
timer("moarPower",randint(3000,10000))
Power=randint(5,30)
}
#the final push!
if(clk("move")&Battery>=2)
{
Battery-=0.8
timer("move",randint(1000,3000))
E:applyForce(V+$V*2)
}
[updated: 2/19/11]:
*fixed the issue where the ball would remain 50,000 lbs if he died and you physguned him back to the charger.
*changed the way it knows when to charge
*updated values in the mini wonderball, it now should die less.
Bookmarks