Page 1 of 1

ACHIEVEMENT_ANYTHING

Posted: Fri Oct 05, 2012 7:49 pm
by enric
When, this special functions, are called?
Are like a TICK called constantly? or when some event has happened?

Re: ACHIEVEMENT_ANYTHING

Posted: Fri Oct 05, 2012 8:43 pm
by pipfromslitherine
Every tick until it returns 1.

Cheers

Pip

Re: ACHIEVEMENT_ANYTHING

Posted: Sat Oct 06, 2012 1:49 pm
by enric
But should be a more optimized way, no?, than calling a function 30 times a second.
If I've several achievements to check in a scenario, and each one need to loop through all units, can this degrade the BA performance...
Look at this:
FUNCTION ACHIEVEMENT_KILL_A_SPECIFIC()
{
int i ;
int unit ;
int counter ;
for(i=0;i<GetUnitCount(1);i++)
{
unit = GetUnitID(1, i) ;
if( GetUnitDead(unit) != 1)
{
if( IsUnitType(unit, "myUnit") == 1 )
{
counter ++ ;
}
}
}
if( counter == 0 )
{
ShowUIScreenX( "BattleHead0", "Anim1", "IDS_ACH_KILLSPECIFIC", "BHead0Image:achievement_star") ;
return 1 ;
}
return 0 ;
}

Re: ACHIEVEMENT_ANYTHING

Posted: Sat Oct 06, 2012 9:59 pm
by pipfromslitherine
Doing a single loop through units per tick won't impact performance in any meaningful way.

Cheers

Pip