Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create Missile -- This won't work



In message "Re: Create Missile -- This won't work", 
'huma@netcom.com' writes:

>> 
>> Hello,
>> 
>>    I've got _a_ fix for the create missile problem; it's short so I'll 
>> included here.
>> 
>> spell_effect.c :
>> 
>> int cast_create_missile(object *op, int dir, char *stringarg)
>> {
>>   int missile_plus=0, missile_nrof;
>>   char *missile_name = NULL;
>This variable doesn't need to be added the way I did it, and it's not
>being assigned  to find_archetype(missille_name) here anyways -- bad news
>>   archetype *at=NULL;
>--------------
>>   object *tmp, *missile=NULL, *weap=NULL;
>> 
>>   for (tmp=op->inv; tmp != NULL; tmp=tmp->below)
>>     if (tmp->type == BOW && QUERY_FLAG(tmp, FLAG_APPLIED))
>>       weap= tmp;
>> 
>>   if (weap==NULL) missile_name = "arrow";
>>   else missile_name = weap->race;
>                        ^
>                        |
>                   this will either be arrows or crossbow bolts.
>    I changed this line to:
>    else missile_name = weap->slaying;
>And added a slaying field to bow and crossbow == to arrow & bolt respectively
>This was the only way I could figure out how to do this witht he existing
>variables, and bow's & crossbows of actual slaying would be really nasty :)

   Here is one way around not using a new field.  This time I tested the
fixes :-)

int cast_create_missile(object *op, int dir, char *stringarg)
{
  int missile_plus=0, missile_nrof;
  char *missile_name = NULL;
  object *tmp, *missile=NULL, *weap=NULL;

  for (tmp=op->inv; tmp != NULL; tmp=tmp->below)
    if (tmp->type == BOW && QUERY_FLAG(tmp, FLAG_APPLIED))
      weap= tmp;

  if (weap==NULL)                                missile_name = "arrow";
  else if (!strcmp(weap->race,"crossbow bolts")) missile_name = "bolt";
  else if (!strcmp(weap->race,"arrows"))         missile_name = "arrow";
  else                                           missile_name = "arrow";

  if (!stringarg || ((1 + SP_level_strength_adjust(op, SP_CREATE_MISSILE)) -
                     (3 * missile_plus)) <= 0)
    missile_plus = SP_PARAMETERS[SP_CREATE_MISSILE].bdam +
                   SP_level_dam_adjust(op, SP_CREATE_MISSILE);
  else
    missile_plus = atoi(stringarg);
  if (missile_plus > 4)
    missile_plus = 4;
  else if (missile_plus < -4)
    missile_plus = -4;
  missile_nrof = SP_PARAMETERS[SP_CREATE_MISSILE].bdur *
                 ((1 + SP_level_strength_adjust(op, SP_CREATE_MISSILE)) -
                  (3 * missile_plus));
  if (!find_archetype(missile_name)) {
        LOG(llevDebug, "Cast create_missile: could not find archtype %s\n", miss
ile_name);
        return 0;
  }
  missile = get_archetype(missile_name);
  missile->nrof = missile_nrof;
  missile->magic = missile_plus;
  SET_FLAG(missile, FLAG_IDENTIFIED);
  if (!cast_create_obj(op,missile,dir))
    pick_up(op, missile);
  return 1;
}



Regards,

 __  __/  /   /   __  /    |   /    Tuan T. Doan
    /    /   /   /   /   / |  /     IEC Layer Testing and Advance Technology
   /    /   /   __  /   /  | /      2201 Lakeside Blvd.  P.O. Box 833871
__/  ______/ __/ __/ __/  __/       Richardson, TX 75083-3871
"It's a kind of magic" -Highlander  Phone: 6-444-4575/214-684-4575
Internet:  tdoan@bnr.ca             Fax:   6-444-3716/214-684-3716