mob/proc/levelup()
ini
if(xp>=maxxp)
xp-=maxxp
maxxp*=2
level+=1
usr<<"\blue Level Up"
sleep(5)
goto ini
Problem description:
Its hard to maintain the fps when this proc starts, then i need a way to check the xp without an ifinite loop
Code:
mob/proc/levelup() Problem description: Its hard to maintain the fps when this proc starts, then i need a way to check the xp without an ifinite loop |
Another thing; don't use goto, and 'usr' doesn't belong in procs; you're gonna wanna replace usr << "\blue Level up" with something like src << "<span style='color=#00f'>Level Up</span>" (you'd use src for correctness and security reasons (as usr would cause a crash when it's not used in a verb), and the <span> is just applying CSS, which is more or less a preference of mine)
Like Goose said, you would want to call levelup() in a Death() proc, like such: mob/proc/Death(mob/killer) |
Danielkage wrote:
but if i get xp to lvl up twice, the code wont work for the two lvls replace if(xp >= maxxp) with while(xp >= maxxp). |
but if i get xp to lvl up twice, the code wont work for the two lvls Ah, then what you are looking for, is a while loop. As pointed out by Pokemonred200: mob/proc/levelup() |
Pokemonred200 wrote:
Another thing; don't use goto, and 'usr' doesn't belong in procs; you're gonna wanna replace usr << "\blue Level up" with something like src << "<span style='color=#00f'>Level Up</span>" (you'd use src for correctness and security reasons (as usr would cause a crash when it's not used in a verb), and the <span> is just applying CSS, which is more or less a preference of mine) > mob/proc/Death(mob/killer) Now its glitching with my verb to give xp(train simulator) verb/Give_XP(mob/m in world) Admin.dm:60:error: Bad input type: usr.levelup Admin.dm:60:error: input type (usr.levelup) must be atomic (area, turf, obj, or mob). |
You're probably looking for something like:
verb/Give_XP(mob/M as mob in world) Before, your indentation was off, so input() may have seen it as extra info for what you were going to provide. Also, mob/M in world would look for every object in world (which includes the tiles on the map), whereas mob/M as mob in world would only look for mobs. And finally, since you were using src and usr in Give_XP, you're effectively giving experience to yourself, rather than the player (mob/M) that you selected. |
mob/verb Here is a simple example. Instead of increasing the xp variable directly use the AddXP() proc to increase xp by the amount you want and it will then check if they leveled up for you. |
So, for instance, if you have a "Death" code that checks if character A killed character B, then you should call "levelup" in that function: