ID:143133
 
Code:
mob
var
movespeed = 3
health = 10
maxhealth = 10
mob/target //variable of type mob, named "target"
swords = 0
axes = 0
maces = 0
obj/item/equipment/weapon/weapon //variable of type obj/item/equipment/weapon, named "weapon"
basedamage = 1
baseattackspeed = 10
damage = 1
attackspeed = 10
targetoverlay
Exit(atom/movable/A)
if(A == weapon) return 0
else return ..()
proc
attackloop(var/mob/M)
while(target && target == M) //while we have a target, and it hasn't changed
if(target in oview(src, 1)) //if we're close enough to hit them...
attack(target) //hit them!
sleep(attackspeed) //then, wait for our next attack attempt to try to make a swing
attack(var/mob/victim)
var/hurtination = rand(0,damage)
src << "You hit [victim] for [hurtination]!"
victim.ouch(src, hurtination)
ouch(var/mob/meanie, var/hurt)
if(meanie) src << "[meanie] hit you for [hurt]" //if() check because sometimes, we may want unknown
else src << "You take [hurt] damage!" //sources of damage
health -= hurt
deathcheck(meanie)
deathcheck(var/mob/murderer)
if(health <= 0)
die(murderer)
die(var/mob/murderer)
if(murderer) world << "[src] has been killed by [murderer]!" //Same deal here
else world << "[src] dies of natural causes."
del(src)
getTarget(var/mob/M)
if(M != src) //attacking yourself is bad form
if(target!=M)
target = M //get the target
spawn() attackloop(M) //and start attacking it
if(client)
targetoverlay = image('life.dmi',M,"FLASH")//make icon attached to mob
usr << targetoverlay //allow usr to see it
else
del(targetoverlay)
target = null
Click()
usr.getTarget(src)
player
icon_state = "player"
die(var/mob/murderer) //Players shouldn't be deleted when they die, they should just be relocated
if(murderer) world << "[src] has been killed by [murderer]!" //Same deal here
else world << "[src] dies of natural causes."
loc = null //Let them stew nowhere for a bit
sleep(10)
health = maxhealth
Move(locate(/area/)) //Then put them back in. We'll just put them in the first available slot in
//whatever area we find.
monster
New()
..()
spawn() AILoop()
proc
AILoop() //alez oup!
while(!client) //Keep on looping forever. However, in the unlikely case that a client is in control
//of a bug, stop the AI so that they can control it.
if(!target) //If we don't have a target...
getTarget(locate(/mob/player/) in oview(5, src)) //get one!
else //otherwise...
if(target in oview(5, src)) //make sure we can still see them
step_towards(src, target) //and take a step towards them
else //but if we've lost them
target = null //forget about them
sleep(movespeed) //between each step, wait an appropriate amount of time
bug //Very buggy
icon='NPCs3.dmi'
icon_state="fly"
health = 5
movespeed = 2
basedamage = 1
damage = 1
baseattackspeed = 5
attackspeed = 5
goblin
icon='NPCs.dmi'
icon_state="gob"
health = 7
movespeed = 3
basedamage = 1
damage = 1
baseattackspeed = 10
attackspeed = 10
joe
icon='Assassan.dmi'
health = 10000
movespeed=1
basedamage = 1000
damage = 5000
baseattackspeed = 3
attackspeed = 2
New()
..()
//When we make a goblin, let's give them a weapon to use. First, pick the type:
var/weapontype = pick(/obj/item/equipment/weapon/sword/training_sword, \
/obj/item/equipment/weapon/axe/training_axe, \
/obj/item/equipment/weapon/mace/training_mace)
//The \ is used to ignore the line break, so we can turn one very long line of code
//into three shorter ones
var/obj/item/equipment/weapon/W = new weapontype(src) //give it to the goblin
W.equip() //then have it equip it

client
var/nextmove = 0 //This keeps track of when next we're allowed to move
Move()
if(world.time < nextmove) //if it's not our time to move yet,
return 0 //do nothing
else //but if it is
nextmove = world.time + mob.movespeed //set the time we can move next
return ..() //then move

obj
item
verb
get()
set src in oview(1)
if(Move(usr)) usr << "You get [src]"
drop()
set src in usr
if(Move(usr.loc)) usr << "You drop [src]"
equipment
verb
equip()
set src in usr
//defined by children
weapon
var/damage
var/attackspeed
var/skillrequired = 0
equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return //Sanity check: a non-mob shouldn't ever be trying to equip something,
//but better safe than sorry. Make sure we're in a mob
if(M.weapon != src) //If this weapon isn't the one equipped
M.weapon = src //Then equip it
M.damage = src.damage + M.basedamage //and add its stats to the player's
M.attackspeed = src.attackspeed
else //but if it IS equipped
M.weapon = null //Unequip it
M.damage = M.basedamage //and return the player's stats to their base values
M.attackspeed = M.baseattackspeed
sword
equip() //However, each weapon type equips things a bit differently, so we override equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return
if(M.swords >= skillrequired) //First, it checks to see if you can use the sword
..() //and if you can, ..() is called. ..() is calling the parent
//function, which can be thought of as what would have been
//called, had we not overridden it. So the parent of
//obj/item/equipment/weapon/sword/equip() is
//obj/item/equipment/weapon/equip(). This will equip the sword
training_sword //and here we have two instances of specific swords. First, a training sword,
skillrequired = 0 //which requires no skill, but is weak
damage = 1
attackspeed = 5
shortsword //and then a shortsword, which requires 10 skill, but is more powerful
skillrequired = 10
damage = 2
attackspeed = 5
axe //and then axes and maces, which work the same as swords...
equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return
if(M.axes >= skillrequired) ..() //except that axes is checked instead of swords
training_axe
damage = 2
attackspeed = 10
broadaxe
damage = 4
attackspeed = 10
mace
equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return
if(M.maces >= skillrequired) ..() //and maces instead of axes or swords
training_mace
damage = 3
attackspeed = 15
mace
damage = 6
attackspeed = 15


Problem description:
cant get monsters to attack back
doesn't look like you put it in AI
In response to PheonixReborn
wat do you mean?
In response to Scarymonkeys623
well, I can't find the attack AI, (if there is one) you know, if the monster is attacked then if there is coding to make it attack back then it should.
mob
var
movespeed = 3
health = 10
maxhealth = 10
mob/target //variable of type mob, named "target"
swords = 0
axes = 0
maces = 0
obj/item/equipment/weapon/weapon //variable of type obj/item/equipment/weapon, named "weapon"
basedamage = 1
baseattackspeed = 10
damage = 1
attackspeed = 10
targetoverlay
Exit(atom/movable/A)
if(A == weapon) return 0
else return ..()
proc
attackloop(var/mob/M)
while(target && target == M) //while we have a target, and it hasn't changed
if(target in oview(src, 1)) //if we're close enough to hit them...
attack(target) //hit them!
sleep(attackspeed) //then, wait for our next attack attempt to try to make a swing
attack(var/mob/victim)
var/hurtination = rand(0,damage)
src << "You hit [victim] for [hurtination]!"
victim.ouch(src, hurtination)
ouch(var/mob/meanie, var/hurt)
if(meanie) src << "[meanie] hit you for [hurt]" //if() check because sometimes, we may want unknown
else src << "You take [hurt] damage!" //sources of damage
health -= hurt
deathcheck(meanie)
deathcheck(var/mob/murderer)
if(health <= 0)
die(murderer)
die(var/mob/murderer)
if(murderer) world << "[src] has been killed by [murderer]!" //Same deal here
else world << "[src] dies of natural causes."
del(src)
getTarget(var/mob/M)
if(M != src) //attacking yourself is bad form
if(target!=M)
target = M //get the target
spawn() attackloop(M) //and start attacking it
if(client)
targetoverlay = image('life.dmi',M,"FLASH")//make icon attached to mob
usr << targetoverlay //allow usr to see it
else
del(targetoverlay)
target = null
Click()
usr.getTarget(src)
player
icon_state = "player"
die(var/mob/murderer) //Players shouldn't be deleted when they die, they should just be relocated
if(murderer) world << "[src] has been killed by [murderer]!" //Same deal here
else world << "[src] dies of natural causes."
loc = null //Let them stew nowhere for a bit
sleep(10)
health = maxhealth
Move(locate(/area/)) //Then put them back in. We'll just put them in the first available slot in
//whatever area we find.
monster
New()
..()
spawn() AILoop()
proc
AILoop() //alez oup!
while(!client) //Keep on looping forever. However, in the unlikely case that a client is in control
//of a bug, stop the AI so that they can control it.
if(!target) //If we don't have a target...
getTarget(locate(/mob/player/) in oview(5, src)) //get one!
else //otherwise...
if(target in oview(5, src)) //make sure we can still see them
step_towards(src, target) //and take a step towards them
if(target in oview(1,src))
src.attack(target)
else //but if we've lost them
target = null //forget about them
sleep(movespeed) //between each step, wait an appropriate amount of time
bug //Very buggy
icon='NPCs3.dmi'
icon_state="fly"
health = 5
movespeed = 2
basedamage = 1
damage = 1
baseattackspeed = 5
attackspeed = 5
goblin
icon='NPCs.dmi'
icon_state="gob"
health = 7
movespeed = 3
basedamage = 1
damage = 1
baseattackspeed = 10
attackspeed = 10
joe
icon='Assassan.dmi'
health = 10000
movespeed=1
basedamage = 1000
damage = 5000
baseattackspeed = 3
attackspeed = 2
New()
..()
//When we make a goblin, let's give them a weapon to use. First, pick the type:
var/weapontype = pick(/obj/item/equipment/weapon/sword/training_sword, \
/obj/item/equipment/weapon/axe/training_axe, \
/obj/item/equipment/weapon/mace/training_mace)
//The \ is used to ignore the line break, so we can turn one very long line of code
//into three shorter ones
var/obj/item/equipment/weapon/W = new weapontype(src) //give it to the goblin
W.equip() //then have it equip it

client
var/nextmove = 0 //This keeps track of when next we're allowed to move
Move()
if(world.time < nextmove) //if it's not our time to move yet,
return 0 //do nothing
else //but if it is
nextmove = world.time + mob.movespeed //set the time we can move next
return ..() //then move

obj
item
verb
get()
set src in oview(1)
if(Move(usr)) usr << "You get [src]"
drop()
set src in usr
if(Move(usr.loc)) usr << "You drop [src]"
equipment
verb
equip()
set src in usr
//defined by children
weapon
var/damage
var/attackspeed
var/skillrequired = 0
equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return //Sanity check: a non-mob shouldn't ever be trying to equip something,
//but better safe than sorry. Make sure we're in a mob
if(M.weapon != src) //If this weapon isn't the one equipped
M.weapon = src //Then equip it
M.damage = src.damage + M.basedamage //and add its stats to the player's
M.attackspeed = src.attackspeed
else //but if it IS equipped
M.weapon = null //Unequip it
M.damage = M.basedamage //and return the player's stats to their base values
M.attackspeed = M.baseattackspeed
sword
equip() //However, each weapon type equips things a bit differently, so we override equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return
if(M.swords >= skillrequired) //First, it checks to see if you can use the sword
..() //and if you can, ..() is called. ..() is calling the parent
//function, which can be thought of as what would have been
//called, had we not overridden it. So the parent of
//obj/item/equipment/weapon/sword/equip() is
//obj/item/equipment/weapon/equip(). This will equip the sword
training_sword //and here we have two instances of specific swords. First, a training sword,
skillrequired = 0 //which requires no skill, but is weak
damage = 1
attackspeed = 5
shortsword //and then a shortsword, which requires 10 skill, but is more powerful
skillrequired = 10
damage = 2
attackspeed = 5
axe //and then axes and maces, which work the same as swords...
equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return
if(M.axes >= skillrequired) ..() //except that axes is checked instead of swords
training_axe
damage = 2
attackspeed = 10
broadaxe
damage = 4
attackspeed = 10
mace
equip()
set src in usr
var/mob/M = loc
if(!istype(M)) return
if(M.maces >= skillrequired) ..() //and maces instead of axes or swords
training_mace
damage = 3
attackspeed = 15
mace
damage = 6
attackspeed = 15

I hope that this fixes it
In response to Vegetassj9
Vegetassj9, I would really appreciate it if you would stop providing blatantly wrong advice to people. Learn something yourself before trying to help others.
In response to Garthor
If you would like to know I fixed his game on yahoo
In response to Vegetassj9
I really, really doubt that, considering the quality of what I've seen you write.
In response to Garthor
that we're only small parts that I wrote and it was late so hard to concentrate