ID:261865
 
Currently, and I do not know how it got this way, You only battle four times. I was looking through the code but I can't find anything that would be obvious to me. So I need your help, heres the code.


mob

Move()
switch(onbattlefield)
if ("battlearea1")
randomencounter1(src)
return ..()
else
return ..()

player
mob/var/turf/battlearea


mob/proc

beginning combat.
randomencounter1(mob/M as mob)
var/turf/battlearea/T
if (prob(20))
for(T in world)
if(!T.occupied)
T.occupied = 1
M.oldlocx = M.x
M.oldlocy = M.y
M.oldlocz = M.z
M.battlearea = T
spawn(1)M.Move(usr.battlearea)
M.oldbattlefield = M.onbattlefield
M.onbattlefield = null
M << "Fight!"
M << "Click on the monster you wish to attack to start"
spawn(1)new /mob/Wolf(locate(M.battlearea.x,M.battlearea.y+4,M.battlearea .z))
return 1
return 0




maincombat(mob/attacker as mob, mob/target as mob)
var/list/CombatOps1 = list("Normal Attack", "Hard Attack", "Run", "Akai Magic")
var/CombatOp1 = input(usr, "What do you wish to do?", "Combat", "Attack") in CombatOps1
switch (CombatOp1)
if ("Normal Attack")
attack(attacker, target)
if ("Hard Attack")
attack(attacker, target)
if ("Run")
flee(attacker, target)
if ("Akai Magic")
akaimagic(attacker, target)



attack(mob/attacker as mob, mob/target as mob)
attacker << "You chose to attack [src]"
if(prob(attacker.hit - target.evade))
normaldamage(attacker, target)
else
attacker << "You miss! And Deal No Damage"
npcattack1(attacker, target)

if(prob(attacker.hit - target.evade))
akaimagic(attacker, target)


and clear battle vars if success
flee(mob/attacker as mob, mob/target as mob)
if (rand(1,3) == 1)
attacker << "You successfuly run from [target]"
endbattle(attacker)
del(target)
else
attacker << "You failed to run and lose a turn!"
npcattack1(attacker, target)

hooray!
akaimagic(mob/attacker as mob, mob/target as mob)
var/maxdamage = attacker.magic - target.magicdefense - (target.agility / 15)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
attacker << "You miss! And Deal No Damage"
npcattack1(attacker, target)
else
attacker << "You hit [src] for [damage] points of damage using your akai!"
target.HP -= damage
npcdeathcheck(attacker, target)



normaldamage(mob/attacker as mob, mob/target as mob)
var/maxdamage = attacker.attack - target.defense - (target.agility / 15)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
attacker << "You miss! (0 dmg)"
npcattack1(attacker, target)
else
attacker << "You hit [src] for [damage] points of damage with a normal attack!"
target.HP -= damage
npcdeathcheck(attacker, target)


maincombat.
npcattack1(mob/defender as mob, mob/monster as mob)
if (prob (monster.hit))
defender << "The [monster] attacks you and hits!"
var/maxdamage = monster.attack - (defender.defense / 4) - (defender.agility / 20)
var/damage = rand ((maxdamage / 2), maxdamage)
if (damage <= 0)
defender << "The attack bounces harmlessly off you."
maincombat(defender, monster)
else
defender << "Hit for [damage] damage!"
defender.HP -= damage
playerdeathcheck(defender, monster)
else
defender << "The [monster] attacks you and misses!"
maincombat(defender, monster)

variables.
endbattle(mob/M as mob)
var/turf/battlearea/T = M.battlearea
T.occupied = 0
M.battlearea = null
M.loc = locate(M.oldlocx,M.oldlocy,M.oldlocz)
M.onbattlefield = M.oldbattlefield
M.oldbattlefield = null
M.oldlocx = null
M.oldlocy = null
M.oldlocz = null
checklevel(M)
You need to be a little more specific. Are you saying that the battle only lasts four rounds, or that it only lets you attack four times (and if so, what exactly happens after?), or that it will only go through four random combats and then no more are generated?

If the last one, I see one potential problem... look at your flee verb and your attack verb. You've got flee(mob/attacker,) and attack(mob/attacker,).... you don't need to ask who's fleeing and attacking, though, because the attacker is also the verb's src!

Do you realize that someone could use that flee verb to tell the Wolf (or whatever monster you're facing) to flee? If you inadvertently did that, then it wouldn't really clear the battle vars correctly, and that might somehow interfere with future battles.
In response to Hedgemistress
"or that it will only go through four random combats and then no more are generated?"

Ahh, i understand. I accidently did that, somehow? o.o;; ....i'm not exactly sure how i did that but how can I fix this, just remove (mob/attacker,)? Please explain ^^;
In response to Karasu Kami
If you can explain what exactly you want me to explain then I will happily explain it... I suggest in the future you take the time and energy you would otherwise expend creating little manga faces and devote it to spelling out exactly what your problem is.

If you're asking me to elaborate on the mob/attacker thing... you have a verb for attacking and one for fleeing. You need a way to tell the game who is being attacked, and (apparently) who is being fled from... you do not need to make a separate argument (that's what those things in parans after the verb name are called) to figure out who is attacking or who is fleeing, because that makes it so that when Bob the Game Player tries to attack the Wolf, the game will ask him "Who's Attacking? Who's Fleeing?", and allow him to force the Wolf to flee or even attack itself, causing all sorts of weird happenings.

If you just get rid of mob/attacker, you'll get compilation errors, because you mention attacker several other times in the code of each verb. The solution is to take mob/attacker out of the verb definition (the line with the verb name and the arguments) and change all mentions of attacker in the code of the verb to say "src" instead. "src" is the source of the verb, and in this case (and most cases where the person owns their own verb, they're not using a verb that belongs to an obj or other character), the "src" is automatically the person who's attacking/fleeing.
In response to Hedgemistress
That's quite harsh Hedge.
In response to Vakir
She doesnt like me, I guess. Thats fine though, atleast i'm getting help from Someone.
In response to Karasu Kami
Can anyone else solve the problem? I'm alright with normal code, but all of my team can not do anything with the battle system, they can only do normal things/guess what the problem and solution for the battle system is. Any help at all?
In response to Vakir
Harsh? :P Do a search on the forum for my key name and you'll see I'm being the model of restraint. The only thing I don't like about special K here is the way he assumes everyone doesn't like him when it's more like everyone doesn't know him.

You have to earn a reputation, even a negative one... you don't get points for telling people how cool you are, so why should you lose them for telling us how annoying you supposedly are? :P
In response to Hedgemistress
Alright, heres a response. Help, or don't help, this is the second thread of mine that i've had to redirect to get back on-topic. So please, help or don't post.
In response to Karasu Kami
A) Don't post on an open forum if you only want certain responses. Outright irrelevancy is frowned upon, yes, but conversations tend to evolve as they go and there's nothing wrong with that.

B) See my post at 3:12 p.m. 11/02/2003... if that's not helpful, clarify. What's confusing you, or does it simply not address your actual problem at all?

If you want help, <MAGIC FONT TAG OF EMPHASIS +3, ELVEN DEFENDER>you need to explain the problem.</MAGIC FONT TAG OF EMPHASIS +3, ELVEN DEFENDER> If you can't explain the problem, then how can anyone possibly begin to fix it? Helping people takes time and effort... if we have to read through your code and imagine what it does, and then compare that to what we imagine you want it to actually do... well, that's a lot of time and a lot of effort and in the end, it's kind of like trying to read tarot cards or tea leaves... it's 50% interpretation and 50% educated guesses. I'm sure I'm not the only qualified coder who's read your post and wants to help... I'm just the only such person who has bothered to take a guess at what exactly you're talking about.
In response to Hedgemistress
The problem is that, after spawning and creating a character (there is no save, Its not implemented yet...) You go through 4 battles, then thats it. You can then freely run through the map without any problem with monsters, nor anything else. It even continues to the next map you enter, thats my problem.