~case/dbns

ref: 85d3c74215baa48cb2fd97d3c85ff6060e7c42b1 dbns/src/marry.c -rw-r--r-- 9.5 KiB
85d3c742Zerhyn SBC oopsie 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/*                           Marriage Code v1.3
                                  By Cid
                            eos.execnet.com:1234

Unlike my other codes this one does require the addition of another pcdata
field.  Like spouse.  If you add it spouse is a string not an integer.
So thats how it works.  Plus you'll have to modify db.c save.c to load up
the spouse string so this will work.   This snippet also includes a rings
command.  It'll create the rings for the married couple.  Which you'll have
to define in mud.h OBJ_VNUM_DIAMOND_RING and OBJ_VNUM_WEDDING_BAND to vnums
that you might have (ofcourse I created 2 rings for this then added in the
marriage code).  The rings command would be the easiest to add in cause of
just putting in 2 lines in mud.h...even though its a lot easier then the
marriage, and divorce code...but it needs the spouse field(checks to see if
they are married).   Well enjoy...btw dont forget to put somewhere in your
code to give me credits or if you just pop in this file...Keep the this header
intact.

Add do_divorce and do_marry to mud.h and tables.c - Ntanel StormBlade
*/


#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "mud.h"

void do_marry( CHAR_DATA *ch, char *argument)
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    CHAR_DATA *victim2;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );


       if ( arg1[0] == '\0' || arg2[0] == '\0' )
          {
             send_to_char("&WSyntax: marry <char1> <char2>\n\r",ch);
             return;
          }

       if ( ((victim = get_char_world(ch,arg1)) == NULL) ||
            ((victim2 = get_char_world(ch,arg2)) == NULL))
          {
          send_to_char("&WBoth characters must be playing!\n\r", ch );
          return;
          }

       if ( IS_NPC(victim) || IS_NPC(victim2))
          {
          send_to_char("&WSorry! Mobs can't get married!\n\r", ch);
          return;
          }


       if (victim->pcdata->spouse[0] == '\0' && victim2->pcdata->spouse[0] == '\0')
          {
            send_to_char("&WYou pronounce them man and wife!\n\r", ch);
            send_to_char("&WYou say the big 'I do.'\n\r", victim);
            send_to_char("&WYou say the big 'I do.'\n\r", victim2);

            act(AT_BLUE,"$n and $N are now declared married!\n\r", victim, NULL, victim2, TO_ROOM);

            victim->pcdata->spouse = str_dup(victim2->name);

            victim2->pcdata->spouse = str_dup(victim->name);

            return;
          }
        else
        {
           send_to_char("&WThey are already married!\n\r", ch);
           return;
        }


       return;
}

void do_divorce( CHAR_DATA *ch, char *argument)
   {
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    CHAR_DATA *victim2;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );

       if ( arg1[0] == '\0' || arg2[0] == '\0' )
          {
          send_to_char("&WSyntax: divorce <char1> <char2>\n\r",ch);
          return;
          }
       if ( ((victim = get_char_world(ch,arg1)) == NULL) ||
            ((victim2 = get_char_world(ch,arg2)) == NULL))
          {
          send_to_char("&WBoth characters must be playing!\n\r", ch );
          return;
          }

       if ( IS_NPC(victim) || IS_NPC(victim2))
          {
          send_to_char("&WI don't think they're Married to the Mob!\n\r", ch);
          return;
          }

       if ( !str_cmp( victim->pcdata->spouse, victim2->name ) && !str_cmp( victim2->pcdata->spouse, victim->name ) )
/*       if (victim->pcdata->spouse != victim2->name || victim2->pcdata->spouse != victim->name)
          {
          send_to_char(AT_WHITE, "They aren't even married!!\n\r",ch);
          return;
          } */
       {
       send_to_char("&WYou hand them their papers.\n\r", ch);
       send_to_char("&WYour divorce is final.\n\r", victim);
       send_to_char("&WYour divorce is final.\n\r", victim2);

       act(AT_WHITE,"$n and $N swap divorce papers, they are no-longer married.",victim, NULL, victim2, TO_NOTVICT);

       DISPOSE( victim->pcdata->spouse         );
       DISPOSE( victim2->pcdata->spouse        );
       victim->pcdata->spouse = str_dup( "" );
       victim2->pcdata->spouse = str_dup( "" );
       return;
       }
       else
       {
       send_to_char("&WThey arent married!", ch);
       return;
       }
}

void do_rings ( CHAR_DATA *ch, char *argument )
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    CHAR_DATA *victim2;
    char        buf  [ MAX_STRING_LENGTH ];
    OBJ_DATA  * ring;
    EXTRA_DESCR_DATA * ed;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );


       if ( ((victim = get_char_world(ch,arg1)) == NULL) ||
            ((victim2 = get_char_world(ch,arg2)) == NULL))
          {
          send_to_char("&WBoth characters must be playing!\n\r", ch );
          return;
          }
/*       if ((victim->pcdata->spouse != victim2->name) || (victim2->pcdata->spouse != victim->name))
       {
          send_to_char(AT_WHITE, "They arent even married!!\n\r", ch);
          return;
       } */

    switch( victim2->sex )
    {
        case SEX_FEMALE:
        {
            ring = create_object( get_obj_index( OBJ_VNUM_DIAMOND_RING ), 0 );
            switch( victim->sex )
            {
                case SEX_FEMALE:
                {
                    sprintf( buf, "This is the beautiful diamond ring given to you by your lovely\n\rwife %s at your wedding. It signifies your eternal love for eachother.\n\r",victim->name );
                    ring->description = str_dup( buf );
                    break;
                }
                case SEX_MALE:
                {
                    sprintf( buf, "This is the beautiful diamond ring given to you by your handsome\n\rhusband %s at your wedding. It signifies your eternal love for eachother.\n\r", victim->name );
                    ring->description = str_dup( buf );
                    break;
                }
                case SEX_NEUTRAL:
                default:
                {
                    sprintf( buf, "This is the beautiful diamond ring given to you by your\n\rspouse %s at your wedding. It signifies your eternal love for eachother.\n\r", victim->name );
                    ring->description = str_dup( buf );
                    break;
                }
            }
/*
            if ( !extra_descr_free )
            {
                ed = alloc_perm( sizeof( *ed ) );
            }
            else
            {
                ed = extra_descr_free;
                extra_descr_free = extra_descr_free->next;
            }
*/
            ed = SetOExtra(ring, "inscription");
//            ed->keyword = str_dup( "inscription" );
            sprintf( buf, "The inscription reads:\n\rTo my lovely wife, yours forever, %s\n\r", victim->name );
            ed->description = str_dup( buf );
//            ed->deleted = FALSE;
//            ed->next = ring->extra_descr;
//            ring->extra_descr = ed;
            break;
        }
        case SEX_MALE:
        case SEX_NEUTRAL:
        default:
        {
            ring = create_object( get_obj_index( OBJ_VNUM_WEDDING_BAND ), 0 );
            switch( victim->sex )
            {
                case SEX_FEMALE:
                {
                    sprintf( buf, "This is the ring given to you by your beautifull wife %s\n\rat your wedding. It signifies your eternal love for eachother.\n\r", victim->name );
                    ring->description = str_dup( buf );
                    break;
                }
                case SEX_MALE:
                {
                    sprintf( buf, "This is the ring given to you by your handsome husband %s\n\rat your wedding. It signifies your eternal love for eachother.\n\r", victim->name );
                    ring->description = str_dup( buf );
                    break;
                }
                case SEX_NEUTRAL:
                default:
                {
                    sprintf( buf, "This is the ring given to you by your spouse %s at\n\ryour wedding. It signifies your eternal love for eachother.\n\r", victim->name );
                    ring->description = str_dup( buf );
                    break;
                }
            }


/*
            if ( !extra_descr_free )
            {
                ed = alloc_perm( sizeof( *ed ) );
            }
            else
            {
                ed = extra_descr_free;
                extra_descr_free = extra_descr_free->next;
            }
*/

            ed = SetOExtra(ring, "inscription");
/*
            ed->keyword = str_dup( "inscription" );
            ed->deleted = FALSE;
            ed->next = ring->extra_descr;
            ring->extra_descr = ed;
*/

            switch( victim->sex )
            {
                default:
                case SEX_MALE:
                {
                    sprintf( buf, "The inscription reads:\n\rTo my handsome husband... Forever yours, %s\n\r", victim->name );
                    ed->description = str_dup( buf );
                    break;
                }
                case SEX_NEUTRAL:
                {
                    sprintf( buf,"The inscription reads:\n\rForever love, %s\n\r", victim->name );
                    ed->description = str_dup( buf );
                    break;
                }
            }
        }
    }

    obj_to_char ( ring, victim );

    return;
}