I'm trying to set up a system that will check to see if a unit is on a particular square and if so attack it. Unfortunately I can't seem to get the attack to work. I know the Function Tick works because I put an artillery strike in it and watched the Germans pound a field into ashes...so what am I missing here? This code does not result in an attack.
FUNCTION Tick(side)
{
int zUnitID;
int zBoom;
If(GetUnitOnTile(28,24) >= 0)
{
zBoom = 70;
zUnitID = GetUnitOnTile(28,24);
BonusHEAttack(zUnitID,zBoom,28,24);
}
}
The following DOES result in an attack at the start of each sides turn:
FUNCTION StartTurn(side)
{
int zUnitID;
int zBoom;
int zCheck;
zCheck = GetUnitOnTile(24,24);
If (zCheck >=0)
{
zBoom = Rand(50,200);
zUnitID = GetUnitOnTile(24,24);
BonusHEAttack(zUnitID,zBoom,24,24);
DamageTile(24,24,zBoom);
}
}
FUNCTION Tick(side)
Moderators: Slitherine Core, BA Moderators
-
pipfromslitherine
- Site Admin

- Posts: 9929
- Joined: Wed Mar 23, 2005 10:35 pm
Re: FUNCTION Tick(side)
Try adding a flag to prevent the attack happening every single tick - as it is once a unit ends up on the tile, it will attempt the bombardment every tick, which might be queuing up too many effects.
Cheers
Pip
Cheers
Pip
Re: FUNCTION Tick(side)
I'll try that, but right now it just doesn't do anything and we cycle to the next turn.
-
pipfromslitherine
- Site Admin

- Posts: 9929
- Joined: Wed Mar 23, 2005 10:35 pm
Re: FUNCTION Tick(side)
I'm getting confused. When do you want the attack to happen - any time during a turn, or just at the start of a new turn?
I would initially suggest adding some Log(... calls to check what is going on. Remember you need to have DEBUGMODE 1 set in your user.txt file to be able to bring up the log window in battle with F6.
Cheers
Pip
I would initially suggest adding some Log(... calls to check what is going on. Remember you need to have DEBUGMODE 1 set in your user.txt file to be able to bring up the log window in battle with F6.
Cheers
Pip
Re: FUNCTION Tick(side)
Pip,
I don't know how to use the Debugmode 1 - so I will add it. I would make a change and watch the game - see what happened. Only way I could debug.
What I want to happen is for it to check every tick if a unit is on the square. if so attack it, and then stop any more attacks (with a flag) during that turn. Not a perfect minefield, but it will do. For booby traps it would attack once per game....
Can you build normal arrays in BA script using C++ conventions?
I don't know how to use the Debugmode 1 - so I will add it. I would make a change and watch the game - see what happened. Only way I could debug.
What I want to happen is for it to check every tick if a unit is on the square. if so attack it, and then stop any more attacks (with a flag) during that turn. Not a perfect minefield, but it will do. For booby traps it would attack once per game....
Can you build normal arrays in BA script using C++ conventions?
-
pipfromslitherine
- Site Admin

- Posts: 9929
- Joined: Wed Mar 23, 2005 10:35 pm
Re: FUNCTION Tick(side)
You can't use arrays in a C style, but there are some scratchpads you can use via the ClearArray and related functions (check the autodocs).
If minefields are what you are after, I would recommend the new object scripting - allows you to set up the object and then use it wherever you like. See the docs here:
http://www.slitherinebravo.net/GameWiki ... user_value
Hope that helps!
Cheers
Pip
If minefields are what you are after, I would recommend the new object scripting - allows you to set up the object and then use it wherever you like. See the docs here:
http://www.slitherinebravo.net/GameWiki ... user_value
Hope that helps!
Cheers
Pip
Re: FUNCTION Tick(side)
pip,
Now for dumb question of the day - Where is the DeBugMode1? Where is the user.txt file?
Now for dumb question of the day - Where is the DeBugMode1? Where is the user.txt file?
-
pipfromslitherine
- Site Admin

- Posts: 9929
- Joined: Wed Mar 23, 2005 10:35 pm
Re: FUNCTION Tick(side)
In the My Documents/My Games/BBCBA folder. Open the USER.TXT file and just add the line
DEBUGMODE 1
and then save and restart the game.
Cheers
Pip
DEBUGMODE 1
and then save and restart the game.
Cheers
Pip
Re: FUNCTION Tick(side)
Thanks!
