ID:139113
 
Code:
obj
Attacks
Take_Down
name = "Take Down"
icon = 'Moves.dmi'
icon_state = "Take Down"
suffix = "*NEW*"
pp=10
ppmax=10
Click()
if(pp>0)
for(var/mob/M in oview(1))
pp--
suffix = "([pp]/[ppmax])"
usr.btarget = M
usr.Take_Down()

-------------------------------

/mob/proc
Take_Down()
set category = "Battle"
set popup_menu = 0
if(usr.btarget:trainer==1)
usr <<"You can't attack trainers."
return
if(usr.Faint==1)
usr <<"Fainted Pokemon can't attack"
return
if(usr.btarget:Faint==1)
usr <<"you can't attack the dead"
return
if(usr.btarget:TD2)
damage=usr.str+50-usr.btarget:def
view(2) << "<font color=white>[usr] attacks [usr.btarget] for [damage] damage."
usr.exp += damage
//src.updateHealth()
usr.levelup()
usr.things()

-------------------------------

mob/proc
things()
var/limitproc=/mob/proc/skillcap
if(usr.level>=16)
usr.icon_state="ivy"
if(usr.level==16&&exp <= 100)
view(2) << "[usr] evolved into Ivysaur!"
usr << sound('Evolving.mid')
if(usr.level>=36)
usr.icon_state="vena"
if(usr.level==36&&exp <= 100)
view(2) << "[usr] evolved into Venosaur!"
usr << sound('Evolving.mid')
if(usr.level==1)
var/obj/Attacks/Take_Down/D = new/obj/Attacks/Take_Down
call(limitproc)(D)
if(usr.level>=12)
var/obj/Attacks/Razor_Leaf/D = new/obj/Attacks/Razor_Leaf
call(limitproc)(D)
if(usr.level>=25)
var/obj/Attacks/Solarbeam/D = new/obj/Attacks/Solarbeam
call(limitproc)(D)
if(usr.level>=36)
var/obj/Attacks/Confusion/D = new/obj/Attacks/Confusion
call(limitproc)(D)


-------------------------------

mob/proc
skillcap(D)
var/i=1
var/s=0
for(i=1,i<=usr.Moves.len,i++)
if("[usr.Moves[i]]"=="[D]")
s++
if(!s)
if(usr.Moves.len<5)
usr.Moves += D
else
var/atom/A= D
if(isobj(A))
var/obj/M = A
var/theproc=/mob/proc/replace
var/obj/P=call(theproc)(M)
if(P=="Cancel") return
usr.Moves -= P
usr.Moves += M

<------------------------------->

client
proc
Save()
if(usr.trainer)
var/savefile/S = new("World/Players/[ckey].sav")
S["mob"] << mob
else
var/savefile/S = new("World/Players/[ckey]~pokemon.sav")
S["mob2"] << mob
LoadPlayer()
if(fexists("World/Players/[ckey].sav"))
alert("Now Loading!")
var/savefile/S = new("World/Players/[ckey].sav")
S["mob"] >> mob
mob.cansave = 1
new/obj/Trainer_Freindly/Return(mob.client)
new/obj/Trainer_Freindly/Sendout(mob.client)
new/obj/Trainer_Freindly/Follow(mob.client)
new/obj/Trainer_Freindly/Catch(mob.client)
else
alert("No Save file")
return
LoadPokemon()
if(fexists("World/Players/[ckey]~pokemon.sav"))
alert("Now Loading!")
var/savefile/S = new("World/Players/[ckey]~pokemon.sav")
S["mob2"] >> mob
mob.cansave = 1
//mob.verbs -= /mob/verb/Send_Out
//mob.verbs -= /mob/verb/Return
//mob.verbs -= /mob/verb/Release_Pokemon
//mob.verbs -= /mob/verb/Pokemon_Follow
//mob.verbs -= /mob/verb/Pokemon_Train
//mob.verbs -= /mob/verb/Pokemon_Attack_Mode
//mob.verbs -= /mob/verb/Wander
//var/obj/hudMeters/health_01/o
//mob.overlays-=o
mob.updateHealth()
/*for(var/mob/A in world)
if(A.client)
new/obj/hudMeters/health_01(A)*/

else
alert("No Save file")
return
Del()
..()

mob
Write(var/savefile/S)
..()
S["x"] << x
S["y"] << y
S["z"] << z
S["verbs"] << verbs
for(var/obj/O in usr.contents)
S["obj"] << O.ammount
Read(var/savefile/S)
..()
loc = locate(S["x"], S["y"], S["z"])
verbs += S["verbs"]
for(var/obj/O in usr.contents)
O.ammount = S["obj"]


Problem description: Alright I know it looks like a lot but I could really use your help, so allow me to explain. All of these scripts were created for a more dynamic approach... Everything seems to be working fine, except for when I save my character and reload it. It double attacks with every one click of the attacking object. At first I thought well it's probably just multiple procs being called, but that doesn't seem to be the case. It's almost like there are multiple clients(?). Click() Isn't something I have control over so can anyone explain why this is happening? As a few notes to my examination, the second hit is rendered so it's not just text repeating. Variables(pp) are decreased twice per attack, it happens so fast that if(pp) is sometimes ignored I changed it to pp>0. I was able to stop it in skillcap by adding a for loop, a pretty grotesque way of doing it but after about 3 or so hours of trying it was the only way I could get the client to completely understand the existence of the second hit. I ran a Find command on one of the tests... In a for loop of usr.Moves because "in" or "Find" alone couldn't see the existence of the attack in the users Moves list, and it came out with some weird indexing which went something like 0 2 3, 0 2 3, so it exists but doesn't exist Lol? To sum things up Click() is being recursed twice per click, and I need help with that, lol.

Are you somehow getting two attack objects on the player screen after loading a character? I'm not sure about this one since you didn't include where your showing/adding the Attack() obj for the player.
In response to Jotdaniel
No but I was getting two objects when the user leveled until I added the for loop in skillcap. If I wasn't clear when I click the object in my inventory that calls the attacking proc the proc is called twice per one click. It seems like the item it's self is being clicked twice. Maybe the item has an item within it(?) I'm not sure if Byond can even do that.
In response to Zaladus
You have a bad mouse? Try adding a delay to the attack verb, see if it still hits twice per click.


EDIT: Also:

http://www.byond.com/ members/?command=reference&path=atom%2Fvar%2Fcontents

obj's can have contents, but I don't think that clicking the owner of said objects would click() them as well.
In response to Jotdaniel
I was able to fix it.

if(world.time > nextFire)
nextFire = world.time