ID:176810
 
proc/UserAttack(mob/animal/attacker,mob/animal/enemy)
var/vary = rand(1,6)
var/vary2 = rand(1,3)
var/power = (attacker.Attack - enemy.Defense)/2 + (vary/vary2)//Line 15
enemy.Health -= power
world << "[attacker] hits [enemy] for [power] damage!"
Deathcheck(enemy,attacker)

proc/Deathcheck(mob/animal/M,mob/animal/killer)
if(M.Health <= 0)
world << "Battle is over! [M] was killed by [killer]"
BattleEnd(M,killer)
else
UserAttack(M,killer)


That's the main battling part. It's basically that there are two owners with thier two animals. And thier animals fight each other. Ya know, like those cartoon shows.

Here's how I call the proc (For demo purposes only)

world/New()
..()
UserAttack(/mob/animal/Falcon,/mob/animal/Eagle)


And this is the bug I get.

runtime error: Cannot read /mob/animal/Falcon (/mob/animal/Falcon).Attack
proc name: UserAttack (/proc/UserAttack)
source file: Combat.dm,15
usr: null
src: null
call stack:
UserAttack(/mob/animal/Falcon (/mob/animal/Falcon), /mob/animal/Eagle (/mob/animal/Eagle))
: New()

What I am aiming for is this:

Both fighters choose thier monsters they want to battle.
Monsters come out.
Fighters choose attacks (in turn based)
Monsters attack (in turns)
Repeat steps 2-4 until battle is over.

Please help,
Sariat
I don't think passing types into the argument will work, try creating the animals on the map first, then maybe something like:


var/mob/A
var/mob/B
for(var/mob/C in world)
if(istype(C,/mob/whatever))
A = C
break
for(var/mob/D in world)
if(istype(D,/mob/something))
B = D
break
UserAttack(A,B)



Not sure, though. It's untested.
In response to Xstream Sage
Xstream Sage wrote:
I don't think passing types into the argument will work, try creating the animals on the map first, then maybe something like:
var/mob/A
var/mob/B
for(var/mob/C in world)
if(istype(C,/mob/whatever))
A = C
break
for(var/mob/D in world)
if(istype(D,/mob/something))
B = D
break
UserAttack(A,B)

No idea what you're on about with that, but the code's pretty messed up.
For one thing: Why not just set A and B to the exact types you're searching for, or loop C and D for those types instead of looping through /mob and then checking istype() (which only makes sense if you don't know the type in advance)? Why not use locate() and sidestep the problems altogether?

Lummox JR
Sariat wrote:
Here's how I call the proc (For demo purposes only)
world/New()
..()
UserAttack(/mob/animal/Falcon,/mob/animal/Eagle)

And this is the bug I get.

runtime error: Cannot read /mob/animal/Falcon (/mob/animal/Falcon).Attack

This surprises you? You passed type paths to the proc, not the actual mobs. A type path has no Attack var, and hence the error.

You need to select those mobs from a list (like your inventory), or create them if they don't exist.

Lummox JR