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

Re: Create Missile -- This won't work



> 
> 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 :)
> 
>   if (!stringarg || ((1 + SP_level_strength_adjust(op, SP_CREATE_MISSILE)) -
Oh ya, this line needs to be:
                      (3 * missile_plus)) <= 0)
>                      (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));
This won't happen (it's in tthe formula :))
I.E.: the part thattt goes 1 + SP_level... - (3 * missile_plus)) <= 0)
>   if (missile_nrof<0) {
>     draw_info(op,"Unable to create missile: bonus too high.");
>     return 0;
>   }
---------------------------------------------
I just added a ! to the beginning of the find_archetype line
and changed tmp = get_archetype(missile_name); to missile = get_archetype(missile_name);
i.e:
  if (!find_archetype(missile_name)) {
        LOG(llevDebug, "Cast create_missile: could not find archtype %s\n", miss
        return 0;
  }
  missile = get_archetype(missile_name);
instead of
>   missile = get_object();
>   copy_object(&at->clone,missile);
----------------------
>   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;
> }
> 
> 

This code won't crash the game anymore, but it wonn't actually create
missiles....

Just add the ! to the find_archetype line and the game won't crash anymore...
(it will look for either the objert arrows or crossbow bolts, neither of
which should be found, though I wonder if it would turn crossbow bolts into
crossbow and create magic crossbow's :) Dunno....

I'll be sending Mark my patch, and If anyone actually wants the patch to 
make it actually work and doesn't want to dig it out of  my reply, just
send email....

Ben