当前位置: 首页>>代码示例>>PHP>>正文


PHP Shadowfunc::diceHits方法代码示例

本文整理汇总了PHP中Shadowfunc::diceHits方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowfunc::diceHits方法的具体用法?PHP Shadowfunc::diceHits怎么用?PHP Shadowfunc::diceHits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shadowfunc的用法示例。


在下文中一共展示了Shadowfunc::diceHits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onThrow

 public function onThrow(SR_Player $player, SR_Player $target)
 {
     $firearms = $player->get('firearms');
     $atk = 20 + $firearms;
     $mindmg = 1;
     $maxdmg = 6;
     $out_dmg = '';
     $out_dmgep = '';
     $out_eff = '';
     $inaccuracy = rand(2, 4) - ($firearms ? 1 : 0);
     $targets = $this->computeDistances($target, $inaccuracy);
     foreach ($targets as $data) {
         list($t, $d) = $data;
         $t instanceof SR_Player;
         $a = $atk - $d + rand(-1, 2);
         $a = Common::clamp($a, 0, $atk);
         $def = $t->get('defense');
         $arm = $t->get('marm');
         $hits = Shadowfunc::diceHits($mindmg, $arm, $atk, $def, $player, $t);
         $hits -= $arm;
         $hits = Common::clamp($hits, 0);
         if ($hits == 0) {
             continue;
         }
         $dmg = round($mindmg + $hits / 10, 2);
         if ($dmg <= 0) {
             continue;
         }
     }
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:30,代码来源:MolotovCocktail.php

示例2: onThrow

 public function onThrow(SR_Player $player, SR_Player $target)
 {
     $party = $player->getParty();
     $ep = $party->getEnemyParty();
     $mc = $party->getMemberCount();
     $firearms = $player->get('firearms');
     $atk = 15;
     $mindmg = 1;
     $maxdmg = 4;
     $damage = array();
     $inaccuracy = rand(2, 4) - ($firearms ? 1 : 0);
     $targets = self::computeDistances($target, $inaccuracy);
     foreach ($targets as $data) {
         list($pid, $d) = $data;
         $target = $ep->getMemberByPID($pid);
         $target instanceof SR_Player;
         $a = $atk - $d * $d + rand(-1, 2);
         $a = Common::clamp($a, 0, $atk);
         $def = $target->get('defense');
         $arm = $target->get('marm');
         $hits = Shadowfunc::diceHits($mindmg, $arm, $a, $def, $player, $target);
         $hits = Common::clamp($hits, 0);
         echo "Dicing... DIST: {$d}, ATK: {$a}, DEF: {$def}. Hits: {$hits}\n";
         //			$hits -= $arm;
         if ($hits <= 0) {
             continue;
         }
         $dmg = round($mindmg + $hits * 0.1, 2);
         $dmg = Common::clamp($dmg, $mindmg, $maxdmg);
         $dmg -= $arm;
         if ($dmg <= 0) {
             continue;
         }
         echo "Blinding the target with {$hits} hits ...\n";
         for ($i = 0; $i < $hits; $i += 3) {
             $target->addEffects(new SR_Effect($i * 10, array('attack' => -0.15), SR_Effect::MODE_ONCE));
         }
         $damage[$pid] = $dmg;
     }
     Shadowfunc::multiDamage($player, $damage, 'The Flashbang totally missed all targets.');
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:41,代码来源:Flashbang.php

示例3: onAttackB

 public function onAttackB(SR_Player $player, $arg, $armor_type)
 {
     $p = $player->getParty();
     $mc = $p->getMemberCount();
     $ep = $p->getEnemyParty();
     if (false === ($target = $this->getOffensiveTarget($player, $arg))) {
         return false;
     }
     $d = abs($player->getY() - $target->getY());
     $d2 = Common::clamp($d - 2, 0);
     if ($d > $this->getItemRange()) {
         $player->getParty()->moveTowards($player, $target);
         return true;
     }
     if ($this instanceof SR_FireWeapon) {
         $this->increase('sr4it_ammo', -$this->getBulletsPerShot());
     }
     # Bows are great for distance
     if ($this instanceof SR_Bow) {
         $d2 /= 4;
     } elseif ($this instanceof SR_MeleeWeapon) {
         $d2 = 0;
     }
     $busy = $player->busy($this->getRealAttackTime());
     $mindmg = $player->get('min_dmg');
     $maxdmg = $player->get('max_dmg');
     $arm = $target->get($armor_type);
     $atk = round(Common::clamp($player->get('attack') - $d2 * 1.2, 1));
     $def = $target->get('defense');
     $hits = Shadowfunc::diceHits($mindmg, $arm, $atk, $def, $player, $target);
     $pname = $player->displayNameNB();
     $tname = $target->displayNameNB();
     $iname = $this->getName();
     # Debug
     //		Dog_Log::debug(sprintf('%s (ATK: %s HP: %s) vs. %s (DEF: %s HP: %s) = HITS: %s',$player->getName(),$atk,$player->getHP(),$target->getName(),$def,$target->getHP(),$hits));
     # Miss
     if ($hits < 1) {
         $p->ntice('5230', array($pname, $tname, $iname, $busy));
         $ep->ntice('5230', array($pname, $tname, $iname, $busy));
         return true;
         // 			$msg .= ' but misses.';
     }
     # Hit
     $damage = $hits * 0.1;
     $damage = round(Common::clamp($damage, 0.0, $maxdmg), 1);
     # Crit?
     $sharp = $player->getCritPermille();
     if (rand(0, 1000) < $sharp) {
         $damage += Shadowfunc::diceFloat(1.0, $hits * 0.1 + 1.0, 1);
         $crit = 1;
         $bold = "";
     } else {
         $crit = false;
         $bold = '';
     }
     # No damage
     if ($damage <= 0) {
         $p->ntice('5231', array($pname, $tname, $iname, $busy));
         $ep->ntice('5231', array($pname, $tname, $iname, $busy));
         return true;
         // 			$msg .= sprintf(' but causes no damage.');
         // 			$hpmsg = sprintf(' %s/%s HP left.', round($target->getHP(), 1), round($target->get('max_hp'), 1));
     }
     $target->dealDamage($damage);
     # Special poison weapons
     $this->onDealDamage($player, $target, $hits, $damage);
     # Some damage
     if (false === $target->isDead()) {
         $p->ntice('5232', array($pname, $tname, $iname, $damage, $busy, $bold, $crit));
         $ep->ntice('5233', array($pname, $tname, $iname, $damage, $target->getHP(), $target->getMaxHP(), $busy, $bold, $crit));
         return true;
     }
     ###########
     # Killed! #
     ###########
     $xp = $target->isHuman() ? 0 : $target->getLootXP();
     $nuyen = $target->getLootNuyen();
     if ($player->isNPC()) {
         $target->resetXP();
     }
     $target->giveNuyen(-$nuyen);
     $tl = $target->getBase('level');
     $ploot = array();
     $pxp = 0;
     foreach ($p->getMembers() as $member) {
         $member instanceof SR_Player;
         $lxp = $xp / $mc;
         $leveldiff = ($tl + 1) / ($member->getBase('level') + 1);
         $lxp *= $leveldiff;
         $lxp = round(Common::clamp($lxp, 0.01), 2);
         $pxp += $lxp;
         $xps[] = $lxp;
         $lny = round($nuyen / $mc, 2);
         $member->giveNuyen($lny);
         $member->msg('5234', array($pname, $tname, $iname, $damage, $busy, Shadowfunc::displayNuyen($lny), $lxp, $bold, $crit));
         $member->giveXP($lxp);
         // 			$member->setOption(SR_Player::STATS_DIRTY, true);
     }
     $p->givePartyXP($pxp);
     $ep->ntice('5235', array($pname, $tname, $iname, $damage, $busy, $bold, $crit));
//.........这里部分代码省略.........
开发者ID:sinfocol,项目名称:gwf3,代码行数:101,代码来源:SR_Weapon.php


注:本文中的Shadowfunc::diceHits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。