Skip to content

Commit

Permalink
Merge pull request #1952 from potsmugen/august
Browse files Browse the repository at this point in the history
feat: expanded AttackMulSet, fixes, refactoring
  • Loading branch information
K4thos authored Aug 19, 2024
2 parents 78e2c10 + 89540fc commit 57735f5
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 109 deletions.
1 change: 1 addition & 0 deletions data/dizzy.zss
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ if !const(Default.Enable.Dizzy) || isHelper || teamSide = 0 {
dizzyPointsSet{value: dizzyPointsMax}
dizzySet{value: 0}
}
assertSpecial{flag: noDizzyPointsDamage}
}

# Set dizzy flag
Expand Down
36 changes: 24 additions & 12 deletions src/bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ func (be BytecodeExp) run_ex(c *Char, i *int, oc *Char) {
case OC_ex_animlength:
sys.bcStack.PushI(c.anim.totaltime)
case OC_ex_attack:
sys.bcStack.PushF(c.attackMul * 100)
sys.bcStack.PushF(c.attackMul[0] * 100)
case OC_ex_inputtime_B:
if c.keyctrl[0] && c.cmd != nil {
sys.bcStack.PushI(c.cmd[0].Buffer.Bb)
Expand Down Expand Up @@ -4123,7 +4123,7 @@ func (sc helper) Run(c *Char, _ []int32) bool {
case 1:
h.player = true
case 2:
h.hprojectile = true
h.hprojectile = true // Currently unused
}
case helper_name:
h.name = string(*(*[]byte)(unsafe.Pointer(&exp[0])))
Expand Down Expand Up @@ -4602,9 +4602,9 @@ const (
explod_pausemovetime
explod_sprpriority
explod_layerno
explod_under
explod_ontop
explod_strictontop
explod_under
explod_shadow
explod_removeongethit
explod_removeonchangestate
Expand Down Expand Up @@ -4669,7 +4669,6 @@ func (sc explod) Run(c *Char, _ []int32) bool {
if c.stWgi().mugenver[0] == 1 && c.stWgi().mugenver[1] == 1 {
e.postype = PT_None
}
e.layerno = crun.layerNo // Default
}
switch id {
case explod_anim:
Expand Down Expand Up @@ -4773,10 +4772,7 @@ func (sc explod) Run(c *Char, _ []int32) bool {
e.sprpriority = 0
}
case explod_under:
if exp[0].evalB(c) {
e.layerno = 0
e.sprpriority = math.MinInt32
}
e.under = exp[0].evalB(c)
case explod_shadow:
e.shadow[0] = exp[0].evalI(c)
if len(exp) > 1 {
Expand Down Expand Up @@ -5171,8 +5167,7 @@ func (sc modifyExplod) Run(c *Char, _ []int32) bool {
case explod_under:
if exp[0].evalB(c) {
eachExpl(func(e *Explod) {
e.layerno = 0
e.sprpriority = math.MinInt32
e.under = exp[0].evalB(c)
})
}
case explod_shadow:
Expand Down Expand Up @@ -6071,7 +6066,6 @@ func (sc projectile) Run(c *Char, _ []int32) bool {
}
p.hitdef.playerNo = sys.workingState.playerNo
}
p.layerno = crun.layerNo // Default
}
switch id {
case projectile_postype:
Expand Down Expand Up @@ -8337,15 +8331,32 @@ type attackMulSet StateControllerBase

const (
attackMulSet_value byte = iota
attackMulSet_damage
attackMulSet_redlife
attackMulSet_dizzypoints
attackMulSet_guardpoints
attackMulSet_redirectid
)

func (sc attackMulSet) Run(c *Char, _ []int32) bool {
crun := c
base := float32(crun.gi().data.attack) * crun.ocd().attackRatio / 100
StateControllerBase(sc).run(c, func(id byte, exp []BytecodeExp) bool {
switch id {
case attackMulSet_value:
crun.attackMul = float32(crun.gi().data.attack) * crun.ocd().attackRatio / 100 * exp[0].evalF(c)
v := exp[0].evalF(c)
crun.attackMul[0] = v * base
crun.attackMul[1] = v * base
crun.attackMul[2] = v * base
crun.attackMul[3] = v * base
case attackMulSet_damage:
crun.attackMul[0] = exp[0].evalF(c) * base
case attackMulSet_redlife:
crun.attackMul[1] = exp[0].evalF(c) * base
case attackMulSet_dizzypoints:
crun.attackMul[2] = exp[0].evalF(c) * base
case attackMulSet_guardpoints:
crun.attackMul[3] = exp[0].evalF(c) * base
case attackMulSet_redirectid:
if rid := sys.playerID(exp[0].evalI(c)); rid != nil {
crun = rid
Expand Down Expand Up @@ -10932,6 +10943,7 @@ const (
modifyChar_redirectid
)

// TODO: Undo all effects if a cached character is loaded
func (sc modifyChar) Run(c *Char, _ []int32) bool {
crun := c
StateControllerBase(sc).run(c, func(id byte, exp []BytecodeExp) bool {
Expand Down
Loading

0 comments on commit 57735f5

Please sign in to comment.