Help with how to go about doing this.
Posted by Gtr
on Mon 21 Jun 2004 08:20 AM
— 16 posts, 60,450 views.
I'v been racking my brains over this one, hope someone can help. How would you go about adding in somthing to check to see if the person in your argument is within a certin number of rooms away in any direction. Like say you wanted a person to follow somone but they were 4 rooms away north and the person had whatever stat it took to see four rooms away, it would check around just within a given number in this case 4.
Thanks.
Hmm, check over how the arrow/bow functions are done. I think the command is do_shoot or do_fire.
Well, if you're just going straight it's pretty simple. You keep taking the north exit, keeping a counter (as Zeno said look at the ranged code) until you find your target or until you go past maximum distance.
The problem comes when you need to check non-straight lines, e.g. two north, one west. Is that something you need to do?
That was the first place I looked, but the problem is it only checks one direction that way, thou all I want is it to check in straight lines, but I want it to check in every direction around the charecter.
Then do it in a loop of all directions of the ch->in_room
Hrmm and if I wanted it to depend on a number set to the charecter of how many rooms it would check...how do you think that would work I have ideas but more wouldnt hurt.
Define "a number set to the charecter".
Ok say the charecters sight range was 5 it would check 5 rooms away in all directions when the command is executed to look for the victim.
What's the catch here? How is this different from what the ranged weapons do? Just make a variable e.g. sight in CHAR_DATA and take the data from there.
Scan already does this, checks how many rooms in a direction based on the % skill you have, with the ranged combat do_fire it gets the rooms limit from the weapon from V4 or V5 if i remember right (sorry no at the game right now), i think that between those 2 bits of code you should be able to come up with what your looking for.
Thnks guys I should have looked at the code better, I have somthing in the works,
OK...well I ran into another problem with this. Scan works by checking the direction you specify, I manged to have it check 1 room away in all directions via. "for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )"
That checks all the exits around the charecter but yeah...only one room away in each direction. What I was refering to was this same thing. But more then one room away (the amount based on a value) the same way without needing to specify a direction.
Why can you not do what we suggested, which was to do just that but continue going in the direction until your value hits 0?
To be honest, I'm not exactly sure how to go about doing that.
Did you look at the ranged weapon code? That there shows you how to go in the same direction until you run out of distance. You need to do that same process but in a loop over the exits of the room.
Hrm...I'll check that out thanks, hope I figure this out.