本文整理汇总了PHP中Shadowfunc::diceFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP Shadowfunc::diceFloat方法的具体用法?PHP Shadowfunc::diceFloat怎么用?PHP Shadowfunc::diceFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shadowfunc
的用法示例。
在下文中一共展示了Shadowfunc::diceFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calcFirewallDamage
private function calcFirewallDamage(SR_Player $player, SR_Player $target, $level, $hits)
{
// echo "Calc damage with $hits hits\n";
$min = $level + 1;
$max = $min + $hits * 1.0;
return Shadowfunc::diceFloat($min, $max);
}
示例2: decideCombat
public static function decideCombat(SR_Player $player, array $args)
{
echo __METHOD__ . PHP_EOL;
$min = isset($args[0]) ? (int) $args[0] : 1.0;
$max = isset($args[1]) ? (int) $args[1] : 1.0;
return array('attack', Shadowfunc::diceFloat($min, $max, 2));
}
示例3: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
// echo "Casting Firebolt with level $level and $hits hits.\n";
$min = 1.0 + $level * 0.2;
$max = $min + $level * 1.0 + $hits * 0.3;
$damage = Shadowfunc::diceFloat($min, $max);
return $this->spellDamageSingleTarget($player, $target, $level, '10040', $damage);
}
示例4: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
echo "Casting " . $this->getName() . " with level {$level} and {$hits} hits.\n";
$min = 0.0;
$max = $hits * 1.5;
$sucked = Shadowfunc::diceFloat($min, $max, 1);
$target->healMP(-$sucked);
// $append = sprintf('%s lost %s MP.', $target->getName(), $sucked);
$this->announceADV($player, $target, $level, '10090', $sucked);
return true;
}
示例5: onASLSetRandom
public static function onASLSetRandom(SR_Player $player)
{
$data = SR_Player::$RACE_BASE[$player->getRace()];
$rand = Shadowfunc::diceFloat(0.8, 1.2, 2);
$age = round($data['age'] * $rand);
$age = Common::clamp($age, 18);
$rand = Shadowfunc::diceFloat(0.8, 1.2, 2);
$bmi = round($data['bmi'] * $rand * 1000);
$height = round($data['height'] * $rand);
return self::onASLSetCustom($player, $age, $bmi, $height);
}
示例6: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
$min = $level + 1;
$max = $min + $level / 4 + $hits / 10;
$gain = Shadowfunc::diceFloat($min, $max);
$oldhp = $target->getHP();
$maxhp = $target->getMaxHP();
$gain = $target->healHP($gain);
$append = Shadowfunc::displayHPGain($oldhp, $gain, $maxhp);
$this->announceADV($player, $target, $level, '10110', $append);
return true;
}
示例7: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
$wis = $potion_player->get('wisdom') * 30;
$min = 20 + $level * 10;
$max = 40 + $level * 20 + $wis;
$seconds = rand($min, $max);
$seconds = $this->lowerSpellIncrement($target, $seconds, 'frozen');
$target->busy($seconds * 10);
$ef = Shadowfunc::diceFloat(0.1, $level, 1);
$target->addEffects(new SR_Effect($seconds, array('frozen' => $ef), SR_Effect::MODE_ONCE_EXTEND));
$this->announceADV($player, $target, $level, '10050', $seconds, $ef);
return true;
}
示例8: onDealDamage
/**
* Poison the target.
* @see SR_Weapon::onDealDamage()
*/
public function onDealDamage(SR_Player $player, SR_Player $target, $hits, $damage)
{
$biotech = Common::clamp($target->getVar('biotech'), 0, 15);
$min = 0.1 - $biotech * 0.01;
$max = 0.3 - $biotech * 0.02;
$duration = rand(20, 40);
$per_sec = Shadowfunc::diceFloat($min, $max, 2);
if ($per_sec > 0) {
$modifiers = array('hp' => $per_sec);
$target->addEffects(new SR_Effect($duration, $modifiers));
$target->msg('5294', array(sprintf('%.02f', $per_sec), GWF_Time::humanDuration($duration)));
}
}
示例9: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
$wis = $potion_player->get('wisdom') * 30;
$min = 5 + $level * 5;
$max = 10 + $level * 10 + $wis;
$seconds = rand($min, $max);
$seconds = $this->lowerSpellIncrement($target, $seconds, 'frozen');
$target->busy($seconds * 10);
$ef = Shadowfunc::diceFloat(0.1, $level, 1);
$target->addEffects(new SR_Effect($seconds, array('frozen' => $ef), SR_Effect::MODE_ONCE_EXTEND));
$min = 0.5 + $level * 0.3;
$max = $min + $level * 0.8 + $hits * 0.25;
$damage = Shadowfunc::diceFloat($min, $max);
return $this->spellDamageSingleTarget($player, $target, $level, '10040', $damage, $seconds);
}
示例10: on_reward
public function on_reward(SR_Player $player, array $args)
{
$bot = Shadowrap::instance($player);
if (count($args) !== 1) {
$bot->reply($this->lang($player, 'usage'));
// $bot->reply('Usage: #reward <attribute|skill>. Will create a new rune.');
return false;
}
$f = strtolower($args[0]);
if (isset(SR_Player::$SKILL[$f])) {
$f = SR_Player::$SKILL[$f];
}
if (isset(SR_Player::$ATTRIBUTE[$f])) {
$f = SR_Player::$ATTRIBUTE[$f];
}
if ($f === 'essence') {
$min = 0.1;
$max = 0.1;
} elseif (in_array($f, SR_Player::$SKILL)) {
$min = 0.2;
$max = 0.6;
} elseif (in_array($f, SR_Player::$ATTRIBUTE)) {
$min = 0.4;
$max = 0.8;
} else {
$bot->reply($this->lang($player, 'unknown'));
// $bot->reply('This skill or attribute is unknown.');
return false;
}
$itemname = 'Rune_of_' . $f . ':' . Shadowfunc::diceFloat($min, $max, 1);
if (false === ($item = SR_Item::createByName($itemname))) {
$bot->reply($this->lang($player, 'broken'));
// $bot->reply('My smith hammer is broken!');
return false;
}
$bot->reply($this->lang($player, 'cheers'));
// $bot->reply('The dwarf cheers and get\'s to work.');
$bot->reply($this->lang($player, 'received', array($itemname)));
// $bot->reply("You received ${itemname}.");
$key = self::REWARD_RUNES;
$player->giveItems(array($item));
$player->decreaseConst($key, -1);
if (!$player->hasConst($key)) {
$bot->reply($this->lang($player, 'rewarded'));
// $bot->reply('You haved used all your #reward now.');
}
return true;
}
示例11: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
echo "Casting Vulcano with level {$level} and {$hits} hits.\n";
$this->announceADV($player, $target, $level);
# Firebolt ads 0.20 per level
$firebolt = $potion_player->getSpell('firebolt');
$firebolt = $firebolt === false ? 0 : $firebolt->getLevel($player);
$firebolt = round($firebolt / 5, 1);
$level += $firebolt;
# Fireball ads 0.25 per level
$fireball = $potion_player->getSpell('fireball');
$fireball = $fireball === false ? 0 : $fireball->getLevel($player);
$fireball = round($fireball / 4, 1);
$level += $fireball;
# Firewall ads 0.3 per level
$firewall = $potion_player->getSpell('firewall');
$firewall = $firewall === false ? 0 : $firewall->getLevel($player);
$firewall = round($firewall * 0.3, 1);
$level += $firewall;
# Inaccurate
$inaccuracy = Common::clamp(3 - $level * 0.1, 1);
$targets = SR_Grenade::computeDistances($target, $inaccuracy);
$p = $player->getParty();
$ep = $p->getEnemyParty();
$damage = array();
foreach ($targets as $data) {
list($pid, $d) = $data;
$target = $ep->getMemberByPID($pid);
$d = Common::clamp($d, 1);
$hits = $this->dice($potion_player, $target, $level);
# Dice hits
echo "!! Vulcano hits={$hits}, Distance={$d}";
$min = 1.0 + $level * 1.0;
# Min damage is quite low
$max = $min + $level + $hits * 1.2;
# The max damage is min + hits
$dmg = Shadowfunc::diceFloat($min, $max);
$dmg /= $d / SR_Party::X_COORD_INC * 1.2;
# Apply area reduction
$dmg = round($dmg, 1);
$damage[$pid] = $dmg;
}
$this->spellDamageMultiTargets($player, $damage, $level);
return true;
}
示例12: alchemicFactory
public static function alchemicFactory(SR_Player $player, $spellname, $level)
{
$ma = $player->get('magic');
$in = $player->get('intelligence');
$wi = $player->get('wisdom');
$alc = $player->get('alchemy');
# 10 - 80 percent randomness
$randomness = 100 - ($wi + $alc * 2 + $in + $ma);
$randomness = Common::clamp($randomness, 10, 80);
$randomness = Shadowfunc::diceFloat(10, $randomness) * 0.01;
# Dice!
$minlevel = round($level - $level * $randomness, 1);
$maxlevel = $level;
$level = Shadowfunc::diceFloat($minlevel, $maxlevel, 1);
$potion = SR_Item::createByName('AlchemicPotion');
$potion->addModifiers(array($spellname => $level, 'magic' => $player->getBase('magic'), 'intelligence' => $player->getBase('intelligence'), 'wisdom' => $player->getBase('wisdom')));
return $potion;
}
示例13: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
$lev = $this->getLevel($player);
$int = $potion_player->get('intelligence');
$wis = $potion_player->get('wisdom');
$min = 0.5;
$min += $level * 0.2;
$min += $wis * 0.2;
$min += $int * 0.1;
$min += $hits * 0.1;
$max = $min * 2;
$metres = Shadowfunc::diceFloat($min, $max, 2);
$ep = $target->getParty();
$ep->movePlayer($target, false, $metres);
$this->announceADV($player, $target, $level, '10020', $metres, $target->getY());
// $append = sprintf('%s got blown away %s metres and is now on position %s.', $target->getName(), $metres, $target->getY());
// $this->announceADV($player, $target, $level, $append);
return true;
}
示例14: cast
public function cast(SR_Player $player, SR_Player $target, $level, $hits, SR_Player $potion_player)
{
echo "Casting Fireball with level {$level} and {$hits} hits.\n";
$this->announceADV($player, $target, $level);
# Firebolt ads 0.20 per level
$firebolt = $potion_player->getSpell('firebolt');
$firebolt = $firebolt === false ? 0 : $firebolt->getLevel($potion_player);
$firebolt = round($firebolt / 5, 1);
$level += $firebolt;
# Inaccuracy
$inaccuracy = Common::clamp(4 - $level * 0.15, 1);
$targets = SR_Grenade::computeDistances($target, $inaccuracy);
$p = $player->getParty();
$ep = $p->getEnemyParty();
$damage = array();
foreach ($targets as $data) {
list($pid, $d) = $data;
$target = $ep->getMemberByPID($pid);
$d = Common::clamp($d, 1);
$hits = $this->dice($potion_player, $target, $level);
# Dice hits
echo "!! Fireball hits={$hits}, Distance={$d}\n";
// $hits /= 2; # We take half..
// $hits /= ($d * 5); # And divide by distance
// $hits = round($hits, 1);
// echo " Fireball hits=$hits\n";
$min = 1.0 + $level * 0.5;
# Min damage is quite low
$max = $min + $level + $hits * 0.5;
# The max damage is min + hits
$dmg = Shadowfunc::diceFloat($min, $max);
$dmg /= $d / SR_Party::X_COORD_INC * 1.4;
# Apply area reduction
$dmg = round($dmg, 1);
// $player->message(sprintf("You have hit %s with %d hits, your damage is %.02f-%.02f, Distance from impact: %.02fm", $target->getName(), $hits, $min, $max, $d));
$damage[$pid] = $dmg;
}
$this->spellDamageMultiTargets($player, $damage, $level);
return true;
}
示例15: computeDistances
/**
* Compute the distances to an explosion.
* Imagaine the game like this
* A
* B E
* F
* CD
* ---0m---
* @param SR_Player $target
* @param unknown_type $radius
* @param unknown_type $atk
* @param unknown_type $atk_delta
*/
public static function computeDistances(SR_Player $target, $inaccuracy = 3)
{
$party = $target->getParty();
$members = $party->getMembers();
$coords = array();
foreach ($members as $m) {
$m instanceof SR_Player;
$coords[$m->getID()] = array($m->getX(), $m->getY());
}
# Point of impact.
$g_x = $coords[$target->getID()][0] + Shadowfunc::diceFloat(-$inaccuracy, +$inaccuracy);
$g_y = $coords[$target->getID()][1] + Shadowfunc::diceFloat(-$inaccuracy, +$inaccuracy);
// echo sprintf("Grenade has coords %.02f / %.02f\n", $g_x, $g_y);
$back = array();
foreach ($coords as $uid => $data) {
list($p_x, $p_y) = $data;
$d = Shadowfunc::calcDistanceB($g_x, $g_y, $p_x, $p_y);
$p = Shadowrun4::getPlayerByPID($uid);
$back[] = array($uid, $d);
// echo sprintf("%s has coords %.02f / %.02f (distance: %.02f)\n", $p->getName(), $p_x, $p_y, $d);
}
return $back;
}