ID:141166
 
Code:
Punching code
        Punch()
if(!src.Doing)
if(src.Combo<=src.MC)
src.Doing=1
if(src.client)
src.Speed+=0.025
src.MSPE+=0.025
src.BPM+=0.5
src.P3=1
src.Attackable=1
if(src.Voices)
var/R=rand(1,3)
if(R==1)
src<<sound("[src.Voice]Attack.WAV")
if(R==2)
src<<sound("[src.Voice]Attack2.WAV")
if(R==3)
src<<sound("[src.Voice]Attack3.WAV")
if(src.LastAttack=="Punch2")
flick("Punch",src)
src.LastAttack="Punch"
//src.Attacking=1
//spawn(10) src.Attacking=0
else
if(src.LastAttack=="Punch")
flick("Punch2",src)
src.LastAttack="Punch3"
else
if(src.LastAttack=="Punch3")
flick("Punch3",src)
src.LastAttack="Punch2"
//src.see_invisible=1
for(var/mob/M in get_step(src,src.dir))
if(ismob(M))
if(M)
if(M.BP>=1)
if(src.Attackable)
if(M.Attackable)
var/d=rand(src.Strength-M.Defense,src.Strength+src.Strength/4)
if(wt == 0)
src.combo += "A"
if(src.combo == "ASA")
//flick("Teleport",src)
wt = 1
view()<<output("[src]: Dynamic Punch!","window5.output1")
M.BP-=d/4
new/obj/Explosion(M.loc)
spawn()
src.finisher = 1
src.ncombo = ""
src.Wait(10,"s")
if(!M.Blocking&&!M.Dodge&&!M.Attacking)
src.Hit2(M)
src.Hit(M)
if(M.Blocking&&!M.Dodge&&!M.Attacking)
src.Hit4(M)
if(M.Dodge&&!M.Blocking&&!M.Attacking)
src.Hit5(M)
if(M.Attacking)
src.Hit6(M)
if(d<M.Defense*4&&!M.Attacking)
if(src.SE)
if(src.client)
src<<sound('W Punch.wav')
//src.Hit(M)
else
if(d>=M.Defense*4&&d<M.Defense*8&&!M.Attacking)
if(!M.Dodge)
if(src.SE)
if(src.client)
src<<sound('Punch.wav')
//for(var/mob/MM in oview(8,src))
//if(MM.SE)
// MM<<sound('Punch.wav')
M.Previousdir=M.dir
step(M,src.dir)
M.dir = M.Previousdir
src<<"<B>You knocked [M] back</B>"
M.Defense+=0.3
M.MDEF+=0.3
if(M.Rage<=93)
M<<"Your rage is becoming stronger."
M.Rage+=7
if(M.Rage>=100)
M.Rage=100
M<<"Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift."
else
if(d>=M.Defense*8&&!M.Attacking)
if(!M.Dodge)
if(!M.ChargingK)
if(src.SE)
if(src.client)
src<<sound('S Punch.wav')
M.Previousdir=M.dir
walk(M,src.dir,2)
M.dir = M.Previousdir
//var/turf/T
//if(T in get_step(M,M.dir))
//src<<"You knocked [M] into a wall!"
if(src.client)
src<<"<B>You sent [M] flying!</B>"
M.Defense+=0.5
M.MDEF+=0.5
if(M.Rage<=90)
M<<"Your rage is becoming stronger."
M.Rage+=10
if(M.Rage>=100)
M.Rage=100
M<<"Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift."

//M.icon_state="KB"
//M.Refresh()
M.Pushed=1
M.Frozen=1
spawn(10)
if(M.client)
M.Frozen=0
src.icon_state=src.Stance
sleep(10)
M.Pushed=0
walk(M,0)
else
if(src.client)
src<<"You attack [M] with a ferocious blow, but the Ki he has charged up keeps him standing in place."
..()
else
if(src.client)
src<<"[M] isn't a combatant yet."
..()
else
if(src.client)
src<<"You aren't a combatant yet. You will become a combatant once you reach 200 BP."
..()
src.DeathCheck(M)
else
src.Death(M)
//if(istype(M,/turf/))
//del(M)
sleep(10-src.Speed/10)
src.Doing=0
sleep(3)
if(!src.Doing)
src.Combo=1
combo = ""
com = 0
wt = 0
hit = 0
ncombo = ""
finisher = 0
if(src.client)
winshow(src,"default.combo",0)
..()


Hits
mob
proc
Hit(mob/M)
var/d=rand(src.Strength/5-M.Defense/5,src.Strength/5+src.Strength/5)
M.BP-=d
M.Defense+=0.1
M.MDEF+=0.1
if(src.client)
winshow(src,"default.combo",1)
winset(src,"combo","text=\" [src.Combo]\"")
if(M)
src.US7(M)
//src << output("<br><br>You punch [M] for [d] damage!","window5.output1")
s_damage(M,d,"white")
src.Combo++
src.MSTR+=0.75
src.Strength+=0.75
src.Speed+=0.05
src.MSPE+=0.05
src.BPM+=1
if(M.Rage<=100)
M << output("<br><br>Your rage is becoming stronger!","window5.output1")
M.Rage+=5
if(M.Rage>=100)
M.Rage=100
M << output("<br><br>Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift.","window5.output1")
Hit3(mob/M)
var/d=rand(src.Strength/5-M.Defense/5,src.Strength/5+src.Strength/3)
M.BP-=d
//M.Defense+=0.2
//M.MDEF+=0.2
if(src.client)
winshow(src,"default.combo",1)
winset(src,"combo","text=\" [src.Combo]\"")
if(M)
src.US7(M)
//src << output("<br><br>You kick [M] for [d] damage!","window5.output1")
s_damage(M,d,"red")
src.Combo++
src.MSTR+=0.75
src.Strength+=0.75
src.Speed+=0.02
src.MSPE+=0.02
src.BPM+=1.2
if(M.Rage<=100)
M << output("<br><br>Your rage is becoming stronger!","window5.output1")
M.Rage+=5
if(M.Rage>=100)
M.Rage=100
M << output("<br><br>Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift.","window5.output1")
//M<<"Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift."
Hit4(mob/M)
var/d=rand(src.Strength/15-M.Defense/5,src.Strength/15+src.Strength/6)
M.BP-=d
M.Defense+=0.3
M.MDEF+=0.3
if(src.client)
winshow(src,"default.combo",1)
winset(src,"combo","text=\" [src.Combo]\"")
if(M)
src.US7(M)
//src << output("<br><br>You kick [M] for [d] damage!","window5.output1")
s_damage(M,d,"white")
src.Combo=0
src.combo=""
src.MSTR+=0.5
src.Strength+=0.5
src.Speed+=0.02
src.MSPE+=0.02
src.BPM+=1.0
src.Doing=0

Hit5(mob/M)
M.Reflexes+=0.3
M.MREF+=0.3
flick("Teleport",M)
if(src.client)
winshow(src,"default.combo",1)
winset(src,"combo","text=\" [src.Combo]\"")
if(M)
src.US7(M)
//src << output("<br><br>You kick [M] for [d] damage!","window5.output1")
src.Combo=0
src.combo=""
src.Rage+=2.5
src.Doing=0

Hit6(mob/M)
if(src.client)
winshow(src,"default.combo",1)
winset(src,"combo","text=\" [src.Combo]\"")
if(M)
src.US7(M)
//src << output("<br><br>You kick [M] for [d] damage!","window5.output1")
src.Combo=0
src.combo=""
src.Doing=0
new/obj/Clash(src.loc)

Hit2(mob/M)
var/H=rand(1,5)
if(H==1)
new/obj/Midhit(M.loc)
flick("Hit2",M)
if(H==2)
new/obj/Lefthit(M.loc)
if(H==3)
new/obj/Righthit(M.loc)
if(H==4)//FACE
new/obj/Highhit(M.loc)
flick("Hit",M)
if(H==5)
new/obj/Lowhit(M.loc)


Problem description: For some reason I'm getting a strange runtime error that has something to do with my macros.

Here it is:

runtime error: type mismatch: 0 += "A"
proc name: Punch (/mob/verb/Punch)
usr: Forerunnerz (/mob/Player)
src: Forerunnerz (/mob/Player)
call stack:
Forerunnerz (/mob/Player): Punch()


See the "A", that part of the error changes for the "K" key too, but then again they are very similar codes, one is for punching("A"), and the other is for kicking("S"), I don't know how I'm getting the Runtime Error but it stops my punch or kick whenever I'm about to hit an enemy but works fine if there is no enemy a step away from me. I know I need to clean this code up but first I want to solve this problem.


Thanks for copy/pasting a whole shitload of redundant code.

Please try;
if(!src.combo) src.combo="[A]"
else src.combo="[src.combo][A]"
In response to Mysame
A better idea would be to avoid ever making the combo var equal to 0; if it's null, you should be able to add text to it fine, and if that doesn't work (I haven't really programmed in DM much recently), he could always just use an empty string.
In response to Mysame
Mysame wrote:
Thanks for copy/pasting a whole shitload of redundant code.

Please try;
> if(!src.combo) src.combo="[A]"
> else src.combo="[src.combo][A]"


Sorry about that, I need to do a clean on my code and honestly I don't know where the runtime error is coming from so I posted the places that I think it would be coming from.

Also, what does the code above do? Can you explain it to me? Thanks.
In response to Forerunnerz
The problem is that you're setting combo to 0, and you cannot add text to numbers; set it to null or "" instead, you can add text to those. Also, look up Boolean logic in the forums if you want to understand his snippet (it's still unnecessary, though).
In response to Jeff8500
Nah, combo and Combo are two different vars, that's my bad, I might change the name soon.

The "combo" var is used to write the combo your making. Say I hit A, the combo will be "A", I press it again before the combo is over, it will be "AA", and so on.

The "Combo" var is used to count which hit your on. You attack once, Combo = 1, attack again it adds one. Combo = 2, and so on..
In response to Forerunnerz
Then use them as such. You are using "combo" where you mean to be using "Combo" and therein lies the error. I STRONGLY suggest changing the names of your variables, for example "combo" and "combocount".
In response to Garthor
Garthor wrote:
Then use them as such. You are using "combo" where you mean to be using "Combo" and therein lies the error. I STRONGLY suggest changing the names of your variables, for example "combo" and "combocount".

Just finished changing them. I can't find the problem in it though.

        Punch()
if(!src.Doing)
if(src.ComboCount<=src.MC)
src.Doing=1
if(src.client)
src.Speed+=0.025
src.MSPE+=0.025
src.BPM+=0.5
src.P3=1
src.Attackable=1
if(src.Voices)
var/R=rand(1,3)
if(R==1)
src<<sound("[src.Voice]Attack.WAV")
if(R==2)
src<<sound("[src.Voice]Attack2.WAV")
if(R==3)
src<<sound("[src.Voice]Attack3.WAV")
if(src.LastAttack=="Punch2")
flick("Punch",src)
src.LastAttack="Punch"
//src.Attacking=1
//spawn(10) src.Attacking=0
else
if(src.LastAttack=="Punch")
flick("Punch2",src)
src.LastAttack="Punch3"
else
if(src.LastAttack=="Punch3")
flick("Punch3",src)
src.LastAttack="Punch2"
//src.see_invisible=1
for(var/mob/M in get_step(src,src.dir))
if(ismob(M))
if(M)
if(M.BP>=1)
if(src.Attackable)
if(M.Attackable)
var/d=rand(src.Strength-M.Defense,src.Strength+src.Strength/4)
if(wt == 0)
src.combo += "A"
if(src.combo == "ASA")
//flick("Teleport",src)
wt = 1
view()<<output("[src]: Dynamic Punch!","window5.output1")
M.BP-=d/4
new/obj/Explosion(M.loc)
spawn()
src.finisher = 1
src.ncombo = ""
src.Wait(10,"s")
if(!M.Blocking&&!M.Dodge&&!M.Attacking)
src.Hit2(M)
src.Hit(M)
if(M.Blocking&&!M.Dodge&&!M.Attacking)
src.Hit4(M)
if(M.Dodge&&!M.Blocking&&!M.Attacking)
src.Hit5(M)
if(M.Attacking)
src.Hit6(M)
if(d<M.Defense*4&&!M.Attacking)
if(src.SE)
if(src.client)
src<<sound('W Punch.wav')
//src.Hit(M)
else
if(d>=M.Defense*4&&d<M.Defense*8&&!M.Attacking)
if(!M.Dodge)
if(src.SE)
if(src.client)
src<<sound('Punch.wav')
//for(var/mob/MM in oview(8,src))
//if(MM.SE)
// MM<<sound('Punch.wav')
M.Previousdir=M.dir
step(M,src.dir)
M.dir = M.Previousdir
src<<"<B>You knocked [M] back</B>"
M.Defense+=0.3
M.MDEF+=0.3
if(M.Rage<=93)
M<<"Your rage is becoming stronger."
M.Rage+=7
if(M.Rage>=100)
M.Rage=100
M<<"Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift."
else
if(d>=M.Defense*8&&!M.Attacking)
if(!M.Dodge)
if(!M.ChargingK)
if(src.SE)
if(src.client)
src<<sound('S Punch.wav')
M.Previousdir=M.dir
walk(M,src.dir,2)
M.dir = M.Previousdir
//var/turf/T
//if(T in get_step(M,M.dir))
//src<<"You knocked [M] into a wall!"
if(src.client)
src<<"<B>You sent [M] flying!</B>"
M.Defense+=0.5
M.MDEF+=0.5
if(M.Rage<=90)
M<<"Your rage is becoming stronger."
M.Rage+=10
if(M.Rage>=100)
M.Rage=100
M<<"Your rage is eating you alive. You can choose to unleash your rage by pressing tab on your keyboard, or release it to calm yourself down by pressing shift."

//M.icon_state="KB"
//M.Refresh()
M.Pushed=1
M.Frozen=1
spawn(10)
if(M.client)
M.Frozen=0
src.icon_state=src.Stance
sleep(10)
M.Pushed=0
walk(M,0)
else
if(src.client)
src<<"You attack [M] with a ferocious blow, but the Ki he has charged up keeps him standing in place."
..()
else
if(src.client)
src<<"[M] isn't a combatant yet."
..()
else
if(src.client)
src<<"You aren't a combatant yet. You will become a combatant once you reach 200 BP."
..()
src.DeathCheck(M)
else
src.Death(M)
//if(istype(M,/turf/))
//del(M)
sleep(10-src.Speed/10)
src.Doing=0
sleep(3)
if(!src.Doing)
src.ComboCount=1
combo = ""
com = 0
wt = 0
hit = 0
ncombo = ""
finisher = 0
if(src.client)
winshow(src,"default.combo",0)
..()
In response to Forerunnerz
If you're still getting the error, then it's elsewhere. Likely in the variable definition, you have

var/combo = 0


Alternatively, it's elsewhere, and you should just search your code for "combo" and find anywhere that you're not treating it as a text string.
In response to Garthor
Garthor wrote:
If you're still getting the error, then it's elsewhere. Likely in the variable definition, you have

var/combo = 0

Alternatively, it's elsewhere, and you should just search your code for "combo" and find anywhere that you're not treating it as a text string.

mob
var
tmp
combo = ""
ComboCount=1


That's what I got as far as the variables go. I looked around with ctrl+F everywhere and couldn't find a "combo" that uses numbers or a "ComboCount" that uses a text string.
In response to Forerunnerz
You may be setting it to another variable which is itself non-text.

You are still getting the exact same error, correct? type mismatch: 0 += "A"?
In response to Garthor
Yeah.
In response to Forerunnerz
Problem fixed. Thanks everyone for your help. Dang problem was in my Refresh proc :"|.