Wiremod Wizardry!

http://marvel.com/universe3zx/images/thumb/0/0b/Amora3b.jpg/440px-Amora3b.jpg

Wiremod Wizardry!

So I was bored one day, and decided to make an expression2 chip. After sitting for ten minutes, unable to gather thoughts enough to come up with an idea for a function, I remembered that I had a DnD meeting with some friends the next day. Playing a spellcaster, I decided to design and code a few interesting, albeit simplistic, spells into an expression2 chip for fun little wizard battles between friends.

This is the fruit of a full 6 hours’ work. (Please don’t troll me on how much of a waste of time this was. I had NOTHING better to do. >.<)

All spells have a certain range at which they will go before ending their sequence. Spells will endeffect at either A. the first entity(prop,player,etc)/wall within range in a line from cast point, or B. at the end of the line at distance equal to range. Whichever comes first.
Almost every spell comes with its own sound effects.
Only one spell can be cast at a time. You can’t machine-gun fireballs or ice-shards. :stuck_out_tongue:
some spells do nothing, but some do certain things to your own props that are interesting.

Controls:
Hold either the Crowbar of Gravgun out, and hold the Use key. Right click to switch spells/turn off casting, Left click to cast the selected spell. A ring indicator in front of you determines selected spell by color.

Spell List:
Fire - Simple fireball with a smoke trail. Explodes when destination reached. No damage. Pushes props.
Ice - Ice shard with a trail. Neat little shatter sound at the end. Pushes props. No damage.
Lightning - Ring of electricity, meant for zapping areas of foes. Pushes props. No damage.
Water - Pillar of water to drown foes. Can also be shot midair. No real damage. :stuck_out_tongue:
Necromancy - A green trail of life-force from your foe to you, as you drain their life-force. Doesn’t do damage. Only for show. :stuck_out_tongue:
Alchemy - Miscellaneous spell. Turns the affected prop (owned by you) into gold! Useful for earning large amounts of currency. Doesn’t affect other players or their props. :stuck_out_tongue:
Spell Barrier - Protects you from all other spells. Unfortunately, also blinds you and renders your spellcasting ability unusable.

Have fun. ^^


@name Wiremod Wizardry (By Sodaguzzler)
@persist FireIce:string
@persist CastState CastDiv Cast Mouse1 Mouse2 Use Mouse1C 
@persist Mouse2C Weapon A Barrier
@persist TargPos:vector OriginPos:vector Direc:vector
@persist TargEnt:entity
### IMPORTANT NOTES:
##Hologram Indexes:
# 0 - Castpos hologram.
# 1 - Spell hologram.
# 2 - Spell Barrier hologram
## Currently, jumping causes the SpellRing to jump high into the air
## as well. If you come up with a fix for this, find any bugs, or
## have any suggestions for the chip, email me at:
##
## sodaguzzler@yahoo.com
##
###
runOnTick(1)
interval(100)
if(duped()){selfDestruct()}
O = owner()
# Location and Angles for spellcaster holo, and location for cast origin.
CastPos = O:pos()+vec(0,0,62.5)+((O:forward()*10))
CastAng = O:angles()+ang(90,0,0)
# Scale factor for spells and spellcaster holo.
Scale = vec(0.1,0.1,0.1)
# Spell colors.
Fire = vec(255,0,0)
Ice = vec(0,0,255)
Zap = vec(255,255,0)
Water = vec(0,255,255)
Necro = vec(0,255,0)
Gold = vec(255,182,0)
Shield = vec(100,100,100)
# Key checkers.
Mouse1 = O:keyAttack1()
Mouse1C = changed(Mouse1)
Mouse2 = O:keyAttack2()
Mouse2C = changed(Mouse2)
BarrierC = changed(Barrier)
Use = O:keyUse()
Weapon = (O:weapon():type()=="weapon_physcannon" | O:weapon():type()=="weapon_crowbar" ? 1 : 0)
WeaponName = O:weapon():type()
if(first())
{
    FireIce="Off"
    holoCreate(0)
    holoModel(0,"hqtorus")
    holoScale(0,Scale)
    holoPos(0,CastPos)
    holoAng(0,CastAng)
    holoParent(0,owner())
    holoColor(0,Fire)
    hint("Welcome, spellcaster. Please don't jump much, as",7)
    hint("your spellring will jump around.",7)
}
###
## Spell switcher mechanism.
# Currently, only fire and ice spells are available.
# As is turning the casting off.
###
if(Use&Mouse2&Mouse2C&Weapon){
    O:soundPlay(0,5,"physcannon/physcannon_dryfire.wav")
    if(FireIce=="Fire"){
        holoColor(0,Ice,255)
        FireIce="Ice"
        hint("Ice Spell selected.",5)}
    elseif(FireIce=="Ice"){
        holoColor(0,Zap,255)
        FireIce="Zap"
        hint("Lightning Spell selected.",5)}
    elseif(FireIce=="Zap"){
        holoColor(0,vec(),0)
        FireIce="Off"
        hint("Spellcasting Off",5)}
    elseif(FireIce=="Off"){
        holoColor(0,Water,255)
        FireIce="Water"
        hint("Water Spell selected.",5)}
    elseif(FireIce=="Water"){
        holoColor(0,Necro,255)
        FireIce="Necro"
        hint("Necromancy Spell selected.",5)}
    elseif(FireIce=="Necro"){
        holoColor(0,Gold,255)
        FireIce="Alch"
        hint("Alchemy Spell selected.",5)}
    elseif(FireIce=="Alch"){
        holoColor(0,Shield,255)
        FireIce="Shield"
        hint("Spell Shield selected.",5)}
    elseif(FireIce=="Shield"){
        holoColor(0,Fire,255)
        FireIce="Fire"
        hint("Fire Spell selected.",5)}
}
###
## SPELL CASTING MECHANISM!
## CRITICAL FUNCTIONS!
## DO NOT EDIT.
###
if(Use&Mouse1&Mouse1C&!Cast&FireIce!="Off"&Weapon&FireIce!="Shield"&!Barrier){Cast=1}
elseif(Use&Mouse1&Mouse1C&Weapon&FireIce=="Shield"){Barrier=!Barrier}
if(Cast){
    if(CastState==0){
        CastState=1
        rangerHitEntities(1)
        rangerDefaultZero(1)
        Eye=rangerOffset(1500,CastPos,O:eye())
        OriginPos=CastPos
        TargPos=(Eye:hit() ? O:aimPos() : CastPos+O:eye()*1500 )
        TargPos=(TargPos:isInWorld() ? TargPos : O:aimPos())
        TargEnt=(Eye:hit() ? O:aimEntity() : noentity())
        Direc=TargPos-OriginPos
        holoCreate(1)
        if(FireIce=="Fire")
        {
            holoColor(1,Fire)
            holoModel(1,"hqsphere")
            holoScale(1,Scale)
            holoEntity(1):setTrails(100,1,5,"trails/smoke",Fire,255)
        }
        if(FireIce=="Ice")
        {
            holoEntity(1):soundPlay(2,1,"ambient/wind/wind_snippet1.wav")
            soundPitch(1,5000)
            holoColor(1,Ice)
            holoModel(1,"hqcone")
            holoAng(1,O:eye():toAngle()+ang(90,0,0))
            holoScale(1,vec(1,1,5))
            holoEntity(1):setTrails(100,1,5,"trails/smoke",Ice,255)
        }
        if(FireIce=="Zap")
        {
            holoAng(1,O:eye():toAngle())
            holoColor(1,Zap)
            holoModel(1,"torus")
            holoScale(1,vec(0.1,0.1,0.1))
        }
        if(FireIce=="Water")
        {
            holoColor(1,Water)
            holoModel(1,"hqcylinder2")
            holoScale(1,Scale)
        }
        if(FireIce=="Necro")
        {
            holoColor(1,Necro)
            holoModel(1,"hqcylinder2")
            holoScale(1,Scale)
            holoAng(1,O:eye():toAngle()+ang(90,0,0))
        }
        if(FireIce=="Alch")
        {
            holoColor(1,Gold)
            holoModel(1,"hqcylinder2")
            holoScale(1,Scale)
            holoAng(1,O:eye():toAngle()+ang(90,0,0))
        }
        holoPos(1,CastPos)}
    elseif(CastState==1&clk("interval")&!Barrier)
    {
        VecScale=Direc/10
        holoPos(1,OriginPos+VecScale*CastDiv)
        CastDiv++
    }
    if(CastState==2)
    {
        CastState=3
        if(FireIce=="Fire")
        {
            TargEnt:applyForce(Direc*5000)
            holoEntity(1):soundPlay(1,2,"weapons/explode5.wav")
            soundVolume(1,200)
            holoScale(1,vec(10,10,10))
            timer("State3",1000)
        }
        elseif(FireIce=="Ice"&Eye:hit())
        {
            TargEnt:applyForce(Direc*5000)
            holoEntity(1):soundPlay(1,2," physics/glass/glass_pottery_break3.wav")
            soundVolume(1,200)
            timer("State3",1000)
        }
        elseif(FireIce=="Ice"){timer("State3",1000)}
        elseif(FireIce=="Zap")
        {
            TargEnt:applyForce(Direc*5000)
            holoEntity(1):soundPlay(1,2,"ambient/levels/labs/electric_explosion2.wav")
            soundVolume(1,200)
            holoScale(1,vec(20,20,5))
            timer("State3",1000)
        }
        elseif(FireIce=="Water")
        {
            holoEntity(1):soundPlay(1,2,"npc/ichthyosaur/water_breath.wav")
            soundVolume(1,200)
            holoScale(1,vec(5,5,50))
            timer("State3",2000)
        }
        elseif(FireIce=="Necro")
        {
            holoEntity(1):soundPlay(1,2,"npc/barnacle/barnacle_gulp2.wav")
            soundVolume(1,200)
            holoScale(1,vec(0.1,0.1,(Direc:length()/10)))
            holoPos(1,OriginPos+(Direc/2))
            timer("State3",2000)
        }
        elseif(FireIce=="Alch")
        {
            holoEntity(1):soundPlay(1,1,"player/pl_drown1.wav")
            soundVolume(1,200)
            TargEnt:setColor(Gold)
            TargEnt:setMaterial("models/shiny")
            timer("State3",10)
        }
    }
    elseif(CastState==3&clk("State3")){holoDelete(1),Cast=0,CastState=0}
    if(CastDiv==10){CastState=2,CastDiv=0}
}
if(Barrier&BarrierC)
{
    holoCreate(2)
    holoModel(2,"hqtorus2")
    holoScale(2,vec(10,10,70))
    holoPos(2,O:pos()+vec(0,0,35))
    holoParent(2,O)
}
elseif(!Barrier&holoEntity(2)){holoDelete(2)}

Nice!

Thanks I guess.

I’ve never really bothered with E2, but why so many if statements?

Because it needs it, it is different to lua…

E2 doesn’t have tables ( or arrays )?

Face it, E2 is basically API for Lua.

Wow that girl has huge tits

ONTOPIC: Nice.

It does have arrays and tables, but i can’t put stuff like holocolor() and holoPos() functions into arrays, and run them when that array element is called. Same with table. They just store variables, not functions. And each spell does something different, so all the if-statements are for context-based actions by the chip.

Also, FUNFACT: Some spells won’t work if the chip is spawned sideways. Don’t ask me why. >< Just be sure to spawn it on the ground, and not a wall.

Wasn’t what I meant.

I want damage so I can pwn the minges.

unless the E2 made a prop hide inside the Holograms, that wouldn’t be possible…

New idea right here. Why not make alchemy turn shit into money? Some kind of weight to number conversion, I.E. 100 pounds is $1. That way it’s harder to leech off of that kind of power.

Two things.

First: code update! Added 2 new spells. invisibility, and telekenisis. invisibility changes your material so that you’re see-through and completely invisible, save for your weapon. The telekenisis spell is a little trickier. It’s a spell that essentially replaces the gravity gun. E+Leftclick to cast the spell on a prop you own, and it flies to you, moved around similar to the gravity gun. When E+leftclick is pressed again, the prop flies at a high velocity! if E+rightclick is pressed, the prop will simply drop to the ground in front of you. Controls are mapped so that when a prop is being moved by telekenisis, the spell switcher doesn’t switch spells on you (which is normally E+rightclick). the telekenisis spell also uses a sound from avon’s Stargate addon. if you do not have this addon, that’s alright. you can either get it, or just not listen to the sound. for those with the addon, it’s the looping watery sound when a gate is open.

Second:

What do you mean by ‘to money’? Real life money, or ingame money used in RP?

Updated Expression:


@name Wiremod Wizardry (By Sodaguzzler)
@outputs FireIce:string
@outputs CastState CastDiv Cast Mouse1 Mouse2 Use Mouse1C 
@outputs Mouse2C Weapon A Barrier Invis Telekenisis Mass
@outputs TargPos:vector OriginPos:vector Direc:vector
@outputs TargEnt:entity
### IMPORTANT NOTES:
##Hologram Indexes:
# 0 - Castpos hologram.
# 1 - Spell hologram.
# 2 - Spell Barrier hologram
## Currently, jumping causes the SpellRing to jump high into the air
## as well. If you come up with a fix for this, find any bugs, or
## have any suggestions for the chip, email me at:
##
## sodaguzzler@yahoo.com
##
###
runOnTick(1)
interval(100)
if(duped()){selfDestruct()}
O = owner()
# Location and Angles for spellcaster holo, and location for cast origin.
CastPos = O:pos()+vec(0,0,62.5)+((O:forward()*10))
CastAng = O:angles()+ang(90,0,0)
# Scale factor for spells and spellcaster holo.
Scale = vec(0.1,0.1,0.1)
# Spell colors.
Fire = vec(255,0,0)
Ice = vec(0,0,255)
Zap = vec(255,255,0)
Water = vec(0,255,255)
Necro = vec(0,255,0)
Gold = vec(255,182,0)
Shield = vec(100,100,100)
InvisC = vec4(0,0,0,100)
Teleken = vec(255,0,134)
# Key checkers.
Mouse1 = O:keyAttack1()
Mouse1C = changed(Mouse1)
Mouse2 = O:keyAttack2()
Mouse2C = changed(Mouse2)
BarrierC = changed(Barrier)
Use = O:keyUse()
Weapon = (O:weapon():type()=="weapon_physcannon" | O:weapon():type()=="weapon_crowbar" ? 1 : 0)
WeaponName = O:weapon():type()
if(first())
{
    FireIce="Off"
    holoCreate(0)
    holoModel(0,"hqtorus")
    holoScale(0,Scale)
    holoPos(0,CastPos)
    holoAng(0,CastAng)
    holoParent(0,owner())
    holoColor(0,vec(),0)
    hint("Welcome, spellcaster. Please don't jump much, as",7)
    hint("your spellring will jump around.",7)
}
###
## Spell switcher mechanism.
# Currently, only fire and ice spells are available.
# As is turning the casting off.
###
if(Use&Mouse2&Mouse2C&Weapon&!Telekenisis){
    O:soundPlay(0,5,"physcannon/physcannon_dryfire.wav")
    if(FireIce=="Fire"){
        holoColor(0,Ice,255)
        FireIce="Ice"
        hint("Ice Spell selected.",5)}
    elseif(FireIce=="Ice"){
        holoColor(0,Zap,255)
        FireIce="Zap"
        hint("Lightning Spell selected.",5)}
    elseif(FireIce=="Zap"){
        holoColor(0,vec(),0)
        FireIce="Off"
        hint("Spellcasting Off",5)}
    elseif(FireIce=="Off"){
        holoColor(0,Water,255)
        FireIce="Water"
        hint("Water Spell selected.",5)}
    elseif(FireIce=="Water"){
        holoColor(0,Necro,255)
        FireIce="Necro"
        hint("Necromancy Spell selected.",5)}
    elseif(FireIce=="Necro"){
        holoColor(0,Gold,255)
        FireIce="Alch"
        hint("Alchemy Spell selected.",5)}
    elseif(FireIce=="Alch"){
        holoColor(0,Shield,255)
        FireIce="Shield"
        hint("Spell Shield selected.",5)}
    elseif(FireIce=="Shield"){
        holoColor(0,InvisC)
        FireIce="Invis"
        hint("Invisibility spell Selected.",5)}
        
    elseif(FireIce=="Invis"){
        holoColor(0,Teleken,255)
        FireIce="Telekenisis"
        hint("Telekenisis selected.",5)}
        
    elseif(FireIce=="Telekenisis"){
        holoColor(0,Fire,255)
        FireIce="Fire"
        hint("Fire spell selected",5)}
}
elseif(Use&Mouse2&Mouse2C&Weapon&Telekenisis)
{
    soundStop(2)
    Telekenisis=0
    timer("State3",10)
}
###
## SPELL CASTING MECHANISM!
## CRITICAL FUNCTIONS!
## DO NOT EDIT.
###
if(Use&Mouse1&Mouse1C&!Cast&FireIce!="Off"&Weapon&
FireIce!="Shield"&!Barrier&FireIce!="Invis"){Cast=1}
elseif(Use&Mouse1&Mouse1C&Weapon&FireIce=="Shield"){Barrier=!Barrier}
elseif(Use&Mouse1&Mouse1C&Weapon&FireIce=="Invis"&!Invis){O:setMaterial("models/effects/vol_light001"),Invis=1}
elseif(Use&Mouse1&Mouse1C&Weapon&FireIce=="Invis"&Invis){O:setMaterial(""),Invis=0}
if(Cast){
    if(CastState==0){
        CastState=1
        rangerHitEntities(1)
        rangerDefaultZero(1)
        Eye=rangerOffset(2000,CastPos,O:eye())
        OriginPos=CastPos
        TargPos=(Eye:hit() ? O:aimPos() : CastPos+O:eye()*2000)
        TargEnt=(Eye:hit() ? O:aimEntity() : noentity())
        TargEnt=(TargEnt:owner() == O ? TargEnt : noentity())
        Direc=TargPos-OriginPos
        holoCreate(1)
        if(FireIce=="Fire")
        {
            holoColor(1,Fire)
            holoModel(1,"hqsphere")
            holoScale(1,Scale)
            holoEntity(1):setTrails(100,1,5,"trails/smoke",Fire,255)
        }
        if(FireIce=="Ice")
        {
            holoEntity(1):soundPlay(2,1,"ambient/wind/wind_snippet1.wav")
            soundPitch(1,5000)
            holoColor(1,Ice)
            holoModel(1,"hqcone")
            holoAng(1,O:eye():toAngle()+ang(90,0,0))
            holoScale(1,vec(1,1,5))
            holoEntity(1):setTrails(100,1,5,"trails/smoke",Ice,255)
        }
        if(FireIce=="Zap")
        {
            holoAng(1,O:eye():toAngle())
            holoColor(1,Zap)
            holoModel(1,"torus")
            holoScale(1,vec(0.1,0.1,0.1))
        }
        if(FireIce=="Water")
        {
            holoColor(1,Water)
            holoModel(1,"hqcylinder2")
            holoScale(1,Scale)
        }
        if(FireIce=="Necro")
        {
            holoColor(1,Necro)
            holoModel(1,"hqcylinder2")
            holoScale(1,Scale)
            holoAng(1,O:eye():toAngle()+ang(90,0,0))
        }
        if(FireIce=="Alch")
        {
            holoColor(1,Gold)
            holoModel(1,"hqcylinder2")
            holoScale(1,Scale)
            holoAng(1,O:eye():toAngle()+ang(90,0,0))
        }
        if(FireIce=="Telekenisis"&!Telekenisis)
        {
            holoColor(1,Teleken)
            holoModel(1,"hqicosphere2")
            holoScale(1,Scale)
        }
        if(FireIce=="Telekenisis"&Telekenisis)
        {
            soundStop(2)
            Telekenisis=0
            TargEnt:applyForce(O:eye()*5000*Mass)
            CastState=3
            timer("State3",10)
        }
            
        holoPos(1,CastPos)}
    elseif(CastState==1&clk("interval")&!Barrier)
    {
        VecScale=Direc/10
        holoPos(1,OriginPos+VecScale*CastDiv)
        CastDiv++
    }
    if(CastState==2)
    {
        CastState=3
        if(FireIce=="Fire")
        {
            holoEntity(1):soundPlay(1,2,"weapons/explode5.wav")
            soundVolume(1,200)
            holoScale(1,vec(10,10,10))
            TargEnt:applyForce(Direc*5000)
            timer("State3",1000)
        }
        elseif(FireIce=="Ice"&Eye:hit())
        {
            holoEntity(1):soundPlay(1,2," physics/glass/glass_pottery_break3.wav")
            soundVolume(1,200)
            TargEnt:applyForce(Direc*5000)
            timer("State3",1000)
        }
        elseif(FireIce=="Ice"){timer("State3",1000)}
        elseif(FireIce=="Zap")
        {
            holoEntity(1):soundPlay(1,2,"ambient/levels/labs/electric_explosion2.wav")
            soundVolume(1,200)
            holoScale(1,vec(20,20,5))
            TargEnt:applyForce(Direc*5000)
            timer("State3",1000)
        }
        elseif(FireIce=="Water")
        {
            holoEntity(1):soundPlay(1,2,"npc/ichthyosaur/water_breath.wav")
            soundVolume(1,200)
            holoScale(1,vec(5,5,50))
            timer("State3",2000)
        }
        elseif(FireIce=="Necro")
        {
            holoEntity(1):soundPlay(1,2,"npc/barnacle/barnacle_gulp2.wav")
            soundVolume(1,200)
            holoScale(1,vec(0.1,0.1,(CastPos:distance(TargPos)/5)))
            holoPos(1,OriginPos+(Direc/2))
            timer("State3",2000)
        }
        elseif(FireIce=="Alch")
        {
            holoEntity(1):soundPlay(1,1,"player/pl_drown1.wav")
            soundVolume(1,200)
            TargEnt:setColor(Gold)
            TargEnt:setMaterial("models/shiny")
            timer("State3",10)
        }
        elseif(FireIce=="Telekenisis"){
            O:soundPlay(2,0,"stargate/wormhole_loop.wav")
            soundVolume(1,200)
            Telekenisis=1
            timer("State3",10)}
    }
    elseif(CastState==3&clk("State3")){holoDelete(1),Cast=0,CastState=0}
    if(CastDiv==10){CastState=2,CastDiv=0}
}
if(Barrier&BarrierC)
{
    holoCreate(2)
    holoModel(2,"hqtorus2")
    holoScale(2,vec(10,10,70))
    holoPos(2,O:pos()+vec(0,0,35))
    holoAng(2,O:angles()+ang(90,0,0))
    holoParent(2,O)
}
elseif(!Barrier&holoEntity(2)){holoDelete(2)}
if(Telekenisis&clk("interval"))
{
    Pos=TargEnt:massCenter()
    HoldPos=O:shootPos()+O:eye()*100
    OVel=O:vel()
    PVel=TargEnt:vel()
    OAVel=O:angVel()
    PAVel=TargEnt:angVel()
    Mass=TargEnt:mass()
    TargEnt:applyForce(((HoldPos-Pos)*10-PVel+OVel)*Mass)
    TargEnt:applyAngForce(((-PAVel)*Mass)+OAVel)
}
elseif(TargEnt==noentity()){Telekenisis=0,soundStop(2)}

Didn’t work for me, kept saying to take stuff out on lines and when i did it wouldnt fire

He ment Rp money…

I get it. ment Rp money.

Is it just me or does he seem like a bot?

Detect in the E2 (may need a Lua extension, I can’t remember offhand) if the player is jumping, and subtract some height while he’s jumping. Probably hacky, but oh well.

you could make an E2 damage system or something similar to make PVP battles feasible, but I don’t see how doing damage could be possible otherwise unless you used physical props that were invisible and controlled by the chip.