pipfromslitherine wrote:Hmmm - interesting point. The command will just find the first instance of the script, and some of them can be for each side (esp in MP for sure). I shall have a look and see what the best solution would be. For now, you could make the global a mask (e.g. use bit 0 to enable for for 0, and bit 1 to enable for side 1) and that would allow the functionality to work?
I think I figured out how a "g" global works, and why it can be jointly used. It appears, from my observations, that the "g" global is saved for the that side when the turn ends. Then, when it's the players turn again, it will load the last value. Currently, I don't see an application for "g" gloabls when generating a random map. So, if my theory is right, I might be able to use a "g" global in future apps.
Your "mask" idea is brilliant! Listen to this ...
Remember I said that the VP is collocated with the "aid station" terrain card? Well, the VP global logic was staring me right in my face! So, I didn't need to create a new global.
Below is the change I made to my new REVIVE_AID.bsf ... Also, I didn't need to add new code to the function STARTTURN_BONUS_REVIVE() ...
Code: Select all
// same as usual, can return -1, -2, or >=0 for disabled, not shown, or normal respectively
function CHECK_BONUSICON_REVIVE()
{
int ret ;
ret = 0 ;
if( (BonusTimerCheck(-1, "Revive") != 0) )
{
ret = -1 ;
}
if (GetScriptGlobal("R_map", "vp9") != GetCurrentSide())
{
ret = -1 ;
}
return ret ;
}
Now, I can use this same mask when controlling the Bonus icon button. For this, I had to make a new function, MerrBonusIconUI. This solves all my logic, allowing the bonus to become available and continues to be available without the players unit on the VP ...
Code: Select all
// draw anything we want to draw on top of the usual rendering.
function UIBUTTON_BONUSICON_REVIVE(x, y)
{
// we can use the normal one as we never set a gBombardment global so it will just show the turn delay etc
MerrBonusIconUI(x, y, "Revive") ;
}
// deal with the logic for a bonus button
FUNCTION MerrBonusIconUI(x, y, name)
{
int wait ;
int turnDelay ;
StartString() ;
if( GetGlobal("gBombardment") > 0)
{
PrintString("IDS_BONUS_IMPACT") ;
PrintStringLiteral(":-") ;
PrintInt( GetGlobal("gBombardment") ) ;
}
else
{
turnDelay = GetBonusValue("Delay", GetCurrentSide(), name) ;
wait = turnDelay - GetGlobal("gCounter") ;
if((wait<=0) && ( GetScriptGlobal("R_map", "vp9") == GetCurrentSide() ) )
{
PrintString("IDS_BONUS_READY") ;
}
else
{
if((wait>0) && ( GetScriptGlobal("R_map", "vp9") == GetCurrentSide() ) )
{
PrintInt(wait) ;
PrintStringLiteral(" ") ;
PrintString("IDS_BONUS_TURNS") ;
}
else
{
PrintStringLiteral(" ") ;
PrintString("IDS_BONUS_UNAVAILABLE") ;
}
}
}
RenderString(x+2,y+22,6,"ffffffff", "ff000000") ;
// now make a tooltip
StartString() ;
StartWorkString() ;
PrintWorkStringLiteral("IDS_BONUS_") ;
PrintWorkStringLiteral(name) ;
PrintString( GetWorkString() ) ;
PrintStringLiteral("\n") ;
if( GetGlobal("gBombardment") > 0)
{
PrintString("IDS_BONUS_TT_IMPACT") ;
PrintInt( GetGlobal("gBombardment") ) ;
}
else
{
turnDelay = GetBonusValue("Delay", GetCurrentSide(), name) ;
wait = turnDelay - GetGlobal("gCounter") ;
if((wait<=0) && ( GetScriptGlobal("R_map", "vp9") == GetCurrentSide() ) )
{
PrintString("IDS_BONUS_TT_READY") ;
}
else
{
if((wait>0) && ( GetScriptGlobal("R_map", "vp9") == GetCurrentSide() ) )
{
PrintString("IDS_BONUS_TT_TURNS") ;
PrintInt(wait) ;
}
else
{
//PrintStringLiteral(" ") ;
PrintString("IDS_BONUS_TT_UNAVAILABLE") ;
}
}
}
SetUITooltip() ;
}
Thanks a bunch for your help! This concludes Pip's lesson on globals ...
