ID:174915
 
I have some problem with infinate loops or something. Like I coded my own battle system, and every once in a while if the battle goes on too long, I get an infinate loop bug to appear in Dream Daemon. If anyone wants to try and help, please page me(Metroid) or email me at WindMetroid@hotmail.com. Thanks ahead of time.
Build in a switch or use while
In response to Fint
It would be nice if you could either do it for me or tell me how to do it. I'm not a super genius that knows how to do something even if ive never heard of it before.
In response to Metroid
switch()
while()

look them up in the ref.


Airjoe
Metroid wrote:
I have some problem with infinate loops or something. Like I coded my own battle system, and every once in a while if the battle goes on too long, I get an infinate loop bug to appear in Dream Daemon. If anyone wants to try and help, please page me(Metroid) or email me at WindMetroid@hotmail.com. Thanks ahead of time.

You'll really need to post some of the code to your battle system before anyone can help you out with it.

Lummox JR
In response to Airjoe
Where should I put this in my code? Here I'll show you one of my procs and tell me where to add that.:
Attack_Up(mob/M)
if(M.attup >> 0)
if(M.mp >= 50)
var
attd = attup/10 * attack
M << "<font color = blue><b>You summon a burst of attack power!"
if(M.attackdoubled == 0)
M << "<font color = blue><b>Your attack increases!"
attd = round(attd)
M.attack += attd
M.attackdoubled = 1
M.mp -= 50
NPCDeathCheck(M)
else if(M.attackdoubled == 1)
M << "<font color = blue><b>The energy combinding in you suddenly bursts away!"
M.mp -= 50
NPCDeathCheck(M)
else
M << "<font color = blue><b>You don't have enouph MP!"
Battle(M)
else
M << "<font color = blue><b>You don't know this skill!"
Battle(M)


Oh and btw, while I'm at it and showing this spell, can u tell me why it dont work, like it seems to skip the var and not add anything. Please help with that too, thanks
In response to Metroid
Lemme explane

Lets say you have 4 differend procs that just run in a row untill someones HP is 0 or less.
When the battle takes a long time you will get that infinate loop error.
DOH

You can do two things:

-use a switch
-use while

You can make a switch to ask a player if he (for example) wants to keep attacking or wants to run.

switch(input(M,"What do you want to do?","Combat") in list("Attack","Run"))
if("Attack")
// What ever attack proc you want to continue with
if("Run")
// Call a proc to stop battle


You can also use while.

While(M.hp > 0)
spawn(20) //To make sure M wont attack each server tick
// Your procs here


If you use while then you wont have to loop cuz while keeps calling the code under it untill M.hp = 0 or less.

Well figure the rest out your self.
And if you can't find a answer to your problems then you sould not be making a battle system.
In response to Fint
Fint wrote:
And if you can't find a answer to your problems then you sould not be making a battle system.

First of all, if I don't make a battle system myself I can't, 1) Learn and fix my mistakes and make a better one later, 2) Have it the ways I want a battle system.
>switch(input(M,"What do you want to do?","Combat") in list("Attack","Run"))
> if("Attack")
> // What ever attack proc you want to continue with
> if("Run")
> // Call a proc to stop battle

I have something like that, it goes like this:
mob
proc
Battle(mob/M)
if(M.defend == 1)
M.defense /= 2
M.defend = 0
if(M.mem == 0)
M.memattack = M.attack
M.memdefense = M.defense
M.memintelligence = M.intelligence
M.memagility = M.agility
M.memluck = M.luck
M.mem = 1
M.lib = 1
M.battle = 1
switch(alert("[src] encountered! Command?",,"Commence Battle","Defend","Run"))
if("Commence Battle")
CommencedBattle(M)
if("Defend")
M.defense *= 2
M.defend = 1
NPCDeathCheck(M)
if("Run")
Run(M)

I don't see a problem with using an alert so don't pester me about it it does the same thing. And how do I use the while exactly? Like whats the spawn(20) about? (I'm sry if im acting like a newb im not completely acurate on some things still, either way, u didnt know at one time so help me out.) Like see i don't have a deathcheck like some people do i think, like after a player attacks, it checks NPCDeathcheck, here Ill show u my Death Checks:
PlayerDeathCheck(mob/M)
if(M.poisoned == 1)
var
poisond = M.maxhp/20
M << "<b><font color = blue>You lose HP due to poison!"
M.hp -= poisond
M.hp = round(M.hp)
if(M.hp <= 0)
M << "<b><font color = blue>You died! The [src] runs away with half your gold!"
M.gold/=2
M.gold = round(M.gold)
M.islocked = 0
M.hp = M.maxhp
M.lefttown = 0
M.battle = 0
M.lib = 0
M.poisoned = 0
M.x = M.innx
M.y = M.inny
M.z = M.innz
M.attack = M.memattack
M.defense = M.memdefense
M.intelligence = M.memintelligence
M.agility = M.memagility
M.luck = M.memluck
if(M.attackdoubled == 1)
M.attackdoubled = 0
if(M.defensedoubled == 1)
M.defensedoubled = 0
if(M.intelligencedoubled == 1)
M.intelligencedoubled = 0
if(M.luckdoubled == 1)
M.luckdoubled = 0
if(M.agilitydoubled == 1)
M.agilitydoubled = 0
M.mem = 0
del src
else
Battle(M)
else
if(M.hp <= 0)
M << "<b><font color = blue>You died! The [src] runs away with half your gold!"
M.gold/=2
M.gold = round(M.gold)
M.islocked = 0
M.hp = M.maxhp
M.lefttown = 0
M.battle = 0
M.lib = 0
M.x = M.innx
M.y = M.inny
M.z = M.innz
M.attack = M.memattack
M.defense = M.memdefense
M.intelligence = M.memintelligence
M.agility = M.memagility
M.luck = M.memluck
if(M.attackdoubled == 1)
M.attackdoubled = 0
if(M.defensedoubled == 1)
M.defensedoubled = 0
if(M.intelligencedoubled == 1)
M.intelligencedoubled = 0
if(M.luckdoubled == 1)
M.luckdoubled = 0
if(M.agilitydoubled == 1)
M.agilitydoubled = 0
del src
M.mem = 0
else
Battle(M)


NPCDeathCheck(mob/M)
if(src.hp <= 0)
M << "<font color = blue><b>You have killed the [src]!"
M << 'winbattle.wav'
M << "<font color = blue><b>You recieve [src.expreward] exp and [src.gold] Gold!"
if(src.jobexpreward >= 1)
M << "<font color = blue><b>You recieve [src.jobexpreward] job exp!"
M.jobexp += jobexpreward
M.attack = M.memattack
M.defense = M.memdefense
M.intelligence = M.memintelligence
M.agility = M.memagility
M.luck = M.memluck
if(M.attackdoubled == 1)
M.attackdoubled = 0
if(M.defensedoubled == 1)
M.defensedoubled = 0
if(M.intelligencedoubled == 1)
M.intelligencedoubled = 0
if(M.luckdoubled == 1)
M.luckdoubled = 0
if(M.agilitydoubled == 1)
M.agilitydoubled = 0
M.exp += src.expreward
M.gold += src.gold
M.islocked = 0
M.battle = 0
M.lib = 0
checkjoblevel(M)
checklevel(M)
M.mem = 0
del src
if(M.boss1 == 1)
M.boss1 = 0
M.boss1defeated = 1
M.loc = locate(16,9,1)
else
NPCAttack(M)


Please don't tell me to not do a new battle system or anything, just tell me what to do to fix the problem, I might be acting like a newb but you have to do something sometime to learn from your mistakes and inprove in coding.
Just be a nice guy and help someone out please.
In response to Lummox JR
On one of the other posts it has some of it, so check it out please.
In response to Metroid
Well, one thing you have to change right off is that you don't need two different DeathCheck() procs, and neither one is set up right. You pass M to PlayerDeathCheck(), but the only extra thing it needs to know is the killer. Instead you're using M and src in that proc interchangeably, where M should be the killer alone and src is the mob who may be dead.

And without keeping M and src straight, there's no hope of getting the rest taken care of. So you have to fix this other problem first.

Lummox JR