ID:264230
 
I need to know how to make it so when you attack a monster is attacks you back, but it don't attack you unless you attack it!

Show me how just edit my coding below.


        Saibaman
name = "Saibaman"
icon = 'Saibaman.dmi'
powerlevel = 1000
maxpowerlevel = 1000
exp = 100
zeni = 100
str = 100
def = 5
player = 0
monster = 1
var/mob/Target
New()
..()
spawn(5)
src.Wander()
proc
Wander()
while(src)
sleep(5)
for(var/mob/Player/M in oview(10))
src.Target = M
break
if(src.Target)
if(src.powerlevel<Target.powerlevel)
var/Rand = rand(1,10)
if(Rand>=8)
step_away(src,Target)
sleep(1)
step_away(src,Target)
sleep(1)
step_away(src,Target)
else
step_towards(src,Target)

else
step_towards(src,Target)

else
step_rand(src)
Bump(atom/M)
if(istype(M,/mob/Player))
var/mob/Player/P = M
var/Damage = src.str
P.powerlevel -= Damage
P.Death()



Don't call Wander on creation, and rather call it when it's being attacked.

But if you wanted to make something completely different, just do that with Wander only targeting the attacker.
In response to Speedro
Speedro wrote:
Don't call Wander on creation, and rather call it when it's being attacked.

How would I take the proc out of the mob and put it into a player's proc.
Or how do I connect them?
Because if I try to put the Wander proc into my combat proc it says: Combat.dm:134:error:M.Wander:undefined proc
And the Wander proc is in the Saibaman.
In response to Gizhy Games
Just make it so when things are attacked, it checks to see if the monster or whatever has a retaliate proc:


mob
verb
attack(mob/m in world)
world<<"[src] attacks [m] long distance!"
m.oh_mygosh_im_being_attacked(src) //call this to see if the monster does\
anything when attacked. (pass back the attacker, if you want!

proc
oh_mygosh_im_being_attacked() //define a retalitation, so you can throw it in whenever\
you want the attacked thing to do something.

monster //so when a monster get's attacked, it retaliates, for example.
oh_mygosh_im_being_attacked(mob/m)
world<<"[src] retaliates by yelling at [m]!"
//so basically you could add your retaliation here.