ACHIEVEMENT_ANYTHING

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

ACHIEVEMENT_ANYTHING

Post by enric »

When, this special functions, are called?
Are like a TICK called constantly? or when some event has happened?
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: ACHIEVEMENT_ANYTHING

Post by pipfromslitherine »

Every tick until it returns 1.

Cheers

Pip
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: ACHIEVEMENT_ANYTHING

Post 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 ;
}
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: ACHIEVEMENT_ANYTHING

Post by pipfromslitherine »

Doing a single loop through units per tick won't impact performance in any meaningful way.

Cheers

Pip
Post Reply

Return to “Battle Academy : Modders Corner ”