# Dynamically Changing Chances for Attacks?

Get help using Construct 2

### » Sat Oct 27, 2012 5:49 am

I have a slash-em-up game in the works and am working on enemy AI.

I have a very black and white system where one hit kills and parries block all damage. This makes camping very easy for the player to just sit still and slash away at incoming enemies.

But I want to change that, so I have put a global variable that increases and decreases based on whether the player is sitting still, or jumping about and getting more involved.

This design is intended to have the player make choices as to wether to be sitting still and risk enemies trying to jump over them, or have them use ranged weapons (which require a different kind of block).

Or...

the player can jump about and the enemies will be less likely to used ranged weapons/jump, but more likely to swamp the player in other ways.

So I have global variable that goes positive in the player sits still for too long.

I want each enemy to have a "chance" to either charge & jump, or use a weapon when within a distance to the player and when the player has been sitting still.

Currently, ALL of the enemies jump or used ranged weapons when the player has sat still, but I need to think of a way to make it a % "chance" for each individual enemy based on the global variable.

Are there any handy conditions or expressions people can recommend I take a look at?

Please refrain from explaining exactly how to do the above, as I learn better when I am pointed in the right direction, but don't have to follow specific instructions.
B
9
S
3
Posts: 151
Reputation: 1,749

### » Sat Oct 27, 2012 4:45 pm

One approach would be to use the random math function and add its result to your global variable. If its over a certain value, then you can have it execute things differently.
B
91
S
44
G
17
Posts: 1,012
Reputation: 18,562

### » Sat Oct 27, 2012 4:46 pm

Another approach is to assign certain values to various different actions that the player is doing like you were talking about.

add all of these up, and then based on the performance of the player the enemies behave differently. That way the game is a bit more random and harder for better players.
B
91
S
44
G
17
Posts: 1,012
Reputation: 18,562

### Who is online

Users browsing this forum: No registered users and 21 guests