Welcome to the Builder Academy

Question mag_areas check for valid targets

More
05 Aug 2012 13:28 #538 by zusuk
Hey everyone, I'm back in the code hacking away at things :P

So I wanted to hear people's thoughts on the checks what are "valid" actually better yet, "invalid" targets of a harmful AoE

The stock code is below
Code:
/* The skips: 1: the caster * 2: immortals * 3: if no pk on this mud, skips over all players * 4: pets (charmed NPCs) * 5: other players in the same group (if the spell is 'violent') * 6: Flying people if earthquake is the spell */ if (tch == ch) continue; if (!IS_NPC(tch) && GET_LEVEL(tch) >= LVL_IMMORT) continue; if (!CONFIG_PK_ALLOWED && !IS_NPC(ch) && !IS_NPC(tch)) continue; if (!IS_NPC(ch) && IS_NPC(tch) && AFF_FLAGGED(tch, AFF_CHARM)) continue; if (!IS_NPC(tch) && spell_info[spellnum].violent && AFF_FLAGGED(tch, AFF_GROUP) && AFF_FLAGGED(ch, AFF_GROUP) && ( ((ch->master == NULL) ? ch : ch->master) == ((tch->master == NULL) ? tch : tch->master) ) ) continue; if ((spellnum == SPELL_EARTHQUAKE) && AFF_FLAGGED(tch, AFF_FLYING))

I brainstormed first what would be appropriate "invalids" in a exclusively PKILL mud (since that seemed easiest to brainstorm for me).

* Self
* Immortals flagged with NOHAS
* Certain spell protection (like #6 above, flying for earthquake)
* Same group
* Master
* Charmee
* Charmee of group member
* (Charmee caster) Group member of master
* (Charmee caster) Don't hit charmee of a group member of master
* (Mobile caster) Don't hit other Mobiles unless they are a charmee of a PC

I have two questions for the community. 1) Is this list comprehensive (in respects to a PKILL perspective) and 2) Is there a crafty way of doing all these checks?

I made a new function and this is its current (long) form. I'm still testing it. And as you can see, it doesn't look very crafty :P
Code:
// pass values spellnum // spellnum = spellnum // -1 = no spellnum, no special handling // -2 = tailsweep // return values // 0 = not allowed to hit target // 1 = allowed to hit target int aoeOK(struct char_data *ch, struct char_data *tch, int spellnum) { // skip self - tested if (tch == ch) return 0; // immorts that are nohas - tested if (!IS_NPC(tch) && GET_LEVEL(tch) >= LVL_IMMORT && PRF_FLAGGED(tch, PRF_NOHASSLE)) return 0; // earthquake currently doesn't work on flying victims - tested if ((spellnum == SPELL_EARTHQUAKE) && AFF_FLAGGED(tch, AFF_FLYING)) return 0; // tailsweep currently doesn't work on flying victims - tested if ((spellnum == -2) && AFF_FLAGGED(tch, AFF_FLYING)) return 0; // same group, skip - tested if (AFF_FLAGGED(tch, AFF_GROUP) && AFF_FLAGGED(ch, AFF_GROUP) && (((ch->master == NULL) ? ch : ch->master) == ((tch->master == NULL) ? tch : tch->master))) return 0; // don't hit the charmee of a group member - tested if (tch->master) if (AFF_FLAGGED(tch, AFF_CHARM) && AFF_FLAGGED(tch->master, AFF_GROUP) && AFF_FLAGGED(ch, AFF_GROUP) && (((ch->master == NULL) ? ch : ch->master) == (((tch->master)->master == NULL) ? tch->master : (tch->master)->master))) return 0; // charmee, don't hit a group member of master -tested if (ch->master) if (AFF_FLAGGED(ch, AFF_CHARM) && AFF_FLAGGED(ch->master, AFF_GROUP) && AFF_FLAGGED(tch, AFF_GROUP) && (((tch->master == NULL) ? tch : tch->master) == (((ch->master)->master == NULL) ? ch->master : (ch->master)->master))) return 0; // charmee, don't hit a charmee of group member of master if (ch->master && tch->master) if (AFF_FLAGGED(ch, AFF_CHARM) && AFF_FLAGGED(tch, AFF_CHARM) && AFF_FLAGGED(ch->master, AFF_GROUP) && AFF_FLAGGED(tch->master, AFF_GROUP) && ((((tch->master)->master == NULL) ? tch->master : (tch->master)->master) == (((ch->master)->master == NULL) ? ch->master : (ch->master)->master))) return 0; // don't hit your master - tested if (ch->master) if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master == tch) return 0; // don't hit your charmee - tested if (tch->master) if (AFF_FLAGGED(tch, AFF_CHARM) && tch->master == ch) return 0; // npc that isn't charmed shouldn't hurt other npc's if (IS_NPC(ch) && !AFF_FLAGGED(ch, AFF_CHARM) && IS_NPC(tch)) return 0; // PK MUD settings if (CONFIG_PK_ALLOWED) { // !PK settings } else { // if pc cast, !pk mud, skip pc if (!IS_NPC(ch) && !IS_NPC(tch)) return 0; // do not hit pc charmee if (!IS_NPC(ch) && AFF_FLAGGED(tch, AFF_CHARM) && !IS_NPC(tch->master)) return 0; // charmee shouldn't hit pc's if (IS_NPC(ch) && AFF_FLAGGED(ch, AFF_CHARM) && !IS_NPC(ch->master) && !IS_NPC(tch)) return 0; } return 1; }

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

More
06 Aug 2012 03:40 #542 by Liko

zusuk wrote: Hey everyone, I'm back in the code hacking away at things :P

So I wanted to hear people's thoughts on the checks what are "valid" actually better yet, "invalid" targets of a harmful AoE

The stock code is below

Code:
/* The skips: 1: the caster * 2: immortals * 3: if no pk on this mud, skips over all players * 4: pets (charmed NPCs) * 5: other players in the same group (if the spell is 'violent') * 6: Flying people if earthquake is the spell */ if (tch == ch) continue; if (!IS_NPC(tch) && GET_LEVEL(tch) >= LVL_IMMORT) continue; if (!CONFIG_PK_ALLOWED && !IS_NPC(ch) && !IS_NPC(tch)) continue; if (!IS_NPC(ch) && IS_NPC(tch) && AFF_FLAGGED(tch, AFF_CHARM)) continue; if (!IS_NPC(tch) && spell_info[spellnum].violent && AFF_FLAGGED(tch, AFF_GROUP) && AFF_FLAGGED(ch, AFF_GROUP) && ( ((ch->master == NULL) ? ch : ch->master) == ((tch->master == NULL) ? tch : tch->master) ) ) continue; if ((spellnum == SPELL_EARTHQUAKE) && AFF_FLAGGED(tch, AFF_FLYING))

I brainstormed first what would be appropriate "invalids" in a exclusively PKILL mud (since that seemed easiest to brainstorm for me).

* Self
* Immortals flagged with NOHAS
* Certain spell protection (like #6 above, flying for earthquake)
* Same group
* Master
* Charmee
* Charmee of group member
* (Charmee caster) Group member of master
* (Charmee caster) Don't hit charmee of a group member of master
* (Mobile caster) Don't hit other Mobiles unless they are a charmee of a PC

I have two questions for the community. 1) Is this list comprehensive (in respects to a PKILL perspective) and 2) Is there a crafty way of doing all these checks?

I made a new function and this is its current (long) form. I'm still testing it. And as you can see, it doesn't look very crafty :P
Code:
// pass values spellnum // spellnum = spellnum // -1 = no spellnum, no special handling // -2 = tailsweep // return values // 0 = not allowed to hit target // 1 = allowed to hit target int aoeOK(struct char_data *ch, struct char_data *tch, int spellnum) { // skip self - tested if (tch == ch) return 0; // immorts that are nohas - tested if (!IS_NPC(tch) && GET_LEVEL(tch) >= LVL_IMMORT && PRF_FLAGGED(tch, PRF_NOHASSLE)) return 0; // earthquake currently doesn't work on flying victims - tested if ((spellnum == SPELL_EARTHQUAKE) && AFF_FLAGGED(tch, AFF_FLYING)) return 0; // tailsweep currently doesn't work on flying victims - tested if ((spellnum == -2) && AFF_FLAGGED(tch, AFF_FLYING)) return 0; // same group, skip - tested if (AFF_FLAGGED(tch, AFF_GROUP) && AFF_FLAGGED(ch, AFF_GROUP) && (((ch->master == NULL) ? ch : ch->master) == ((tch->master == NULL) ? tch : tch->master))) return 0; // don't hit the charmee of a group member - tested if (tch->master) if (AFF_FLAGGED(tch, AFF_CHARM) && AFF_FLAGGED(tch->master, AFF_GROUP) && AFF_FLAGGED(ch, AFF_GROUP) && (((ch->master == NULL) ? ch : ch->master) == (((tch->master)->master == NULL) ? tch->master : (tch->master)->master))) return 0; // charmee, don't hit a group member of master -tested if (ch->master) if (AFF_FLAGGED(ch, AFF_CHARM) && AFF_FLAGGED(ch->master, AFF_GROUP) && AFF_FLAGGED(tch, AFF_GROUP) && (((tch->master == NULL) ? tch : tch->master) == (((ch->master)->master == NULL) ? ch->master : (ch->master)->master))) return 0; // charmee, don't hit a charmee of group member of master if (ch->master && tch->master) if (AFF_FLAGGED(ch, AFF_CHARM) && AFF_FLAGGED(tch, AFF_CHARM) && AFF_FLAGGED(ch->master, AFF_GROUP) && AFF_FLAGGED(tch->master, AFF_GROUP) && ((((tch->master)->master == NULL) ? tch->master : (tch->master)->master) == (((ch->master)->master == NULL) ? ch->master : (ch->master)->master))) return 0; // don't hit your master - tested if (ch->master) if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master == tch) return 0; // don't hit your charmee - tested if (tch->master) if (AFF_FLAGGED(tch, AFF_CHARM) && tch->master == ch) return 0; // npc that isn't charmed shouldn't hurt other npc's if (IS_NPC(ch) && !AFF_FLAGGED(ch, AFF_CHARM) && IS_NPC(tch)) return 0; // PK MUD settings if (CONFIG_PK_ALLOWED) { // !PK settings } else { // if pc cast, !pk mud, skip pc if (!IS_NPC(ch) && !IS_NPC(tch)) return 0; // do not hit pc charmee if (!IS_NPC(ch) && AFF_FLAGGED(tch, AFF_CHARM) && !IS_NPC(tch->master)) return 0; // charmee shouldn't hit pc's if (IS_NPC(ch) && AFF_FLAGGED(ch, AFF_CHARM) && !IS_NPC(ch->master) && !IS_NPC(tch)) return 0; } return 1; }


Looks simple and pretty easily to expand upon.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
07 Aug 2012 02:56 #550 by Vatiken
1) I think it's completely up to your personal preference. The "stock" way of doing an AOE attack is probably more up my alley just because I like having the added risk when doing AOE strikes within a group. Your set up is definitely more safer.

2) Simpler the better and your way seems fine.

3) I hate the stock group/follower system.

tbaMUD developer/programmer

Please Log in or Create an account to join the conversation.

More
08 Aug 2012 00:39 #568 by zusuk
Thanks for the input...

Yeah the whole stock group/follower system seems a tad primitive.

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

More
08 Aug 2012 03:09 #573 by Vatiken
Rumour has it there is a snippet for an overhauled group system in the download section.

tbaMUD developer/programmer

Please Log in or Create an account to join the conversation.

More
08 Aug 2012 16:08 #592 by zusuk
hahah, at first i was like, 'huh' ... snippets?

then i was like, 'ooooh, snippets!'

then i was like, 'ruh roh, requires 306 update' :P

i just spent like 1.5 hours patching it to my hacked up version of tba, vatiken... it is a beautiful creation you have made, this group-system of yours ;p

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

Please Log in or Create an account to join the conversation.

Time to create page: 0.232 seconds