ID:150870
 
Uhm, this is gonna sound -really- stupid, but Im not gonna learn unless I ask.. buuuut

Well.. now that I think about it, its more like 2 questions..

Sorry for being such a n00b ^^;;

How do you set up byond to know which direction a mob is facing?

And how do you set that into the combat system, so you can attack whats in front of you, instead of anything within one tile

thanks for the help, again, I hate being such a n00b, but I gotta learn this somehow

Elorien
[email protected]
On 7/13/01 4:50 pm Elorien wrote:
Uhm, this is gonna sound -really- stupid, but Im not gonna learn unless I ask.. buuuut

Well.. now that I think about it, its more like 2 questions..

Sorry for being such a n00b ^^;;

How do you set up byond to know <and display> which direction a mob is facing?

And how do you set that into the combat system, so you can attack whats in front of you, instead of anything within one tile <like I have it set up right now>

thanks for the help, again, I hate being such a n00b, but I gotta learn this somehow

Elorien
[email protected]

There's a built in var that mobs have, called "dir", that stands for what direction a mob, obj, or whatever is facing. The value is actually stored as a number, but BYOND has built in macros, whereby if you type a direction like NORTH (all caps, no quotes... as opposed to north or "NORTH"), the compiler will read it as the appropriate number... so no need to bother learning what direction is what number, unless you're doing something really complicated.

The best way to make your attacks "directional" is to eliminate the argument... that is, don't make it

attack(mob/victim as mob in oview(1))

Just make it:

attack()

with a var called victim or target or opponent or enemy or something, defined in the verb itself.

attack()
mob/enemy

For the actual attack code, I think this might work:

if (enemy in get_step(src,src.dir))
attack code goes here

In response to LexyBitch
Okie, Im confused.

I tried that, but I got a butload of errors from that if statement..

And -yes- I remembered to put an alternate else for it >:P

Any other input on this subject would be great, as well as how to -display- different directions, as the resources Ive been learning from are rather under written on those subjects ^^

Thanks in advance

Elorien, the n00bmiester ^_~
[email protected]
In response to Elorien
K, I got the display of the directions.. yea, so Im an idiot >:P

I still dont get how to make an attack hit -just- the enemy in front of you.

right now Im using

attack(mob/M as mob in oview(1))

which Im sure you all know will bring up a stupid window asking you which one when theres multiple enemies around you...

So.. any help would be nice ^^; Im learning @.@ slowly *L*

Elorien, the n00b
[email protected]
In response to LexyBitch
On 7/13/01 5:02 pm LexyBitch wrote:
On 7/13/01 4:50 pm Elorien wrote:
Uhm, this is gonna sound -really- stupid, but Im not gonna learn unless I ask.. buuuut

Well.. now that I think about it, its more like 2 questions..

Sorry for being such a n00b ^^;;

How do you set up byond to know <and display> which direction a mob is facing?

And how do you set that into the combat system, so you can attack whats in front of you, instead of anything within one tile <like I have it set up right now>

thanks for the help, again, I hate being such a n00b, but I gotta learn this somehow

Elorien
[email protected]

There's a built in var that mobs have, called "dir", that stands for what direction a mob, obj, or whatever is facing. The value is actually stored as a number, but BYOND has built in macros, whereby if you type a direction like NORTH (all caps, no quotes... as opposed to north or "NORTH"), the compiler will read it as the appropriate number... so no need to bother learning what direction is what number, unless you're doing something really complicated.

The best way to make your attacks "directional" is to eliminate the argument... that is, don't make it

attack(mob/victim as mob in oview(1))

Just make it:

attack()

with a var called victim or target or opponent or enemy or something, defined in the verb itself.

attack()
mob/enemy

For the actual attack code, I think this might work:

if (enemy in get_step(src,src.dir))
attack code goes here

...I'm not sure how useful this is, since it uses a very strange feature that most people aren't aware about, but here goes:

mob/verb/attack()
var/mob/M
for(var/mob/M in get_step(src,src.dir)) break
//set M to the first mob found in the turf in front of me

if(M) //there's a mob in front of me
//so attack it here
In response to Spuzzum
K, I tried sticking that code in, and it compiled fine, but I keep getting errors in the game.. Ill C&P them now..

Cannot execute null.DeathCheck().
proc name: attack (/mob/verb/attack)
usr: Elorien (/mob)
src: Elorien (/mob)
call stack:
Elorien (/mob): attack()


The attack code Im using is as follows, guess that might be a little help

verb
attack()
for(var/mob/M in get_step(src,src.dir)) break
if(M)
if (ap > 0)
usr << "You attack [M]! oview() << "[usr] attacks [M]!" var/damage = rand(0,strength) if (damage > 0)
M.HP -= damage world << "[damage] damage else
world << "[usr] attacks, but misses!"
ap = 0
spawn(10)
ap = 1
else
..()
else
..()
M.Deathcheck()


K, so some of it is pretty primitive, but Im working on it >:P

Any help would be great ^_^

Thanks

Elorien, the ultran00b
[email protected]


In response to Elorien
On 7/14/01 11:15 am Elorien wrote:
Cannot execute null.DeathCheck().
proc name: attack (/mob/verb/attack)
usr: Elorien (/mob)
src: Elorien (/mob)
call stack:
Elorien (/mob): attack()

This means that you're trying to call DeathCheck() on a mob variable that isn't defined (therefore its value is null). So, you need to look for the line where you call DeathCheck() and figure out how it might be called for an undefined mob variable.

Also, you might want to turn on debugging (something like Preferences menu, Code Preferences - I don't have Dream Maker in front of me right now). That will tell you the exact line number where it happened.

verb
attack()
for(var/mob/M in get_step(src,src.dir)) break
if(M)
if (ap > 0)
usr << "You attack [M]! oview() << "[usr] attacks [M]!" var/damage = rand(0,strength) if (damage > 0)
M.HP -= damage world << "[damage] damage else
world << "[usr] attacks, but misses!"
ap = 0
spawn(10)
ap = 1
else
..()
else
..()
M.Deathcheck()

Ok, here's where you call DeathCheck(). You're calling it for the variable M, so let's look at that. How could it be null (undefined)? Well, take a look at your first if (M) way up there. That means "if M is defined (not null), do this stuff..." M is only defined if there's somebody in the space next to you. The bottom else corresponds to that if, so it means "otherwise (if M is not defined, nobody is next to you), do the bottom stuff..." So, you're only calling DeathCheck() when M is not defined (nobody there). That's probably not what you want to do, right? It doesn't make any sense to do a DeathCheck for something that doesn't exist anyway.

So, you probably want to move that DeathCheck() up above, under the first if() somewhere. It's your game, so you'll have to work out precisely where you think it should be. ;-)
In response to Air Mapster
Why do I bother? @.@ *LOL*

K, I found that deathcheck problem, thanks Air Mapster, you can be sure youll be in any credits I ever put up for anything I make ^_~

K, like I said, I fixed that, but then I discovered that the attack was broken @.@

for some reason its sending 'attack' to the user and nothing else x.x;; Ive been looking over it for like 15 mins.. I cant figure out whats up @.@

*10 mins later*

Still stumped.. the most I can figure out is -maybe- when the attack verb is called, it loops or something and doesnt actually get to the attack itself.. Im gonna c&p the code again... Im still learning @.@ sooo sorry for the constant asking ^^;


BTW, if I ever make anything that I wanna let other people use, you can be sure that youll be in my credits Air Mapster ^_~ Youve saved me twice now *LOL*

verb
attack()
for(var/mob/M in get_step(src,src.dir))break
if(M) //there's a mob in front of me
if (ap > 0)
usr << "You attack [M]!" oview() << "[usr] attacks [M]!" var/damage = rand(0,strength) if (damage > 0)
M.HP -= damage world << "[damage] damage!" else
world << "[usr] attacks, but misses!"
ap = 0
spawn(10)
ap = 1
else
..()
M.DeathCheck()
..()

*looks over it for awhile longer*

Nope.. still cant figure it out x.x;;;

Elorien, the n00b of all time
[email protected]

In response to Elorien
verb
attack()
for(var/mob/M in get_step(src,src.dir))break
if(M) //there's a mob in front of me
if (ap > 0)
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(0,strength)
if (damage > 0)
M.HP -= damage
world << "[damage] damage!" else
world << "[usr] attacks, but misses!"
ap = 0
spawn(10)
ap = 1
else
..()
M.DeathCheck()
..()

hmmm, well
i tried to tab it out as good as i possibly could
that one line was throwing you WAY off, you need to make that one long line into 3 lines like i did here

remember, i have no idea if this is what you meant to make it tabed like

i need to know what your doing, really, ap makes no sense to me, so i dont know wthere to put that, hehe
In response to FIREking
uhm... I dont see any difference.. cept the new stuff gets like 2 errors >:P

*sigh* I should just rebuild that section I think.. or at least try to..

Thanks for your help everyone.. if you can figure out how to make that code work, please tell me @.@


Elorien
[email protected]