Add Understanding Priem Execution Variables
parent
f5adaf40c4
commit
13643682c3
203
Understanding-Priem-Execution-Variables.md
Normal file
203
Understanding-Priem-Execution-Variables.md
Normal file
@ -0,0 +1,203 @@
|
||||
# Understanding Priem Execution Variables
|
||||
|
||||
## Overview
|
||||
|
||||
In the battle system, there are three key variables that control the execution flow of priems (techniques):
|
||||
|
||||
1. `$pr_momental_this`
|
||||
2. `$pr_tested_this`
|
||||
3. `$pr_used_this`
|
||||
|
||||
These variables are used to determine which code block in a priem file should be executed and to pass the user ID to the priem file.
|
||||
|
||||
## Detailed Explanation
|
||||
|
||||
### `$pr_momental_this`
|
||||
|
||||
**Purpose**: Used for immediate (momental) effects that modify damage calculations during an attack.
|
||||
|
||||
**When it's set**:
|
||||
- Set in the Battle.php file before requiring a priem file
|
||||
- Used in damage calculation methods
|
||||
- Set to either the attacker's or defender's ID depending on the context
|
||||
|
||||
**How it works**:
|
||||
- When set, the priem file executes the code block that defines the `$fx_moment` function
|
||||
- This function typically modifies damage values and applies immediate effects
|
||||
- Used for defensive priems that reduce incoming damage or offensive priems that enhance outgoing damage
|
||||
- The function returns the modified damage value
|
||||
|
||||
**Example from Priem1.php (Прикрыться/Cover)**:
|
||||
```php
|
||||
if (isset($pr_momental_this)) {
|
||||
$fx_moment = function ($uid, $enemy, $j_id, $yron, $profil) {
|
||||
if (!isset($btl->stats[$btl->uids[$uid]]['um_priem'][$j_id])) {
|
||||
global $u, $btl;
|
||||
$yron -= 3;
|
||||
$btl->priemAddLogFast($uid, 0, "" . $btl->stats[$btl->uids[$u2]]['effects'][$btl->stats[$btl->uids[$uid]]['u_priem'][$j_id][0]]['name'],
|
||||
'{tm1} ' . $btl->addlt(1, 17, $btl->users[$btl->uids[$uid]]['sex'], null),
|
||||
0, time());
|
||||
if ($yron < 0) {
|
||||
$yron = 1;
|
||||
}
|
||||
$btl->stats[$btl->uids[$uid]]['um_priem'][$j_id] = true;
|
||||
}
|
||||
return round($yron);
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### `$pr_tested_this`
|
||||
|
||||
**Purpose**: Used to test if a priem can be applied in the current battle context.
|
||||
|
||||
**When it's set**:
|
||||
- Set in the Battle.php file before requiring a priem file
|
||||
- Used in methods that check if priems can be applied
|
||||
- Set to the user ID that is being tested
|
||||
|
||||
**How it works**:
|
||||
- When set, the priem file executes the code block that defines the `$fx_priem` function for testing
|
||||
- This function typically checks conditions like mana availability, cooldowns, or specific battle states
|
||||
- Used to determine if a priem should be available for use
|
||||
- The function returns the modified attack array
|
||||
|
||||
**Example from Priem1.php (Прикрыться/Cover)**:
|
||||
```php
|
||||
elseif (isset($pr_tested_this)) {
|
||||
$fx_priem = function ($id, $at, $uid, $j_id) {
|
||||
// -- начало приема
|
||||
global $u, $btl;
|
||||
//
|
||||
//Параметры приема
|
||||
$pvr['used'] = 0;
|
||||
//
|
||||
$uid1 = $btl->atacks[$id]['uid1'];
|
||||
$uid2 = $btl->atacks[$id]['uid2'];
|
||||
if ($uid == $uid2) {
|
||||
$a = 1;
|
||||
$b = 2;
|
||||
$u1 = $uid1;
|
||||
$u2 = $uid2;
|
||||
} elseif ($uid == $uid1) {
|
||||
$a = 2;
|
||||
$b = 1;
|
||||
$u1 = $uid2;
|
||||
$u2 = $uid1;
|
||||
}
|
||||
if (isset($at['p'][$a]['priems']['kill'][$uid][$j_id])) {
|
||||
mysql_query('UPDATE `eff_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $btl->stats[$btl->uids[$uid]]['u_priem'][$j_id][3] . '" AND `uid` = "' . $uid . '" LIMIT 1');
|
||||
$btl->stats[$btl->uids[$uid]]['u_priem'][$j_id] = true;
|
||||
}
|
||||
//
|
||||
// -- конец приема
|
||||
return $at;
|
||||
};
|
||||
unset($pr_used_this);
|
||||
}
|
||||
```
|
||||
|
||||
### `$pr_used_this`
|
||||
|
||||
**Purpose**: Used to apply a priem's effects during battle.
|
||||
|
||||
**When it's set**:
|
||||
- Set in the Battle.php file before requiring a priem file
|
||||
- Used in methods that apply priem effects
|
||||
- Always set to the user ID that is executing the priem
|
||||
|
||||
**How it works**:
|
||||
- When set, the priem file executes the code block that defines the `$fx_priem` function for application
|
||||
- This function typically modifies the battle state, applies effects, and updates the attack array
|
||||
- Used to implement the actual effects of the priem
|
||||
- The function returns the modified attack array
|
||||
|
||||
**Example from Priem1.php (Прикрыться/Cover)**:
|
||||
```php
|
||||
elseif (isset($pr_used_this)) {
|
||||
$fx_priem = function ($id, $at, $uid, $j_id) {
|
||||
// -- начало приема
|
||||
global $u, $btl;
|
||||
//
|
||||
//Параметры приема
|
||||
$pvr['used'] = 0;
|
||||
//
|
||||
//echo '$user::['.$uid.']->("Прикрыться");';
|
||||
$uid1 = $btl->atacks[$id]['uid1'];
|
||||
$uid2 = $btl->atacks[$id]['uid2'];
|
||||
if ($uid == $uid2) {
|
||||
$a = 1;
|
||||
$b = 2;
|
||||
$u1 = $uid1;
|
||||
$u2 = $uid2;
|
||||
} elseif ($uid == $uid1) {
|
||||
$a = 2;
|
||||
$b = 1;
|
||||
$u1 = $uid2;
|
||||
$u2 = $uid1;
|
||||
}
|
||||
if ($a > 0) {
|
||||
$j = 0;
|
||||
$k = 0;
|
||||
$wp = 3;
|
||||
while ($j < count($at['p'][$a]['atack'])) {
|
||||
if (isset($at['p'][$a]['atack'][$j]['yron']) && (
|
||||
$at['p'][$a]['atack'][$j][1] == 1 ||
|
||||
$at['p'][$a]['atack'][$j][1] == 4 ||
|
||||
$at['p'][$a]['atack'][$j][1] == 5)) {
|
||||
if ($pvr['used'] = 0 && !isset($at['p'][$a]['priems']['kill'][$uid][$j_id])) {
|
||||
//
|
||||
$at['p'][$a]['atack'][$j]['yron']['y'] -= 3;
|
||||
$at['p'][$a]['atack'][$j]['yron']['r'] += 3;
|
||||
$at['p'][$a]['atack'][$j]['yron']['k'] -= 3;
|
||||
$at['p'][$a]['atack'][$j]['yron']['m_k'] -= 3;
|
||||
$at['p'][$a]['atack'][$j]['yron']['m_y'] -= 3;
|
||||
//
|
||||
$at['p'][$a]['atack'][$j]['yron']['plog'][] = '$this->deleffm(1,' . (0 + $uid) . ',' . $btl->stats[$btl->uids[$uid]]['u_priem'][$j_id][3] . ');
|
||||
$this->priemAddLog( ' . $id . ', ' . $b . ', ' . $a . ', ' . $u2 . ', ' . $u1 . ',
|
||||
"' . $btl->stats[$btl->uids[$u2]]['effects'][$btl->stats[$btl->uids[$uid]]['u_priem'][$j_id][0]]['name'] . '",
|
||||
"{tm1} ' . $btl->addlt($b, 17, $btl->users[$btl->uids[$u2]]['sex'], null) . '",
|
||||
' . ($btl->hodID + 1) . ' );';
|
||||
//
|
||||
$at['p'][$a]['atack'][$j]['yron']['used'][] = [$j_id, $uid, $pvr['used']];
|
||||
$at['p'][$a]['atack'][$j]['yron']['kill'][] = [$j_id, $uid, $pvr['kill']];
|
||||
//
|
||||
$at['p'][$a]['priems']['kill'][$uid][$j_id] = true;
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
}
|
||||
//
|
||||
// -- конец приема
|
||||
return $at;
|
||||
};
|
||||
unset($pr_used_this);
|
||||
}
|
||||
```
|
||||
|
||||
## Execution Flow
|
||||
|
||||
The execution flow of a priem typically follows these steps:
|
||||
|
||||
1. **Testing Phase**:
|
||||
- `$pr_tested_this` is set
|
||||
- The priem file is required
|
||||
- The `$fx_priem` function is called to test if the priem can be applied
|
||||
- This happens when checking available priems for a user
|
||||
|
||||
2. **Application Phase**:
|
||||
- `$pr_used_this` is set
|
||||
- The priem file is required
|
||||
- The `$fx_priem` function is called to apply the priem's effects
|
||||
- This happens when a user activates a priem
|
||||
|
||||
3. **Momental Phase**:
|
||||
- `$pr_momental_this` is set
|
||||
- The priem file is required
|
||||
- The `$fx_moment` function is called to modify damage calculations
|
||||
- This happens during damage calculation, after a priem has been applied
|
||||
|
||||
## Conclusion
|
||||
|
||||
These three variables form the core of the priem execution system, allowing for different behaviors depending on the context in which a priem is being used. This design pattern enables a single priem file to handle multiple aspects of a technique's functionality, from testing conditions to applying effects to modifying damage calculations.
|
Loading…
x
Reference in New Issue
Block a user