#ifndef AFFECT_H #define AFFECT_H //***************************************************************************** // // affect.h // // Affects are temporary changes to numericvalues assocciated with a character. // For instance, a character can have a +10 strength affect. Each affect has a // duration. Negative-duration affects are permenanant. // //***************************************************************************** typedef struct affect_data AFFECT_DATA; #define AFFECT_VAR_INT 0 #define AFFECT_VAR_DOUBLE 1 #define NUM_AFFECT_VARS 2 // // prepare the affects system for use void init_affects(void); // // create a new affect with the given name and duration. Durations of less than // zero are treated as permenant. Durations are measured in seconds (note: this // is not like the SECONDS macro in utils.h. Just a plain old number). AFFECT_DATA *newAffect(const char *name, int duration); const char *affectGetName(AFFECT_DATA *affect); int affectGetDuration(AFFECT_DATA *affect); const char *affectGetType(AFFECT_DATA *affect); void affectSetType(AFFECT_DATA *affect, const char *type); // // adds a new modifier to the affect. When the affect is placed on something, // all of the modifiers will be placed on that thing. Amounts that are actually // ints will be handled appropriately at the time the affect is applied/removed. void affectAddModifier(AFFECT_DATA *affect, const char *affect_type, double amount); // // adds a new affect type to the list of possible affects. Addremove should // be a function that takes the form: // void addremove(void *thing, const char *affect_type, vartype amount); // // of course, affect_type in the above function does not neccessarily have to // be used; it is just a convenience thing, because most affect types will // probably plug into some underlying system (e.g. stats) that will not require // separate functions for each variable assocciated with it. void add_affect_type(const char *affect_type, int vartype, void *addremove); void add_py_affect_type(const char *affect_type, int vartype, void *addremove); // // hopefully these are self-explanatory? :) Once an affect is added to a // character, it should -not- be modified or deleted. void charAddAffect (CHAR_DATA *ch, AFFECT_DATA *affect); void roomAddAffect (ROOM_DATA *room, AFFECT_DATA *affect); void objAddAffect (OBJ_DATA *obj, AFFECT_DATA *affect); void charRemoveAffect(CHAR_DATA *ch, const char *affect); void roomRemoveAffect(ROOM_DATA *room, const char *affect); void objRemoveAffect (OBJ_DATA *obj, const char *affect); bool charIsAffected (CHAR_DATA *ch, const char *affect); bool objIsAffected (OBJ_DATA *obj, const char *affect); bool roomIsAffected (ROOM_DATA *room, const char *affect); LIST *charGetAffects (CHAR_DATA *ch); LIST *roomGetAffects (ROOM_DATA *room); LIST *objGetAffects (OBJ_DATA *obj); // // remove all of the affects that are on the character void charUnaffect (CHAR_DATA *ch, bool remove_permenants); void roomUnaffect (ROOM_DATA *room, bool remove_permenants); void objUnaffect (OBJ_DATA *obj, bool remove_permenants); // // If you're wanting to add a permenant modifier to something, and you don't // want to go through the affect system, this can act as a 'short cut'. Hint: // especially useful for items that add affects onto characters until the items // are removed. This is not really part of affects, but it uses the same // underlying functions and procedures, so it was put here. Amounts that are // actually ints and not doubles will be converted appropriately. void charAddModifier(CHAR_DATA *ch, const char *affect_type, double amount); void roomAddModifier(ROOM_DATA *room,const char *affect_type, double amount); void objAddModifier (OBJ_DATA *obj, const char *affect_type, double amount); #endif // AFFECT_H