Room_Affects.txt
snippets · 7.7 KB · 2010-03-30
Room Affects snippet for ROT 1.4 with OLC: room-wide affects. The author asks for bug reports.
Download « Back to the snippets list
My first snippet I have release. Please review and if ya find any bugs please let me know so I can fix them.
THIS FILE DOES HOPE THAT YOU KNOW WHERE ALL THIS STUFF IS AND THAT YOU HAVE ROT 1.4 W/OLC
BUT WOULDN'T BE HARD TO GET TO WORK IN OTHER CODE BASES EITHER.
Kizeren----
ALL I ASK IS THAT YOU EMAIL ME AND LET ME KNOW YOU ARE USING IT.
AND MAYBE PUT MY NAME IN ALONG WITH THE CODE BUT NOT NESSICARY.
EMAIL: SHAUNMCBRIDE@CHARTER.NET
OR IF YOU WANT TO SEE IT IN ACTION FIRST DROP BY
PRETTY SIMPLE JUST LOOK FOR THE "++++++UNDER" MEANS FIND THE LINE OR SNIP OF CODE IN THE SOURCE FILE
"++++++PUT" JUST PUT THE NEXT LINE OF CODE UNDER THE ABOVE.
MINDOR.BSD.ST PORT 4000
--------------act_move.c---------------
++++++UNDER
if ( IS_NPC( ch ) && HAS_TRIGGER( ch, TRIG_ENTRY ) )
mp_percent_trigger( ch, NULL, NULL, NULL, TRIG_ENTRY );
if ( !IS_NPC( ch ) )
mp_greet_trigger( ch );
++++++++PUT
/* Room Affects, Kizeren 2003 */
if (!IS_NPC(ch) && (to_room->affect_room_type == AFFECT_SLOW))
{
sn = skill_lookup("slow");
level = ch->level;
act("$n is moving slower.\n\r",ch, 0, 0, TO_ROOM);
stc("You feel slower now.\n\r", ch);
af.where = TO_AFFECTS;
af.type = sn;
af.level = level;
af.duration = level/2;
af.location = APPLY_DEX;
af.modifier = -1 - (level >= 18) - (level >= 25) - (level >= 32);
af.bitvector = AFF_SLOW;
affect_join (ch, &af);
return;
}
else if (!IS_NPC(ch) && (to_room->affect_room_type == AFFECT_PLAGUE))
{
sn1 = skill_lookup("plague");
level = ch->level;
stc("You caught the plague.\n\r", ch);
af.where = TO_AFFECTS;
af.type = sn1;
af.level = level;
af.duration = level/2;
af.location = APPLY_STR;
af.modifier = -1 - (level >= 18) - (level >= 25) - (level >= 32);
af.bitvector = AFF_PLAGUE;
affect_join (ch, &af);
return;
}
else if (!IS_NPC(ch) && (to_room->affect_room_type == AFFECT_TELE))
{
pRoomIndex = get_random_room(ch);
stc("You have been teleported!!",ch);
char_from_room(ch);
char_to_room(ch, pRoomIndex);
do_look(ch, "auto");
return;
}
else if (!IS_NPC(ch) && (to_room->affect_room_type == AFFECT_SHOCK))
{
value1 = (ch->hit/2);
value2 = (ch->move/2);
value3 = (ch->mana/2);
stc("You have been electrified!!\n\r",ch);
ch->hit = value1;
ch->move = value2;
ch->mana = value3;
return;
}
------------------BIT.C-------------------------
++++++IN "flag_stat_type"
+++++PUT
{ affect_room_flags, TRUE },
------------------olc.c-------------------------
++++++++++++++UNDER
if ( ( value = flag_value( room_flags, command ) ) != NO_FLAG )
{
TOGGLE_BIT(pRoom->room_flags, value);
SET_BIT( pArea->area_flags, AREA_CHANGED );
send_to_char( "Room flag toggled.\n\r", ch );
return;
}
+++++++++++++++PUT
if ( ( value = flag_value( affect_room_flags, command ) ) != NO_FLAG )
{
pRoom->affect_room_type = value;
SET_BIT( pArea->area_flags, AREA_CHANGED );
stc( "Room Affect set.\n\r", ch );
return;
}
-----------------olc_act.c-----------------------
++++++++++++++++UNDER
{ "mprog", mprog_flags, "MobProgram flags." },
+++++++++++++++PUT
{ "affect_room", affect_room_flags, "Affect Room Flags." },
++++++++++++++++UNDER
sprintf( buf, "Vnum: [%5d]\n\rSector: [%s]\n\r",
pRoom->vnum, flag_string( sector_flags, pRoom->sector_type ) );
strcat( buf1, buf );
+++++++++++++++PUT
sprintf( buf, "Room Aff: [%s]\n\r",
flag_string( affect_room_flags, pRoom->affect_room_type ));
strcat( buf1, buf );
++++++++++++++UNDER
/* sector flags */
pRoom->sector_type = pRoom2->sector_type;
+++++++++++++++PUT
/* affect room flags */
pRoom->affect_room_type = pRoom2->affect_room_type;
-----------------------OLC_SAVE.C-------------------
+++++++++++++UNDER
fprintf( fp, "%d\n", pRoomIndex->sector_type );
+++++++++++++++++PUT
fprintf( fp, "%d\n", pRoomIndex->affect_room_type);
-----------------TABLES.C---------------
ADD THIS WHERE EVER YOU FEEL COMFORTABLE DOING IT.
const struct flag_type affect_room_flags[]=
{
{ "None", AFFECT_NONE, TRUE },
{ "shock", AFFECT_SHOCK, TRUE },
{ "tele", AFFECT_TELE, TRUE },
{ "slow", AFFECT_SLOW, TRUE },
{ "poison", AFFECT_POISON, TRUE },
{ "sleep", AFFECT_SLEEP, TRUE },
{ "curse", AFFECT_CURSE, TRUE },
{ "blind", AFFECT_BLIND, TRUE },
{ "plague", AFFECT_PLAGUE, TRUE },
{ "weaken", AFFECT_WEAKEN, TRUE },
{ "berserk", AFFECT_BERSERK, TRUE },
{ NULL, 0, 0 }
};
AFFECT_NONE I USED AS A PLACEHOLDER WHEN I WAS DOING THIS CODE.
AFFECT_SHOCK I THINK TAKES AWAY 1/3 OF ALL POINTS "HP/MANA/MOVE"
AFFECT_TELE OFCOURSE RANDOMLY TELEPORTS THEM
AFFECT_SLOW CASTS THE SLOW SPELL ON THEM
AFFECT_POISON CASTS THE POINSON SPELL
AFFECT_SLEEP CASTS THE SLEEP SPELL
AFFECT_CURSE CASTS THE CURSE SPELL
AFFECT_BLIND CASTS THE BLIND SPELL
AFFECT_PLAGUE CASTS THE PLAGUE SPELL
AFFECT_WEAKEN CASTS THE WEAKEN SPELL
AFFECT_BERSERK CASTS THE BERSERK SPELL
------------------MERC.H--------------------------------
+++++++++++++++++UNDER
/*
* Room type.
*/
struct room_index_data
+++++++++++++++++PUT
sh_int affect_room_type;
+++++++++++++++++++UNDER
/* BIT.C */
+++++++++++++++++++PUT
extern const struct flag_type affect_room_flags[];
ADD THESE NEW DEFINES TO THE MERC.H FILE.
#define AFFECT_NONE 0
#define AFFECT_SHOCK 1
#define AFFECT_TELE 2
#define AFFECT_SLOW 3
#define AFFECT_POISON 4
#define AFFECT_SLEEP 5
#define AFFECT_CURSE 6
#define AFFECT_BLIND 7
#define AFFECT_PLAGUE 8
#define AFFECT_WEAKEN 9
#define AFFECT_BERSERK 10
-------------------------------------------------------------
OKAY NOW HERE IS THE TRICK. DO ALL THE ABOVE DO A CLEAN COMPILE AND THERE SHOULD BE NO ERRORS. (FINGER CROSSED)
AFTER GAME IS UP AND RUNNING. DO AN "ASAVE_WORLD" THIS SHOULD DUMP ALL THE AREAS WITH THE NEW
ROOM AFFECTS SET TO ZERO IN THE AREA FILES.
BEFORE YOU SHUT DOWN YOU MIGHT WANT TO LOOK AT A SMALL AREA FILE AND LOOK UNDERNEATH THE
SECTOR BIT TO SEE IF THERE IS A ZERO IF THAT IS WHERE YOU PUT THE AFFECT_ROOM IN THE OLC_SAVE.C FILE.
ONE THAT ALL DONE AT THIS LAST PEACE OF CODE IN DB.C
------------------db.c-------------------------
+++++++++++++UNDER
SET_BIT(pRoomIndex->room_flags,ROOM_NOWHERE);
++++++++++++++PUT
pRoomIndex->affect_room_type = fread_number( fp );
--------------------------------------------------------------
AFTER THIS IS DONE REBOOT AND IT SHOULD READ THE NEW AREA LAYOUT WITH NO PROBLEMS.
IF YA FIND SOMETHING MISSING LET ME KNOW I WILL DIG THE CODE BACK UP FROM THE BASEMENT OF THE
HARD DRIVE AND REVAMP IT.