Function calls another func which returns value into func

Get help using Construct 2

Post » Wed Apr 13, 2016 4:12 pm

How sure are you that the function wil not get called again in the time that the wait action waits + the time that the delayed actions excute ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 13, 2016 4:24 pm

99Instances2Go wrote:How sure are you that the function wil not get called again in the time that the wait action waits + the time that the delayed actions excute ?


Up to 100% ;-) the "attack" process can only be active 1 time for each player; if cooldown=true (or "1".. no bools as global vars :/ ) then you wont be able to attack a second time. Cooldown will switch back to 0 (false) when the whole attacking process and returning to "starting position" is finished.
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Wed Apr 13, 2016 4:32 pm

So there is more then one player? And they call the same function ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 13, 2016 5:03 pm

99Instances2Go wrote:So there is more then one player? And they call the same function ?


Currently Im planning only 1 vs 1 combats (player vs. AI (PvE) and later Ill do an "arena-like" multiplayer (PvP)). Both players - or player and AI - will have access to the same "atack-process"; in other words there is only 1 routine for both. The "attack preparation" will be the same for both; the function called after "attack preparation" which shows the animations will have several if-clauses for identifying which player/AI got which hero and which animation (and set movement) has to be shown. Ild like to hold the source slim and compact, thats why.

(The long version:)
I thought, making a single "attack"-routine would be the easiest way to get this done, regarding that there will be several protagonists/anthagonists/whatever which will be doing exactly the same (regardeless of the animations, attackspeeds, etc. they got). The game will have its focus on stats/combats. I want to make it possible for (for example in PvP) a new player who doesnt really got good equipment to win against a player who already spend several hours in the game if he plays "better" (meaning: countering/bloking/studying the opponent). If you know the game (series) "Lost Souls"/"Dark Souls" - thats what I took as a "reference" in complexity and gameplay (yes, its nearly impossible to port such a milestone in gaming history into a mobile game, but Im not doing a clone - Im focussing on its complexity about what you can do with your hero/character).

@Magistross: just got home from work, tested it - and it works perfectly! Once again: thanks!
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Post » Wed Apr 13, 2016 5:53 pm

Not against a single "attack"-routine. But, i know for sure that the logic will break if (yet exactly do as advertised) if you gooing to call that function by differend players.

There is only one wait action i will use. The wait 0 seconds action. I will not use it in any other cases. And excuse me for trying, but i still try to get you to do the same. My intentions are good, althought they probaly sound stubborn.

I dont use 'wait' actions because:

1/
The time they wait is not reliable. That 0.5 seconds you wait looks fine. But then youre charakters get in a big fight. Trowing particles all over. Dropping the framerate temporaly. And before you know it, that 0.5 second will be 2 seconds in reality.

2/
If the event containing the wait actions executes again before the waiting is over, the logic will collapse. You will never know wich results pair with wich call.

3/
Pauzing the game will mess up the logic.

4/
And in youre case (and in so many other cases i have seen) the wait actions have no 'feeling' with the reality of the game. They just happen unconditional. At one point in developping you will not want players to overlap. But then 1 Collision is enough to break the logic. Because 'the wait' is not personal, it is not attached to a certain instance (player). There will (by instance) still be wait actions waiting while the objects that are meant to wait are killed and destroyed.

5/
Timers still are a more reliable solution. Because its a behaviour attached to an instance, and each instance has its own running timer. They dont mix up. On top you get triggers for free. You can leave them in the wild until a trigger gets your attention. Althougt there time is not reliable, they will never cross over.

Thank you for taking me serious independed of my childish English. I cant do better.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 13, 2016 6:10 pm

Point 1 is irrelevant. For a 0.5 second wait to become 2.0 seconds, the game will be lagging to hell. And no matter what kind of method is in place to schedule events, everything will be a complete mess.

All others points become moot using the example I provided.

However, I am also an advocate of the "no wait action" philosophy. Timers are incredibly more versatile and easier to manage. They are basically deferred functions that use instance variables as parameter.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Wed Apr 13, 2016 7:00 pm

99Instances2Go wrote:Thank you for taking me serious independed of my childish English. I cant do better.


First off, its not important if your english (or whatever language you write) is correct or not (my english isnt better at all.. :-D), the context of what you are writing about is - and yours is! ;-)

Indeed, your points are right. I just tested it out a bit, playing arround (the player now auto-attacks in 3 second intervalls, the enemy attacks with the same function in 0.5s intervalls). The "animations" are looking fine, also the GUI (after pressing attack, the attack-buttons are faded out (and will be faded in back again when cooldown=0)).

Arent wait timers frame indipendend? Normally they should not be affected by framerates in generell. For every kinds of movements Im going to use dt. There shouldnt be *that* many particles (if realizable, Im going to make a little benchmark on the first start, getting the cpu usage/framerate while showing a few particles; then the game should set up correctly itself for having the best gfx/framerate option... gonna make a "graphic" option menu where the player can adjust things like max. particles shown or particle-quality in general for choosing his best experience ingame) because its aimed for mobile devices. Testing this will become a bit hard, because I got a nvidia shield k1 which doesnt represent the hardware on Android in general (and a Lumia 640, which is also not that interesting for the most users).

Back to topic:
Yes, you are right about what you say on timers/wait-actions. But while testing I didnt encountered any problem with that. At first Im doing the PvE version - PvP is part of a far future for this project (when its about doing the PvP part Ill do a server/client version... PvP games are hotspots for hackers, so the client will only be there for sending requests to the server/backend which does everything when it comes to calculate, displaying health, etc.; the client will only be there for the "visuals" - but thats another point which isnt worth mentioning here.

Heres a "demo" of the current state (sorry for the very rudimental graphics.. how I said, first I need the core-system, then Ill go for gui, graphics and the stuff that makes fun.. gfx used are from Kenney, if one wants to know: http://kenney.nl/projects/kenney-game-assets-2), enemy attacks in 1.5s intervalls. To attack, just press the light-green-button (bottom left of the gui above the right player character):

(to /2: while testing I didnt encountered problems, as already said)
http://proxy.wtf/construct2/combat_system_test_timers/

to 4/
As the "wait" time is influenced by the attack-speed which is calculated out of your stats, I (at least hopefully) think, that the "unpersonal" scenario will not hit onto this. Ill also have no collisions (sprite collisions); I plan to include hitboxes. Since there wont be a "dodge" action, I dont have worries about that point. When player/enemy is killed, im going to deactivate the groups which are responsable for initiating attacks.

Ive also tested "signals" and waiting for them, but that would extent the code pretty much, thats why Ive chosen the wait action.

Sorry for that wall of text ;-)

Have a great day,
Proxy
B
24
S
14
G
9
Posts: 118
Reputation: 6,799

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests