ok my battle system worked fine but i added class/save and i login thro that now but now the monster dont read my guy
be sure to pay good attenion there are 2 systems hhere
contact me at [email protected] or post on here plz tell me what you did if you fix it
mob/proc
this is the battle system
Rbattle(mob/Enemy,mob/Enemy2,mob/Enemy3)
var/turf/Map
for (var/turf/BattleGrounds/BatLoc in world)
var/Taken=0
for (var/atom/A in BatLoc)
if(A.density==1){Taken=1}
if(!Taken){Map=BatLoc}
if (!Map){return}
usr.XLoc=usr.x
usr.YLoc=usr.y
usr.ZLoc=usr.z
usr.inbattle=1
usr.south=0
usr.Move(Map)
usr.dir=WEST
usr<<"You are under attack!
To attack hit Numpad 5 with numlock off."
usr.client.lazy_eye = 5
textonscreenbackground(1,1,5,3)
textonscreenTEXT(1.5,12,3,1.3," Attack")
textonscreenTEXT(1.5,12,2,1.3," Run")
new/obj/menu/Curser(usr.client)
if(Enemy!=null)Enemy.Move(locate(usr.x-4,usr.y,usr.z))
if(Enemy2!=null)Enemy2.Move(locate(usr.x-4,usr.y + 1,usr.z))
if(Enemy3!=null)Enemy3.Move(locate(usr.x-4,usr.y-1,usr.z))
var/list/WhichTurn=new()
var/list/ppl=new()
for(var/mob/Aa in world)ppl+=Aa
var/nextturn,PlayerOrder
do
for (var/aa=0;aa<=length(ppl);aa++)
PlayerOrder=0
for(var/mob/ppp in ppl)
if (ppp.Agility>PlayerOrder){nextturn=ppp;PlayerOrder=ppp.Agi lity}
else if (ppp.Agility==PlayerOrder)nextturn=ppp
WhichTurn+=nextturn
ppl-=nextturn
while (length(ppl)>0)
do
for(var/mob/pp in WhichTurn)
if (pp.Health>0)
if (pp.client)
if(usr.inbattle==1){pp<<"It is now your turn!";pp.Turn = 1}
else return
while(pp.Turn)sleep(5)
else{pp.MonsterAttack()}
while(1)
//You Attack
Attack()
var/list/MonsterList=new()
for (var/mob/M in view())
if(M!=null)
if (M.Health > 0){MonsterList += M}
MonsterList-=usr
MonsterList += "Cancel"
var/mob/enemy = input("knight") in MonsterList
if (enemy == "Cancel")
return
var/hitpercent=50+usr.Dexterity
var/hitpercent2=hitpercent-enemy.Agility
if(hitpercent2>100) hitpercent2=100
if(hitpercent2<0) hitpercent=0
var/hitpercent3=rand(1,100)
var/damagefirst=rand(usr.Strength)
var/damagecount=damagefirst-enemy.Defense
sleep(2)
if(hitpercent3 <= hitpercent2)
if(damagecount > 0)
enemy.Health -= damagecount
view()<<"[usr] Attacks [enemy] for [damagecount]"
if (enemy != null)
if (enemy.Health < 1)
if (istype(enemy,/mob/monsters)){enemy.icon = null}
usr.Victory()
usr.Turn = 0
else{view() << "[usr]'s attack bounced off [enemy].";usr.Turn = 0}
else{view() << "[usr] attacks [enemy], but misses.";usr.Turn = 0}
//Monster Attack
mattack()
for (var/mob/Player in view())
if (Player.client && Player.Health > 0)
for (var/mob/M in view())
if (M.Bnum == Bnum && M.client)
var/hitpercent=50+usr.Dexterity
var/hitpercent2=hitpercent - M.Agility
if(hitpercent2>100) hitpercent2 = 100
if(hitpercent2<0) hitpercent = 0
var/hitpercent3=rand(1,100)
var/damagefirst=rand(src.Strength)
var/damagecount=damagefirst-M.Defense
sleep(2)
if(hitpercent3 <= hitpercent2)
if(damagecount > 0){M.Health -= damagecount;view()<<"[src] Attacks [M] for [damagecount]";M.DeathCheck()}
else{view() << "[src]'s attack bounced off [M]."}
else{view() << "[src] attacks [M], but misses."}
//Run, Run RUN!!
Run()
switch(rand(1,3))
if(3)
usr<<"You tryed to run, And Succeeded!"
usr.inbattle=0
usr.client.lazy_eye = 0
usr.Bnum = 0
usr.Turn=0
usr.close_menu()
for(var/mob/monsters/M in oview(5)) del M
usr.Move(locate(usr.XLoc,usr.YLoc,usr.ZLoc))
else{usr<<"You tryed to run, but failed.";usr.Turn=0}
//When you die, aww
DeathCheck()
if(istype(src,/mob/person))
if(src.Health<=0)
src.icon_state = null
src.client.lazy_eye = 0
src.Move(locate(usr.XLoc, usr.YLoc, usr.ZLoc))
src.Bnum = 0
src.inbattle=0
src.close_menu()
src<<"you died"
//Victory proc, when you win! DING DING
Victory()
var/mm=0
for(var/mob/monsters/M in oview(5))
if(M!=null)
if (M.Health > 0)
mm++
if(mm==0)
var/Gained_Exp
for(var/mob/monsters/M in oview(5))
Gained_Exp+=M.exp
del M
usr<<"Victory is at hand"
usr<<"You Gained [Gained_Exp] Experience!"
usr.close_menu()
usr.exp+=Gained_Exp
usr.Leveling_up()
usr.inbattle=0
usr.client.lazy_eye = 0
usr.Bnum = 0
usr.Move(locate(usr.XLoc,usr.YLoc,usr.ZLoc))
//Level up proc
Leveling_up()
if(usr.exp>=usr.maxexp)
usr<<"You gained a level!"
usr.Level++
usr.exp=0
usr.maxexp+=usr.maxexp/5
usr.Strength++
usr<<"Strength + 1"
usr.Defense++
usr<<"Defense + 1"
usr.Health+=20
usr.MaxHealth+=20
usr<<"Health + 20"
close_menu()
for(var/obj/text/O in client.screen)del O
for(var/obj/back/O in client.screen)del O
for(var/obj/menu/O in client.screen)del O
textonscreenbround(var/Xcoord1, var/Ycoord1, var/Xcoord2, var/Ycoord2)
for(var/Xcoord=Xcoord1,Xcoord<=Xcoord2,Xcoord++)
for(var/Ycoord=Ycoord1,Ycoord<=Ycoord2,Ycoord++)
var/obj/back/background=new(client)
if(Xcoord==Xcoord1)background.icon_state="l"
if(Xcoord==Xcoord2)background.icon_state="r"
if(Ycoord==Ycoord1)background.icon_state="b"
if(Ycoord==Ycoord2)background.icon_state="t"
if(Xcoord==Xcoord1&&Ycoord==Ycoord1)background.icon_state="l l"
if(Xcoord==Xcoord2&&Ycoord==Ycoord2)background.icon_state="u r"
if(Xcoord==Xcoord1&&Ycoord==Ycoord2)background.icon_state="u l"
if(Xcoord==Xcoord2&&Ycoord==Ycoord1)background.icon_state="l r"
background.screen_loc="[Xcoord],[Ycoord]"
textonscreenTEXT(var/Xcoord1, var/Xcoord2, var/Ycoord1, var/Ycoord2,var/T)
var Xcoord=Xcoord1,Ycoord=Ycoord1
Textonscreenproc(T)
for(var/Y in textonscreenlist)
var/obj/text/characters=new(client)
if(Xcoord==round(Xcoord)&&Ycoord==round(Ycoord)) characters.screen_loc="[Xcoord],[Ycoord]"
else if(Xcoord!=round(Xcoord)&&Ycoord==round(Ycoord)) characters.screen_loc="[Xcoord-0.5]:16,[Ycoord]"
else if(Xcoord==round(Xcoord)&&Ycoord!=round(Ycoord)) characters.screen_loc="[Xcoord],[Ycoord-0.5]:+16"
else if(Xcoord!=round(Xcoord)&&Ycoord!=round(Ycoord)) characters.screen_loc="[Xcoord-0.5]:16,[Ycoord-0.5]:+16"
characters.icon_state="[Y]"
Xcoord+=0.5
if(Xcoord==Xcoord2)
Xcoord=Xcoord1;Ycoord-=0.5
if(Ycoord==Ycoord2-0.5)
break
Textonscreenproc(var/textonscreen)
textonscreenlist=list()
for(var/a=1,a<=length(textonscreen),a++)
textonscreenlist+=copytext(textonscreen,a,a+1)
mob/proc
//starts the random battle
tbattle(mob/Enemy,mob/Enemy2,mob/Enemy3)
var/turf/Map
for (var/turf/BattleGrounds/BatLoc in world)
var/Taken=0
for (var/atom/A in BatLoc)
if(A.density==1){Taken=1}
if(!Taken){Map=BatLoc}
if (!Map){return}
usr.XLoc=usr.x
usr.YLoc=usr.y
usr.ZLoc=usr.z
usr.inbattle=1
usr.south=0
usr.Move(Map)
usr.dir=WEST
usr<<"You are under attack!
To attack hit Numpad 5 with numlock off."
usr.client.lazy_eye = 5
textonscreenbackground(1,1,5,3)
textonscreenTEXT(1.5,12,3,1.3," Attack")
textonscreenTEXT(1.5,12,2,1.3," Run")
new/obj/menu/Curser(usr.client)
if(Enemy!=null)Enemy.Move(locate(usr.x-4,usr.y,usr.z))
if(Enemy2!=null)Enemy2.Move(locate(usr.x-4,usr.y + 1,usr.z))
if(Enemy3!=null)Enemy3.Move(locate(usr.x-4,usr.y-1,usr.z))
var/list/WhichTurn=new()
var/list/ppl=new()
for(var/mob/Aa in world)ppl+=Aa
var/nextturn,PlayerOrder
do
for (var/aa=0;aa<=length(ppl);aa++)
PlayerOrder=0
for(var/mob/ppp in ppl)
if (ppp.Agility>PlayerOrder){nextturn=ppp;PlayerOrder=ppp.Agi lity}
else if (ppp.Agility==PlayerOrder)nextturn=ppp
WhichTurn+=nextturn
ppl-=nextturn
while (length(ppl)>0)
do
for(var/mob/pp in WhichTurn)
if (pp.Health>0)
if (pp.client)
if(usr.inbattle==1){pp<<"It is now your turn!";pp.Turn = 1}
else return
while(pp.Turn)sleep(5)
else{pp.MonsterAttack()}
while(1)
//You Attack
var/list/MonsterList=new()
for (var/mob/M in view())
if(M!=null)
if (M.Health > 0){MonsterList += M}
MonsterList-=usr
MonsterList += "Cancel"
var/mob/enemy = input("Attack who?") in MonsterList
if (enemy == "Cancel")
return
var/hitpercent=50+usr.Dexterity
var/hitpercent2=hitpercent-enemy.Agility
if(hitpercent2>100) hitpercent2=100
if(hitpercent2<0) hitpercent=0
var/hitpercent3=rand(1,100)
var/damagefirst=rand(usr.Strength)
var/damagecount=damagefirst-enemy.Defense
sleep(2)
if(hitpercent3 <= hitpercent2)
if(damagecount > 0)
enemy.Health -= damagecount
view()<<"[usr] Attacks [enemy] for [damagecount]"
if (enemy != null)
if (enemy.Health < 1)
if (istype(enemy,/mob/monsters)){enemy.icon = null}
usr.Victory()
usr.Turn = 0
else{view() << "[usr]'s attack bounced off [enemy].";usr.Turn = 0}
else{view() << "[usr] attacks [enemy], but misses.";usr.Turn = 0}
//Monster Attack
MonsterAttack()
for (var/mob/Player in view())
if (Player.client && Player.Health > 0)
for (var/mob/M in view())
if (M.Bnum == Bnum && M.client)
var/hitpercent=50+usr.Dexterity
var/hitpercent2=hitpercent - M.Agility
if(hitpercent2>100) hitpercent2 = 100
if(hitpercent2<0) hitpercent = 0
var/hitpercent3=rand(1,100)
var/damagefirst=rand(src.Strength)
var/damagecount=damagefirst-M.Defense
sleep(2)
if(hitpercent3 <= hitpercent2)
if(damagecount > 0){M.Health -= damagecount;view()<<"[src] Attacks [M] for [damagecount]";M.DeathCheck()}
else{view() << "[src]'s attack bounced off [M]."}
else{view() << "[src] attacks [M], but misses."}
//Run, Run RUN!!
switch(rand(1,3))
if(3)
usr<<"You tryed to run, And Succeeded!"
usr.inbattle=0
usr.client.lazy_eye = 0
usr.Bnum = 0
usr.Turn=0
usr.close_menu()
for(var/mob/monsters/M in oview(5)) del M
usr.Move(locate(usr.XLoc,usr.YLoc,usr.ZLoc))
else{usr<<"You tryed to run, but failed.";usr.Turn=0}
//When you die, aww
if(istype(src,/mob/person))
if(src.Health<=0)
src.icon_state = null
src.client.lazy_eye = 0
src.Move(locate(usr.XLoc, usr.YLoc, usr.ZLoc))
src.Bnum = 0
src.inbattle=0
src.close_menu()
src<<"you died"
//Victory proc, when you win! DING DING
var/mm=0
for(var/mob/monsters/M in oview(5))
if(M!=null)
if (M.Health > 0)
mm++
if(mm==0)
var/Gained_Exp
for(var/mob/monsters/M in oview(5))
Gained_Exp+=M.exp
del M
usr<<"Victory is at hand"
usr<<"You Gained [Gained_Exp] Experience!"
usr.close_menu()
usr.exp+=Gained_Exp
usr.Leveling_up()
usr.inbattle=0
usr.client.lazy_eye = 0
usr.Bnum = 0
usr.Move(locate(usr.XLoc,usr.YLoc,usr.ZLoc))
//Level up proc
if(usr.exp>=usr.maxexp)
usr<<"You gained a level!"
usr.Level++
usr.exp=0
usr.maxexp+=usr.maxexp/5
usr.Strength++
usr<<"Strength + 1"
usr.Defense++
usr<<"Defense + 1"
usr.Health+=20
usr.MaxHealth+=20
usr<<"Health + 20"
for(var/obj/text/O in client.screen)del O
for(var/obj/back/O in client.screen)del O
for(var/obj/menu/O in client.screen)del O
textonscreenbackground(var/Xcoord1, var/Ycoord1, var/Xcoord2, var/Ycoord2)
for(var/Xcoord=Xcoord1,Xcoord<=Xcoord2,Xcoord++)
for(var/Ycoord=Ycoord1,Ycoord<=Ycoord2,Ycoord++)
var/obj/back/background=new(client)
if(Xcoord==Xcoord1)background.icon_state="l"
if(Xcoord==Xcoord2)background.icon_state="r"
if(Ycoord==Ycoord1)background.icon_state="b"
if(Ycoord==Ycoord2)background.icon_state="t"
if(Xcoord==Xcoord1&&Ycoord==Ycoord1)background.icon_state="l l"
if(Xcoord==Xcoord2&&Ycoord==Ycoord2)background.icon_state="u r"
if(Xcoord==Xcoord1&&Ycoord==Ycoord2)background.icon_state="u l"
if(Xcoord==Xcoord2&&Ycoord==Ycoord1)background.icon_state="l r"
background.screen_loc="[Xcoord],[Ycoord]"
var Xcoord=Xcoord1,Ycoord=Ycoord1
for(var/Y in textonscreenlist)
var/obj/text/characters=new(client)
if(Xcoord==round(Xcoord)&&Ycoord==round(Ycoord)) characters.screen_loc="[Xcoord],[Ycoord]"
else if(Xcoord!=round(Xcoord)&&Ycoord==round(Ycoord)) characters.screen_loc="[Xcoord-0.5]:16,[Ycoord]"
else if(Xcoord==round(Xcoord)&&Ycoord!=round(Ycoord)) characters.screen_loc="[Xcoord],[Ycoord-0.5]:+16"
else if(Xcoord!=round(Xcoord)&&Ycoord!=round(Ycoord)) characters.screen_loc="[Xcoord-0.5]:16,[Ycoord-0.5]:+16"
characters.icon_state="[Y]"
Xcoord+=0.5
if(Xcoord==Xcoord2)
Xcoord=Xcoord1;Ycoord-=0.5
if(Ycoord==Ycoord2-0.5)
break
tonscreen(var/textonscreen)
textonscreenlist=list()
for(var/a=1,a<=length(textonscreen),a++)
textonscreenlist+=copytext(textonscreen,a,a+1)
and this is the saving system
Login()
// Spawn here to avoid problems with calling prompts during login.
spawn()
src.CreateCharacter()
proc/CreateCharacter()
// In this case, the code creates a /mob/human or /mob/ogre with the specified attributes.
// Get the character information from them. (You would probably want to do with this a browser page.)
var/prompt_title = "New Character"
var/help_text = "What do you want to name the character?"
var/default_value = key
var/char_name = input(src, help_text, prompt_title, default_value) as null|text
if (!char_name)
// Guess they don't want to create a new character after all, so send them to choose a character.
client.base_ChooseCharacter()
return
// Make sure there isn't already a character named that.
// Character names are stored as ckey, so get the ckey version of the name.
var/ckey_name = ckey(char_name)
var/list/characters = client.base_CharacterNames()
if (characters.Find(ckey_name))
alert("You already have a character named that! Please choose another name.")
src.CreateCharacter()
return
var/list/classes = list("fighter", "knight")
help_text = "Which class would you like to be?"
default_value = "fighter"
var/char_class = input(src, help_text, prompt_title, default_value) in classes
// Okay we have enough information, so it's time to create the character and switch the player to it.
var/mob/new_mob
switch(char_class)
if ("fighter") new_mob = new /mob/fighter()
if ("knight") new_mob = new /mob/knight()
// Set the attributes.
new_mob.name = char_name
// Now switch the player client over to the new mob and delete myself since I'm no longer needed.
src.client.mob = new_mob
var/turf/first_location = locate(1, 1, 1)
new_mob.Move(first_location)
del(src)
mob
Login()
..()
// This is just here for this sample, to make it clear which mob you've logged into.
sample_report()
verb
add_save_verb()
// Adds save_me verb to the mob, to show that verb saving works.
src.verbs += /mob/proc/save_me
remove_save_verb()
src.verbs -= /mob/proc/save_me
proc
sample_report()
src << "
"
src << "\blue You are [name]."
src << "\blue Your class is [type]."
save_me()
// This demonstrates verb saving and how to manually save the mob whenever you want..
// This proc gets added and saved as a verb only if add_verb is called by the player.
src.client.base_SaveMob()
src << "\red You have been saved."
mob/fighter
icon = 'fighter.dmi'
mob/knight
icon = 'knight.dmi'
</1></1></0></0></0></0>
ID:143091
Dec 21 2007, 5:14 pm
|
|
Your only allowed to post your problem in one thread.