Method code for $robot.activate_reaction()

[Turn off line numbering]
  1: arg id;
  2: var ra, key, e, inserted, chance, times;
  3: 
  4: // Make sure the sender is a writer, added by Sean 20 Feb 1998
  5: (> .perms(sender()) <);
  6: if (!reactions || !dict_contains(reactions, id))
  7:     throw(~noreaction, "No reaction with id '" + id + "'.");
  8: if (!active)
  9:     active = #[];
 10: [key, chance, times] = sublist(reactions[id], 3, 3);
 11: if (dict_contains(active, key)) {
 12:     ra = active[key];
 13:     if (ra.contains(id))
 14:         return .update_active(key, id, [chance, times]);
 15:     active = dict_del(active, key);
 16:     ra = map e in (ra) to (e);
 17: } else {
 18:     ra = [];
 19: }
 20: for e in [1 .. listlen(ra)] {
 21:     if (ra[e][2][1] < chance) {
 22:         ra = insert(ra, e, [id, [chance, times]]);
 23:         inserted++;
 24:     }
 25: }
 26: if (!inserted)
 27:     ra += [[id, [chance, times]]];
 28: active = dict_add(active, key, hash e in (ra) to (e));
 29: active_ids = dict_add(active_ids || #[], id, key);
 30: 
 31: // Hook into 'social; .hook_into_events() will not add twice, so we're safe
 32: // Added by Sean 20 Feb 1998
 33: // Only hook if the type is not 'tell
 34: if (key != 'tell)
 35:     .hook_into_event('social);
 36: 
 37: // $#Edited: 21 Feb 98 00:30 $user_sean
 38: // $#Edited: 22 Feb 98 14:07 $user_sean

["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]

the Cold Dark