ID:141502
 
Code:
Click()
//alert("I'm sorry, but Im still working on this!", "Combat")
var/mob/M
var/list/mob/Target
var/atks
var/dam
var/attack
var/defence
for (M in world)
if (M.BattleNumber)
if (usr.BattleNumber == M.BattleNumber)
if (usr.teamnum != M.teamnum && M != usr)
Target += M
else if (!M.teamnum && M != usr)
Target += M
if (!Target)
alert("No one to attack")
return
atks = round(usr.spd/10)
if (atks < 1)
atks = 1
do
M = input("Who would you like to attack?","Attacks Left: [atks]") in Target
attack = roll(1.20) + round(usr.atk/2+usr.spd/2+usr.str)
defence = roll(1,20) + round(M.agi/2-5)+round(M.spd/2-5)+round(M.blk/2)
if (attack >= defence)
dam = (rand(round(usr.melee/2.1)+round(usr.str/2-5),usr.melee+round(usr.str/2-5))) - (round(M.con/2-5)+round(M.def/2))
usr << "You slash at [M] for [dam]!"
M << "[usr] slashes a you for [dam]!"
M.hp -= dam
atks -= 1
while(atks > 0)


Problem description: ok so after the mob is defined as M, Defence is being put together. unfortunate its saying that M is null when you run the game. however when your defining dam M is not null.
Honestly? I would never structure code like that for simplicity's sake.

var/Target = ""
//then...
var/mob/T = src.Target

var/dmg = src.strength-T.defense


Done deal with typecasting the Target var. >_>
In response to Spunky_Girl
Im never that simple. >.< simple bores me, plus it adds a little flare to combat when you have multiple stats to work up. Atleast I think so.
In response to Sleinth
lol So you like to take the shortest and simplest snippets of coding and make them extremely long and complicate? Kind of like turning 2+2=4 into 1+5-3+2-3*4/2=4?
In response to Spunky_Girl
not exactly. When I play a game with just attack and defence I get bored to fast. So I dont like to make games that work on that principal.
In response to Sleinth
It was just an example snippet. I didn't post it so for you to HAVE to utilize it word-for-word (snippet-for-snippet? o.O). It just gives you a way of establish a targeting system without the complicity of using lists and adding/removing values in that list.
In response to Spunky_Girl
its text based so it would make it rather redundent if I did a targeting system.
In response to Spunky_Girl
Spunky_Girl wrote:
(...) turning 2+2=4 into 1+5-3+2-3*4/2=4?

That does not equal 4 <_<
In response to Andre-g1
Way to put it
In response to Yash 69
1+5-3+2-3*4/2=4

Let's go step by step, shall we ?

1) 1+5-3+2-12/2 = 4

2) 1+5-3+2-6 = 4

3) 6-3+2-6 = 4

4) 3+2-6 = 4

5) 5-6 = 4

And finally, -1 = 4, obviously, not.
In response to Andre-g1
I already know its a -1 i'm agreeing with you >_>
In response to Yash 69
I should start quoting <_<

Way to edit your post, Yash.
In response to Andre-g1
Forgot my parentheses. :)

(1+5-3+2-3)*4/2=4