ID:147944
 
I was searching through the fourms and everyone said client.click is EVIL! and now I see why. I need to know how to make it so more than 1 click() works. I currently have one for attack, but i also want to have click() open door and tresure chest, and a click() login screen.

heres the click attack one, what do i do to male it work for the others?

client.Click(mob/m/M  in AtomTypeInRange(src, 1, /mob/m))
if(istype(M,/mob/m)) if(M in range(1))
var/maxdamage = usr.attack - M.defense - (M.agility / 15)
var/damage = rand ((maxdamage / 2), maxdamage)
usr << "You attack [M]!"
usr << "You Do [damage] damage!"
M << "[usr] attacks you!"
M << "[usr] Does [damage] damage!"
M.HP -= damage
M.Death()
Please, please help me =)
The solution is not to use client/Click(), but to use the Click() procs for those individual kinds of objects.

Lummox JR
In response to Lummox JR
so like:
turf
clickhere
click()
usr<<"You Clicked Me!"



like that?
In response to DarkCampainger
that doesn't work =(
my attacks don't register anymore
In response to DarkCampainger
Try something like this
turf/door
Click()
//Snippet to open and close it
mob/badguy
Click()
//Snippet to attack it
obj/pickup
Click()
//Snippet to pick it up

I hope this helps a little.

~; ){en )3ishop ;~
In response to NeoHaxor
well it worked for the door & treasure chest....well now i'm going to insert it into each badguy =(
that will take a while....
In response to DarkCampainger
Yes, client doesnt have to be there. client is stating it only for that one purpose, this may take longer but its the most efficient way to do it.and it must be a capital c i believe, like Click()
In response to DarkCampainger
everything works exept the attacking =(
heres my attack code with my attemp of a click proc:
mob/m
Troll
name = "Troll"
icon = 'monsters.dmi'
icon_state = "troll"
HP = 30
Max_HP = 30
attack = 8
expreward = 50
healthreward = 0
defense = 8
agility = 10
goldreward = 70
Click()
var/mob/m/M
if(istype(M,/mob/m)) if(M in range(1))
var/maxdamage = usr.attack - src.defense - (src.agility / 15)
var/damage = rand ((maxdamage / 2), maxdamage)
usr << "You attack [src]!"
usr << "You Do [damage] damage!"
src << "[usr] attacks you!"
src << "[usr] Does [damage] damage!"
src.HP -= damage
src.Death()
var/mob/PC/P
New()
. = ..()
spawn()
Wander()
proc/Wander()
while(src) var/Found = 0 for(P in oview(5))
step_towards(src,P)
Found = TRUE
break if(Found != TRUE)
step_rand(src)
sleep(10)
sleep(5)
Bump(mob/M)
if(istype(M,/mob/PC))if(M.iamDM == 0)
Attack(M) proc/Attack(mob/PC/M)
flick("trollattack",src)
sleep(10)
var/maxdamage = src.attack - (M.defense / 4) - (M.agility / 20)
var/damage = rand ((maxdamage / 2), maxdamage)
if(damage < 0)
M<<"[src] attacks You! But Your So Stong It Just Bounces Off!"
else
M.HP -= damage
view(src) << "[src] attacks [M]!"
view(src) << "[damage] damage!"
M.PCDeath()
if(M.rebound == 1)
var/reboundmaxdamage = M.attack - (src.defense / 4) - (src.agility / 20)
var/rebounddamage = rand ((reboundmaxdamage / 2), reboundmaxdamage)
var/reboundenddamage = (rebounddamage / 4)
if(damage < 0)
M<<"Recoil Hits [src]! But Your It's Stong It Just Bounces Off!"
else
src.HP -= reboundenddamage
view(M) << "[M] attacks [src]!" view(M) << "[reboundenddamage] damage!"
src.Death()

what am i doing wrong?
(some things are just out of line)
In response to DarkCampainger
DarkCampainger wrote:
everything works exept the attacking =(
heres my attack code with my attemp of a click proc:
> mob/m
> Troll
> name = "Troll"
> icon = 'monsters.dmi'
> icon_state = "troll"
> HP = 30
> Max_HP = 30
> attack = 8
> expreward = 50
> healthreward = 0
> defense = 8
> agility = 10
> goldreward = 70
> Click()
> var/mob/m/M
> if(istype(M,/mob/m)) if(M in range(1))
> var/maxdamage = usr.attack - src.defense - (src.agility / 15)
> var/damage = rand ((maxdamage / 2), maxdamage)
> usr << "You attack [src]!"
> usr << "You Do [damage] damage!"
> src << "[usr] attacks you!"
> src << "[usr] Does [damage] damage!"
> src.HP -= damage
> src.Death()
> var/mob/PC/P
> New()
> . = ..()
> spawn()
> Wander()
> proc/Wander()
> while(src) var/Found = 0 for(P in oview(5))
> step_towards(src,P)
> Found = TRUE
> break if(Found != TRUE)
> step_rand(src)
> sleep(10)
> sleep(5)
> Bump(mob/M)
> if(istype(M,/mob/PC))if(M.iamDM == 0)
> Attack(M) proc/Attack(mob/PC/M)
> flick("trollattack",src)
> sleep(10)
> var/maxdamage = src.attack - (M.defense / 4) - (M.agility / 20)
> var/damage = rand ((maxdamage / 2), maxdamage)
> if(damage < 0)
> M<<"[src] attacks You! But Your So Stong It Just Bounces Off!"
> else
> M.HP -= damage
> view(src) << "[src] attacks [M]!"
> view(src) << "[damage] damage!"
> M.PCDeath()
> if(M.rebound == 1)
> var/reboundmaxdamage = M.attack - (src.defense / 4) - (src.agility / 20)
> var/rebounddamage = rand ((reboundmaxdamage / 2), reboundmaxdamage)
> var/reboundenddamage = (rebounddamage / 4)
> if(damage < 0)
> M<<"Recoil Hits [src]! But Your It's Stong It Just Bounces Off!"
> else
> src.HP -= reboundenddamage
> view(M) << "[M] attacks [src]!" view(M) << "[reboundenddamage] damage!"
> src.Death()
>

what am i doing wrong?
(some things are just out of line)

Hmm, lol im probably wrong but try defining it as a variable, so something like this....

mob/m
var

Troll
name = "Troll"
icon = 'monsters.dmi'
icon_state = "troll"
HP = 30
Max_HP = 30
attack = 8
expreward = 50
healthreward = 0
defense = 8
agility = 10
goldreward = 70

...Then

mob/m
Troll
Click()
//And then the rest of the code.

Please don't qoute me on this lol, this is just another faital attempt of mine to look/sound like one of the pros, but I think that should fix it.

In response to The Conjuror
No =(
In response to DarkCampainger
DarkCampainger wrote:
what am i doing wrong?

This:
var/mob/m/M
if(istype(M,/mob/m)) if(M in range(1))

You never said what M is, so it's null. if(istype(M,anything)) will always fail.

However you don't need M; src will do quite nicely.

You should take this Click() proc out from under /mob/m/Troll and put it under /mob/m instead. It's generic to all monsters, and for others if you need anything more you can always override it.

Lummox JR
In response to Lummox JR
k, i'll try that....


It Works!!!!!!!!!!
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,
Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,Thank you,

And Thanks To Everyone Else That Helped Me In This Form =)

after I finish up some work on my game I think I'll Make A demo on more than 1 click proc =)
In response to DarkCampainger
DarkCampainger wrote:
well it worked for the door & treasure chest....well now i'm going to insert it into each badguy =(
that will take a while....

of course it will! and why insert it in every badguy? You should be able to just add it once to your badguy mob definition, and all the specific detailed badguys inherit that proc. That is what Object-Oriented Programming is supposed to do! :p