Okay I got this cool arena code from one of the snippets page. It has
commands do_war, do_startwar, do_nowar, and do_wartalk. Well when it
sprintf's a message to char it has a call right below the sprintf
do_wartalk(buf);. It was having a problem with this so I tried
do_wartalk(send_to_char, buf); was this wrong? Let me show you the code:
(sorry if this is a bit long) I have comments near areas of interest.
Hello all,
I've just finished with some arena code. It's not completely
bug tested, so use this at your own risk, but what I have tested
seems to work pretty well. I'm not too picky. I don't care if
you use it, I don't care if you give me any recognition, I don't
care if you print it out, tear it up, and piss on it. All I ask
is that if you like it to send me some e-mail with some comments,
or suggestions, etc,. Also any bugs you find I would appreciate
being sent to me so I can change this accordingly. As of right
now it only supports one kind of war, which is a single war. Every
man/woman for themselves. I'm currently in the process of a team
war which divides the people up into red and blue teams, and
they have a massive rumble. So, when you use this, simply use
the syntax: startwar 1 <min_level> <max_level>.
Here goes nothing:
/* Act.Comm.C */
In the do_channels function, add:
send_to_char("war ",ch);
if (!IS_SET(ch->comm,COMM_NOWAR))
send_to_char("ON\n\r", ch);
else
send_to_char("OFF\n\r", ch);
Add this anywhere:
void do_wartalk(const char *txt)
{
DESCRIPTOR_DATA *d;
char buf[MAX_STRING_LENGTH];
for (d = descriptor_list; d != NULL; d = d->next)
{
CHAR_DATA *victim;
victim = d->original ? d->original : d->character;
if (d->connected == CON_PLAYING &&
!IS_SET(victim->comm,COMM_NOWAR) &&
!IS_SET(victim->comm,COMM_QUIET))
{
sprintf(buf, "&c[&RWAR&c] &R%s&w\n\r", txt);
send_to_char(buf, victim);
}
}
}
Also anywhere, add:
void do_nowar(CHAR_DATA *ch, char *argument)
{
if (IS_SET(ch->comm, COMM_NOWAR))
{
REMOVE_BIT(ch->comm, COMM_NOWAR));
send_to_char("War channel ON.\n\r", ch);
}
else
{
SET_BIT(ch->comm, COMM_NOWAR));
send_to_char("War channel OFF.\n\r", ch);
}
}
********************************* This is what I added to act_comm.c
******************************************
/* Arena War Channel is here! */
************* located in do_channels area **********************
send_to_char("{RWar{x ",ch);
if (!IS_SET(ch->comm,COMM_NOWAR))
send_to_char("ON\n\r", ch);
else
send_to_char("OFF\n\r", ch);
****************** located right below comment /* RT auction rewritten in
ROM style */ ******************
void do_wartalk( CHAR_DATA *ch, char *argument )
{
char buf[MAX_STRING_LENGTH];
DESCRIPTOR_DATA *d;
for (d = descriptor_list; d != NULL; d = d->next)
{
CHAR_DATA *victim;
victim = d->original ? d->original : d->character;
if (d->connected == CON_PLAYING &&
!IS_SET(victim->comm,COMM_NOWAR) &&
!IS_SET(victim->comm,COMM_QUIET))
{
sprintf( buf, "{W[{RWAR{W] {R%s{x\n\r", argument );
send_to_char(buf, victim);
}
}
}
void do_nowar( CHAR_DATA *ch, char *argument )
{
if (IS_SET(ch->comm, COMM_NOWAR))
{
REMOVE_BIT(ch->comm, COMM_NOWAR);
send_to_char("{RWar channel {WON{R.{x\n\r", ch);
}
else
{
SET_BIT(ch->comm, COMM_NOWAR);
send_to_char("{RWar channel {WOFF{R.{x\n\r", ch);
}
}
***************** This is the patches version and I didn't change it
***********************
/* Fight.C */
At the top, add:
#include "arena.h" <-**************added***************
Find the lines:
************************ patches version *****************************
if ( victim->position == POS_DEAD )
{
group_gain( ch, victim );
Right under this, there is a line that says:
if (!IS_NPC(victim)) - Change it to:
if (!IS_NPC(victim) &&
!IS_SET(victim->in_room->room_flags, ROOM_ARENA));
************************ what I have ******************************
if (!IS_NPC(victim) && !IS_SET(victim->in_room->room_flags, ROOM_ARENA));
{
************************ patches version ***************************
Before the lines:
sprintf( log_buf, "%s got toasted by %s at %s [room %d]",
(IS_NPC(victim) ? victim->short_descr : victim->name),
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->name, ch->in_room->vnum);
Add:
if (!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
After them, add:
else
{
REMOVE_BIT(victim->act, PLR_ARENA);
inwar--;
if (inwar == 1)
{
sprintf(buf, "{Y%s {Ris victorious in the arena!{x", ch->name);
do_wartalk(buf);
wartype = 0;
min_level = 0;
max_level = 0;
iswar = FALSE;
inwar = 0;
wartimer = 0;
wartimeleft = 0;
REMOVE_BIT(ch->act, PLR_ARENA);
char_from_room(ch);
char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
}
}
************************** what I have ********************************
if (!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
sprintf( log_buf, "%s got toasted by %s at %s [room %d]",
(IS_NPC(victim) ? victim->short_descr : victim->name),
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->name, ch->in_room->vnum);
if (IS_SET(victim->act, PLR_ARENA))
{
REMOVE_BIT(victim->act, PLR_ARENA);
inwar--;
if (inwar == 1)
{
char buf[MAX_STRING_LENGTH];
sprintf(buf, "{Y%s {Ris victorious in the arena{W!{x", ch->name);
do_wartalk(ch, buf);
wartype = 0;
min_level = 0;
max_level = 0;
iswar = FALSE;
inwar = 0;
wartimer = 0;
wartimeleft = 0;
REMOVE_BIT(ch->act, PLR_ARENA);
char_from_room(ch);
char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
do_look(ch, "auto");
}
}
*************************** patches version *****************************
Find the comment:
/* dump the flags */
Add to the line that say:
if (ch != victim && !IS_NPC ...
&& !IS_SET(victim->in_room->room_flags, ROOM_ARENA);
Find the comment:
/* Player doing the killing */ <- **found this twice and did the following**
After the:
else
{
Add:
if (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return FALSE;
There is another exact same comment further down, do the same to it.
******************************* what I have
***********************************
/* dump the flags */
if (ch != victim && !IS_NPC(ch) && !is_same_clan(ch,victim) &&
!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
*************************** patches version
*********************************
Find the comment:
/*
* Charm-o-Rama.
*/
Add before it:
if (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return;
In the function: Void raw_kill: Before the line:
make_corpse(victim)
Add:
if (!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
Find the line:
send_to_char("Kill stealing is not permitted...")
Add to to the if statement:
|| !IS_SET(victim->in_room->room_flags, ROOM_ARENA);
/* Interp.C */
Declare this line somewhere:
{ "war", do_war, POS_STANDING, 0, LOG_NORMAL, 1},"
And:
{ "nowar", do_nowar, POS_RESTING, 0, LOG_NORMAL, 1},"
and
{ "wartalk", do_wartalk, POS_RESTING, 0, LOG_NORMAL, 1}, <---
**Wartalk wasn't here before I added it thinking all do_commands are suppost
to be in here may-be wrong?**
As well as: (This one should be in imm defines)
{ "startwar", do_startwar, POS_DEAD, IM, LOG_NORMAL, 0 },
/* Interp.H */ <- *** command.h for those of us using OLC ***
Of course, add:
DECLARE_DO_FUN( do_war );
DECLARE_DO_FUN( do_startwar );
DECLARE_DO_FUN( do_nowar );
DECLARE_DO_FUN( do_wartalk ); <- *************** I added this, wrong?
*****************
/* Merc.H */
#define ROOM_ARENA (XX) <-- Whatever your next open variable is. <-
***Found an open variable and replaced XX in all perspective sections***
#define PLR_ARENA (XX)
#define COMM_NOWAR (XX)
#define SINGLE_WAR_WAITING_ROOM (Vnum,whichever you want on your mud) <-
***VNUM of room is 31***
/* Tables.C */
After the line:
{"nowhere", ROOM_NOWHERE ....
Add:
{ "arena", ROOM_ARENA, TRUE },
Ok, I hope that should be about it. There is an arena.h, and arena.c
file included. You have to add arena.o to your objfiles. Also, in
the arena.c file, you'll notice a line that goes:
random = get_room_index(12004) <<< ***Changed this to random =
get_room_index((number_range(32-95))) ***
You'll have to edit some rooms on your mud, and give them the "arena"
flag, then simply change this line to:
random = get_room_index((number_range(vnum, vnum))) - Whatever they
are on your mud.
Sorry for the length of this note, I hope it helps some people out.
If you have any comments, or suggestions, bugs, etc., e-mail me at
[EMAIL PROTECTED] I'll also be glad to help you get it up and running
on your own mud.
// RuineR
// The Mad Coder
[ Part 2: "Attachment information." ]
Shortly after I posted the code, I found a couple things that need to
be changed. First of all, at the
"dump the flags" comment part.
Take out the part that says:
&& !IS_SET(victim->in_room->room_flags, ROOM_ARENA)
replace it with
&& !IS_SET(victim->act, PLR_ARENA) <**** replaced, as requested ****
If you don't, you got "crash-o-rama" :)
Also, there are a hell of alot more "kill stealing not permitted"
areas you have to add the !IS_SET(victim->in_room->room_flags, <-- ****
added in all occurances ****
ROOM_ARENA), to.. unless of course you to make it so when people are
fighting in the arena, they can't attack people that are already
fighting, which takes out the fun of every man for himself.
// RuineR
// The Mad Coder
Ok, I've included another arena.c file, replace the old one with
this, there are a few fixes in it. And here is a listing of just
SOME of the changes that need to take place in FIGHT.C. (I'm going
over this one again, cause it's the only one that needs changed)
The rest of the changes to get this code running were in my first
post, and shouldn't need changed. Once again, sorry for the mutiple
posts, and I hope somebody makes good use of this code. :)
/* fight.c */
Find the following:
/*
* Payoff for killing things.
*/
if ( victim->position == POS_DEAD )
{
group_gain( ch, victim );
if ( !IS_NPC(victim))
Change the last line to:
if (!IS_NPC(victim) && !IS_SET(victim->in_room->room_flags,
ROOM_ARENA)
Find the following:
sprintf(log_buf, "%s got toasted by %s at %s [room %d]",
(IS_NPC(victim) ? victim->short_descr : victim->name),
(IS_NPC(ch) ? ch->short_descr : ch->name),
ch->in_room->name, ch->in_room->vnum);
Add immediately after:
if (IS_SET(victim->act, PLR_ARENA))
{
REMOVE_BIT(victim->act, PLR_ARENA);
inwar--;
if (inwar == 1)
{
*************************************Added line here char
buf[MAX_STRING_LENGTH]; **************************************
sprintf(buf, "{Y%s {Ris victorious in the arena{W!{x", ch->name);
do_wartalk(buf); <-**** was changed to do_wartalk(send_to_char, buf)
wartype = 0;
min_level = 0;
max_level = 0;
iswar = FALSE;
inwar = 0;
wartimer = 0;
wartimeleft = 0;
REMOVE_BIT(ch->act, PLR_ARENA);
char_from_room(ch);
char_to_room(ch, get_room_index(ROOM_VNUM_TEMPLE));
do_look(ch, "auto");
}
}
Find the following:
/* dump the flags */
if (ch != victim && !IS_NPC(ch) && !is_same_clan(ch,victim))
Change the last line to:
if (ch!= victim && !IS_NPC(ch) && !is_same_clan(ch,victim) &&
!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
Find the following (2 occurances):
/* player doing the killing */
Add in the "else" statement:
if (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return FALSE;
Find the following:
/*
* Charm-o-rama
*/
Before it, add:
if (IS_SET(victim->in_room->room_flags, ROOM_ARENA))
return;
In the raw_kill function - Find:
make_corpse(victim);
Add before it:
if (!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
Also in the raw_kill function - Find:
extract_char(victim, FALSE);
Before it, add:
if (!IS_SET(victim->in_room->room_flags, ROOM_ARENA))
After it, add:
else
{
char_from_room(victim);
char_to_room(victim, (get_room_index(ROOM_VNUM_TEMPLE)));
do_look(victim, "auto");
}
Finally, find all occurances of the line:
send_to_char("Kill stealing is not permitted.\n\r", ch);
Add to the check:
&& !IS_SET(victim->in_room->room_flags, ROOM_ARENA);
---------arena.c
****************************** Here is my arena.c
***************************************
/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* In order to use any part of this Merc Diku Mud, you must comply with *
* both the original Diku license in 'license.doc' as well the Merc *
* license in 'license.txt'. In particular, you may not remove either of *
* these copyright notices. *
* *
* Much time and thought has gone into this software and you are *
* benefitting. We hope that you share your changes too. What goes *
* around, comes around. *
***************************************************************************/
/***************************************************************************
* ROM 2.4 is copyright 1993-1996 Russ Taylor *
* ROM has been brought to you by the ROM consortium *
* Russ Taylor ([EMAIL PROTECTED]) *
* Gabrielle Taylor *
* Brian Moore ([EMAIL PROTECTED]) *
* By using this code, you have agreed to follow the terms of the *
* ROM license, in the file Rom24/doc/rom.license *
***************************************************************************/
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#endif
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "merc.h"
#include "arena.h"
void do_startwar(CHAR_DATA *ch, char *argument)
{
char buf[MAX_STRING_LENGTH];
char arg1[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
DESCRIPTOR_DATA *d;
argument = one_argument(argument, arg1);
argument = one_argument(argument, arg2);
argument = one_argument(argument, arg3);
if (arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0')
{
send_to_char("{BSyntax{W: {Bstartwar {Y<{Wtype{Y> <{Mmin_level{Y>
<{Mmax_level{Y>{x\n\r", ch);
return;
}
if (atoi(arg1) < 1 || atoi(arg1) > 2)
{
send_to_char("{CThe type either has to be {W1{C, or {W2{C.{x\n\r", ch);
return;
}
if (atoi(arg2) <= 0 || atoi(arg2) > 250)
{
send_to_char("{CLevel must be between {W1 {Cand {W250{C.{x\n\r", ch);
return;
}
if (atoi(arg3) <= 0 || atoi(arg3) > 250)
{
send_to_char("{CLevel must be between {W1 {Cand {W250{C.{x\n\r", ch);
return;
}
if (atoi(arg3) < atoi(arg2))
{
send_to_char("{CMax level must be greater than the min level.{x\n\r",
ch);
return;
}
if (iswar == TRUE)
{
send_to_char("{RThere is already a war going!{x\n\r", ch);
return;
}
iswar = TRUE;
wartype = atoi(arg1);
min_level = atoi(arg2);
max_level = atoi(arg3);
sprintf(buf, "{C%s {Rwar started for levels {Y%d {Rto {Y%d{R. {WType
'{RWAR{W' to kill or be killed{x", wartype == 1 ? "Single" : "Team",
min_level, max_level);
do_wartalk(buf);
wartimeleft = 3;
for (d = descriptor_list; d != NULL; d = d->next)
{
if (!IS_NPC(d->character))
{
if (IS_SET(d->character->act, PLR_ARENA))
REMOVE_BIT(d->character->act, PLR_ARENA);
}
}
}
void do_war(CHAR_DATA *ch)
{
char buf[MAX_STRING_LENGTH];
ROOM_INDEX_DATA *location;
if (iswar != TRUE)
{
send_to_char("{RThere is no war going!{x\n\r", ch);
return;
}
if (ch->level < min_level || ch->level > max_level)
{
send_to_char("{CSorry, you can't join this war.{x\n\r", ch);
return;
}
if (IS_SET(ch->act, PLR_ARENA))
{
send_to_char("{RI don't think so.{x\n\r", ch);
return;
}
if (wartype == 1)
{
if ((location = get_room_index(SINGLE_WAR_WAITING_ROOM)) == NULL)
{
send_to_char("{CArena is not yet completed, sorry.{x\n\r", ch);
return;
}
else
{
act("{M$n {Wgoes to get $s {RASS{W whipped in war!{x", ch, NULL, NULL,
TO_ROOM);
char_from_room(ch);
char_to_room(ch, location);
SET_BIT(ch->act, PLR_ARENA);
sprintf(buf, "{C%s {R({CLevel {Y%d{R) {Wjoins the war!{x", ch->name,
ch->level);
do_wartalk(buf);
act("{R$n {Warrives to get $s {RASS{W whipped!{x", ch, NULL, NULL,
TO_ROOM);
inwar++;
do_look(ch, "auto");
return;
}
}
}
void war_update(void)
{
char buf[MAX_STRING_LENGTH];
CHAR_DATA *ch;
DESCRIPTOR_DATA *d;
ROOM_INDEX_DATA *random;
int x;
if (wartimeleft > 0)
{
sprintf(buf, "{R%d tick%s {Wleft to join the war.{x", wartimeleft,
wartimeleft == 1 ? "" : "s");
do_wartalk(buf);
sprintf(buf, "{M%d {W%s %s fighting in the war, so far.{x", inwar, inwar
== 1 ? "person" : "people", inwar == 1 ? "is" : "are");
do_wartalk(buf);
sprintf(buf, "{CType of war{W: {Y%d {R- {Y%d{R, {C%s war{R.{x",
min_level, max_level, wartype == 1 ? "Single" : "Team");
do_wartalk(buf);
wartimeleft--;
return;
}
if (wartimeleft == 0 && iswar == TRUE && wartimer == 0)
if (inwar == 0 || inwar == 1)
{
sprintf(buf, "{CNot enough people for war. {WWar reset.{x");
do_wartalk(buf);
iswar = FALSE;
wartimeleft = 0;
wartimer = 0;
min_level = 0;
max_level = 0;
wartype = 0;
for(d = descriptor_list; d != NULL; d = d->next)
{
if (IS_SET(d->character->act, PLR_ARENA))
{
char_from_room(d->character);
char_to_room(d->character, (get_room_index(ROOM_VNUM_TEMPLE)));
do_look(d->character, "auto");
}
}
}
else
{
sprintf(buf, "{WThe battle begins! {M%d {Wplayers are fighting!{x",
inwar);
do_wartalk(buf);
wartimer = 20;
for(d = descriptor_list; d != NULL; d = d->next)
{
if (IS_SET(d->character->act, PLR_ARENA))
{
random = get_room_index((number_range(31, 95)));
char_from_room(d->character);
char_to_room(d->character, random);
do_look(d->character, "auto");
}
}
}
}
return;
}
************************************************* here is my arena.h file
*****************************************
int min_level;
int max_level;
int inwar;
int wartype;
int wartimeleft;
int wartimer;
bool iswar;
Sorry it was so lengthy. If anyone could help with this. I noticed
that if I do the command startwar
after a few ticks it shutsdown the mud and gives me this stackdump:
Exception: STATUS_ACCESS_VIOLATION at eip=6108530D
eax=00000000 ebx=00000001 ecx=FFFFFFFF edx=00000006 esi=0000000E
edi=00000006
ebp=0022D654 esp=0022D650 program=E:\Rom24\area\rom.exe
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0022D654 6108530D (00000006, 0022D6F6, 0022D8B4, 61087E80)
0022D8B4 610887EB (61098020, 0022D904, 00401E20, 0022D978)
0022D8E4 61087DF3 (0022D904, 00401E20, 0022D974, 61084F0F)
0022D964 61084F0F (0022D994, 00401E20, 00000006, 00401E87)
0022EB94 00401E87 (0022EBD4, 00000006, 0022FDD4, 00498E67)
0022FDD4 00498E70 (0A35C1E8, 00000000, 0022FE54, 0042E761)
0022FDE4 00470764 (00001068, 00000004, 00000000, 0022FE00)
0022FE54 0042E761 (00000004, 0042DFE4, 0022FEA4, 0042E153)
0022FEA4 0042E15C (00000002, 0A010E58, 0A010278, 00000000)
0022FF10 61003FA2 (00000000, 00000000, BAC5AC38, 000004EC)
0022FF40 610041B9 (0042E024, 00000000, E1E939C8, 00000003)
0022FF60 610041F8 (00000000, 00000000, 81325870, 00000005)
0022FF90 004994F7 (0042E024, FFFFFFFF, 80430C77, 00000000)
0022FFC0 0040103D (00000000, 00000000, 7FFDF000, 00000000)
0022FFF0 77E992A6 (00401000, 00000000, 000000C8, 00000100)
End of stack trace
Plus the %d doesn't reflect the tick # in the ticks left message. Thanks for
the help
before hand!
Dantin