Get Experience Points

0 favourites
  • 8 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hey there, i have a quiet simple question, it shouldnt be too hard, but im really struggling with it. I have build a leveling system, which itself works totally fine.

    The enemy AI is based on a "state-variable", as example, 1 is idle, 2 is walking right etc. So if you kill an enemy, it's state is set to "dead" and you recieve experience points.

    The enemies are all in a family called "enemies" and they are all handled as separate instances.

    My problem now is, damage and states works fine for separate enemies, but when it comes to give experience points, my problem starts. My setup right now is like this. (I tried many many different setups)

    For each - enemy

    Health is >0

    Trigger once

    Set variable to "dead" and add points to variable "exp" for player

    Now the exp points will be added continiously and i understand why, but i still couldnt figure out a legit way to just add exp points ONE time on enemies death.

  • So why not add only on enemies death?

    So add the action giving experience points to the event that makes the enemies health go under 0..

  • If i use on destroy it works fine, but i want to leave the dead enemies on the ground. So i have to put them to state "dead".

    The event that makes it go down, is the players collision box colliding with the enemy. If i put the exp points to the attack action + hp below zero, it doesnt work.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • For your solution you can add a boolean instanca variable which determine if exp already got calculated or not... BUT checking all enemies all the time just for calculating exp points seems to be like a connon for a fly.

    Each enemy/target should have an instance variable "health", then

    On BULLET collision with TARGET

    • decrease TARGETs health points
    • if TARGETs health points <= 0

    -- run "dead" animation

    -- calculate XP

    Something like that should work, if it doesn't, just give us a screenshot cause there is something else giving you problem.

  • Ok here is my collision event.

    And here is the experience point event.

    The damage works fine. The strange thing is, also the experience points work fine, but only when i kill the first enemy, after the second one the exp will be added continiously.

    The question is, how to make it just happen one time. Even "trigger once" didnt work, cause the enemy is set to state 11 "dead" and will continiously give exp. So how can i stop it?

  • Optimally, HEALTH <= 0 (and any condition filtering the For Each) should go above the For Each.

    If you don't destroy the enemy right away, your only resort would be to use a boolean or another state variable (using AI_STATE <> 11 could be ok too if an AI_STATE doesn't change once dead). "Trigger once" in that context doesn't make much sense, in fact, using a "Trigger once" in a loop is one sure way to get unwanted behavior. As soon as it loops more than once, "Trigger once" get mixed up and make each iteration a "new trigger", thus explaining your problem.

    Also, the "Trigger once" in the collision event is redundant, and you might as well remove it altogether.

  • I think in this case I would just put the

    enemys health < 0 subevent

    as a subevent of the collision event..

  • Thank you all guys for your help, but somehow it still doesnt work. I guess i will go with destroy enemy and try some kind of workaround.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)