ID:159323
 
obj/flag
icon = 'flag.dmi'






//CAPTURE THE FLAG TIME!

var/list/teams=list("R"=list(),"B"=list())

GM/verb/Start_CTF()
set category = "GM"
if(!CTF_Status)
switch(input("Start CTF?") in list("Yes","No"))
if("Yes")
world << "<font color = yellow><b>**Capture the Flag event has Started!!!</font></b>"
CTF_Status = 1
else return

proc/CTF_Players()
return length(teams["R"])+length(teams["B"])

mob/verb/Join_Capture_The_Flag()
if(!CTF_Status)
src << "There is no CTF game going on."
return 0
if(CTF_Players() <= maxplayers)
if(length(team["R"])==length(team["B"]))
var/teamcolor=pick("R","B")
world<<"[src.name] has been picked to join [teamcolor]!"
teams[teamcolor]+=src
src<<"You are Player[CTF_Players()]"
if(teamcolor=="R") src.Move(locate(locate(x,y,z),src.dir))
else src.Move(locate(locate(x,y,z),src.dir))
return 1
if(length(team["R"])<length(team["B"]))
var/teamcolor="R"
world<<"[src.name] has been picked to join [teamcolor]!"
teams[teamcolor]+=src
src<<"You are Player[CTF_Players()]"
src.Move(locate(locate(x,y,z),src.dir))
return 1
if(length(team["R"])>length(team["B"]))
var/teamcolor="B"
world<<"[src.name] has been picked to join [teamcolor]!"
teams[teamcolor]+=src
src<<"You are Player[CTF_Players()]"
src.Move(locate(locate(x,y,z),src.dir))
return 1
else src<<"CTF is full. No more players are allowed in. You'll have to wait for the next game."



obj/flag
var/team
density = 1

mob
Bump(atom/A)
if(istype(A,/obj/flag))
var/obj/flag
if(team != src.team)

if(flag.Move(src))

src << "You pick up \an [team] flag!"
else
src << "You cannot pick this up!"
else
src << "You cannot pick up your own flag!"
Enter(atom/movable/A)
if(src.contents.len)
return
return 1

mob/proc/Death()
var/obj/Flag = locate() in src
if(Flag) //if there is a lag obj in src's contents...
Flag.Move(locate(x,y,z))

DeathCheck()
hits+=1
usr.mhit+=1
spawn(1)
usr.Unlock()
if(le<=0)
if(icon=='Barrier.dmi')
del src
if(mode == "Boss Battle" && src.boss == 1)
world << "<B><U><FONT COLOR = R>WORLD ANNOUNCEMENT:</B> <font color=R>[usr] has defeated the boss [src]!"
world << "[usr] won 1 event point!"
src.boss = 0
usr.events += 1
else
usr<<"You have defeated [src]!"
src<<"[usr] has defeated you."
src.le=src.mle
if(usr.le==usr.mle)
usr.pkills+=1
if(usr.le<=4)
usr.cckills+=1
usr.kills+=1
src.deaths+=1
if(usr.team=="B")
Bscore+=1
if(usr.team=="R")
Rscore+=1
if(usr.team=="G")
greenscore+=1
if(usr.team=="Y")
yellowscore+=1
if(usr.team=="RB")
rainbowscore+=1
if(usr.npc==1)
del(src)
spawn(1)
chartype=""
overlays=null
icon=null
barr=0
direction="right"
loc=locate(,,)
status="g"
canmove=1
delayattack=0
shotdelay=0
LockShow()
usr.Unlock()


mob/Stat()
statpanel("Scores")
stat("Kills",kills)
stat("Deaths",deaths)
stat("Perfect Kills",pkills)
stat("Close Call Kills",cckills)
stat("Event Points",events)
stat("Chat Points",chat)
statpanel("Random Scores")
stat("Deflects",deflects)
stat("Suicides",suicides)
stat("Melee Weapon Uses",melee)
stat("Melee Weapon Hits",mhit)
stat("Projectile Weapon Uses",projectile)
stat("Projectile Weapon Hits",phit)
stat("Times been hit",hits)
stat("Times dodged projectiles",pdodge)
stat("Jumps",jumps)
stat("Dashes",dashes)
statpanel("World Scores")
stat("B team",Bscore)
stat("Green team",greenscore)
stat("R team",Rscore)
stat("Yellow team",yellowscore)
stat("Rainbow team",rainbowscore)
if(mode=="PTB")
statpanel("Bases")
for(var/mob/base/B/B in world)
stat("B",B.le)
for(var/mob/base/R/R in world)
stat("R",R.le)
for(var/mob/base/Yellow/Y in world)
stat("Yellow",Y.le)
for(var/mob/base/Green/G in world)
stat("Green",G.le)


that's what I have so far. I got myself stuck... I still need to code in the spawn point for the flags, like where they start, and than after someone dies, and it is bumped, where it returns to. And I need a score system, so like everytime a flag is "captured" it tallies 1 score, and the CTF is over at 5. Thanks in advance.
This isn't a code request forum, though sometimes I and some others will post code snippets for you and others like you to study.

You want to look at the initial() proc and Bump() proc for the flag returning to its original location when bumped into.

As for the score system, two simple world variables should do the trick. Every time someone of the opposite team "captures" or *enters their base with the opposing team's flag in their contents, add a score to the appropriate team.

* hint: look up the Entered() proc
In response to Spunky_Girl (#1)
Wow, I look at this code ag ain and it all comes together. Sorry, GUess I've been kinda sick lately, and it's affect(effecting?) my thought process. Guess I just got frustrated. Once again Spunky_Girl is here to save the day! lol.

1 more thing, I guess im just being dumb again and can think of it, I have after death if somehas the flag it returns to (x,y,z) what should I put to get it return to its original icon at the spot of death?