SetEntityOnFire * Attempts to set the Entity on fire. Entities that are not Burnable or are already on fire will return before any processing * Entities that do not have Stats (such as furniture) will return after setting the fire time and chance to stop at max * Entities with Stats will have their fire time (char_fire) and chance to stop being on fire (chanceToPutOutFire) reduced by their CON
| 27440 | * Calculations for reductions is outlined in this function |
| 27441 | */ |
| 27442 | bool Entity::SetEntityOnFire(Entity* sourceOfFire) |
| 27443 | { |
| 27444 | // Check if the Entity can be set on fire |
| 27445 | if ( this->flags[BURNABLE] ) |
| 27446 | { |
| 27447 | if ( this->behavior == &actPlayer ) |
| 27448 | { |
| 27449 | Stat* myStats = this->getStats(); |
| 27450 | if ( myStats ) |
| 27451 | { |
| 27452 | if ( myStats->type == SKELETON ) |
| 27453 | { |
| 27454 | return false; |
| 27455 | } |
| 27456 | if ( myStats->type == AUTOMATON ) |
| 27457 | { |
| 27458 | return false; |
| 27459 | } |
| 27460 | if ( myStats->breastplate && myStats->breastplate->type == MACHINIST_APRON ) |
| 27461 | { |
| 27462 | return false; |
| 27463 | } |
| 27464 | if ( myStats->amulet && myStats->amulet->type == AMULET_BURNINGRESIST ) |
| 27465 | { |
| 27466 | this->degradeAmuletProc(myStats, AMULET_BURNINGRESIST); |
| 27467 | return false; |
| 27468 | } |
| 27469 | } |
| 27470 | } |
| 27471 | // Check if the Entity is already on fire |
| 27472 | if ( !(this->flags[BURNING]) ) |
| 27473 | { |
| 27474 | this->flags[BURNING] = true; |
| 27475 | serverUpdateEntityFlag(this, BURNING); |
| 27476 | |
| 27477 | /* Set the time the Entity will be on fire, based off their CON |
| 27478 | * |\_ MAX_TICKS_ON_FIRE is reduced by every 2 points in CON |
| 27479 | * | |
| 27480 | * |\_ Fire has a minimum of 4 cycles (120 ticks), and a maximum of 20 cycles (600 ticks), cycles are based off of TICKS_TO_PROCESS_FIRE |
| 27481 | * | \_ Constants are defined in entity.hpp: MIN_TICKS_ON_FIRE and MAX_TICKS_ON_FIRE |
| 27482 | * | |
| 27483 | * \_ For every 5 points of CON, the chance to stop being on fire is increased |
| 27484 | * \_ The chance to stop being on fire has a minimum of 1 in 10, and a maximum of 1 in 5 |
| 27485 | * \_ Constants are defined in entity.hpp: MIN_CHANCE_STOP_FIRE and MAX_CHANCE_STOP_FIRE |
| 27486 | */ |
| 27487 | |
| 27488 | // Set the default time on fire |
| 27489 | this->char_fire = MAX_TICKS_ON_FIRE; |
| 27490 | // Set the default chance of putting out fire |
| 27491 | this->chanceToPutOutFire = MAX_CHANCE_STOP_FIRE; |
| 27492 | |
| 27493 | // If the Entity is not a Monster, it wont have Stats, end here |
| 27494 | if ( this->getStats() == nullptr ) |
| 27495 | { |
| 27496 | return true; // The Entity was set on fire, it does not have Stats, so it is on fire for maximum duration |
| 27497 | } |
| 27498 | |
| 27499 | if ( this->behavior == &actPlayer ) |
no test coverage detected