ID:746079
 
Keywords: , proc, undef, var
(See the best response by Robertbanks2.)
Code:
Here is some of my battle codes
mob
verb
Attack(mob/M in oview(1))
set category="Fighting"
if(src.attacking==0)
if(src.meditate==0)
if(src.resting==0)
if(src.stamina>=3)
if(M.safe==0)
if(istype(M,/mob/characters))
M.Attack_Mob()
src.attacking=1
sleep(5)
src.stamina-=rand(1,4)
src.attacking=0
var/attackturn
mob/var/defenseup=0
mob/var/attackup=0
mob
proc
TakeDamage(mob/attacker, dmg)
dmg=max(1, min(attacker.powerlevel/src.powerlevel*attacker.level), 50)
src.hp-=(dmg-src.defenseup+attacker.attackup)
src.deathcheck()
mob
proc
Attack_Mob(mob/defender,dmg)
if(src.level-3 >= defender.level)
var/src.random=rand(1,4)
if(src.random==1)
flick("sparpunch",src)
flick("sparstance",src)
flick("sparblock",defender)
defender.oview(10)<<'punch_med.wav'
defender.Take_Damage(src, dmg)
defender.powerlevel-=rand(2,6)*src.level
src.maxpowerlevel+=rand(2,20)*src.level
defender << "<fontcolor=red><i>[src.name] hits you for [dmg] damage</i></font>"
src << "<fontcolor=red><i>You hit [defender.name] for [dmg] damage</i></font>"
defender.KO()
sleep(2)
if(src.random==2)
flick("sparkick",src)
flick("sparstance",src)
flick("sparblock",defender)
defender.oview(10)<<'punch_med.wav'
defender.Take_Damage(src, dmg)
defender.powerlevel-=rand(2,3)*src.level
src.maxpowerlevel+=rand(3,10)*src.level
defender << "<fontcolor=red><i>[src.name] hits you for [dmg] damage</i></font>"
src << "<fontcolor=red><i>You hit [defender.name] for [dmg] damage</i></font>"
defender.KO()
sleep(2)
if(src.random==3)
flick("sparfury",src)
flick("sparstance",src)
flick("sparblock",defender)
defender.oview(10)<<'punch_med.wav'
defender.Take_Damage(src, dmg)
defender.powerlevel-=rand(6,18)*src.level
src.maxpowerlevel+=rand(10,15)*src.level
defender << "<fontcolor=red><i>[src.name] hits you for [dmg] damage</i></font>"
src << "<fontcolor=red><i>You hit [defender.name] for [dmg] damage</i></font>"
src.stamina-=rand(1,3)
defender.KO()
sleep(2)
if(src.random==4)
flick("sparforward",src)
flick("sparback",src)
flick("sparhit",defender)
defender.oview(10)<<'punch_hvy.wav'
defender.Take_Damage(src, dmg)
defender.powerlevel-=rand(12,36)*src.level
src.maxpowerlevel+=rand(5,15)*src.level
defender << "<fontcolor=red><i>[src.name] hits you for [dmg] damage</i></font>"
src << "<fontcolor=red><i>You hit [defender.name] for [dmg] damage</i></font>"
src.stamina-=rand(1,9)
defender.KO()
sleep(2)
else
src<<"You Violently Swing At [defender] But Hurt Yourself!"
src.hp-=5
src.stamina-=25
defender.hp-=1
sleep(5)

My Errors are a bunch of undef proc or var that im sure i defined already.When i usually get a bunch like this there was always that one error causing everything but i cant find any here.
Fighting_Procedure.dm:144:error: damg: undefined var
Fighting_Procedure.dm:34:error: defender.oview: undefined proc
Fighting_Procedure.dm:35:error: defender.Take_Damage: undefined proc
Fighting_Procedure.dm:46:error: defender.oview: undefined proc
Fighting_Procedure.dm:47:error: defender.Take_Damage: undefined proc
Fighting_Procedure.dm:58:error: defender.oview: undefined proc
Fighting_Procedure.dm:59:error: defender.Take_Damage: undefined proc
Fighting_Procedure.dm:71:error: defender.oview: undefined proc
Fighting_Procedure.dm:72:error: defender.Take_Damage: undefined proc
Fighting_Procedure.dm:29:warning: random: variable defined but not used
Fighting_Procedure.dm:91:error: src.oview: undefined proc
Fighting_Procedure.dm:92:error: src.oview: undefined proc
Fighting_Procedure.dm:106:error: src.oview: undefined proc
Fighting_Procedure.dm:110:error: src.oview: undefined proc
Flight Map.dm:118:error: src.loc: cannot change constant value
Flight Map.dm:124:error: src.loc: cannot change constant value
Flight Map.dm:130:error: src.loc: cannot change constant value
Flight Map.dm:136:error: src.loc: cannot change constant value


Problem description:
Albro1 wrote:
They look like indentation errors. If var references are being called undefined procs, it is usually because your indentation is wrong. But yeah, do what Stephen said.

I doubt it would be that because these errors are appearing in random places.I would of caught these indention error indention error while i was coding.
Plus i clearly defined these variables.

DarkCampainger wrote:
Also, oview() is a global process. It doesn't belong to any atom (ie don't prepend it with "src.", "defender.", ect)

I did not know that, i thought there needed to be a mob/player there in order for it to work.Like
M.oview() is everyone in M sight.If what you saying is true then i think im using the wrong proc which one should i use?
Your indentation is way off.

I can't fix it since I am on my phone...
how so?
Best response
This has nothing to do with indentation.

Fighting_Procedure.dm:144:error: damg: undefined var

You spell it dmg in every other instance, probably a typo.


Fighting_Procedure.dm:71:error: defender.oview: undefined proc

That's not how you call oview(). It's oview(range,viewer)


Fighting_Procedure.dm:72:error: defender.Take_Damage: undefined proc

It's TakeDamage, no underscore.


Fighting_Procedure.dm:29:warning: random: variable defined but not used

You defined random but didn't use it? I can't tell what line it's supposed to be, so I can't help with that one.


Flight Map.dm:118:error: src.loc: cannot change constant value

Use Move() instead of trying to change the var directly.



Most of these issues are obviously from a lack of knowledge about the language, or from using a source and not being familiar with the naming conventions.

Go read some tutorials and stop ripping. If you keep copy pasting huge chunks from a ripped source, people are going to stop helping you.
I hate that i was so obvious
I keep telling you guys i coded all this a few years back.I cant remember what was in my head back then so my entire src is looking a little junky.That damg was actually from another take damage code i coded a long time ago where i used damg instead of dmg in my new recent one.Lol ask your admin mates on here i coded that whole battle system by myself.Just missed silly minor errors
In response to Robertbanks2
Robertbanks2 wrote:
This has nothing to do with indentation.
Sorry my iPhone showed it all out of whack for some reason disregard my post...
@ATHK, I figured that was the case, phones are kinda funky about that sort of thing.

@NightSparta, If that's the case, you still need to read some tutorials/study the language more. If you knew it at one point, going back over some of the commonly used things should only take a few days and will help immensely.
All these errors makes so much sense now.When i ran the src nothing worked they way it should and i was frustrated but now i know why.I don't know why the DM never showed me these errors before but i was wrong when i thought that all these errors were caused by a few errors.These are actually errors in my src but like i said i compiled before and the DM never said anything.Basically these errors are from misusing src for usr.I remember when i first started this src a few years back i didnt know the difference between the two.

I have one more question about the built in Enter() Exit() Entered() Exited().Correct me if im wrong but Enter() and Exit() are for doors and Entered and Exited() are for areas.
No... Enter() is called to find out whether you are able to enter an atom. Entered() is called after successfully entering one. The same is true for Exit/ed().

When you pick up an item, it calls Enter(), defaults to true, and then calls Entered(). When you step into a new turf, it calls Enter() to see if that turf is dense, as well as to find out if any other atoms are in your way, if you succeed, it calls Entered().
EDIT: This is in reply to NightSparta, not Robertbanks2.

You are wrong. Enter(), Exit(), Entered(), and Exited() are not made specifically for things.

Enter() is called when you try to enter a turf. By default, this does things like see if the tile is dense and so are you. If it returns 0, you don't move into the tile. If it returns 1, you move into the tile and Entered() is called.

The same concept applies to Exit() and Exited(). Exit() is called when you try to exit, and if it returns 1, it calls the Enter() proc of the turf you are moving to.