ID:141368
 
Sorry I've been asking so much v.v but..

Code:
mob/Pokemon
verb
Attack()
set category="Pokemon Commands"
set name="Attack(Close)"
for(var/mob/M in get_step(usr,usr.dir))
if(M.rank=="Pokemon")
if(M.Faint)
usr<<"This Pokemon is fainted"
else
var/damage = round(usr.Attack*2 - M.Defense)
M.HP -= damage
world<<"[usr.name] did [damage] damage to [M]"
if(M.HP<=0)
M.HP=0
if(M.owner=="None")
del(M)
else
Faint(M)
else
return
mob/Pikachu
verb
Thunderschock()
set category="Pokemon Commands"
set name="Thundershock"
if(firing>=1)
return
else
var/obj/Thundershock/A = new/obj/Thundershock(loc, src)
firing=1
A.loc = usr.loc
if(usr.dir==NORTH)
A.y += 1
if(usr.dir==SOUTH)
A.y -= 1
if(usr.dir==EAST)
A.x += 1
if(usr.dir==WEST)
A.x -= 1
walk(A,usr.dir)
sleep(10)
firing=0
obj
Thundershock
icon='thundershock.dmi'
density=1
var/mob/attacker
New(a, mob/m)
.=..(a)
attacker = m

Bump(atom/A)
if(ismob(A))
var/mob/M = A
if(M.rank=="Pokemon")
if(M.Faint)
attacker << "The [M.name] is fainted"
else
var/damage1 = attacker.AttackD*attacker.Level
var/damage2 = attacker.Attack*2 + damage1
var/damage3 = round(damage2 - M.Defense)
M.HP -= damage3
world<<"[attacker.name] did [damage3] damage to [M]"
del(src)
if(M.HP<=0)
M.HP=0
if(M.owner=="None")
del(M)
else
M.Faint(M)
else
del(src)
return
mob
proc
Faint(mob/M)
M<<"Your Pokemon fainted. Please return it now."
M.overlays+='pokeball.dmi'
M.Faint=1


Problem description:
Thundershock works well and does damage, but for some reason, it wont faint. It gets down to 0 HP, and then I keep attacking it, and nothing. Then I walk up and use the Attack() verb, and it kills it.. Why wont thundershock kill it?
Xyphon101 wrote:
Sorry I've been asking so much v.v but..

Code:
> mob/Pokemon
> verb
> Attack()
> set category="Pokemon Commands"
> set name="Attack(Close)"
> for(var/mob/M in get_step(usr,usr.dir))
> if(M.Faint)
> usr<<"This Pokemon is fainted"
> else
> var/damage = round(usr.Attack*2 - M.Defense)
> M.HP -= damage
> view() << "[usr.name] did [damage] damage to [M]"
> if(M.HP<=0)
> M.HP=0
> if(M.owner=="None")
> del(M)
> else
> Faint(M)
> mob/Pikachu
> verb
> Thunderschock()
> set category="Pokemon Commands"
> set name="Thundershock"
> if(firing>=1)
> return
> else
> var/obj/Thundershock/A = new/obj/Thundershock(loc, src)
> firing=1
> A.loc = usr.loc
> if(usr.dir==NORTH)
> A.y-=1
> if(usr.dir==SOUTH)
> A.y+=1
> if(usr.dir==WEST)
> A.x+=1
> if(usr.dir==EAST)
> A.x-=1
> walk(A,usr.dir)
> sleep(10)
> firing=0
> obj
> Thundershock
> icon='thundershock.dmi'
> density=1
> var/mob/attacker
> New(a, mob/B)
> .=..(a)
> attacker = B
>
> Bump(A)
> if(ismob(A))
> var/mob/M = A
> if(M.Faint)
> attacker << "The [M.name] is fainted"
> else
> var/damage1 = attacker.AttackD*attacker.Level
> var/damage2 = attacker.Attack*2 + damage1
> var/damage3 = round(damage2 - M.Defense)
> M.HP -= damage3
> view() << "[attacker.name] did [damage3] damage to [M]"
> if(M.HP<=0)
> M.HP=0
> if(M.owner=="None")
> del(M)
> else
> M.Faint(M)
> mob
> proc
> Faint(mob/M)
> M<<"Your Pokemon fainted. Please return it now."
> M.overlays+='pokeball.dmi'
> M.Faint=1
>

Problem description:
For some reason as soon as the thundershock comes out it says "This pokemon is already fainted", even before it bumps (when it shouldnt be possible unless it bumps).
Also, it gives me the "Your pokemon fainted. Please return it now", when it's supposed to show it to the other person (it does or the attack verb)

Why does it work for the attack verb and not for thundershock? Help?
Also when I took away the M.HP<=0, and the if(M.Faint), when the thundershock hit it it wouldnt do anything.

I'm not even going to look at the rest of your code until you call the default parent function after Bump.

Bump(atom/A)
..()
In response to Haywire
obj
Thundershock
icon='thundershock.dmi'
density=1
var/mob/attacker
New(a, mob/m)
.=..(a)
attacker = m

Bump(atom/A)
if(ismob(A))
var/mob/M = A
if(M.Faint)
attacker << "The [M.name] is fainted"
else
var/damage1 = attacker.AttackD*attacker.Level
var/damage2 = attacker.Attack*2 + damage1
var/damage3 = round(damage2 - M.Defense)
M.HP -= damage3
view() << "[attacker.name] did [damage3] damage to [M]"
del(src)
if(M.HP<=0)
M.HP=0
if(M.owner=="None")
del(M)
else
M.Faint(M)
else
usr<<"v.v"

mob
proc
Faint(mob/M)
M<<"Your Pokemon fainted. Please return it now."
M.overlays+='pokeball.dmi'
M.Faint=1


I don't know how, but I got it to work for the most part, except it doesn't do damage. But for some reason, it still looks at del(src). And if I take away del(src), it keeps on hitting the enemy and it dies from one thundershock, but it doesnt say it did any damage... Whats going on?
In response to Haywire
Oh, I got everything to work except for one thing. It wont faint.
I get it to 0 HP, and it doesnt faint, then I go up to it and use a regular attack and it does.. Why ?
In response to Xyphon101
In response to Ghtry
In contrast, I'd advise sticking to the movement system. It's already fleshed-out as well as reliable, and you barely need to do any special work, can rely on built-in workings and it's usually easy to integrate whatever you want through its hooks. Being integrated into an existing working system is meaningful, as for example your standalone implementation doesn't handle density well and needs to be changed specifically to account for it. Using the movement system's hooks (minimally only Bump()), you can already have a pretty much fully-functioning projectile functioning with like 5 lines:
obj/projectile
density = 1
New(loc,fire_dir) walk(src,fire_dir,1)
Bump(mob/M)
if(istype(M)) M.TakeDamage(10)
del src

Of course, as with all things there could be exceptions depending on specific needs when a different design is preferable. Perhaps someone will actually want a realistic gun, heh :P, which doesn't even have a visible projectile per-se, that just travels in a line instantly and right through some obstacles.
In response to Kaioken
I found out myself beforehand, but thanks anyways guys.