Aller au contenu

Photo

Calling a function error


  • Veuillez vous connecter pour répondre
1 réponse à ce sujet

#1
Nebril2

Nebril2
  • Members
  • 59 messages

Hi all!

 

 

I created a function wich gives random item properties to an object. I plan to use it often so thats why its better to create a function that i can call every time and not to make the whole script everytime i need it.  

 

 

 

I called "my_functions" to the include script and inside i created this: 

 

 

void EnchantItemAt(object oArma, int nTr)

{
  while (nTr > 0)
  {
 
  int nR = Random(21);
 
  if (nR == 1)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAbilityBonus(IP_CONST_ABILITY_CHA, d4(1)), oArma);
                                                 Declaration dont match parameters error.
  if (nR == 2)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAbilityBonus(IP_CONST_ABILITY_CON, d4(1)), oArma);
  if (nR == 3)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAbilityBonus(IP_CONST_ABILITY_DEX, d4(1)), oArma);
  if (nR == 4)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAbilityBonus(IP_CONST_ABILITY_INT, d4(1)), oArma);
  if (nR == 5)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAbilityBonus(IP_CONST_ABILITY_STR, d4(1)), oArma);
  if (nR == 6)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAbilityBonus(IP_CONST_ABILITY_WIS, d4(1)), oArma);
  //if (nR == 7)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAdditional(IP_CONST_ADDITIONAL_CURSED), oArma);
  if (nR == 8)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAdditional(IP_CONST_ADDITIONAL_CURSED), oArma);
  if (nR == 9)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAttackBonus(d4(1)), oArma);
  if (nR == 10)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAttackBonus(d4(1)), oArma);
  if (nR == 11)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyAttackBonusVsAlign(d6(1),d4(1)), oArma);
  if (nR == 12)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_ALERTNESS), oArma);
  if (nR == 13)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_CLEAVE), oArma);
  if (nR == 14)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_COMBAT_CASTING), oArma);
  if (nR == 15)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_DISARM), oArma);
  if (nR == 16)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_KNOCKDOWN), oArma);
  if (nR == 17)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_POWERATTACK), oArma);
  if (nR == 18)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_SNEAK_ATTACK_1D6), oArma);
  if (nR == 19)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusFeat(IP_CONST_FEAT_WHIRLWIND), oArma);
  if (nR == 20)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyBonusSpellResistance(d6(1)), oArma);
  //if (nR == 21)
  AddItemProperty(DURATION_TYPE_PERMANENT, ItemPropertyCastSpell(Random(300),Random(14)), oArma);
 
 
 
   nTr = nTr-1;
 
 
  }
 
 
}

 

Ok, so thats my function... then i added a placeable wich onused it should give a random itemprop to the user weapon: 

 

On placeable script OnUsed i created:

 

 

#include"my_functions"    <--- here im including the function list.

 
 
void main()
{
 
  object oPC = GetLastUsedBy();
  object oAr = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND);
  int nT = 3;
  EnchantItemAt(oAr, nT);    <---here im calling it with both entrance parameters object and int declared . 
 
 
}

 

Well i think this should work, but i get a "declaration dont match parameters" on the "my_functions" in red showed before.

 

Obviously im doing something wrong when calling the function but i cant figure out what. 

 

So i need some help.

 

Thank you :)

 

 

 

 

 

 

 



#2
WhiZard

WhiZard
  • Members
  • 1 204 messages

I copied and pasted the red lines and I did not receive an error.  Try recompiling.

 

Also your include only looks at cases 1-20 when the range of Random(21) is 0-20. Further the script will always add a cast spell property (intended for 21, but the conditional and not its result were commented out).