## Coding an Aura

Questions, Explanations, Howtos

Slime Squisher

Posts: 354

Joined: Thursday, 14th April 2011, 17:28

### Coding an Aura

--Decided to revert to an earlier version and try something different, still getting an error xD--
What I want, is a doughnut shaped "silence" aura. ie, it affects a square 2 tiles around the player, but not the tile the player is standing on.
I can achieve an easy silence aura by just returning the radius I want in the silence_radius(), but that silences the player also. Not exactly what I need here :p

I do C#, not so much C++
If anyone has any insight, I'd really appreciate it!

coord-circle.h
Code:
enum circle_type
{
C_CIRCLE,      // circle specified by pre-squared radius
C_POINTY,      // circle with square radius r*r
C_ROUND,       // circle with square radius r*r+1
C_SQUARE,      // square with radius r
C_DOUGHNUT     // square with hole in center
};

coord-circle.cc
Code:

void circle_def::init(int param, circle_type ctype)
{
switch (ctype)
{
case C_CIRCLE:
break;
case C_ROUND:
break;
case C_POINTY:
break;
case C_SQUARE:
break;
case C_DOUGHNUT:
radius_sq = (radius - origin.rdist());     // I don't think this will work, it returns an int, but is what I want even possible using this method?
}
is_square = (ctype == C_SQUARE);
init_bbox();
}
infinitevox on akrasiac & berotato
Busy dying horrible deaths from chugging too many pots of Mutation.

Dungeon Master

Posts: 634

Joined: Sunday, 22nd September 2013, 14:46

### Re: Coding an Aura

I think you're barking up the wrong tree. You want to check out the _actor_areas function in areas.cc, and add a method to the actor class so that can check if it's using your new spell instead of the normal silence spell (unless this is replacing silence entirely, in which case you can skip that), and modify the radius_iterator constructor there. There's an exclude_center parameter you can pass it.

Slime Squisher

Posts: 354

Joined: Thursday, 14th April 2011, 17:28

### Re: Coding an Aura

wheals wrote:I think you're barking up the wrong tree. You want to check out the _actor_areas function in areas.cc, and add a method to the actor class so that can check if it's using your new spell instead of the normal silence spell (unless this is replacing silence entirely, in which case you can skip that), and modify the radius_iterator constructor there. There's an exclude_center parameter you can pass it.

That's what I tried originally, but kept running into a "FixedArray" error when I tried to compile.
The other issue is that in the radius_iterator you can only pass an int for r, but I'm guessing from what you're saying is that there is another parameter I'm missing.
I'll mess around some more and see where I can pass exclude_center, trying it that way.
Thank you for the help

This is probably the wrong place to try and pass this, but I'm basically guessing right now :p
Code:
static void _actor_areas(actor *a)
{
int r;
// regular silence spell as an example
if ((r = a->silence_radius()) >= 0)
{
_agrid_centres.emplace_back(AREA_SILENCE, a->pos(), r);

for (radius_iterator ri(a->pos(), r, C_SQUARE); ri; ++ri)
_set_agrid_flag(*ri, areaprop::SILENCE);
no_areas = false;
}
// my silence aura
if ((r = a->sil_aura_radius()) >= 0)
{
_agrid_centres.emplace_back(AREA_SILENCE, a->pos(), r);

for (radius_iterator ri(a->pos(), r, C_SQUARE, exclude_center); ri; ++ri)
_set_agrid_flag(*ri, areaprop::SILENCE);
no_areas = false;
}

Then:
Code:
// return radius of silence as an example
{
return _silence_range(duration[DUR_SILENCE]);
}

// return radius of my silence aura
{
if (you.species == SP_FOO)
{
return 2;
}
return -1;
}

// snippet to handle monster radius
{
return -1;
}
infinitevox on akrasiac & berotato
Busy dying horrible deaths from chugging too many pots of Mutation.

Dungeon Master

Posts: 634

Joined: Sunday, 22nd September 2013, 14:46

### Re: Coding an Aura

infinitevox wrote:
Code:

for (radius_iterator ri(a->pos(), r, C_SQUARE, true); ri; ++ri)

I think this will get it working (you need to pass true for exclude_center so it, well, excludes the center).

For this message the author wheals has received thanks:
infinitevox

Slime Squisher

Posts: 354

Joined: Thursday, 14th April 2011, 17:28

### Re: Coding an Aura

Thank you for that
I won't be able to compile and test until tonight, at the earliest, but I'm rather hopeful about this
infinitevox on akrasiac & berotato
Busy dying horrible deaths from chugging too many pots of Mutation.

Slime Squisher

Posts: 354

Joined: Thursday, 14th April 2011, 17:28

### Re: Coding an Aura

wheals wrote:
infinitevox wrote:
Code:

for (radius_iterator ri(a->pos(), r, C_SQUARE, true); ri; ++ri)

I think this will get it working (you need to pass true for exclude_center so it, well, excludes the center).

Sorry for double post and stuff, but I wanted to let you know that this worked perfectly!
It kills me that I didn't see that you could pass _exlude_center there though :p
Thanks again!
infinitevox on akrasiac & berotato
Busy dying horrible deaths from chugging too many pots of Mutation.