Hey all, anyone sees the solution for this:

BasGoodboyBasGoodboy Member, PRO Posts: 310
edited October 2013 in Working with GS (Mac)
I keep having problems with my Arena scene. This should be the last one to completely fix the scene:

The idea:
You have 3 actions, dagger sword and xbow.
I made the sword action and xbow action with a powerbar, which will go up each second and on release burst extra dps depending on the power in the powerbar.

The opponent:
The opponent spawns randomly on 3 locations, closeby (use dagger), middlefar (use sword), and far away (use xbow)
The problem is, the sword action should only do damage when the opponent is at location 'middlefar'.

The problem:
This all worked, untill I built in the powerbar thingy. Now, when the sword button gets released and the opponent is in the location 'middlefar', it all goes well. When the opponent is on an other location (closeby or far away), the text 'missed' spawns.
All works very smooth. BUT.. when the opponent spawns back at the location middlefar, he still gets a hit from the previous done sword action from maybe a minute ago.

I included a boolean or two to make sure everything resets after the opponent switches locationspawn, but it al won't work.

Here is a small idea of the Arena scene:
image

I hope you understand what I mean, I tried everything in my power, but don't know how to fix this.

Best regards,

Goodboi Gamestudios | Monster Jumper now on the App Store

Comments

  • MantoManto Member Posts: 796
    How do you detect whether the enemy is close, middlefar, or far away? Do you have an attribute for it?
  • -Timo--Timo- Member Posts: 2,313
    I think you constrained the power of the sword with an attribute? if so then put an actor in the scene and display text with that attribute. so you can be sure if it really resets.
  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @Manto1 it detects that by an attribute, which changes integer from 1 to 3 when the enemy spawns an other distance.
    @timolapre1998 yes, I constrained the power of the sword with the attribute 'swordpower'. I made all my scene integers visible ingame and they all reset perfect. I am really lost now.

    My code looks something like this:

    Code of button swordaction:

    if touch is inside, spawn actor powerbar.

    if touch is released, and when 'enemypositioninteger' =2 (which means middlefar), change attribute 'enemyhealth' to 'enemyhealth'-'swordpower',
    change 'enemypositionrandom' (which makes the enemy spawn random away)
    change attribute 'swordpowerbar' to 0 (sets swordpowerbar off)
    change attribute 'swordpower' to 0 (sets the power integer of the swordpowerbar to 0)

    Like I said, all integers reset perfectly after an actions, but the weirdest thing is my enemy will keep getting hit after the action is done and he spawns back to position 2 (middlefar)..

    Please someone help.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @BasGoodboy In every case where enemypositioninteger is mentioned, i.e here for one in your sword action rules, reset back to zero before the next spawn. Try that, see if that solves it for you.

    if touch is released, and when 'enemypositioninteger' =2 (which means middlefar),
    change attribute 'enemypositioninteger' to 0
    change attribute 'enemyhealth' to 'enemyhealth'-'swordpower',
    change 'enemypositionrandom' (which makes the enemy spawn random away)
    change attribute 'swordpowerbar' to 0 (sets swordpowerbar off)
    change attribute 'swordpower' to 0 (sets the power integer of the swordpowerbar to 0)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @gyroscope that woudn't work for me, since the enemypositioninteger really gives the enemy a new spawn. So each 2 seconds the enemy actor changes position by the position integer. So if I would make him 0, he would simply change position!

    I hope you understand what I mean.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2013

    I see, then why not give it a "neutral" number that isn't linked with a position? So 4, whatever, is just temporary until the next random spawn position of, presumably, 0, 1 or 2...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @gyroscope just tried.. no result :(

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited October 2013
    Put a change attribute or attributes in the actor that spawns put it at the top of the stack. When it spawns have those change attributes reset the damage attributes right away. This will only fire once at spawn since they are not in a rule. This ensures every time a new enemy spawns the damage is reset before any code that would see a hit fires. But ideally you need to be sure the damage resets before the actor destroys. You can put the destroy rule in a .3 sec timer with run to completion checked and have the reset code right before the destroy.
  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @FryingBaconStudios ok gonna try now.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited October 2013
    Okay here's the thing.

    @FryingBaconStudios I putted a 0.3 second timer on the respawn after the hit, so the codes have enough time to do their work. This makes no difference tho. The changing of attributes to reset the damage on a newly spawned enemy doesnt make difference, because it's not a new enemy, but still the same, only spawned on an other location. It doesn't get destroyed or anything in the meantime just a new locationspawn.

    I notice that the damage rule (change attribute 'enemyhealth' to 'enemyhealth'-'swordpower') isn't the problem, since the opponent doesnt lose health anymore after the original action, but I see there's a problem because I also have a rule that the opponent will change colors to red (like bleedy effect) for 0.3 seconds after the touch release of the sword action, and a rule that plays a sword slash sound, also on the release touch on sword action.

    Somehow, the bleed effect and the sword slash are still going true automatically every few seconds after the original action.

    By the way @FryingBaconStudios all actions reset perfect before the respawn, I see that at the integers which I putted visible on the scene.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2013

    Reading your Rules again, I'm not understanding the relationship between 'enemypositioninteger' and 'enemypositionrandom' (I thought they might be the same thing)... ok, so try resetting the enemypositionrandom to 4 this time (or any other number not associated with a position) just after it's chosen it's random position number, and it has triggered the necessary Rules in swordactionrules, etc...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @gyroscope: No, you were right, the enemypositioninteger and enemypositionrandom I was talking about are the same. That was maybe a bit confusing, but i'm using 'enemypositionrandom' as name for the enemy position integer attribute.

    So basically it's the same thing.

    I'm really stuck here. I am gonna check if I can put on a proper screenshot of the rules here.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited October 2013

    Hmm, are you certain that "swordpowerbar" and sword power" attributes are being reset to 0 then; and if they are perhaps add at the beginning of the sword Rule "and when swordpowerbar <> 0 and sword power <> 0".... see if that does it...

    It's basically as @FryingBaconStudios is saying (well, and me!); it's to reset everything before the next random spawn every time, which would surely solve your problem.

    I'm still clutching at straw here a bit trying to help because I only half-understand what's going on with your Rules...

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited October 2013
    It took me some while, since I had to cut and paste some, but here's the code i made for it. @gyroscope @FryingBaconStudios and ofc others I appreciate your help a lot! It really all resets by the looks by it for me, since Ive put the used integers visible in the scene and they are all set to 0 when the opponent respawns at an other position. Maybe you can see something in this:

    Code of the swordpowerbar:
    (spawns when an integer called 'swordpowerbar' = 1 and destroys when 'swordpowerbar' = 0 and every second generates power with an integer called 'swordpower'):
    image

    Code of swordbutton:
    image
    image
    image
    image

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Okay I think your problem is the last rule. You're using touch is released. Remember touch is released is fixed to on once it's released. It's not momentary like touch is pressed. Changed that rule to touch is pressed and wrap all the code inside it in a timer set to for .3 seconds run to completion checked.
  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited October 2013
    @FryingBaconStudios thanks a lot so far. I changed it like you said, put all in a 0.3 second timer which runs to completion, you got me into a next level, altho it's not yet the complete thing and I don't understand the logistic.

    But it is still not exactly what I am aiming for. Now, indeed, the weird swordslash sounds and bleed effect won't show up on other spawns, so that's super!

    Only now, if you click the swordaction, and the opponent is spawned on an other position then 'middlefar' (closeby or far away), you can build up the sword action bar with energy like it's supposed to, but you can't release it when the opponent gets spawned on the middlefar position, this goes automatically. This makes the difficulty very easy. Also, when the opponent is already spawned at the middlefar position, and you press the sword action button, there is no energy gaining in the sword action bar, it's an automaticaly hit on the lowest energy.

    Hope you understand what I mean.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Also try (I'm harping on about this aspect.... ;-) ) in that last Rule:

    When touch is released ---or pressed as Dave suggested--
    When game.Aren...=1
    When game.ArenaRandomAction = 3

    Change Attribute game.ArenaRandomAction to 0
    ---etc as you've already got

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    @gyroscope ofc I did that haha. Sorry it wasn't on the screenies, keep changing the rules to tryout and things. But yes I have that now!

    Still I have that issue. But now I'm wandering with the option @FryingBaconStudios gave me if it isn't cooler to make the powerbar go up and down very fast and first tap it spawns and second tap it hits.. might be cooler, and I think I know how to do this now!

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited October 2013
    Yeah just watch your logic as it seems a bit spread out. Try thinking of a simpler code structure. It seems to me you're not informed on how rules function. You need to study rules more in depth and how they react to different triggers. Mostly when a rule executes and when it cuts off.


  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited October 2013
    @FryingBaconStudios thanks for the tips mate. All thanks a lot. I made my powerbar go very fast up and down now at first press, and second press fires at whatever power it is at that moment. This all works and I think this is better then the old variant. ATM this was the last coding I really needed for my game to complete I think. But you never know, I'm quite impulsive as it comes to finishing the game with new thingies.

    I know that vid @FryingBaconStudios. And I know my coding is a bit spread out, I'm a chaotic man but it worked until now. Still am quite a noob in GS but proud on the results so far.

    Goodboi Gamestudios | Monster Jumper now on the App Store

Sign In or Register to comment.