- Posts: 157
- Thank you received: 17
Affect Field
- Fizban
- Topic Author
- Offline
- Administrator
-
Less
More
5 years 7 months ago #7599
by Fizban
Affect Field was created by Fizban
Trigedit has an affect field.
if %actor.affect(sanctuary)% for example checks if the actor is affected by sanctuary.
Its coded as such:
It works fine, usually.
The problem is when you apply something via dg_affect it cant be properly verified from a script.
It searches for the terms in quotes in spello. So you can check if the player is affected by dg_affect, but you can't tell the nature of said affect.
I debated changing the code to work like this:
But that has issues too. It'd break existing scripts because it'd look for different verbiage, ie. SANCT is the bit name for sanctuary. It also wouldn't detect things like the armor spell. The armor spell adjusts armor, but it doesn't set a bit, if you cast it repeatedly, the duration infact stacks.
I suppose I could do something like this:
That'd return false negatives less often at least, and wouldn't break a ton of existing scripts, but it still isn't perfect.
if %actor.affect(sanctuary)% for example checks if the actor is affected by sanctuary.
Its coded as such:
if (!str_cmp(field, "affect")) {
if (subfield && *subfield) {
int spell = find_skill_num(subfield);
if (affected_by_spell(c, spell))
strcpy(str, "1");
else
strcpy(str, "0");
} else
strcpy(str, "0");
}
It works fine, usually.
The problem is when you apply something via dg_affect it cant be properly verified from a script.
spello(SPELL_DG_AFFECT, "Script-inflicted", 0, 0, 0, POS_SITTING,
TAR_IGNORE, TRUE, 0,
NULL);
spello(SPELL_SANCTUARY, "sanctuary", 110, 85, 5, POS_STANDING,
TAR_CHAR_ROOM, FALSE, MAG_AFFECTS,
"The white aura around your body fades.");
It searches for the terms in quotes in spello. So you can check if the player is affected by dg_affect, but you can't tell the nature of said affect.
I debated changing the code to work like this:
if (!str_cmp(field, "affect")) {
if (subfield && *subfield) {
char buf[MAX_STRING_LENGTH];
sprintbitarray(AFF_FLAGS(c), affected_bits, AF_ARRAY_MAX, buf);
if (str_str(buf, subfield))
strcpy(str, "1");
else
strcpy(str, "0");
} else
strcpy(str, "0");
}
But that has issues too. It'd break existing scripts because it'd look for different verbiage, ie. SANCT is the bit name for sanctuary. It also wouldn't detect things like the armor spell. The armor spell adjusts armor, but it doesn't set a bit, if you cast it repeatedly, the duration infact stacks.
I suppose I could do something like this:
if (!str_cmp(field, "affect")) {
if (subfield && *subfield) {
int spell = find_skill_num(subfield);
if (affected_by_spell(c, spell)) {
strcpy(str, "1");
} else {
char buf[MAX_STRING_LENGTH];
sprintbitarray(AFF_FLAGS(c), affected_bits, AF_ARRAY_MAX, buf);
if (str_str(buf, subfield))
strcpy(str, "1");
}else
strcpy(str, "0");
} else
strcpy(str, "0");
}
That'd return false negatives less often at least, and wouldn't break a ton of existing scripts, but it still isn't perfect.
Please Log in or Create an account to join the conversation.
- thomas
-
- Offline
- Administrator
-
Less
More
- Posts: 818
- Thank you received: 159
5 years 7 months ago #7600
by thomas
Replied by thomas on topic Affect Field
I'd split it up in two different fields, keep %actor.affect(spellname)% as is and add %actor.affect_bit(bitname)% as a separate way to check.
Please Log in or Create an account to join the conversation.
Time to create page: 0.083 seconds