collapse

Author Topic: Projectile Reflection/Re-Reflection  (Read 3709 times)

0 Members and 1 Guest are viewing this topic.

Offline Space (DCL)

  • IMT Content Architect
  • *
  • Posts: 1166
  • Country: United States us
  • Last Login:November 01, 2024, 11:50:56 PM
  • If you see this, I'm alive!
Projectile Reflection/Re-Reflection
« on: September 13, 2023, 12:58:39 AM »
This is to add full reflection and special re-reflection to your character's projectiles. These projectiles MUST be made as Helpers!

First, paste the following Code to ALL your HELPER based Projectiles
This will include FULL compatability (Reflect and Re-Reflect)
This also includes compatability with Vans reflector chars.

The difference is, you will be using a dedicated (or shared) REFLECT stateno.
You will also use the following sysvars in your code!

Code: [Select]
;sysvar(0) ;Vans compatability
;sysvar(1) ;Reflected state behavior (Vans compatabilty)
;sysvar(2) ;Saved Stateno for Reflection/Re-reflection
;sysvar(4) ;Reflection Status (0 = Normal/Re-Reflected, 1 = Reflected)
 
;----------------------------------------
; Reflection Compatability
;----------------------------------------
[State VANS COMPATIBILITY]
type = VarSet
trigger1 = !time
sysvar(0) = 131072 ;VANS COMPATABILITY
 
[State VANS COMPATIBILITY REFLECTED STATE]
type = VarSet
trigger1 = !time
sysvar(1) = 821337 ;SHARED REFLECTED STATE, YOU CAN RENAME THIS IF NECESSARY
 
[State SaveState for Reflection]
type = VarSet
trigger1 = !time
sysvar(2) = StateNo ;Use the same Stateno as this Projectile
 
 
;NOTE 1, this State will be explained later.
[State Re-Reflect Compatibility]
type = ChangeState
triggerall = sysvar(4) = 1 ;In Reflected Status
triggerall = MoveContact = 1 ;On 1st Contact
trigger1 = root, numprojID(262144) ;Unique ProjID spawned (VANS)
trigger1 = NumHelper(821337) ;UNIQUE REFLECTOR HELPER
trigger2 = NumPartner ;Partner?
trigger2 = partner, numprojID(262144) ;Partner spawns Unique ProjID (VANS)
trigger2 = partner, NumHelper(821337) ;Partner has UNIQUE REFLECTOR
value = sysvar(1) ;Reflection/Re-Reflect State
ignorehitpause = 1 ;This must be 1
;-------------------------------------




Next, on your projectile's hitdefs, include the following line
Code: [Select]
;-------------------------------------
Triggerall = SysVar(4) = 0 ;Normal/Re-Reflected
;-------------------------------------

Now, copy/paste all your hitdefs, this will be your Reflected HitDefs. Change the
triggerall line to the following:
Code: [Select]
;-------------------------------------
Triggerall = SysVar(4) = 1 ;Reflected Status
;-------------------------------------


In these Reflected HitDefs, add the following parameters as well.
Code: [Select]
;-------------------------------------
;REFLECTION STATUS
guard.dist = 0 ;NO GUARDDIST FOR OPPONENT
affectteam = F ;ATTACK TEAM MATES
fall.kill = 0 ;RE-REFLECTOR GETHITVAR TRIGGER
;-------------------------------------

I use the Fall.Kill = 0 parameter as the trigger for Re-Reflecting
your own projectile back! This will eliminate using HitDef IDs from Vans's method.
Your projectiles will still be reflected by Vans method though.



IMPORTANT! FROM NOTE 1:
All your projectiles MUST have at least a Pausetime of 1 for the hit.
If you use Variables to detect the number of remaining hits with Ignorehitpause = 1, they will get affected and will give you unclear results. Adjust your projectiles accordingly, or if you find another method that can work, please feel free to do so! I couldn't find another way.

Code: [Select]
PauseTime = 1,#

Next, you must add the following Statedef to your character. This can be used as a common/shared state. The Statedef Number cna be whatever you like. As long as all your projectiles match this statedef number (sysvar(1)).

Code: [Select]
;-------------------------------------
; Projectile Reflection/Re-Reflect State
;-------------------------------------
[Statedef 821337]
type = U
movetype = I
physics = N
ctrl = 0
 
[State just in case]
type = SelfState
trigger1 = !ishelper
value = 5050
 
[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA
ignorehitpause = 1
 
[State 0, PosFreeze]
type = PosFreeze
trigger1 = 1
value = 1
ignorehitpause = 1
 
;sysvar(0) = 131072 ;Vans Compatability
;sysvar(1) = 821337 ;Vans compat (This Reflected State)
;sysvar(2) = MY_PROJ_STATEDEF ;Your projectile's saved stateno
 
[State Reflect Turn]
type = Turn ;Obligatory TURN
trigger1 = SysVar(0) = 131072 ;Compatible Projectile
trigger1 = SysVar(2) ;My Saved State exists
trigger1 = ishelper ;Im a Helper Proj
Persistent = 0
 
[State Set Reflection Status]        ;1 = Reflected, 0 = Normal/Re-Reflected
type = VarSet
trigger1 = SysVar(0) = 131072 ;Compatible Projectile
trigger1 = SysVar(2) ;Sysvar(2) is my saved stateno
sysvar(4) = ifelse(sysvar(4) = 1, 0, 1) ;Swap Reflection Status
Persistent = 0
 
[State SelfState MyMethod]
type = SelfState                         ; <- If SysVar(2) is saved and is non-zero
trigger1 = SysVar(0) = 131072      ; using my version of compatible projectiles
trigger1 = sysvar(2)                     ; SysVar(2) exists
value = sysvar(2)                        ; Sysvar(2) is the saved stateno
 
[State SelfState VANS Method]
type = SelfState
trigger1 = sysvar(0) = 131072    ;sysvar(2) doesnt exist in other states
trigger1 = !sysvar(2)                   ;VANS Method does not use sysvar(2)
trigger1 = sysvar(1) ;sysvar(1) is saved and is non-zero
value = sysvar(1) ;VANS state, other compatable projectiles
 
[State 0, RemoveExplod] ;Dont orphan Explods if any!!
type = RemoveExplod
trigger1 = sysvar(0) != 131072
trigger1 = time > 2
trigger1 = ishelper
 
[State DestroySelf] ;Not compatible?
type = DestroySelf ;Remove it
trigger1 = sysvar(0) != 131072
trigger1 = time > 2
trigger1 = ishelper
;-------------------------------------

Now, on your characters's Reflection States
I personally use a Helper as a Reflector, so I set
its SysVar(0) the following for more compatability.
If this sysvar resets to 0 due to an incompatible
projectile, then it will trigger sending a new
projectile from your character.

Code: [Select]
[State Reflector Compatability]
type = VarSet
trigger1 = !time
sysvar(0) = 262144
 
;Include the ReversalDef for projectiles
[State 0, ReversalDef] ;ReversalDef prioritized over HitOverride
type = ReversalDef
trigger1 = 1
reversal.attr = SCA,NP,SP
pausetime = 0,0
sparkno = -1
hitsound = -1
p1stateno = 100000 ;Your Reflectors next state
p2stateno = 821337 ;Send proj to reflected stateno (shared)
 
;Include the HitOverride for projectiles to be Re-Reflected
[State 0, HitOverride]
type = HitOverride
trigger1 = 1
attr = SCA, NP, SP
stateno = 100001 ;RE-REFLECT OVERRIDE, this will be different
ignorehitpause = 1 ;than the one in ReversalDef
;---------------------------------------------


Next, add what is necessary for the successful reflection state

Code: [Select]
;EXAMPLE REFLECTOR SUCCESS STATEDEF
[Statedef 100000]
movetype = A
ctrl = 0
anim = 9999 ;Blank Anim, use an animated one if needed
 
[State Obtain Target Projetcile ID if Compatible]
type = VarSet
triggerall = !Var(0)
trigger1 = numtarget
trigger1 = target, ishelper
var(0) = target, ID
ignorehitpause = 1
 
[State 0, Not Compatible? Send Your Own!]
type = VarSet
trigger1 = sysvar(0)
trigger1 = !playeridexist(var(0))
sysvar(0) = 0
 
[State Proximity Blocker, Attach to Reflected Projectile]
type = Helper
trigger1 = playeridexist(var(0))
name = "Proximity Blocker" ;Note 2, this Helper will be explained later!
ID = 821338 ;ID can be whatever you like
stateno = 821338 ;Statedef can also be whatever you like!
ownpal = 0 ;This helper is generated by your Reflector!
persistent = 0
......etc etc more code for your reflector!

Next is the Re-Reflect state for your Reflector. This will be triggered by HitOverride.
Code: [Select]
[Statedef 100001]
movetype = I
ctrl = 0
sprpriority = 2
anim = 9999 ;Blank anim
 
;FROM NOTE 1:
;Projetciles are always owned by the root. This is similar to Vans's method.
;The difference is using a different GetHitVar parameter, saving your HitDef IDs
;By default, Fall.Kill is always set to 1. Setting to 0 in the Reflected HitDefs
;will cause this Projectile to appear
;Note that the ID of this projectile is the sysvar(0) of your Reflector Helper (262144)
;WHen your projectile detects this, it gets sent to the Re-Reflect stateno.
[State Re-Reflection Projectile]
type = Projectile
trigger1 = gethitvar(fall.kill) = 0 ;Use Fall.Kill = 0 parameter in the
trigger1 = sysvar(0) ;Reflected Projectile's HitDef
ProjID = sysvar(0) ;to set this HitOverride's
projanim = 9999 ;GetHitVar(fall.kill) = 0
projremovetime = 1 ;Keeps the HitDef ID
ignorehitpause = 1 ;Use a blank anim for this Proj Sctrl
persistent = 0
 
[State Display]
type = DisplayToClipboard
trigger1 = 1
text = "check hitdef fall.kill = %d  Reflector NumProjID = %d"
params = gethitvar(fall.kill), root,numprojid(sysvar(0))
ignorehitpause = 1


FROM NOTE 2:
Now, add the Proximity Blocker helper.
This statedef (and its helper ID) can be whatever you like
as long as they are correct! This helper is made by the reflector helper.
Code: [Select]
;-------------------------------------
; Projectile Re-Reflect Proximity Blocker
; This helper is strictly for adding proximity
; blocking for the reflected projectile so
; the original owner of the projectile
; does not get stuck in an unblockable situation.
;-------------------------------------
[Statedef 821338]
movetype = A ;Movetype = A for Guard proximity
ctrl = 0
anim = 9741 ;invisible anim. use whatever
 
[State 0, Get Parent Target ID]
type = VarSet
trigger1 = parent, ishelper
trigger1 = parent, var(0)
var(0) = parent, var(0) ;Copy my reflector's target ID saved to a var
persistent = 0
ignorehitpause = 1
 
[State Add Compatability]
type = VarSet
trigger1 = playeridexist(var(0))
trigger1 = playerid(var(0)), sysvar(0) = 131072
sysvar(0) = playerid(var(0)), sysvar(0)
persistent = 0
ignorehitpause = 1
 
[State Add Compatability]
type = VarSet
trigger1 = playeridexist(var(0))
trigger1 = sysvar(0) = 131072
trigger1 = playerid(var(0)), sysvar(1)
sysvar(1) = playerid(var(0)), sysvar(1)
persistent = 0
ignorehitpause = 1
 
[State Add Compatability]
type = VarSet
trigger1 = playeridexist(var(0))
trigger1 = sysvar(0) = 131072
trigger1 = playerid(var(0)), sysvar(2)
sysvar(2) = playerid(var(0)), sysvar(2)
persistent = 0
ignorehitpause = 1
 
[State 0, PosSet] ;Attach to reflected projectile
type = PosSet
trigger1 = playeridexist(var(0))
x = playerid(var(0)),pos x
y = playerid(var(0)),pos y - 50 ;adjust pos if necessary
ignorehitpause = 1
 
[State 0, DestroySelf]
type = DestroySelf
trigger1 = !playeridexist(var(0)) || !sysvar(0)
trigger2 = playeridexist(var(0))
trigger2 = playerid(var(0)), sysvar(2) ;My Reflect SavedState exists
trigger2 = playerid(var(0)), sysvar(4) = 0 ;Reflect Status Changed to 0
trigger3 = playeridexist(var(0))
trigger3 = !playerid(var(0)), sysvar(2) ;VANS COMP (does not use Sysvar(2))
trigger3 = playerid(var(0)), movetype != A || playerid(var(0)), sysvar(1) != sysvar(1) ;MoveType changed/Reflect State Changed


Non-compatible projectile reflection example:
In this example, my character enters their reflection animation (separate from the Helper Reflector).

Code: [Select]
[State  Noncompatible Projectile Helper] ;No compatible projectile? Send one of your own.
type = Helper
trigger1 = numhelper(821337) ;Unique Reflector Helper ID
trigger1 = helper(821337), sysvar(0) = 0 ;Unique Reflector SysVar was reset to 0
trigger1 = AnimElem = 4
trigger1 = anim = 1307
ID = 1050
stateno = 1050
name = "Non-compatible projectile reflected"
postype = p1
pos = 36,-62
ownpal = 1


I will update this post if I notice any mistakes after proofreading several times, if you encounter an issue please demonstrate it if possible.

I hope this works for full game implementation. Enjoy!

~Space23 (DCL)


(click to show/hide)
zzz...I'm top tier...screw you Doom and Wesker...zzz

Offline O Ilusionista

  • Since 1999 and kicking :)
  • IMT Content Architect
  • *
  • Posts: 12476
  • Country: Brazil br
  • Last Login:November 11, 2024, 12:35:15 PM
  • OpenBOR & Mugen addicted
    • BMT - Brazil Mugen Team
    • Email
Re: Projectile Reflection/Re-Reflection
« Reply #1 on: September 13, 2023, 08:59:44 AM »
Thanks for the code buddy, I will try it as soon as possible. Right now, I am using Loganir's Wonder Woman reflect code.
I remember there is a bug in Mugen 1.0 if the helper has any explod bound on it - in Mugen 1.1, they added a new sctrl for that.

Tags:
 


* IMT Facebook

Help us by Donating!

IMT Discord

Join us at our Discord! Click the image below!

* IMT Shoutbox

Sorry, this shoutbox does not exist.

* Recent Posts

D2TD VS Showcase Thread by D2TD
[November 24, 2024, 09:12:03 AM]


Marvel vs. Capcom: Eternity of Heroes REMAKE Game Update 1.3.0 - N.A.O.H. by LightFlare
[November 21, 2024, 09:44:09 PM]


Terrordrome: Rise of the Boogeymen Extended Version ( jeepers creepers) version by leonardo
[November 19, 2024, 10:22:47 PM]


Hill of the Nameless(1.1 Only) by Vegaz by LightFlare
[November 19, 2024, 10:50:39 AM]


Golden Axe Returns by gokudo99
[November 19, 2024, 03:59:31 AM]


Barkley Shut Up and Jam! Stages by Vegaz by LightFlare
[November 12, 2024, 11:26:21 AM]


[BOR] _Avengers United Battle Force_ by O Ilusionista
[November 11, 2024, 12:35:24 PM]


Eternal Lament Stage 1.1 & 1.0 by O Ilusionista
[November 11, 2024, 12:34:54 PM]


MatreroG's Stages W.I.P. Concepts by MatreroG
[November 11, 2024, 07:00:56 AM]


Spooky House(1.1 Only/AIGS) by Vegaz by LightFlare
[October 31, 2024, 11:31:36 AM]

* IMT Calendar

November 2024
Sun Mon Tue Wed Thu Fri Sat
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 [26] 27 28 29 30

SimplePortal 2.3.5 © 2008-2012, SimplePortal