Learn You a Game Jam - Day 10 Work Log


Going to log as I work tonight, see if it can help me stay focused.  I did a lot of pacing and thinking last session, but not a lot of coding. 

First up is the lottery upgrade!  Right now its a hack with no arguments being passed to the ticket or called when the ticket is selected.  Fine to test the Behavior Engine, but it needs more flexibility to be useful.  First have an add_ticket fucntion that I have to add an argument to for the new array:  

func add_tickets(function, arguments, tickets_to_add):

I don't know how to define these types if I wanted to... Callable, Array, Integer.  All of the ACTION_ functions are stored in variables that are just ACT_ versions of their ACTION_ names. Like so:

@onready var ACT_walk_to_node = Callable(self,"ACTION_walk_to_node")

The "self" in Callable referring to the node that the script is in, because you can call functions in other nodes just like a normal function call.  So for my "Walk to MainTank until you get to 50 pixels" ticket and my "Hesitate" ticket the add_ticket calls look like this:

add_tickets(ACT_walk_to_node,[main_tank,50],10)
add_tickets(ACT_hesitate,[],1)

I have the scene tree MainTank node hard code define as main_tank, but I will update this when I get the personal tables going it it will define main_tank through them instead.  It should only be one, but I can do "closest MainTank" like any other type just in case.

Once all the behaviors are loaded we just have to pick one at random and call it with its arguments using the absurdly useful pick_random() method of Array (Arrays have a TON of useful methods, which I look to exploit in these behaviors):

lottery_pick = lottery_hopper.pick_random()
lottery_pick[0].callv(lottery_pick[1])

callv() is method of Callables that I think can use a variable number of arguments, which we need!  Doesn't work with just call(), so callv() it is!  The pick is an exported variable, just so ever one can see what ever one else is up to...

And... success!  The lottery now has a function AND any number of parameters for the function RIGHT ON THE TICKET!

When you pick a ticket, you just CALL IT.  Then hold on to it, you are going to be doing this a while.

So right now, with only two options there is not a lot of reason to care what happened in the last lottery.  The only thing that shuts off decisions being made for the Guildie is the 1 sec hesitation.  Running from one "go to main_tank" to another is fine, but it won't be when your Guildie is deciding between 20 actions on 300 targets.  It will pick another thing to do every frame and end up doing none of them.

So, when an action is selected from the lottery, it needs to start an Input Off timer and turn off accepting_input on the character for the duration, turning it back on with timeout().  This is so you give them enough time to do what you asked before it decides again, including time to run animations like sword swings.

I am running turning off and on the accepting_input as part of the animation, but it is inflexible. For instance, I couldn't use the "idle" animation for "hesitation" because in idle you have control and hesitation you do not.  NO MORE, we are decoupling the "Accept Input" function from the animation and adding a special Timer!

Ok, that took a bit of doing, but its done and it will work much better now.  Each ACTION will be able to set how long it will repeat for and set a timer.  Every time an action tries to reset the timer it check to see if its running already and it the last two lottery tickets match.  If so, it will skip the timer set.  So new actions will set the timer, but already running ones won't unless the timer is stopped.  (meaning it won the next lottery )

This will allow me to fine tune behaviors.  Now on to the Personal Character Lists so out Characters have all the info they need to add the right amount of Tickets for each action, and what arguments those tickets will have.  We don't really need this for the Guildie since his ability right now is centered on Items, but I will need it for the Priest and I want to get the MainTank references off the scene tree and get them pulled off the BIG BOARD!

So I made these GM_character_lookup and GM_item_lookup Dictionaries a few days ago but I didn't have much of a plan on how I was going to retrieve the info. I literally have to re-watch the Brackys video on GDScript - the part about Dictionaries - to remember how to use them...


 Ok, so I got a lot done in the above gap - I got the Guildie to poll a personal_item_lookup (decided to make on for items too, but it only has distance right now) for the distances and came up with this:

add_tickets(ACT_walk_to_node,[node_id,5],min(int(500/distance+.01),50))

INVERSERE PROPORTIONS, I FINALLY USE YOU!  I feel like I'm going to use this a lot.  So what this does is add tickets inversely proportional to the distance the Guildie is from the Item, up to a max of 50 tickets per item. These would be nearby, and once you get really close the number gets crazy.  The exact proportion is at 100 pixels away (about where my Guildie happened to start from my Crozier in the test) the function will add 5 tickets to pick it up.  It would reach its max of 50 at 10 pixels...

You see that slick Divide by Zero error prevention... I noticed the Guildie would never try to stay at the Item when it got to its location... I think because at 0 distance, it broke the function to add tickets, but not enough to crash.  So now it will never be 0.

And my boy heads towards the item!  Once he get closer he's determined!


Buuuut its after midnight.  I'm so CLOSE to a completed Guildie, but I don't think I have the fortitude.  

Get Guildies

Leave a comment

Log in with itch.io to leave a comment.