Aller au contenu

Photo

Problems using some functions in the same script


6 réponses à 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
FergusM

FergusM
  • Members
  • 460 messages
Also, I tried writing another script file with only a single function (to call from my first script), but an error message tells me that I need either main or StartingConditional. Why? A lot of the existing scripts don't seem to follow that, what's up?

#3
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.

#4
Craig Graff

Craig Graff
  • Members
  • 608 messages

DavidSims wrote...

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.


Well you can get rid of it, but only by turning off Auto Compile On Save under Tools > Options > Script Editor. If you do that, just make sure you compile or export before testing.

#5
Magic

Magic
  • Members
  • 187 messages

FergusM wrote...

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

WR_SetFollowerState() will send an EVENT_TYPE_PARTY_MEMBER_HIRED in line 376:
SendPartyMemberHiredEvent(oCreature, FALSE, nMinLevel, bPreventLevelup);
This event is processed in the player_core.ncs script but after your current script. Mostly likely, the auto-scaling of the follower in player_core.ncs is removing your added ability.

For a quick test you could try a
SetLocalInt(oReaver,FOLLOWER_SCALED,TRUE);
before your call of WR_SetFollowerState(). If you're not using a custom level up package that would be all, actually.

#6
FergusM

FergusM
  • Members
  • 460 messages
Thanks for the info, Magic, I think that's exactly it. I actually want to keep the scaling, so I shall simply find a way to stagger the two scripts (one with the hire, one with the abilities) without it being noticeable.

#7
Malcroix

Malcroix
  • Members
  • 360 messages

DavidSims wrote...

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.


I want to change some stuff in sys_soundset_h, which is an include and won't compile. I found that 3 core scripts include this script: rules_core, player_core, creature_core. Is this the correct way to proceed:

1. Change the include, save, export as nss, put the nss into override;

2. Compile the referencing scripts (this puts a whole bunch of files into override/toolsetexport, among them another nss of the include I'm changing);

3. Launch game.

Because so far it didn't work. Maybe because I made a mistake in changing the included script itself, but I would like to exclude the probability that it's because I haven't followed the correct protocol for changing includes.

Help please?