Skip to content

Commit 4fdaac7

Browse files
committed
Update ProceduralEffect
1 parent f267073 commit 4fdaac7

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ Additions:
6666
* PlayerHUD:
6767
- GetIndex
6868
- GetLayout
69+
* ProceduralEffect
70+
- Fix fartScale.
71+
- GetScore
72+
- GetTriggerChanceScale
6973
* Room:
7074
- TriggerOutput(RoomEventOutput GroupIdx)
7175
* RoomConfig:

docs/docs/ProceduralEffect.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,20 @@ ___
8383
#### [ProceduralEffectConditionType](enums/ProceduralEffectConditionType.md) GetConditionType ( ) {: .copyable aria-label='Functions' }
8484
Returns the timing when the effect was triggered.
8585

86+
___
87+
### GetScore () {: aria-label='Functions' }
88+
#### float GetScore ( ) {: .copyable aria-label='Functions' }
89+
90+
The score is used to generate the `ProceduralItem`. Each `ProceduralItem` has a score limit when generating its effects. If the limit is reached, no more effect will be added.
8691
___
8792
### GetTriggerChance () {: aria-label='Functions' }
8893
#### float GetTriggerChance ( ) {: .copyable aria-label='Functions' }
8994

90-
Values range from `0` to `1`.
95+
This is the actual change that the game actually uses. In most cases, this value ranges from `0` to `1`. This is the value that the result of `GetTriggerChanceScale` has been applied.
96+
97+
___
98+
### GetTriggerChanceScale () {: aria-label='Functions' }
99+
#### float GetTriggerChanceScale ( ) {: .copyable aria-label='Functions' }
100+
101+
In most cases, this value should be `1`.
91102
___

libzhl/functions/ProceduralEffect.zhl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ struct ProceduralEffect depends (
8383
}}
8484
int effectConditionType : 0x0;
8585
int effectActionType : 0x4;
86-
float triggerChance : 0x30;
87-
} : 0x60;
86+
float triggerChanceScale : 0x30;
87+
float score : 0x60;
88+
} : 0x68;

repentogon/LuaInterfaces/ProcedualItems/LuaProceduralEffect.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ LUA_FUNCTION(Lua_PEGetActionProperty) {
6969
lua_setfield(L, -2, "flags2");
7070
break;
7171
case ProceduralEffect::ACTION_FART:
72-
lua_pushnumber(L, pi->GetActionData()->fart.fartScale);
72+
lua_pushnumber(L, pi->GetActionData()->fart.fartScale * 6);
7373
lua_setfield(L, -2, "scale");
7474
lua_pushnumber(L, pi->GetActionData()->fart.radius * 6.f / 85.f);
7575
lua_setfield(L, -2, "radius");
@@ -78,11 +78,10 @@ LUA_FUNCTION(Lua_PEGetActionProperty) {
7878
return 1;
7979
}
8080

81-
8281
LUA_FUNCTION(Lua_PEGetTriggerChance) {
8382
ProceduralEffect* pi = *lua::GetRawUserdata<ProceduralEffect**>(L, 1, lua::metatables::ProceduralEffectMT);
84-
float chance = pi->triggerChance;
85-
//manually fix the chance from 0 ~ 1 to the actual rate.
83+
float chance = pi->triggerChanceScale;
84+
/* Note: the chance is hard coded in the game program. */
8685
switch (pi->effectConditionType)
8786
{
8887
case ProceduralEffect::CONDITION_TEAR_FIRE:
@@ -100,13 +99,27 @@ LUA_FUNCTION(Lua_PEGetTriggerChance) {
10099
return 1;
101100
}
102101

102+
LUA_FUNCTION(Lua_PEGetTriggerChanceScale) {
103+
ProceduralEffect* pi = *lua::GetRawUserdata<ProceduralEffect**>(L, 1, lua::metatables::ProceduralEffectMT);
104+
lua_pushnumber(L, pi->triggerChanceScale);
105+
return 1;
106+
}
107+
108+
LUA_FUNCTION(Lua_PEGetScore) {
109+
ProceduralEffect* pi = *lua::GetRawUserdata<ProceduralEffect**>(L, 1, lua::metatables::ProceduralEffectMT);
110+
lua_pushnumber(L, pi->score);
111+
return 1;
112+
}
113+
103114
static void RegisterProceduralItem(lua_State* L) {
104115
luaL_Reg functions[] = {
105116
{"GetConditionType", Lua_PEGetConditionType},
106117
{"GetActionType", Lua_PEGetActionType},
107118
{"GetConditionProperty", Lua_PEGetConditionProperty},
108119
{"GetActionProperty", Lua_PEGetActionProperty},
109120
{"GetTriggerChance", Lua_PEGetTriggerChance},
121+
{"GetTriggerChanceScale", Lua_PEGetTriggerChanceScale},
122+
{"GetScore", Lua_PEGetScore},
110123
{ NULL, NULL }
111124
};
112125
lua::RegisterNewClass(L, lua::metatables::ProceduralEffectMT, lua::metatables::ProceduralEffectMT, functions);

0 commit comments

Comments
 (0)