ID:156203
 
I am a beginner at BYond and think it is really cool. however I am running into problems with A.I., I can make a proc to do damage to user but I can find a way to run the proc without a verb activated by the usr.
this is my current code:

mob/evil
name = "shadow knight"
icon = 'evil knight.dmi'
health = 50
strenght = 10
skill = 10
alignment = "bad"
proc
slash(mob/trg in view(1))
trg.hurtme(src.strenght)
view() << "[usr] was slashed by [src] for [src.strenght] points"

I cannot find a way to run the proc without it needing to be triggered by the user
mob
test_npc
icon = 'npc.dmi'
Bump(atom/A)
if(ismob(A))
var/mob/X = A
world << "[X] has been bumped by [src]"


Look into <font size=1>Bump()</font>, if this is what you meant.
How do you want it to be called?

Clicking on the map
Running into it
Just when in view
etc

In response to Pirion (#2)
I figured he meant <font size=1>Bump()</font> because he defined a <font size=1>Slash()</font> proc.
In response to Neimo (#3)
For starters; @ the OP: DO NOT USE "USR" IN PROCS

I do not see the purpose of designing a game where it is required to "bump" someone to "attack" them. If he wants the proc to be called by the player, then he should simply turn the proc into a verb. End of story.
In response to Spunky_Girl (#4)
Well, it looks as if he's making an AI mob.

A evil "shadow knight". The AI bumps them, not the player.
In response to Neimo (#5)
Shall I repeat what I posted previously? It is poor design to have NPCs "attack" through "bumping". And to add to that, I think it's just lazy because then all you would have to do is program in a walk_to() proc for the NPC, and then overwrite the Bump() of the NPCs to have it attack upon bumping into another mob, and you'd be on your merry way. Do YOU bump into things to "attack" them? No. You would punch or kick them to attack them. The only thing where Bump() MIGHT come in handy for, is "tackling" for a football-like game, where you have to throw yourself at other players haha (or something along those lines).
In response to Spunky_Girl (#6)
Or like some Mario game.
In response to Spunky_Girl (#4)
Nobody asked for design philosophy, so it doesn't matter if you see the point of not.
In response to Pirion (#8)
But yeah, Neimo, I tried out your code. When I went to go check it out, bumping into the npc did nothing. So I don't think that'll answer help him out.
In response to Neimo (#1)
all I really want is for a npc to attack the player when he comes into range without the player having to execute a verb
In response to Redxam1112 (#10)
@ Gtgoku55: The code was for the AI to bump into you.
In response to Neimo (#11)
*Face Palm*
In response to Gtgoku55 (#12)
can I please just get the code, I want the NPC to attack the usr when the usr walks past
In response to Redxam1112 (#13)
Overwrite the player's Move() proc to execute the NPC's AI proc when the player moves into range.
In response to Pirion (#2)
when in view
In response to Spunky_Girl (#14)
I don't understand, would you please put it in code
In response to Redxam1112 (#15)
Then do view for crying out loud... >_>
In response to Spunky_Girl (#6)
It's quite the opposite of "poor design".

Enemies that Bump is far greater design, simply because you don't have to throw in calculations into the field. You just know by sure fact that the Enemy reached the player, because it obviously called Bump(), and then do the rest of the attack function.

The other way would involve having to calculate the distance between the Target and the Enemy, then keep calculating until the Enemy is within the desired distance, then you can call the rest of the function. Too much work for something so simple with a more proper design.

Projectile-based attacks, yes Bump isn't desired.
1-Tile Distant Attacks, Bump() is the only efficient and logical desired function.

The topic relates on Computer AI's ability to attack. Not the player's. The player acts far differently compared to the Computer AI.
In response to Maximus_Alex2003 (#18)
Using Bump() complicates the call stack: AI() calls step_towards() (oh: and you can't use step_to() by the way) calls Move() calls Bump() calls Attack(), rather than just having AI() calling Attack(). Furthermore, as you mentioned, it forces a dichotomy between melee attacks and ranged attacks that does not need to exist: a generalized AI() proc could easily handle both in the same manner, but if you are going to rely on Bump() for melee attacks, it won't work.

Furthermore, Bump() won't necessarily be called in certain circumstances. For example, if the location is dense, Bump() will always be called on the turf first. Or, if there are multiple dense objects in a location, Bump() won't necessarily be called on the one you want.

So no, I would not call this the opposite of "poor design".
Page: 1 2