Aller au contenu

Photo

Problems using some functions in the same script


1 réponse à ce sujet

#1
FergusM

FergusM
  • Members
  • 460 messages
I'm trying to add a party member and then give them an ability, as such:

object oReaver = UT_GetNearestCreatureByTag(oLeader,"reaver");
WR_SetFollowerState(oReaver, FOLLOWER_STATE_ACTIVE);
AddAbilityEx(oReaver,3,1);//Critical Strike

The problem is, the ability does not show up. Now, if I put that last line in a separate script and trigger that, the ability gets added. I tried using CommandWait() between adding the party member and adding the ability, but that did not help. Any ideas for how to get this all to go off at once?

On a somewhat related note, I tried to move the AddAbility line into a separate function in the script.

void main(){
  //stuff
  addAbilities();
}

void addAbilities(){
  //stuff
}

But the compiler tells me that addAbilities is an unidentified identifier. How do I get that to work?

Modifié par FergusM, 11 février 2010 - 04:30 .


#2
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
Not sure what's up with AddAbility().



The firest doesn't compile becuase the function isn't defined yet. The compiler is very simple, and works top down. You can either move the function above the main function, or put a function declaration like this:



void addAbilities();



void main(){

//stuff

addAbilities();

}



void addAbilities(){

//stuff

}



As for the compile error with header files (scripts with no main/startingconditional), ignore that. There's no way to get rid of it and yes, it's annoying. You can't compile header files, only save them, so to see the changes in game make sure you compile the scripts that include the header.