enemies attacks timer

Gurtag

Active member
hey guys is there a way to set up how often an enemy is able to use an attack? like i want say enemy to be able to use attack/freespecial (#) every 60 seconds for example.. i know i can use mp for this but if say enemy uses others attack that consume mp, then one attack afects the frecuency of using the other, is there a way to avoid this?
 
Probably you can use this:

attackthrottle {rate} {time}

  • rate: chance to cancel attack (must be between 0.0 and 1.0)
  • time: in seconds, how long should this entity stay tame until next check, the engine will generate a random number between 0 and this value.
  • note: some action will cancel the timer, for example, getting hit. Seeing the target block or attacking will also affects the timer. A value of 0.5-0.75 should be OK.
  • the idea is to allow using high aggressive settings to give the AI super quick initial "reflexes" but still enough delay between subsequent attacks to avoid unbeatable cheapness
 
As @O Ilusionista said, you can use attackthrottle for frquency of attacks - but it doesn't refer to use of a single move.

You can disable an individual move multiple ways. The most advanced would be thinkscript, but quick and dirty - and probably what I would do, is a @cmd function on the first frame that checks a timer or initializes one if it doesn't exist yet. If the timer hasn't expired yet, cancel the move into something else or back to idle. You could use parameters to set up alternates.

C:
/*
 * slot:     Entity variable reserved for this move's timer.
 * seconds:  Minimum time between uses.
 * fallback: Animation to use while the move is cooling down.
 */
void dc_move_cooldown(void slot, int seconds, int fallback) {
 
    void acting_entity = getlocalvar("self");
    int now = openborvariant("elapsed_time");
    void ready_at = getentityvar(acting_entity, slot);

    // An unused timer allows the first attempt immediately.
    if(ready_at == NULL()) {
        ready_at = 0;
    }

    if(now < ready_at) {
        // Return to idle or substitute another attack.
        if(fallback == openborconstant("ANI_IDLE")){
            setidle(acting_entity, fallback, 1);
   
        } else {
            performattack(acting_entity, fallback, 1);
        }

        return;
    }

    // Allow this attempt and record when the move becomes available.
    int next_time = now + seconds * openborvariant("game_speed");
 
    setentityvar(acting_entity, slot, next_time);
}

Code:
anim freespecial2
    loop 0
    delay 5

    @cmd dc_move_cooldown "cooldown_fs2" 60 openborconstant("ANI_IDLE")
    frame data/chars/enemy/special_start.png

    # Remaining attack frames follow.

HTH,
DC
 
Back
Top Bottom