Counters, trggers and changes in survive

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

Counters, trggers and changes in survive

Post by Lachu »

I developing counters for Freeciv.
Also, I am maintainer of Progress;

In progress, I introduced remember_* field to effects, where asterix is range name, such like player Also, I add to effects field telling how long effect should be activated.

When, many years ago, I told about this features, someone told to implement it to Freeciv. This person have an idea: change survive to contains turn requirement entry will be activate. Either requirement change state from true to false, it will be still activated for survive turns.

I think, survive could been changed to string and could be one of:
Inf/true
8/false
Or natural number.

We must save turn of activation, name/type of re entry and value.
For example:
T122, Tech, Bridge Building

When we check requirement entry is true:
1. Evaluate requirement entry
2. Find similar pair on list
3. If is not true, go to point five
4. Else, update Turn or create list of truth requirement entry and go to next requirement entry. If isEnd
5.Check Turn + Survive is higher than current turn
6. If this true, evaluate as true. End
7. Evaluate to false, remove from list

If survive is inf, can end on point 2, if entry on list exist

Triggers are similar to effects, but event-driven. Also, we must split effect only for effects, only for triggers and for both.
For example:
1. Add to Counter, Set Counter Value and Victory will be triggers
2. OutputBonus will be effect
3. HealUnit will be both

How triggers could work?
Imagine, we need to increase counter Victory Points with type Scenario Hall Of Fame. It have two requirements. When event update_something(REQ_NAME, REQ_VALUE, Unit, Tile, Player, City, .. ) was fired, we find each effect with REQ_NAME and REQ_VALUE in reuirements list. We perform algorithm given above, but when we evaluate each entry in trigger requirement list as true, we call INC_COUNTER_VALUE.

Triggers will have fields:
1. Name/Type
2. Subject
3/ Value
4. Requirement list

Thanks to this mechanism, many actions could be possible, like adding units experience, adding religions, loyalty of cities, etc.
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

Re: Counters, trggers and changes in survive

Post by Lachu »

On list of passed requirement, we must store also subject.

When something. that might be subject was destroyed, we lookup over passed requirement vector and removes each entry with subject.
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: Counters, trggers and changes in survive

Post by eldritch_cookie »

sorry english isn't my first language so i may be misunderstanding something. i love the idea of counters,there is just so much a ruleset creator could do with counters, so please continue that, i also like the idea of changing the survives field from maintaining the effect permanently to a number of turns and possibly permanent.

however that could be implemented by ruleset creators using counters, they create 2 identical effects that have different requirements and 2 helper effects and 2 counters, we will call them effect "A", effect "B" , helper "A" , helper "B" , "had" counter and "turns" counter, what we do is the following effect A has a requirement,which when met along with effect A being activated helper A increases the had counter, when effect A's requirement is not met and we have a non zero had counter helper B sets the turns counter to the desired turn duration amount and effect B has a requirement of a non zero turns counter , we obviously decrement the turns counter every turn. sure it is somewhat involved but this example shows the power of counters and that altough hard, generalized counters can create any survive effect.so maybe focus on counters, and only when they are finished create things which can be implemented in them.
also ints can be negative so instead of a string which we need to parse, maybe just a number for survive would be enough, 0 is not surviving -1 is permanent and any other number above 0 is turns which it still survives.

about triggers i like the idea of splitting effects into passive ones and ones that happen once or multiple times when their requirements are met, so for instance the give immediate techs effect would be moved to a trigger, triggers could have a field repeatable where it says if it can happen again after being first met and it could follow a similar structure to my recommendation to the survives field where -1 is infinitely repeatable and 0 is not repeatable and any number greater than 0 is the number of times it can repeat, triggers also should have a frequency field for how frequently it can happen provided its requirements are met so for instance, a turn frequency would happen once per turn but a action frequency would happen after every action(like unit move and attack). So for instance a trigger like [trigger_vampires_lifesteal] could have requirements of "action", "attack" and "unitclass","vampire" a frequency of action and a repeatable entry of -1 and a effect of heal unit so the vampire unitclass would heal after every battle they initiated. the trigger could optionally accept a callback entry for calling lua functions directly. and counters would be incredibly useful for triggers maybe that vampire lifesteal is too overpowered so we could use counters to make it happen only some times. so all things considered triggers would be incredibly useful.

also when you mention progress what are you referring to? i searched progress game open source and found nothing. so maybe a link would help
Lachu
Elite
Posts: 472
Joined: Sat May 04, 2013 2:19 pm

Re: Counters, trggers and changes in survive

Post by Lachu »

English is not my native too.

I only understood you a little.
About triggers, there is one problem.

Should we activate trigger with all requirement meet, when one of it's requirement change value or when? I think first option is good.
I cannot reminder any example of bad design of first solution - maybe in future I will wrote.

But, what is important - maybe add steps to triggers, so example:
(based on someone's counter idea and first approach to implementing this - search in redmine - I only write from my memory)

[trigger_enemy_killed_result]
name0 = "wipe_unit"
subject0 = "action_target"
value0 = ""
name1 = "move_onto_unit_tile"
subject1 = "action_target"
value1 = ""
name2 = "reduce_mp"
subject2= "actor"
value = "1'

actor_reqs = {
}

target_reqs = {
"name", "value", "range"
"MaxHP", 0, "Unit"
"UnitOnTile", 0, "Tile"
}

So many new mechanism could be introduced thanks to triggers.
Post Reply