ID:145933
 
Code:


Problem description:

nowt major.. just started on a new game and i lost my old attack system.. so i used a coding help one... thing is though it comes up with errors saying

M defined type: M

how i sort that out ?
kk u must b a n00b coder or just dumb LoL ok im guessing this problem comes up in a VERB so heres what u shud do if its a verb
mob
(TAB)verb
(TAB)(TAB)Attack(mob/M in world)

(tab) = the tab button
In response to JRR-Zero
all the problems are where you put usr or src...

on this coding i got, it uses M

and i changed all the M to usr and vise vesa and even though the errors go... the monsters won't attack now....



In response to Ultifighter
dude u need (mob/M in world) or (mob/M) usr & src = PC's
mob/M = NPC's & PC's

if you stuck post the coding by putting (<(dm>)then (</dm)>) no () lol
In response to JRR-Zero
u cnat relly sya what he need boy he show no cdoe n00b LOL

<_<

We can't exactly pinpoint the problem in the code if you don't show it to us. There is no specific way to make a code, and therefore no specific way to have it, JRR-Zero, I'm looking at you.
In response to CaptFalcon33035
all he told me was he had M as undifend so i told him how u define it in my second posti did say post the coding if u read it :P


who likes my new avater
In response to JRR-Zero
mob
badguy
icon = 'icons.dmi'
icon_state = "badguy"
hp = 10 //badguys hp
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
spawn(1) //wait for 1/10 of a second
Look() //starts the Look() proc
Bump(mob/M) //when badguy bumps into someone, thing it bumps into is M
if(M.client) //M is a client
MonsterAttack(M) //goes to monsterattack send M
peacefulguy
icon = 'icons.dmi'
icon_state = "peacefulguy"
hp = 10 //peacefulguys hp
New() //Starts a ummm pattern...best way I can describe it
.=..() //continue as normal before next lines of codes
spawn(1) //wait for 1/10 of a second
NonAggresiveLook() //starts the Look() proc
Bump(mob/M) //when peacefulguy bumps into someone, thing it bumps into is M
if(M.client) //M is a client
MonsterAttack(M) //goes to monsterattack send M
obj
sword //the pic of the sword that appears when you attack
icon = 'icons.dmi'
icon_state = "sword"
mob
verb
Attack() //the verb name, look no var/mob/M in oview(1)
if(src.attacking == 0) //if 0 it attacks if 1 it doesnt
var/obj/K = new/obj/sword //assigns the sword to K
// PLEASE keep in mind that the sword is a visual effec it does no real damage
src.attacking = 1 //makes it so you cant attack while it equals 1
K.dir = src.dir //make the direction of K(sword) the direction of the player
K.loc = src.loc //gives the loc of K(sword) the same as the player
step(K, dir) //K(sword) take a step in the direction of the player
var/turf/X = K.loc //the turf the sword is on
spawn(3)//this nifty thing sleeps for the lines underneath it but continues the rest of the code as normal
del(K) //deletes the visual sword
for(var/mob/M as mob in X) //the mob (if any) that is in the loc of the sword
if(M == src) //if that mob is the player, it continues out of the loop
continue
var/damage = rand(1,5) //assigns a random number between 1 and 5 to damage
if(prob(70))//You got a 70% chance of it continueing and not going to the else
src<<"You attack [M] for [damage] damage!" //says you attack
M<<"[src] attacks you for [damage] damage!" //tells the mob (in case that mob is another player) you attacked them
M.hp -= damage //the mobs hp is subtracted by the number in damage
if(M.hp <= 0) //if the mobs hp is less than or equal to 0
del(M) //deletes mob from world NOT A VALID DEATH CODE WHEN FACING PLAYERS, DO CHANGE
else //if you didn't hit
src<<"You attempt to attack [M] but miss!" //says player miss
M<<"[src] attempts to attack you but misses!" //tells the M player missed
sleep(7) //code sleeps for 7/10 of a second, this is waht keeps marcos for super fast attacks
src.attacking = 0
proc
Look() //name of the proc
var/mob/usr/M //makes the variable M which has to be mob/usr
while(src) //while src is still alive
if(M in oview(5)) //looks for a mob/usr in oview(5)
walk_to(src,M,1,4) //src walks to M until it is within 1 block away, moving 4/10th of a second
if(M in oview(1)) //checks if M is in oview(1), if true it continues
step_towards(src,M) //src step towards M which cause the bump()
else //if M isnt in oview(1)
step_rand(src) //steps randomly on the field
break //breaks out of while loop
else //if M isnt in oview(5)
for(M in view(src)) //for every M that is in view of src
break //breaks out of while loop
sleep(5) //sleeps half a sec before re-doing loop
spawn(2) //waits 2/10 a second before continue to do Look() again
Look() //redoes loop
mob
proc
NonAggresiveLook() //name of proc
var/mob/usr/M //variable M has to be mob/usr
while(src) //while src is stil kickin
if(M in oview(5)) //if M is in oview(5)
if(M.name in src.killlist) //now if M.name is in src.killlist, this has it only attack if attacked!
walk_to(src,M,1,4) //src walks to M until 1 block away, moving 4/10ths of a second
if(M in oview(1)) //if M is in oview(1)
step_towards(src,M) //src steps toward M
else //if usr.name isnt in src.killlist
sleep(15)//pauses for 1 and 1/2 seconds
step_rand(src) //step randomly on the field
break //breaks out of the while loop
else //if M isnt in oview(5)
for(M in view(src)) //for all Ms in view(src)
break //breaks out of the while loop
sleep(5) //pauses 1/2 second before redoing loop
spawn(2) // pauses 2/10 of second before redoing proc
NonAggresiveLook() //redoes proc
mob
proc
MonsterAttack(mob/M) //the proc name for the monster attacking, defines M as usr
var/dodamage = rand(1,src.mondamage) //assigns dodamage random number 1 out of src's damage (3)
var/hit = rand(1,100) //assigns a random numer of 1 though 100 to hit
if(hit <= 50) //if hit is less than or equal to 50, it continues
M.hp -= dodamage //minuses usr hp by dodamage
M<<"[src] hit you for [dodamage] damage!" //says how much
else //if hit is greater than 50
M<<"[src] attempted to hit you but misses!" //says src missed
if(M.hp <= 0) //if M.hp less than or equal to 0
death(M) //sends M to death proc
mob
proc
death(mob/M) //death proc with M as usr or as the creature you killed
if(M.client) //if M is a client (player)
M.loc = locate(1,1,1) //sends M to 1,1,1 on map
M.hp = 30 //makes usr hp = 30 so they have full hp
else //if M isnt a client
del(M) //delete M from game
mob/var
mondamage = 3 //monsters damage
killlist = list("") //the peaceful's monster kill list, if you attack you name gets in here
attacking = 0
<dm>
In response to JRR-Zero
Don't use (tab) to denote tabnessness, just press spacebar 3-4 times.
In response to JRR-Zero
Reguardless, there is no use in giving him code that won't help in the slightest bit.