You must be logged in to post messages.
Please login or register

Scenario Design
Moderated by Yeebaagooon, TAG

Hop to:    
Welcome! You are not logged in. Please Login or Register.6 replies
Age of Mythology Heaven » Forums » Scenario Design » Special Trigger Condition - Unit Type Killed By Player
Bottom
Topic Subject:Special Trigger Condition - Unit Type Killed By Player
Niley
Mortal
posted 30 July 2019 02:44 PM EDT (US)         
Hello, everyone!

I want to make a kind of tower defense game for multiplayer and I'm looking for a way to apply a buff (modify protounit) to the one player who manages to kill certain gaia units around the map. So basically a game with the twist of collecting buffs.

Example:
Player 3 kills a gaia chimera and from that gains a +2 attack damage for all their heroes.

My problem is that I somehow need to check the kills of different players against certain unit types, best would be if I can check what player the killed units belonged to. Army commands don't help since I can put the units into armies but still can't check who killed them.
I already tried to use the advanced triggers by pftq but those don't seem to enable this very specific feature.

Please tell me if there's a trigger set that could help me or if you know how to create such a custom trigger!
Thank you very much!
AuthorReplies:
nottud
Mortal
posted 31 July 2019 01:07 PM EDT (US)     1 / 6       
This is quite difficult - I guess on unit death you do a search for the player who has a unit closest to it and grant the buff to them?

There is also the unit killed cost stat value that might help - you could set the cost of the gaia units to ludicruosly high values and then check for which of the high values the player;s stat changed by which would tell you which player got the kill.
Niley
Mortal
posted 31 July 2019 02:03 PM EDT (US)     2 / 6       
Checking for the closest player sadly is no good since there are ranged units too...

The unit killed cost stat value is new to me... How exactly does it work? Sounds like a score that tracks the amount of costs for killed and lost units? If I can apply different values to different unit types that could maybe work.

[This message has been edited by Niley (edited 07-31-2019 @ 02:03 PM).]

Niley
Mortal
posted 05 August 2019 04:37 AM EDT (US)     3 / 6       
I need some more explanation for the unit killed cost stat value, please. How exactly does it work and where can I find it?

It sounds like first I assign special cost stats to different gaia units and then if a player killed them the player's "unit killed cost stat" will go up by that value? Then I can check for who's stat reached this value to give them the boost, right?

Can I reset that stat to allow for multiple checks on different units?



edit: Okay I think I understand now how it works. However I'm still looking for a way to reset the 'unit killed cost stat value' so I can check on the next kill aswell. It shouldn't be staking up forever since I can hardly test for any value it might reach combining all different unit kills throughout the game (there are supposed to be 10 different buffs). Any tips for getting a reset?

[This message has been edited by Niley (edited 08-05-2019 @ 03:53 PM).]

Yeebaagooon
EXCO Emeritus
posted 10 August 2019 03:13 AM EDT (US)     4 / 6       
Try something like this out on a blank map and you should be able to gain understanding by tweaking a few parameters.

Trigger: P1Level.
High priority, looped.

Condition:
Quest Var Stat Value, "Player1Next" < Enemy Units killed cost (player 1)

Effects:

Quest Var Modify ("Player1Next"(+[Number here]))
Quest Var Modify ("Player1Level"(+1))
Effect for levelling (modify protounit etc.)
Maybe send chat ("+(1*trQuestVarGet("P1Level"))+")(That gives you their level)


[Number here] The larger this is, the less often it will trigger. So if you set it to 1 and you kill an egyptian villager which costs 50 food, you will level up 50 levels for each villager killed.
If you set that number to 500 - it will take ten villagers for one level.
If you use modify protounit to make the villager cost 450 more food, then it essentially becomes one level per villager again - but will also trigger if you kill other units totalling more than 500 resources.
So use a higher number to make it trigger less when killing other units.

______________________________________ Yeebaagooon ______________________________________
____________________ AoMH Seraph ____________________
"I saw the picture and became immediately worried about Yeeb seducing and buying out Zen" - Shanks13
"Yeebaagooon had never seen a more handsome man in all his life. He couldn't control himself, He needed to act. Gripping the mirror in his strong arms he kissed the figure before him..." - Out Reach
AoMH: Unfinished Scenarios|Singleplayer: Codename Ripto 5.0|Multiplayer: Minigames X 4.7|CSC 7
Ex Seraphs Dictator, Spore Heaven Seraph

[This message has been edited by Yeebaagooon (edited 08-10-2019 @ 03:13 AM).]

Lewonas
Mortal
posted 10 August 2019 05:01 AM EDT (US)     5 / 6       
It sounds like first I assign special cost stats to different gaia units and then if a player killed them the player's "unit killed cost stat" will go up by that value? Then I can check for who's stat reached this value to give them the boost, right?
Correct.
Can I reset that stat to allow for multiple checks on different units?
You cannot reset the stat. But you can use quest vars to store the cost stat and whenever the player kills another unit substract the new cost stat with the value stored in the quest var to get the cost value of the new kill.


The ideal way to tackle this issue would be to set the total cost of all the units to 0. You can use nottud's Absolute Modify Protounit effects or my AMP Modify Protounit effects to do this.

So now, let's say there are supposed to be 10 different unit types that each grant an unique buff towards the player that killed the unit. You can set the total cost of those units to 1, 2, 3 [...], 10 respectively. And finally, create a trigger that grants the buff:

Trigger name = Player1_buff
Always [X] Run Immediately [ ] Loop [X]

Condition: Quest Var Stat Value
Player: 1
Stat: Unit killed cost
Operator: >
QV PointZero: p1_kill_cost


Effect: Quest Var Copy
Var name: p1_kill_cost
To var: p1_previous_kill_cost


Effect: QV Set Stat Value
Player: 1
Stat: Unit killed cost
Var name: p1_kill_cost


Effect: Quest Var Copy
Var name: p1_kill_cost
To var: p1_kill_cost_delta


Effect: Quest Var Modify 2
Var name: p1_kill_cost_delta
Operator: -
Var name 2: p1_previous_kill_cost


Conditional Quest Var Check
Var name: p1_kill_cost_delta
Operator: ==
Value: 1


Grant the buff for the unit that costs 1

Conditional zEND

Conditional Quest Var Check
Var name: p1_kill_cost_delta
Operator: ==
Value: 2


Grant the buff for the unit that costs 2

Conditional zEND

etc.

---

But of course, this only works if you don't need to use the unit costs for anything else (such as training the units from buildings, or for a leveling system). Otherwise the triggering would get a bit more complex than this where you have to work with large threshold values like nottud suggested.

EDIT: You could also use an alternative solution, like, deploy something like a relic near the location where the unit died. And when a player gets close to the relic, they collect the buff off that unit. This method would involve using ytriggers. Just a suggestion.

What are the key ingredients to make a popular RPG? To find out, read the results of the RPG survey.
Want to create an advanced patrol/pathfinding system? Have a look at the powerful Pathfinding triggers.
Games I'm playing: The Witness [80%] Chivalry: Medieval Warfare [20%]

[This message has been edited by Lewonas (edited 08-10-2019 @ 05:15 AM).]

Niley
Mortal
posted 12 August 2019 11:38 AM EDT (US)     6 / 6       
Woah, thanks! I will try this out asap
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Mythology Heaven | HeavenGames