Location: PHPKode > projects > PhpBlock > A9.8/modules/dungeon/action/objectsearchtrap.class.php
<?php
include_once $PATH_TO_CODE."/modules/dungeon/action/abstractobjectaction.class.php";

class ObjectSearchTrap extends AbstractObjectAction {
    function __construct() {
        parent::__construct(DungeonConstante::$ACTION_OBJECT_SEARCH_TRAP);
    }

    public function action($locZoneActionArray) {
        global $gloObjectManager;
        $locManageAction = ManageAction::getInstance();
        $locPlayer = $locManageAction->getPlayer();
        
        $locTargetObjectId= $locZoneActionArray[1];
        $locTargetZoneId = $locZoneActionArray[2];
        $locTargetZone = $gloObjectManager->getZone($locTargetZoneId);
        $locTargetBlock = $gloObjectManager->getBlock($locTargetZone->blockId);
        if($locTargetObject = $this->getObjectOfPlayer($locTargetObjectId, $locPlayer->playerId, true, true)) {
            if(Zone::getRange3d($locTargetZoneId, $locTargetObject->zoneId) > 1) {
                $locManageAction->addPlayerInfo("target zone ".Zone::staticGetTextZoneCoord($locTargetZoneId)." and unit zone ".Zone::staticGetTextZoneCoord($locTargetObject->zoneId)." are too far (range of ".Zone::getRange3d($locTargetZoneId, $locTargetObject->zoneId).")");
            } else {
            	if($locTargetObject->isAvailableToFindTrap()) {
	                $locActionPoint = $locTargetObject->getActionPoint();
	                $locCost = $locTargetObject->getTrapSearchCost();
	                if($locActionPoint < $locCost) {
	                    $locManageAction->addPlayerInfo("target object has not enough action point to search a trap (only $locActionPoint, $locCost are necessary)");
	                } else {
	                    $locTargetObject->addActionPoint(-$locCost);
	
	                    $locManageAction->addPlayerInfo("unit try to detect a trap on ".Zone::staticGetTextZoneCoord($locTargetZoneId));
	                    if(rand(1, 100) <= DungeonConstante::$DEFAULT_PERCENT_FIND_TRAP) {
	                        $locTrapArray = $locTargetZone->getObjectsNotAlliance(DungeonConstante::$REAL_OBJECT_TYPE_TRAP, $locPlayer->allianceId, 1, 1, 1);
	                        if(count($locTrapArray) > 0) {
	                            $locManageAction->addPlayerInfo("unit destroy a trap on zone: ".Zone::staticGetTextZoneCoord($locTargetZoneId));
	                            $locTrapArray[0]->kill($locTargetObject);
	                        }
	                    }
	                }
                } else {
                	$locManageAction->addPlayerInfo("unit can't find trap");
                }
            }
        }
    }
}



















?>
Return current item: PhpBlock