~ubuntu-branches/ubuntu/utopic/tinymux/utopic

« back to all changes in this revision

Viewing changes to src/rob.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ervin Hearn III
  • Date: 2008-04-11 23:18:25 UTC
  • mfrom: (1.1.5 upstream) (6.1.1 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080411231825-1pq4trckagyk8roo
Tags: 2.6.5.27-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// rob.cpp -- Commands dealing with giving/taking/killing things or money.
2
2
//
3
 
// $Id: rob.cpp,v 1.4 2006/01/07 08:26:39 sdennis Exp $
 
3
// $Id: rob.cpp 492 2006-11-30 17:12:25Z brazilofmux $
4
4
//
5
5
 
6
6
#include "copyright.h"
91
91
            }
92
92
        }
93
93
 
94
 
        if (  Wizard(victim)
 
94
        if (  RealWizard(victim)
95
95
           || (  0 < mudconf.killguarantee
96
96
              && !(  RandomINT32(0, mudconf.killguarantee-1) < cost
97
97
                  || key == KILL_SLAY)))
100
100
            //
101
101
            notify(executor, "Your murder attempt failed.");
102
102
            buf1 = alloc_lbuf("do_kill.failed");
103
 
            sprintf(buf1, "%s tried to kill you!", Name(executor));
 
103
            mux_sprintf(buf1, LBUF_SIZE, "%s tried to kill you!", Moniker(executor));
104
104
            notify_with_cause_ooc(victim, executor, buf1);
105
105
            if (Suspect(executor))
106
106
            {
107
 
                strcpy(buf1, Name(executor));
 
107
                mux_strncpy(buf1, Moniker(executor), LBUF_SIZE-1);
108
108
                if (executor == Owner(executor))
109
109
                {
110
 
                    raw_broadcast(WIZARD, "[Suspect] %s tried to kill %s(#%d).", buf1, Name(victim), victim);
 
110
                    raw_broadcast(WIZARD, "[Suspect] %s tried to kill %s(#%d).", buf1, Moniker(victim), victim);
111
111
                }
112
112
                else
113
113
                {
114
114
                    buf2 = alloc_lbuf("do_kill.SUSP.failed");
115
 
                    strcpy(buf2, Name(Owner(executor)));
 
115
                    mux_strncpy(buf2, Moniker(Owner(executor)), LBUF_SIZE-1);
116
116
                    raw_broadcast(WIZARD, "[Suspect] %s <via %s(#%d)> tried to kill %s(#%d).",
117
 
                        buf2, buf1, executor, Name(victim), victim);
 
117
                        buf2, buf1, executor, Moniker(victim), victim);
118
118
                    free_lbuf(buf2);
119
119
                }
120
120
            }
128
128
        buf2 = alloc_lbuf("do_kill.succ.2");
129
129
        if (Suspect(executor))
130
130
        {
131
 
            strcpy(buf1, Name(executor));
 
131
            mux_strncpy(buf1, Moniker(executor), LBUF_SIZE-1);
132
132
            if (executor == Owner(executor))
133
133
            {
134
 
                raw_broadcast(WIZARD, "[Suspect] %s killed %s(#%d).", buf1, Name(victim), victim);
 
134
                raw_broadcast(WIZARD, "[Suspect] %s killed %s(#%d).", buf1, Moniker(victim), victim);
135
135
            }
136
136
            else
137
137
            {
138
 
                strcpy(buf2, Name(Owner(executor)));
 
138
                mux_strncpy(buf2, Moniker(Owner(executor)), LBUF_SIZE-1);
139
139
                raw_broadcast(WIZARD, "[Suspect] %s <via %s(#%d)> killed %s(#%d).",
140
 
                    buf2, buf1, executor, Name(victim), victim);
 
140
                    buf2, buf1, executor, Moniker(victim), victim);
141
141
            }
142
142
        }
143
 
        sprintf(buf1, "You killed %s!", Name(victim));
144
 
        sprintf(buf2, "killed %s!", Name(victim));
 
143
        mux_sprintf(buf1, LBUF_SIZE, "You killed %s!", Moniker(victim));
 
144
        mux_sprintf(buf2, LBUF_SIZE, "killed %s!", Moniker(victim));
145
145
        if (!isPlayer(victim))
146
146
        {
147
147
            if (halt_que(NOTHING, victim) > 0)
152
152
                }
153
153
            }
154
154
        }
155
 
        did_it(executor, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL, (char **)NULL, 0);
 
155
        did_it(executor, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL, 0,
 
156
            NULL, 0);
156
157
 
157
158
        // notify victim
158
159
        //
159
 
        sprintf(buf1, "%s killed you!", Name(executor));
 
160
        mux_sprintf(buf1, LBUF_SIZE, "%s killed you!", Moniker(executor));
160
161
        notify_with_cause_ooc(victim, executor, buf1);
161
162
 
162
163
        // Pay off the bonus.
166
167
            cost /= 2;  // Victim gets half.
167
168
            if (Pennies(Owner(victim)) < mudconf.paylimit)
168
169
            {
169
 
                sprintf(buf1, "Your insurance policy pays %d %s.", cost,
 
170
                mux_sprintf(buf1, LBUF_SIZE, "Your insurance policy pays %d %s.", cost,
170
171
                    mudconf.many_coins);
171
172
                notify(victim, buf1);
172
173
                giveto(Owner(victim), cost);
232
233
    {
233
234
        sp = str = alloc_lbuf("do_give.gfail");
234
235
        safe_str("You can't give ", str, &sp);
235
 
        safe_str(Name(thing), str, &sp);
 
236
        safe_str(Moniker(thing), str, &sp);
236
237
        safe_str(" away.", str, &sp);
237
238
        *sp = '\0';
238
239
 
239
 
        did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL, A_AGFAIL, (char **)NULL, 0);
 
240
        did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL, A_AGFAIL, 0,
 
241
            NULL, 0);
240
242
        free_lbuf(str);
241
243
        return;
242
244
    }
243
245
    if (!could_doit(thing, recipient, A_LRECEIVE))
244
246
    {
245
247
        sp = str = alloc_lbuf("do_give.rfail");
246
 
        safe_str(Name(recipient), str, &sp);
 
248
        safe_str(Moniker(recipient), str, &sp);
247
249
        safe_str(" doesn't want ", str, &sp);
248
 
        safe_str(Name(thing), str, &sp);
 
250
        safe_str(Moniker(thing), str, &sp);
249
251
        safe_chr('.', str, &sp);
250
252
        *sp = '\0';
251
253
 
252
 
        did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL, A_ARFAIL, (char **)NULL, 0);
 
254
        did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL, A_ARFAIL, 0,
 
255
            NULL, 0);
253
256
        free_lbuf(str);
254
257
        return;
255
258
    }
258
261
    if (!(key & GIVE_QUIET))
259
262
    {
260
263
        str = alloc_lbuf("do_give.thing.ok");
261
 
        strcpy(str, Name(giver));
262
 
        notify_with_cause_ooc(recipient, giver, tprintf("%s gave you %s.", str, Name(thing)));
 
264
        mux_strncpy(str, Moniker(giver), LBUF_SIZE-1);
 
265
        notify_with_cause_ooc(recipient, giver, tprintf("%s gave you %s.", str, Moniker(thing)));
263
266
        notify(giver, "Given.");
264
 
        notify_with_cause_ooc(thing, giver, tprintf("%s gave you to %s.", str, Name(recipient)));
 
267
        notify_with_cause_ooc(thing, giver, tprintf("%s gave you to %s.", str, Moniker(recipient)));
265
268
        free_lbuf(str);
266
269
    }
267
 
    did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP, (char **)NULL, 0);
268
 
    did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC, (char **)NULL, 0);
 
270
    did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP, 0, NULL, 0);
 
271
    did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC, 0,
 
272
        NULL, 0);
269
273
}
270
274
 
271
275
static void give_money(dbref giver, dbref recipient, int key, int amount)
296
300
        }
297
301
        if (!could_doit(giver, recipient, A_LUSE))
298
302
        {
299
 
            notify(giver, tprintf("%s won't take your money.", Name(recipient)));
 
303
            notify(giver, tprintf("%s won't take your money.", Moniker(recipient)));
300
304
            return;
301
305
        }
302
306
    }
346
350
    {
347
351
        if (amount == 1)
348
352
        {
349
 
            notify(giver, tprintf("You give a %s to %s.", mudconf.one_coin, Name(recipient)));
350
 
            notify_with_cause_ooc(recipient, giver, tprintf("%s gives you a %s.", Name(giver), mudconf.one_coin));
 
353
            notify(giver, tprintf("You give a %s to %s.", mudconf.one_coin, Moniker(recipient)));
 
354
            notify_with_cause_ooc(recipient, giver, tprintf("%s gives you a %s.", Moniker(giver), mudconf.one_coin));
351
355
        }
352
356
        else
353
357
        {
354
 
            notify(giver, tprintf("You give %d %s to %s.", amount, mudconf.many_coins, Name(recipient)));
 
358
            notify(giver, tprintf("You give %d %s to %s.", amount, mudconf.many_coins, Moniker(recipient)));
355
359
            notify_with_cause_ooc(recipient, giver, tprintf("%s gives you %d %s.",
356
 
                Name(giver), amount, mudconf.many_coins));
 
360
                Moniker(giver), amount, mudconf.many_coins));
357
361
        }
358
362
    }
359
363
 
373
377
    // Transfer the money and run PAY attributes
374
378
    //
375
379
    giveto(recipient, cost);
376
 
    did_it(giver, recipient, A_PAY, NULL, A_OPAY, NULL, A_APAY, (char **)NULL, 0);
 
380
    did_it(giver, recipient, A_PAY, NULL, A_OPAY, NULL, A_APAY, 0, NULL, 0);
377
381
    return;
378
382
}
379
383