Go で書き直した Ikemen
リビジョン | 5cc1500ce3e29246a309400d79ba09fbea43cd91 (tree) |
---|---|
日時 | 2019-06-16 10:11:54 |
作者 | neatunsou <sisiy4excite@gmai...> |
コミッター | neatunsou |
Stagefrontedge、Stagebackedgeを追加
Projectileにprojangleを追加
targetにbindしたフレーム中にDestroyselfをするとbind先を5050に戻す仕様を無効にした
BindToTargetのlocalcoord対応を修正
Projectileに足場を作るためのplatform機能を追加。まだ作りかけなので使用非推奨
@@ -361,6 +361,9 @@ const ( | ||
361 | 361 | OC_ex_drawpalno |
362 | 362 | OC_ex_maparray |
363 | 363 | OC_ex_selfstatenoexist |
364 | + OC_ex_groundangle | |
365 | + OC_ex_stagefrontedge | |
366 | + OC_ex_stagebackedge | |
364 | 367 | OC_ex_gethitvar_animtype |
365 | 368 | OC_ex_gethitvar_airtype |
366 | 369 | OC_ex_gethitvar_groundtype |
@@ -1082,7 +1085,7 @@ func (be BytecodeExp) run(c *Char) BytecodeValue { | ||
1082 | 1085 | case OC_pos_x: |
1083 | 1086 | sys.bcStack.PushF((c.pos[0]*c.localscl/oc.localscl - sys.cam.Pos[0]/oc.localscl)) |
1084 | 1087 | case OC_pos_y: |
1085 | - sys.bcStack.PushF(c.pos[1] * c.localscl / oc.localscl) | |
1088 | + sys.bcStack.PushF((c.pos[1] - c.platformPosY) * c.localscl / oc.localscl) | |
1086 | 1089 | case OC_power: |
1087 | 1090 | sys.bcStack.PushI(c.getPower()) |
1088 | 1091 | case OC_powermax: |
@@ -1564,6 +1567,12 @@ func (be BytecodeExp) run_ex(c *Char, i *int, oc *Char) { | ||
1564 | 1567 | *i += 4 |
1565 | 1568 | case OC_ex_selfstatenoexist: |
1566 | 1569 | *sys.bcStack.Top() = c.selfStatenoExist(*sys.bcStack.Top()) |
1570 | + case OC_ex_groundangle: | |
1571 | + sys.bcStack.PushF(c.groundAngle) | |
1572 | + case OC_ex_stagefrontedge: | |
1573 | + sys.bcStack.PushF(c.stageFrontEdge()) | |
1574 | + case OC_ex_stagebackedge: | |
1575 | + sys.bcStack.PushF(c.stageBackEdge()) | |
1567 | 1576 | default: |
1568 | 1577 | sys.errLog.Printf("%v\n", be[*i-1]) |
1569 | 1578 | c.panic() |
@@ -2820,7 +2829,7 @@ func (sc posSet) Run(c *Char, _ []int32) bool { | ||
2820 | 2829 | case posSet_x: |
2821 | 2830 | crun.setX(sys.cam.Pos[0]/crun.localscl + exp[0].evalF(c)*lclscround) |
2822 | 2831 | case posSet_y: |
2823 | - crun.setY(exp[0].evalF(c) * lclscround) | |
2832 | + crun.setY(exp[0].evalF(c)*lclscround + crun.platformPosY) | |
2824 | 2833 | case posSet_z: |
2825 | 2834 | exp[0].run(c) |
2826 | 2835 | case posSet_redirectid: |
@@ -3593,6 +3602,7 @@ const ( | ||
3593 | 3602 | projectile_remvelocity |
3594 | 3603 | projectile_accel |
3595 | 3604 | projectile_projscale |
3605 | + projectile_projangle | |
3596 | 3606 | projectile_offset |
3597 | 3607 | projectile_projsprpriority |
3598 | 3608 | projectile_projstagebound |
@@ -3603,6 +3613,11 @@ const ( | ||
3603 | 3613 | projectile_pausemovetime |
3604 | 3614 | projectile_ownpal |
3605 | 3615 | projectile_remappal |
3616 | + projectile_platform | |
3617 | + projectile_platformwidth | |
3618 | + projectile_platformheight | |
3619 | + projectile_platformfence | |
3620 | + projectile_platformangle | |
3606 | 3621 | projectile_redirectid |
3607 | 3622 | ) |
3608 | 3623 |
@@ -3691,6 +3706,8 @@ func (sc projectile) Run(c *Char, _ []int32) bool { | ||
3691 | 3706 | if len(exp) > 1 { |
3692 | 3707 | p.scale[1] = exp[1].evalF(c) |
3693 | 3708 | } |
3709 | + case projectile_projangle: | |
3710 | + p.angle = exp[0].evalF(c) | |
3694 | 3711 | case projectile_offset: |
3695 | 3712 | x = exp[0].evalF(c) * lclscround |
3696 | 3713 | if len(exp) > 1 { |
@@ -3720,6 +3737,22 @@ func (sc projectile) Run(c *Char, _ []int32) bool { | ||
3720 | 3737 | if len(exp) > 1 { |
3721 | 3738 | rp[1] = exp[1].evalI(c) |
3722 | 3739 | } |
3740 | + case projectile_platform: | |
3741 | + p.platform = exp[0].evalB(c) | |
3742 | + case projectile_platformwidth: | |
3743 | + p.platformWidth[0] = exp[0].evalF(c) * lclscround | |
3744 | + if len(exp) > 1 { | |
3745 | + p.platformWidth[1] = exp[1].evalF(c) * lclscround | |
3746 | + } | |
3747 | + case projectile_platformheight: | |
3748 | + p.platformHeight[0] = exp[0].evalF(c) * lclscround | |
3749 | + if len(exp) > 1 { | |
3750 | + p.platformHeight[1] = exp[1].evalF(c) * lclscround | |
3751 | + } | |
3752 | + case projectile_platformangle: | |
3753 | + p.platformAngle = exp[0].evalF(c) | |
3754 | + case projectile_platformfence: | |
3755 | + p.platformFence = exp[0].evalB(c) | |
3723 | 3756 | default: |
3724 | 3757 | if !hitDef(sc).runSub(c, &p.hitdef, id, exp) { |
3725 | 3758 | afterImage(sc).runSub(c, &p.aimg, id, exp) |
@@ -1077,6 +1077,7 @@ type Projectile struct { | ||
1077 | 1077 | remanim int32 |
1078 | 1078 | cancelanim int32 |
1079 | 1079 | scale [2]float32 |
1080 | + angle float32 | |
1080 | 1081 | clsnScale [2]float32 |
1081 | 1082 | remove bool |
1082 | 1083 | removetime int32 |
@@ -1106,6 +1107,11 @@ type Projectile struct { | ||
1106 | 1107 | palfx *PalFX |
1107 | 1108 | localscl float32 |
1108 | 1109 | parentAttackmul float32 |
1110 | + platform bool | |
1111 | + platformWidth [2]float32 | |
1112 | + platformHeight [2]float32 | |
1113 | + platformAngle float32 | |
1114 | + platformFence bool | |
1109 | 1115 | } |
1110 | 1116 | |
1111 | 1117 | func newProjectile() *Projectile { |
@@ -1118,7 +1124,7 @@ func (p *Projectile) clear() { | ||
1118 | 1124 | scale: [...]float32{1, 1}, clsnScale: [...]float32{1, 1}, remove: true, localscl: 1, |
1119 | 1125 | removetime: -1, velmul: [...]float32{1, 1}, hits: 1, priority: 1, |
1120 | 1126 | prioritypoint: 1, sprpriority: 3, edgebound: 40, stagebound: 40, |
1121 | - heightbound: [...]int32{-240, 1}, facing: 1, aimg: *newAfterImage()} | |
1127 | + heightbound: [...]int32{-240, 1}, facing: 1, aimg: *newAfterImage(), platformFence: true} | |
1122 | 1128 | p.hitdef.clear() |
1123 | 1129 | } |
1124 | 1130 | func (p *Projectile) setPos(pos [2]float32) { |
@@ -1321,7 +1327,7 @@ func (p *Projectile) cueDraw(oldVer bool, playerNo int) { | ||
1321 | 1327 | if p.ani != nil { |
1322 | 1328 | sd := &SprData{p.ani, p.palfx, [...]float32{p.pos[0] * p.localscl, p.pos[1] * p.localscl}, |
1323 | 1329 | [...]float32{p.facing * p.scale[0] * p.localscl, p.scale[1] * p.localscl}, [2]int32{-1}, |
1324 | - p.sprpriority, 0, 0, 0, [...]float32{1, 1}, false, playerNo == sys.superplayer, | |
1330 | + p.sprpriority, p.facing * p.angle, 0, 0, [...]float32{1, 1}, false, playerNo == sys.superplayer, | |
1325 | 1331 | sys.cgi[playerNo].ver[0] != 1, p.facing} |
1326 | 1332 | p.aimg.recAndCue(sd, sys.tickNextFrame() && notpause) |
1327 | 1333 | sys.sprites.add(sd, |
@@ -1502,6 +1508,8 @@ type Char struct { | ||
1502 | 1508 | cpucmd int32 |
1503 | 1509 | attackDist float32 |
1504 | 1510 | offset [2]float32 |
1511 | + platformPosY float32 | |
1512 | + groundAngle float32 | |
1505 | 1513 | stchtmp bool |
1506 | 1514 | inguarddist bool |
1507 | 1515 | pushed bool |
@@ -2581,6 +2589,18 @@ func (c *Char) selfStatenoExist(stateno BytecodeValue) BytecodeValue { | ||
2581 | 2589 | _, ok := c.gi().states[stateno.ToI()] |
2582 | 2590 | return BytecodeBool(ok) |
2583 | 2591 | } |
2592 | +func (c *Char) stageFrontEdge() float32 { | |
2593 | + if c.facing > 0 { | |
2594 | + return sys.cam.XMax/c.localscl - c.pos[0] | |
2595 | + } | |
2596 | + return c.pos[0] - sys.cam.XMin/c.localscl | |
2597 | +} | |
2598 | +func (c *Char) stageBackEdge() float32 { | |
2599 | + if c.facing < 0 { | |
2600 | + return sys.cam.XMax/c.localscl - c.pos[0] | |
2601 | + } | |
2602 | + return c.pos[0] - sys.cam.XMin/c.localscl | |
2603 | +} | |
2584 | 2604 | func (c *Char) time() int32 { |
2585 | 2605 | return c.ss.time |
2586 | 2606 | } |
@@ -3425,17 +3445,17 @@ func (c *Char) bindToTarget(tar []int32, time int32, x, y float32, hmf HMF) { | ||
3425 | 3445 | if t := sys.playerID(tar[0]); t != nil { |
3426 | 3446 | switch hmf { |
3427 | 3447 | case HMF_M: |
3428 | - x += float32(t.size.mid.pos[0]) | |
3429 | - y += float32(t.size.mid.pos[1]) | |
3448 | + x += t.size.mid.pos[0] * (320 / float32(t.localcoord)) / c.localscl | |
3449 | + y += t.size.mid.pos[1] * (320 / float32(t.localcoord)) / c.localscl | |
3430 | 3450 | case HMF_H: |
3431 | - x += float32(t.size.head.pos[0]) | |
3432 | - y += float32(t.size.head.pos[1]) | |
3451 | + x += t.size.head.pos[0] * (320 / float32(t.localcoord)) / c.localscl | |
3452 | + y += t.size.head.pos[1] * (320 / float32(t.localcoord)) / c.localscl | |
3433 | 3453 | } |
3434 | 3454 | if !math.IsNaN(float64(x)) { |
3435 | - c.setX(t.pos[0] + t.facing*x) | |
3455 | + c.setX(t.pos[0]*t.localscl/c.localscl + t.facing*x) | |
3436 | 3456 | } |
3437 | 3457 | if !math.IsNaN(float64(y)) { |
3438 | - c.setY(t.pos[1] + y) | |
3458 | + c.setY(t.pos[1]*t.localscl/c.localscl + y) | |
3439 | 3459 | } |
3440 | 3460 | c.targetBind(tar[:1], time, c.facing*c.distX(t, c), (t.pos[1]*t.localscl/c.localscl)-(c.pos[1]*c.localscl/t.localscl)) |
3441 | 3461 | } |
@@ -3946,7 +3966,7 @@ func (c *Char) bind() { | ||
3946 | 3966 | if bt := sys.playerID(c.bindToId); bt != nil { |
3947 | 3967 | if bt.hasTarget(c.id) { |
3948 | 3968 | if bt.sf(CSF_destroy) { |
3949 | - c.selfState(5050, -1, -1, -1) | |
3969 | + //c.selfState(5050, -1, -1, -1) | |
3950 | 3970 | c.setBindTime(0) |
3951 | 3971 | return |
3952 | 3972 | } |
@@ -3998,6 +4018,18 @@ func (c *Char) xScreenBound() { | ||
3998 | 4018 | x = MaxF(sys.stage.leftbound/c.localscl, MinF(sys.stage.rightbound/c.localscl, x)) |
3999 | 4019 | c.setPosX(x) |
4000 | 4020 | } |
4021 | +func (c *Char) xPlatformBound(pxmin, pxmax float32) { | |
4022 | + x := c.pos[0] | |
4023 | + if c.ss.stateType != ST_A { | |
4024 | + min, max := c.getEdge(c.edge[0], true), -c.getEdge(c.edge[1], true) | |
4025 | + if c.facing > 0 { | |
4026 | + min, max = -max, -min | |
4027 | + } | |
4028 | + x = MaxF(min+pxmin/c.localscl, MinF(max+pxmax/c.localscl, x)) | |
4029 | + } | |
4030 | + c.setX(x) | |
4031 | + c.xScreenBound() | |
4032 | +} | |
4001 | 4033 | func (c *Char) gethitBindClear() { |
4002 | 4034 | if c.isBound() { |
4003 | 4035 | c.setBindTime(0) |
@@ -4338,7 +4370,7 @@ func (c *Char) action() { | ||
4338 | 4370 | } |
4339 | 4371 | for { |
4340 | 4372 | c.posUpdate() |
4341 | - if c.ss.physics != ST_A || c.vel[1] <= 0 || c.pos[1] < 0 || | |
4373 | + if c.ss.physics != ST_A || c.vel[1] <= 0 || (c.pos[1]-c.platformPosY) < 0 || | |
4342 | 4374 | c.ss.no == 105 { |
4343 | 4375 | break |
4344 | 4376 | } |
@@ -4432,6 +4464,8 @@ func (c *Char) update(cvmin, cvmax, | ||
4432 | 4464 | c.scf(SCF_ko) && c.scf(SCF_over) { |
4433 | 4465 | c.exitTarget(true) |
4434 | 4466 | } |
4467 | + c.platformPosY = 0 | |
4468 | + c.groundAngle = 0 | |
4435 | 4469 | c.atktmp = int8(Btoi((c.ss.moveType != MT_I || |
4436 | 4470 | c.hitdef.reversal_attr > 0) && !c.hitPause())) |
4437 | 4471 | c.hoIdx = -1 |
@@ -5320,7 +5354,7 @@ func (cl *CharList) clsn(getter *Char, proj bool) { | ||
5320 | 5354 | } |
5321 | 5355 | if proj { |
5322 | 5356 | for i, pr := range sys.projs { |
5323 | - if i == getter.playerNo && getter.helperIndex == 0 || len(sys.projs[i]) == 0 { | |
5357 | + if len(sys.projs[i]) == 0 { | |
5324 | 5358 | continue |
5325 | 5359 | } |
5326 | 5360 | c := sys.chars[i][0] |
@@ -5328,14 +5362,47 @@ func (cl *CharList) clsn(getter *Char, proj bool) { | ||
5328 | 5362 | c.atktmp = -1 |
5329 | 5363 | for j := range pr { |
5330 | 5364 | p := &pr[j] |
5331 | - if p.id < 0 || p.hits < 0 || p.hitdef.affectteam != 0 && | |
5365 | + if (i == getter.playerNo && getter.helperIndex == 0 && p.platform == false) || | |
5366 | + p.id < 0 || p.hits < 0 || p.hitdef.affectteam != 0 && | |
5332 | 5367 | (getter.teamside != p.hitdef.teamside-1) != (p.hitdef.affectteam > 0) { |
5333 | 5368 | continue |
5334 | 5369 | } |
5335 | - if dist := (getter.pos[0]*getter.localscl - p.pos[0]*p.localscl) * p.facing; dist >= 0 && | |
5336 | - dist <= float32(c.size.proj.attack.dist)*c.localscl { | |
5370 | + dist := (getter.pos[0]*getter.localscl - (p.pos[0])*p.localscl) * p.facing | |
5371 | + if p.platform == false && | |
5372 | + dist >= 0 && dist <= float32(c.size.proj.attack.dist)*c.localscl { | |
5337 | 5373 | getter.inguarddist = true |
5338 | 5374 | } |
5375 | + if p.platform == true { | |
5376 | + //Platformの足場上空判定 | |
5377 | + if getter.pos[1]*getter.localscl-getter.vel[1]*getter.localscl <= (p.pos[1]+p.platformHeight[1])*p.localscl && | |
5378 | + getter.platformPosY*getter.localscl >= (p.pos[1]+p.platformHeight[0])*p.localscl { | |
5379 | + angleSinValue := float32(math.Sin(float64(p.platformAngle) / 180 * math.Pi)) | |
5380 | + angleCosValue := float32(math.Cos(float64(p.platformAngle) / 180 * math.Pi)) | |
5381 | + oldDist := (getter.oldPos[0]*getter.localscl - (p.pos[0])*p.localscl) * p.facing | |
5382 | + onPlatform := func(protrude bool) { | |
5383 | + getter.platformPosY = ((p.pos[1]+p.platformHeight[0]+p.velocity[1])*p.localscl - angleSinValue*(oldDist/angleCosValue)) / getter.localscl | |
5384 | + getter.groundAngle = p.platformAngle | |
5385 | + //足場に乗っている状態 | |
5386 | + if getter.ss.stateType != ST_A { | |
5387 | + getter.pos[0] += p.velocity[0] * p.facing * p.localscl / getter.localscl | |
5388 | + getter.pos[1] += p.velocity[1] * p.localscl / getter.localscl | |
5389 | + if protrude { | |
5390 | + if p.facing > 0 { | |
5391 | + getter.xPlatformBound((p.pos[0]+p.velocity[0]*2*p.facing+p.platformWidth[0]*angleCosValue*p.facing)*p.localscl, (p.pos[0]-p.velocity[0]*2*p.facing+p.platformWidth[1]*angleCosValue*p.facing)*p.localscl) | |
5392 | + } else { | |
5393 | + getter.xPlatformBound((p.pos[0]-p.velocity[0]*2*p.facing+p.platformWidth[1]*angleCosValue*p.facing)*p.localscl, (p.pos[0]+p.velocity[0]*2*p.facing+p.platformWidth[0]*angleCosValue*p.facing)*p.localscl) | |
5394 | + } | |
5395 | + } | |
5396 | + } | |
5397 | + } | |
5398 | + if dist >= (p.platformWidth[0]*angleCosValue)*p.localscl && dist <= (p.platformWidth[1]*angleCosValue)*p.localscl { | |
5399 | + onPlatform(false) | |
5400 | + } else if p.platformFence && oldDist >= (p.platformWidth[0]*angleCosValue)*p.localscl && | |
5401 | + oldDist <= (p.platformWidth[1]*angleCosValue)*p.localscl { | |
5402 | + onPlatform(true) | |
5403 | + } | |
5404 | + } | |
5405 | + } | |
5339 | 5406 | if p.hits == 0 { |
5340 | 5407 | continue |
5341 | 5408 | } |
@@ -2041,6 +2041,12 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string, | ||
2041 | 2041 | return bvNone(), err |
2042 | 2042 | } |
2043 | 2043 | out.append(OC_ex_, OC_ex_selfstatenoexist) |
2044 | + case "groundangle": | |
2045 | + out.append(OC_ex_, OC_ex_groundangle) | |
2046 | + case "stagefrontedge": | |
2047 | + out.append(OC_ex_, OC_ex_stagefrontedge) | |
2048 | + case "stagebackedge": | |
2049 | + out.append(OC_ex_, OC_ex_stagebackedge) | |
2044 | 2050 | case "=", "!=", ">", ">=", "<", "<=", "&", "&&", "^", "^^", "|", "||", |
2045 | 2051 | "+", "*", "**", "/", "%": |
2046 | 2052 | if !sys.ignoreMostErrors || len(c.maeOp) > 0 { |
@@ -4589,6 +4595,10 @@ func (c *Compiler) projectile(is IniSection, sc *StateControllerBase, | ||
4589 | 4595 | projectile_projscale, VT_Float, 2, false); err != nil { |
4590 | 4596 | return err |
4591 | 4597 | } |
4598 | + if err := c.paramValue(is, sc, "projangle", | |
4599 | + projectile_projangle, VT_Float, 1, false); err != nil { | |
4600 | + return err | |
4601 | + } | |
4592 | 4602 | |
4593 | 4603 | // hitdef部分 |
4594 | 4604 | if err := c.hitDefSub(is, sc); err != nil { |
@@ -4638,6 +4648,26 @@ func (c *Compiler) projectile(is IniSection, sc *StateControllerBase, | ||
4638 | 4648 | if err := c.afterImageSub(is, sc, "afterimage."); err != nil { |
4639 | 4649 | return err |
4640 | 4650 | } |
4651 | + if err := c.paramValue(is, sc, "platform", | |
4652 | + projectile_platform, VT_Bool, 1, false); err != nil { | |
4653 | + return err | |
4654 | + } | |
4655 | + if err := c.paramValue(is, sc, "platformwidth", | |
4656 | + projectile_platformwidth, VT_Float, 2, false); err != nil { | |
4657 | + return err | |
4658 | + } | |
4659 | + if err := c.paramValue(is, sc, "platformheight", | |
4660 | + projectile_platformheight, VT_Float, 2, false); err != nil { | |
4661 | + return err | |
4662 | + } | |
4663 | + if err := c.paramValue(is, sc, "platformangle", | |
4664 | + projectile_platformangle, VT_Float, 1, false); err != nil { | |
4665 | + return err | |
4666 | + } | |
4667 | + if err := c.paramValue(is, sc, "platformfence", | |
4668 | + projectile_platformfence, VT_Bool, 1, false); err != nil { | |
4669 | + return err | |
4670 | + } | |
4641 | 4671 | return nil |
4642 | 4672 | }) |
4643 | 4673 | return *ret, err |