Jump to content
  • 0

Help with projectile coding


Sweets

Question

hello guys I hope someone could help me out with coding my char. I figured out how to code normal punches and punches in the air. I'm now focused on projectiles. I know how to code projectile's while char is standing but I just can't for the life of me code my char shooting a projectile while in the air?

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

its the exact same idea as on the ground. except you need to limit the character a little bit.

 

for instance if you add a velset code with x and y = 0, then they won't move.

also make sure you set your statdef's physics = N , if your physics = A, then gravity will pull you back to the ground which ususally makes the projectile not happen.

 

 

Link to comment
Share on other sites

  • 0

Thanks ryon Ive been watching the tutorials very closely I'm really trying to understand codes. I read how velset effect my char and A or N phycis will effect my char in the air. 

I think i messed up my helper code but I don't no where. I want it to shot straight down when my char is in the air. But My char won't summon my helper animation or hit the target player it just shows my exploding animation on the ground 

Here is my code

- 220 is my char shooting projectile

-230 is the projectile it self

-240 is my exploding animation

 

[statedef 221] 
type = A
movetype= a
physics = n
juggle = 1
ctrl = 0
anim = 220 
sprpriority = 1
 
 
 
[State 221, 1] 
type = Helper
trigger1 = 1
name = "power ball" 
ID = 222 
stateno = 222
pos = 0,0
postype = p1
ownpal = 1 
supermovetime = 0 
pausemovetime = 0
;size.xscale =
;size.yscale =
;keyctrl = 0 
 
[state 221, 2] 
type = playsnd
trigger1 = time = 2
value = 0, 4 
 
[state 221, 3]
type = changestate 
trigger1 = animtime = 0
value = 0
ctrl = 1
;---------------------------------------------------------------
;cammand jump special helper (projectile)itself
[statedef 222] 
type = A
movetype= A
physics = n 
ctrl = 0
anim = 230 
sprpriority = 2 
velset = 0,1
 
[State 222, 1] 
type = HitDef
trigger1 = time = 0 
attr = S, NA
hitflag = maf
animtype = Medium 
damage = 200,0
guardflag = MA
pausetime = 1,1
sparkno = s1
hitsound = s5,2
guardsound = s6,0
ground.type = high
ground.slidetime = 0
ground.hittime = 0
ground.velocity = 0
air.velocity = 0,0
 
[State 222, 2]
type = ChangeState
trigger1 = movecontact 
value = 223
 
[state 222, 3]
type = changestate 
trigger1 = POS Y > -5 / VEL Y > -5
value = 224
 
;---------------------------------------------------------------
;cammand jump special helper (projectile) hitting player
[statedef 223] 
type = A
movetype= A
physics = n 
ctrl = 0
anim = 240 
sprpriority = 2 
velset = 0,0
 
 
[State 223, 1]
type = DestroySelf
trigger1 = animtime = 0
 
;--------------------------------------------------------------
;cammand jump special helper (projectile) hitting ground
[statedef 224] 
type = A
movetype= A
physics = n 
ctrl = 0
anim = 240 
sprpriority = 2 
velset = 0,0
 
[State 224, 1]
type = PosSet
trigger1 = 1
y = 0
 
[State 224, 2]
type = DestroySelf
trigger1 = animtime = 0
Link to comment
Share on other sites

  • 0
On 1/14/2016 at 4:54 PM, Sweets said:
[state 222, 3]
type = changestate 
trigger1 = POS Y > -5 / VEL Y > -5
value = 224

I think this trigger is the one that doesn't work properly. It tries to resolve the condition pos y > 5, then divide it with vel y, and then check if the result is greater than -5. Its odd if you only want to check if the helper hit the ground.

 

You can use

trigger1 = pos y >= 0

 

or

trigger1 = vel y > 0

trigger1 = pos y > -vel y

 

as alternative to that trigger. First one is simpler, but can allow the helper go below the ground very often. Second one is what I'm using and works pretty well, took it from here. Anyway, on state 224 you're resetting its pos y to 0, which is great because you're preventing it to go below ground.

 

Keep in mind that multiple helpers are generated every tick on state 221.

 

 

Edit: Or you can just replace / with && and it will work fine :P

Link to comment
Share on other sites

  • 0
On 1/17/2016 at 7:12 PM, ShinLucho said:

 Or you can just replace / with && and it will work fine :P

 

Ha funny but I just can't get my helper to appear  it just shows my exploding animation. So do you mind giving me a simple helper code?

 

Link to comment
Share on other sites

  • 0
On 19/1/2016 at 11:22 PM, Sweets said:

 

Ha funny but I just can't get my helper to appear  it just shows my exploding animation. So do you mind giving me a simple helper code?

 

Your helper is already simple, it just need some fixs

 

;---------------------------------------------------------------
;Projectile helper
[statedef 222]
type = A
movetype= A
physics = n
ctrl = 0
anim = 230
sprpriority = 2
velset = 0,1
 
[State hitdef]
type = HitDef
trigger1 = !time
attr = S, NP
hitflag = maf
animtype = Medium
damage = 200,0
guardflag = MA
pausetime = 1,1
sparkno = s1
hitsound = s5,2
guardsound = s6,0
ground.type = high
ground.slidetime = 0
ground.hittime = 0
ground.velocity = 0
air.velocity = 0,0
 
[State to exploding state]
type = ChangeState
trigger1 = movecontact
trigger2 = vel y > 0
trigger2 = pos y > -vel y
value = 223
 
;---------------------------------------------------------------
;Exploding projectile
[statedef 223]
type = A
movetype= A
physics = n
ctrl = 0
anim = 240
sprpriority = 2
velset = 0,0

 

[state safe pos ground]
type = posset
trigger1 = !time
trigger1 = pos y > 0
y = 0

 

[State end]
type = DestroySelf
trigger1 = !animtime

Link to comment
Share on other sites

  • 0
On 1/21/2016 at 8:03 AM, ShinLucho said:

Your helper is already simple, it just need some fixs

 

 

Thanks I wouldn't of gone this far without your help. I'm almost done with my char. I just need help with the controls or commands 

I want to make them (up and x) but it hardly ever works it ether jumps 80℅ of the time or gabs

*jabs

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...