ID:157407
 
I have 3 questions:

1.How can I figure out the max map size that I could create a title screen for? I made my map display 11 by 11 icons and set my view on 5 but an icon at spot 11,11 on login was closer looking to me, it was not on the edge (the map was anchored).

2. How can I get a proc to continue forever? Here is what I have.

3.Am I using round correctly here? I want the divided answer in one part to be rounded.

mob/var/continuE = 3
mob/proc/Regeneration()
while(continuE)
if(src.chakra<src.maxchakra)
src.chakra+=src.chakraregen
src.stamina+=src.staminaregen/round(3)
if(src.chakra>src.maxchakra)
src.chakra = src.maxchakra
..()
if(src.stamina>src.maxstamina)
src.stamina = src.maxstamina
..()
if(src.chakra==src.maxchakra)
src.stamina+=src.staminaregen
if(src.stamina>src.maxstamina)
src.stamina = src.maxstamina
..()
1) Look up client.eye and client.perspective. That may be your problem.

2) ... that code is just friggin' god awful. I don't even know what you're trying to do. In any case, use while(1) (if Kaioken shows up spewing claims that for() is better than while(1), ignore the lunatic), and look into the sleep() proc. Programs don't like infinite loops that don't pause.
In response to Popisfizzy
Can you maybe correct me on what is so awful, ignoring the locate.
In response to Darkjohn66
This part:
mob/var/continuE = 3
mob/proc/Regeneration()
while(continuE)
if(src.chakra<src.maxchakra)
src.chakra+=src.chakraregen
src.stamina+=src.staminaregen/round(3)
if(src.chakra>src.maxchakra)
src.chakra = src.maxchakra
..()
if(src.stamina>src.maxstamina)
src.stamina = src.maxstamina
..()
if(src.chakra==src.maxchakra)
src.stamina+=src.staminaregen
if(src.stamina>src.maxstamina)
src.stamina = src.maxstamina
..()
In response to Popisfizzy
I did not ask what is wrong, but how to fix it/do it a different way, so why are you using sarcasm. Also, I originally tried using while(1) but it never increased, and it still isn't.
mob/proc/Regeneration()
while(1)
sleep(2)
if(src.chakra<src.maxchakra)
src.chakra+=src.chakraregen
src.stamina+=src.staminaregen/round(3)
if(src.chakra>src.maxchakra)
src.chakra = src.maxchakra
..()
if(src.stamina>src.maxstamina)
src.stamina = src.maxstamina
..()
if(src.chakra==src.maxchakra)
src.stamina+=src.staminaregen
if(src.stamina>src.maxstamina)
src.stamina = src.maxstamina
..()
mob/verb/test3()
src << "Your stamina:[src.stamina]"


Thanks so much!
In response to Darkjohn66
What are you trying to do? Have them regenerate stamina at a constant rate?

[Edit]

Fixed a few things 'cause I realized how I was doing it was stupid.

mob
var
// They regen 10 stamina every 2 seconds.
stamina_regen_rate = 10
stamina_regen_time = 20

proc/RegenerateStamina()
// Make sure you use spawn() when calling this, or
// else the proc calling it will never move on.

while(1)
sleep(sleep_regen_time)

stamina += stamina_regen_rate
if(stamina > max_stamina)
stamina = max_stamina


There are better ways to handle this, though. One method I would use is to keep stamina (and a fair amount of other stats) in a datum, and only begin to regen when the the stat is damaged. Damaging would be done by another proc, which would check when to call it.
In response to Popisfizzy
I was trying to make a levelup sort of proc but it is not working.

mob/proc/LevelUp()
while(1)
if(exp>maxexp)
sleep(1)
exp = 0
maxexp*=round(1.25)
level++
str++
skillpoints+=100
maxstamina+=10
staminaregen++


mob
proc/RegenerateStamina()
while(1)
sleep(staminaregentime)

stamina += staminaregen
if(stamina < maxstamina)
exp+=90
if(stamina > maxstamina)
stamina = maxstamina


The exp amount just keeps increasing nothing ever changes.
In response to Darkjohn66
You only need to check if exp > maxexp immediately after you change exp. There's no reason to be checking it ten times a second.
In response to Garthor
Aw. So, what your saying is, I have to repeatly call procs instead of looping through forever even if it will be called in almost everything anyways?


mob/proc/KO()
while(1)
if(stamina <= 0)
icon_state = "ko"
wounds+=rand(26,34)
stunned = 1
sleep(120)
stunned = 0
icon_state = "normal"
sleep(2)
In response to Darkjohn66
Yes. Of course, you can just make a proc that encapsulates the exp gain and calls the levelcheck() proc for you.

And by "can" I mean "should":

mob/proc/gainexp(var/N)
exp += N
levelcheck()


I also have no idea how the code you linked is relevant, here. I guess I'll point out that Bad Things will happen if a player logs out (and is saved) in the middle of it, though.
In response to Garthor
Is this the right idea?

mob/proc/Deathcheck(mob/M as mob)
// while(1)

if(stamina == 0||chakra == 0&&wounds>woundlimit||wounds==woundlimit)
if(stamina == 0||chakra == 0&&wounds>woundlimit||wounds==woundlimit)
M.bounty = M.bounty + round((bounty * 1.15 + rand(10,20) + M.bounty/6))
M.bountycheck()
bounty = 0
bountycheck()
world << "<U><B>[src] was killed by [M]!"
if(village == 2)
loc = locate(/turf/hospitalspawn/leaf)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 3)
loc = locate(/turf/hospitalspawn/sound)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 4)
loc = locate(/turf/hospitalspawn/suna)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 5)
loc = locate(/turf/hospitalspawn/mist)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 6)
loc = locate(/turf/hospitalspawn/rain)
wounds = 0
stamina = 1
chakra = 1
return
mob/proc/KO()
if(stamina <= 0||chakra <= 0)

icon_state = "ko"
wounds+=rand(26,34)
stunned = 1
Deathcheck()
sleep(120)
stunned = 0
icon_state = "normal"
sleep(2)


mob
proc/Regenerate()
while(1)
sleep(staminaregentime)
chakra+=chakraregen
stamina += staminaregen
if(stamina < maxstamina)
exp+=100
LevelUp()
if(stamina > maxstamina)
stamina = maxstamina
if(chakra > maxchakra)
chakra = maxchakra
KO()
/*
mob
proc/RegenerateChakra()
while(1)
sleep(chakraregentime)

chakra += chakraregen
if(chakra < maxchakra)
exp+=10
LevelUp()
if(chakra > maxchakra)
chakra = maxchakra
*/

mob/proc/LevelUp()
if(exp>maxexp)
exp = 0
maxexp = (round(maxexp * 1.25))
level++
str++
con++
int++
rfx++
attributepoints+=6
skillpoints+=100
maxstamina+=10
maxchakra+=10
staminaregen++
chakraregen++
In response to Darkjohn66
In response to Darkjohn66
mob/proc/Deathcheck(mob/M as mob)//This proc is completely pointless
// while(1)

if(stamina == 0||chakra == 0&&wounds>woundlimit||wounds==woundlimit)// So for someone to kill someone else you have to hit them so their stamina or chakra is EXACTLY 0? If you hit them below it, this check won't pass.
if(stamina == 0||chakra == 0&&wounds>woundlimit||wounds==woundlimit)// Why do you have the exact same check twice in a row?
M.bounty = M.bounty + round((bounty * 1.15 + rand(10,20) + M.bounty/6))
M.bountycheck()
bounty = 0
bountycheck()
world << "<U><B>[src] was killed by [M]!"
if(village == 2)//No
loc = locate(/turf/hospitalspawn/leaf)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 3)//No
loc = locate(/turf/hospitalspawn/sound)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 4)//No
loc = locate(/turf/hospitalspawn/suna)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 5)//No
loc = locate(/turf/hospitalspawn/mist)
wounds = 0
stamina = 1
chakra = 1
return
if(village == 6)//No. See how redundant that is? Why not move the wounds, stamina, and chakra edits to before the checks. You will save many lines of code.
loc = locate(/turf/hospitalspawn/rain)//I'm fairly sure this needs a (in list) to specify where it's checking but it could well default to in world, which is bad. You need a list devoted to holding just /turf/hospitalspawn, so that you can search through them for the right one and not the entire world.
wounds = 0
stamina = 1
chakra = 1
return
mob/proc/KO()
if(stamina <= 0||chakra <= 0)

icon_state = "ko"
wounds+=rand(26,34)
stunned = 1
Deathcheck() // You are calling a completely pointless proc here
sleep(120) // As Garthor mentioned, if someone logs out during this delay it will save them as being dead
stunned = 0
icon_state = "normal"
sleep(2)


mob
proc/Regenerate()
while(1)
sleep(staminaregentime)
chakra+=chakraregen
stamina += staminaregen
if(stamina < maxstamina)
exp+=100
LevelUp()
if(stamina > maxstamina)
stamina = maxstamina
if(chakra > maxchakra)
chakra = maxchakra
KO()//Why is this here? You are not lowering stamina or chakra, you are raising them. Assuming you call KO() where you should (Whenever stamina or chakra is lowered) then this check will never pass, and will be executing as fast as the program allows.

// You also don't have a delay here. All infinite loops need a delay, as a general rule. There are some exceptions, but this is not one of them.
/*
mob
proc/RegenerateChakra()
while(1)
sleep(chakraregentime)

chakra += chakraregen
if(chakra < maxchakra)
exp+=10
LevelUp()
if(chakra > maxchakra)
chakra = maxchakra
*/

mob/proc/LevelUp()
if(exp>maxexp)
exp = 0
maxexp = (round(maxexp * 1.25))
level++
str++
con++
int++
rfx++
attributepoints+=6
skillpoints+=100
maxstamina+=10
maxchakra+=10
staminaregen++
chakraregen++