Random Code

Posted by Shadwen on Sat 13 Apr 2013 06:50 AM — 5 posts, 22,993 views.

#0
Hi. Im having an issue editing the code to incorporate my idea.

I want the random code to work like this.



Mobs cap at 65 here.

Moblevel/5 + Player Luck/5 = amount.

I want to add that amount to the random roll.

What would be the string i would add or the code to use? im still new at this whole coding thing.
#1
Ok. I just need to increase the random amounts. Where would this be altered?


void random_apply( OBJ_DATA *obj, CHAR_DATA *mob )
{
   int chance;
   int applychance;
   int antitype;

   static int attrib_types[] = { APPLY_STR, APPLY_DEX, APPLY_DEX, APPLY_INT, APPLY_INT, APPLY_INT, APPLY_WIS, APPLY_WIS,
      APPLY_WIS, APPLY_CON, APPLY_CON, APPLY_CON, APPLY_LCK, APPLY_LCK, APPLY_LCK, APPLY_CHA, APPLY_CHA,
      APPLY_CHA, APPLY_HITROLL, APPLY_DAMROLL, APPLY_SPELLDAM };
   static int power_types[] = { APPLY_MANA, APPLY_MANA, APPLY_HIT, APPLY_HIT, APPLY_MOVE, APPLY_MOVE };
   static int save_types[] = { APPLY_SAVING_SPELL, APPLY_SAVING_SPELL, APPLY_SAVING_BREATH, APPLY_SAVING_BREATH,
      APPLY_SAVING_PARA, APPLY_SAVING_DAMAGE };
   static int attrib_mods[] = { -3, -2, -2, -1, -1, -1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3 };
   static int power_mods[] = { -30, -20, -10, -10, -5, -5, 5, 5, 5, 10, 10, 10, 20, 20, 20, 30 };
   static int save_mods[] = { -3, -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 1, 1, 2, 3 };   

   AFFECT_DATA *paf;   

   separate_obj( obj );
   CREATE( paf, AFFECT_DATA, 100 );
   paf->type	     = -1;
   paf->duration     = -1;
   switch (number_range(1, 4)) {
   case 1:
      paf->location  = attrib_types[number_range(0, nelems(attrib_types)-1)];
      paf->modifier  = attrib_mods[number_range(0, nelems(attrib_mods)-1)];
      xCLEAR_BITS( paf->bitvector );
      LINK( paf, obj->first_affect, obj->last_affect, next, prev );
      break;
   case 2:
      paf->location  = power_types[number_range(0, nelems(power_types)-1)];
      paf->modifier  = power_mods[number_range(0, nelems(power_mods)-1)];
      xCLEAR_BITS( paf->bitvector );
      LINK( paf, obj->first_affect, obj->last_affect, next, prev );
      break;
   case 3:
      paf->location  = attrib_types[number_range(0, nelems(attrib_types)-1)];
      paf->modifier  = attrib_mods[number_range(0, nelems(attrib_mods)-1)];
      xCLEAR_BITS( paf->bitvector );
      LINK( paf, obj->first_affect, obj->last_affect, next, prev );
      break;
   case 4:
      paf->location  = save_types[number_range(0, nelems(save_types)-1)];
      paf->modifier  = save_mods[number_range(0, nelems(save_mods)-1)];
      xCLEAR_BITS( paf->bitvector );
      LINK( paf, obj->first_affect, obj->last_affect, next, prev );
      break;
   }

   xSET_BIT(obj->extra_flags, ITEM_MAGIC);
   
   if (number_percent() <= 10)
	xSET_BIT(obj->extra_flags, ITEM_GLOW);
   if (number_percent() <= 10)
	xSET_BIT(obj->extra_flags, ITEM_HUM);
Amended on Mon 15 Apr 2013 12:41 AM by Zeno
USA #2
You're sure that is the code you want to modify? Where is it used, just to be sure? Because the above seems to apply to an obj and/or mob.
#3
Act_Obj is the location.
USA #4
Can you be more specific? What in act_obj?