Skip to content

Commit

Permalink
Addendum to: r1655
Browse files Browse the repository at this point in the history
#Added an icon helper procs library by Lummox Jr.
#Added more icon+overlay functionality by DarkCampainger. Both can be found under icon_procs.dm.
#Added continuous beam code by Gunbuddy to atom.dm. You can now create continuous beams of energy/magic/monkeys/whatever. For instance, pAI cords. It's really awesome.
#Like optical camo? Well I have good news. New stealth "graphic." May need some fine tuning depending on player/coder preference. It's also a little slow to change (due to update_clothing()). With that said, it's a lot cooler than what we had before. Check it out.
#Added the getIconMask() and AddCamoOverlay() procs for the above.
#Added animated satic filter icons by Koil to icons.
#New force wall and shield icons. Shield icons moved to effects.dmi.
#Changed up the abandoned mining station.
#Moved a few carp spawn points closer to the station. Added a few more.

Ninjas:
No longer spawn whoknowswhere like they did at times before.
Get a unique stealth graphic. Yup. Also, small chance of failure.
New energy net icon and effects. Energy net now uses the beam code mentioned above. It will now check for stealth.
Fixed some graphical icon issues with ninja suit. Added a female black jumpsuit to icons for this reason. Added icon directions to ninja effects.
Some more general code cleanup.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1664 316c924e-a436-60f5-8080-3fe189b3f50e
  • Loading branch information
[email protected] committed Jun 5, 2011
1 parent d67f72c commit fe889a3
Show file tree
Hide file tree
Showing 25 changed files with 3,146 additions and 2,260 deletions.
69 changes: 67 additions & 2 deletions code/defines/atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,70 @@ obj
src.moved_recently = 1
return

////////////

/*
Beam code by Gunbuddy
Beam() proc will only allow one beam to come from a source at a time. Attempting to call it more than
once at a time per source will cause graphical errors.
Also, the icon used for the beam will have to be vertical and 32x32.
The math involved assumes that the icon is vertical to begin with so unless you want to adjust the math,
its easier to just keep the beam vertical.
*/
/atom/proc/Beam(atom/BeamTarget,icon_state="b_beam",icon='beam.dmi',time=50, maxdistance=10)
//BeamTarget represents the target for the beam, basically just means the other end.
//Time is the duration to draw the beam
//Icon is obviously which icon to use for the beam, default is beam.dmi
//Icon_state is what icon state is used. Default is b_beam which is a blue beam.
//Maxdistance is the longest range the beam will persist before it gives up.
var/EndTime=world.time+time
while(BeamTarget&&world.time<EndTime&&get_dist(src,BeamTarget)<maxdistance&&z==BeamTarget.z)
//If the BeamTarget gets deleted, the time expires, or the BeamTarget gets out
//of range or to another z-level, then the beam will stop. Otherwise it will
//continue to draw.

dir=get_dir(src,BeamTarget) //Causes the source of the beam to rotate to continuosly face the BeamTarget.

for(var/obj/overlay/beam/O in orange(10,src)) //This section erases the previously drawn beam because I found it was easier to
if(O.BeamSource==src) //just draw another instance of the beam instead of trying to manipulate all the
del O //pieces to a new orientation.
var/Angle=round(Get_Angle(src,BeamTarget))
var/icon/I=new(icon,icon_state)
I.Turn(Angle)
var/DX=(32*BeamTarget.x+BeamTarget.pixel_x)-(32*x+pixel_x)
var/DY=(32*BeamTarget.y+BeamTarget.pixel_y)-(32*y+pixel_y)
var/N=0
var/length=round(sqrt((DX)**2+(DY)**2))
for(N,N<length,N+=32)
var/obj/overlay/beam/X=new(loc)
X.BeamSource=src
if(N+32>length)
var/icon/II=new(icon,icon_state)
II.DrawBox(null,1,(length-N),32,32)
II.Turn(Angle)
X.icon=II
else X.icon=I
var/Pixel_x=round(sin(Angle)+32*sin(Angle)*(N+16)/32)
var/Pixel_y=round(cos(Angle)+32*cos(Angle)*(N+16)/32)
if(DX==0) Pixel_x=0
if(DY==0) Pixel_y=0
if(Pixel_x>32)
for(var/a=0, a<=Pixel_x,a+=32)
X.x++
Pixel_x-=32
if(Pixel_x<-32)
for(var/a=0, a>=Pixel_x,a-=32)
X.x--
Pixel_x+=32
if(Pixel_y>32)
for(var/a=0, a<=Pixel_y,a+=32)
X.y++
Pixel_y-=32
if(Pixel_y<-32)
for(var/a=0, a>=Pixel_y,a-=32)
X.y--
Pixel_y+=32
X.pixel_x=Pixel_x
X.pixel_y=Pixel_y
sleep(3) //Changing this to a lower value will cause the beam to follow more smoothly with movement, but it will also be more laggy.
//I've found that 3 ticks provided a nice balance for my use.
for(var/obj/overlay/beam/O in orange(10,src)) if(O.BeamSource==src) del O
9 changes: 9 additions & 0 deletions code/defines/obj.dm
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,15 @@
unacidable = 1
var/i_attached//Added for possible image attachments to objects. For hallucinations and the like.

/obj/overlay/beam//Not actually a projectile, just an effect.
name="beam"
icon='beam.dmi'
icon_state="b_beam"
var/tmp/atom/BeamSource
New()
..()
spawn(10) del src

/obj/portal
name = "portal"
icon = 'stationobjs.dmi'
Expand Down
7 changes: 7 additions & 0 deletions code/defines/obj/clothing/jumpsuit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
item_state = "bl_suit"
color = "black"

/obj/item/clothing/under/color/blackf
name = "Female Black Jumpsuit"
desc = "This one is a lady-size!"
icon_state = "black"
item_state = "bl_suit"
color = "blackf"

/obj/item/clothing/under/color/blue
name = "Blue Jumpsuit"
icon_state = "blue"
Expand Down
38 changes: 20 additions & 18 deletions code/defines/procs/helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,22 @@
if(degree < 315) return WEST
return NORTH|WEST

//Returns direction that the mob or whomever should be facing in relation to the target.
//This proc does not grant absolute direction and is mostly useful for 8dir sprite positioning.
//I personally used it with getline() to great effect.
/proc/get_dir_to(turf/start,turf/end)//N
var/xdiff = start.x - end.x//The sign is important.
var/ydiff = start.y - end.y

var/direction_x = xdiff<1 ? 4:8//East - west
var/direction_y = ydiff<1 ? 1:2//North - south
var/direction_xy = xdiff==0 ? -4:0//If x is the same, subtract 4.
var/direction_yx = ydiff==0 ? -1:0//If y is the same, subtract 1.
var/direction_f = direction_x+direction_y+direction_xy+direction_yx//Finally direction tally.
direction_f = direction_f==0 ? 1:direction_f//If direction is 0(same spot), return north. Otherwise, direction.

return direction_f
/proc/angle2text(var/degree)
return dir2text(angle2dir(degree))

/proc/Get_Angle(atom/movable/start,atom/movable/end)//For beams.
if(!start || !end) return 0
var/dy
var/dx
dy=(32*end.y+end.pixel_y)-(32*start.y+start.pixel_y)
dx=(32*end.x+end.pixel_x)-(32*start.x+start.pixel_x)
if(!dy)
return (dx>=0)?90:270
.=arctan(dx/dy)
if(dy<0)
.+=180
else if(dx<0)
.+=360

//Returns location. Returns null if no location was found.
/proc/get_teleport_loc(turf/location,mob/target,distance = 1, density = 0, errorx = 0, errory = 0, eoffsetx = 0, eoffsety = 0)
Expand Down Expand Up @@ -472,9 +473,6 @@ Turf and target are seperate in case you want to teleport some distance from a t

return destination

/proc/angle2text(var/degree)
return dir2text(angle2dir(degree))

/proc/text_input(var/Message, var/Title, var/Default, var/length=MAX_MESSAGE_LEN)
return sanitize(input(Message, Title, Default) as text, length)

Expand Down Expand Up @@ -984,6 +982,10 @@ Turf and target are seperate in case you want to teleport some distance from a t
/proc/between(var/low, var/middle, var/high)
return max(min(middle, high), low)

proc/arctan(x)
var/y=arcsin(x/sqrt(1+x*x))
return y

//returns random gauss number
proc/GaussRand(var/sigma)
var/x,y,rsq
Expand Down
Loading

0 comments on commit fe889a3

Please sign in to comment.