ID:263203
 
Code:
mob
proc
Attack()
for(var/mob/M in oview(src.TargetList))
var/damage = src.Atk - M.Def
var/critical = rand(src.Lck, 100)+ rand(-1,5)
var/dice = "2d16"
var/diceout = roll(dice)
var/Missed = src.Spd-(M.Spd+rand(-2,5))
if(src.CanAttack)
if(Missed<=0)
if(critical == (src.Lck+rand(-3,3)))
if(damage<=0)
damage = 0
src<<"You hit [M]!"
else
var/newdamage = round(damage*rand(1.5,3))
M.Hp-=newdamage
src<<"You hit [M]!"
else
if(damage<=0)
damage = 0
else
M.Hp-=damage
src<<"You hit [M]!"
else
if(diceout<= 15)
var/luckyhit = round(damage/2)
if(damage<=0)
damage = 0
else
M.Hp-=luckyhit
src<<"You hit [M]!"
else
oview(src)<<"<font color = yellow><b>[src] missed [M]!</b></font>"
while(M in src.TargetList && M in oview(src.Cansee))
if(src.CanAttack)
if(Missed<=0)
if(critical == (src.Lck+rand(-3,3)))
if(damage<=0)
damage = 0
//
else
var/newdamage = round(damage*rand(1.5,3))
M.Hp-=newdamage
src<<"You hit [M]!"
//
else
if(damage<=0)
damage = 0
//
else
M.Hp-=damage
src<<"You hit [M]!"
else
if(diceout<= 15)
var/luckyhit = round(damage/2)
if(damage<=0)
damage = 0
else
M.Hp-=luckyhit
src<<"You hit [M]!"
else
oview(src)<<"<font color = yellow><b>[src] missed [M]!</b></font>"


Problem description:
When I don't have a target, it gives me the error invalid view size. When I do have a target, it does nothing. Why?
mob
proc
Attack()
for(var/mob/M in oview(src.TargetList))

How exactly is src.TargetList created and what does it contain (Im assuming that it is actually a list)? Is there a particular reason why you aren't just using view(src) or oview(src)?
In response to Vermolius
Vermolius wrote:
mob
proc
Attack()
for(var/mob/M in oview(src.TargetList))

How exactly is src.TargetList created and what does it contain (Im assuming that it is actually a list)? Is there a particular reason why you aren't just using view(src) or oview(src)?

No, TargetList isnt a list. Its just an easy name for a variable to remember.

mob
var
TargetList = ""


And yes, theres a reason I am not using view(src) and oview(src). Im using the variable CanSee to determine how close to the monster the player has to be. Later, when I get this problem fixed, the varible CanSee is going to be changed depending on what weapon the player is weilding. Example, if the player has a dagger/knife, CanSee will be 1. If they are using a sword, CanSee will be 2, a LongSword, Cansee will be 3, Staff, CanSee will be 3, etc..
Without really reading, <code>if(!target)return</code>
In response to Dead_Demon
I didn't really read the attack verb but from what I just read... Depending on the weapon a player is using their range increases?

-Exophus
In response to Exophus
Yes. Right now, I have CanSee set to 5 as default, althought when it is finished, CanSee will be 1. Im just going to redo it again, and see what I get. >_>
In response to Dead_Demon
I went back through and redid the code, and now nothing happens(even when I do have an attack target or I don't have one...)

mob
proc
Attack(mob/M)
if(istype(M,/mob/))
var/damage = (src.Atk - M.Def)+rand(-1,7)
var/CriticalDice = "3d6"
var/CriticalRoll = roll(CriticalDice)
var/CriticalHit = CriticalRoll+src.Lck
var/Miss = src.Spd+rand(-2,12) - M.Spd
for(M in oview(src))
while(M in src.TargetList && M in src.Cansee)
if(Miss<=M.Spd/2)
viewers(src)<<"<font color = yellow><b>[src] attacks, but misses [M]!</font></b>"
sleep(src.WaitAttack)
else
var/Dice2 = "2d6"
var/Stumble = roll(Dice2)
if(Stumble<5)
viewers(src)<<"<font color = yellow><b>[src] stumbles!</font></b>"
sleep(src.WaitAttack)
else
if(damage<=0)
damage = 0
viewers(src)<<"<font color = yellow><b>[src] doesn't even scratch [M]!</font></b>"
sleep(src.WaitAttack)
else
if(CriticalHit<15)
var/CriticalDamage = round(damage*rand(1.5,3))
M.Hp-=CriticalDamage
viewers(src)<<"<font color = yellow><b>[src] landed a deathly blow! Critical Hit!</font></b>"
if(M.Hp<=0)
world<<"<font color = yellow><b>[M] has died!</font></b>"
return
else
sleep(src.WaitAttack)
else
M.Hp-=damage
viewers(src)<<"<font color = yellow><b>[src] hits [M]!</font></b>"
if(M.Hp<=0)
world<<"<font color = yellow><b>[M] has died!</font></b>"
else
sleep(src.WaitAttack)
..()


Thankyou for trying to help me with this lengthy snippet of code in advance
In response to Dead_Demon
Your while loop won't work because you are trying to look "in" a plain variable.
while(M in src.TargetList && M in src.Cansee)
Instead you could try.
while(src.TargetList == M && src.Cansee == M)
In response to Vermolius
Nope, didn't work. :\ No matter how many times I try, I can't seem to get this thing to work...
I did find this out though.
The error starts somewhere after if(istype(M,/mob/)). When I took that out, I actually got an error. It was
Undefined Variable : M.Def.
Think that the if(istype(M,/mob/)) has something to do with it?
In response to Dead_Demon
Can we see the verb/proc that you call Attack() from?
In response to Exophus
Sure
mob
verb
Fight()
usr.Attack()

and
client
Center()
usr.Attack()