FUNCTION Tick(side)

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
buffpilot
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 14
Joined: Tue Aug 28, 2012 11:11 pm

FUNCTION Tick(side)

Post by buffpilot »

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

Re: FUNCTION Tick(side)

Post by pipfromslitherine »

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
buffpilot
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 14
Joined: Tue Aug 28, 2012 11:11 pm

Re: FUNCTION Tick(side)

Post by buffpilot »

I'll try that, but right now it just doesn't do anything and we cycle to the next turn.
pipfromslitherine
Site Admin
Site Admin
Posts: 9929
Joined: Wed Mar 23, 2005 10:35 pm

Re: FUNCTION Tick(side)

Post by pipfromslitherine »

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
buffpilot
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 14
Joined: Tue Aug 28, 2012 11:11 pm

Re: FUNCTION Tick(side)

Post by buffpilot »

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?
pipfromslitherine
Site Admin
Site Admin
Posts: 9929
Joined: Wed Mar 23, 2005 10:35 pm

Re: FUNCTION Tick(side)

Post by pipfromslitherine »

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
buffpilot
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 14
Joined: Tue Aug 28, 2012 11:11 pm

Re: FUNCTION Tick(side)

Post by buffpilot »

pip,

Now for dumb question of the day - Where is the DeBugMode1? Where is the user.txt file?
pipfromslitherine
Site Admin
Site Admin
Posts: 9929
Joined: Wed Mar 23, 2005 10:35 pm

Re: FUNCTION Tick(side)

Post by pipfromslitherine »

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
buffpilot
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 14
Joined: Tue Aug 28, 2012 11:11 pm

Re: FUNCTION Tick(side)

Post by buffpilot »

Thanks!
Post Reply

Return to “Battle Academy : Modders Corner ”