Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: bomb3rman on June 05, 2017, 01:20:46 pm

Title: Kill ship = fill up bank account
Post by: bomb3rman on June 05, 2017, 01:20:46 pm
Hey I ran into a problem.

I wanted to make a mission where when Player kills a ship the Variable BankAccount gets filled up + 100. I don't want to make 50 events for every enemy ship that's maybe killable by the player, so I want it to be in one event.

What I did:
    when
        any of
          Enemy 1
          Enemy 2...

        was destroyed by
          0
          Alpha 1
         <Argmument>
        modify-variable
         BankAccount
         +
         BankAccount
         100

I test the mission and after killing several ships the counter is at 100 (because it became true only once, that's logical for me)... But I don't seem to find out which conditional (or is it about repeat count/trigger count?) I need to use to "reset" the event to look if I kill another of the ships under argument. So the goal is: 12 enemies, kill all 12 of them, BankAccount = 1200...
Yeah I could make 12 different events to check, but I'm lazy :P And I think there's a smarter solution, but what am I missing here?

In short: How do I reset the event to check again if there is one of the arguments killed by the player and NOT become true directly because the one ship was already destroyed by the player?

Thanks, guys!
Title: Re: Kill ship = fill up bank account
Post by: 0rph3u5 on June 05, 2017, 01:41:53 pm
Hey,

You are on the right track. You have to set a repeat count (or trigger count? - I keep forgeting which is which) on the event, otherwise it will only run once.

For the second problem you add a "invalidate-argument" to the event so it discards an argument that already checked as detroyed.
Title: Re: Kill ship = fill up bank account
Post by: bomb3rman on June 05, 2017, 02:03:53 pm
It's working with the trigger count set equal to the max. number of ships to be destroyed perfectly!

And

Quote
For the second problem you add a "invalidate-argument" to the event so it discards an argument that already checked as detroyed.

That was what I was looking for! Now the "used" argument gets deleted so it doesn't trigger permanently :)

Thanks!

Now you can save money to your Bank Account and go shopping with it during the next missions ;)
Title: Re: Kill ship = fill up bank account
Post by: Axem on June 05, 2017, 02:48:14 pm
I've got an idea for possible alternative that might be more "portable".

Instead of making a huge argument list, there's a sexp that tracks the player's kills. So you'd have a variable that tracks playerKills and compare it to the actual kills returned by the sexp. If they are different, then increase the bank account by the difference (and update that playerKills variable to equal the real kills). That way you could just copy and paste the single event without needing to populate the argument list.

But if you got what works and you like it, then that's cool. :)
Title: Re: Kill ship = fill up bank account
Post by: bomb3rman on June 05, 2017, 03:14:52 pm
This might work as well, though I don't understand completely what you're saying :)

I'm probably going to increase the BankAccount differently if you kill bombers, transports or fighters. So the simple Playerkills = something alone wouldn't help.

The other version would work for me in that case, I just need to make maybe 3 or 4 events and put every ship in the right sexp to give the right amount of money...
Title: Re: Kill ship = fill up bank account
Post by: 0rph3u5 on June 05, 2017, 03:33:45 pm
Isn't there a "percent-ship-type-destroyed" SEXP that could shorten this? - You would have to limit the number of ships to one that gives workable percentages (1,2,4,5,10,20,25,50,100) and set "ignore for counting goal" to all other ships

I know there is one for "percent-ships-destroyed" of a defined group which I used to use for arrival cues in hositle wing as it als counted waves of wings in total percentage...

EDIT: It's called "ship-type-destroyed"....

EDIT2: however the help text says it doesn't distinguish between fighters and bombers and then the eligible types include "Fighter", "Bomber" and "Fighter/Bomber". Since this is an SEXP from the age when we FREDed onto clay tablets, I guess it was modified to make that distinction?
(I mean there is a grammar error left in the help text; it says "types" but the SEXP doesn't take additional arguments besides a percentage and a single ship type)
Title: Re: Kill ship = fill up bank account
Post by: Axem on June 05, 2017, 05:22:27 pm
This might work as well, though I don't understand completely what you're saying :)

I'm probably going to increase the BankAccount differently if you kill bombers, transports or fighters. So the simple Playerkills = something alone wouldn't help.

The other version would work for me in that case, I just need to make maybe 3 or 4 events and put every ship in the right sexp to give the right amount of money...

Okay, I figured it was something like that then. Then that is probably your best bet then (outside of lua scripting).
Title: Re: Kill ship = fill up bank account
Post by: karajorma on June 05, 2017, 06:49:18 pm
Now you can save money to your Bank Account and go shopping with it during the next missions ;)

Just out of interest, how do you plan to handle that?
Title: Re: Kill ship = fill up bank account
Post by: bomb3rman on June 06, 2017, 12:38:57 am
I know there is one for "percent-ships-destroyed" of a defined group which I used to use for arrival cues in hositle wing as it als counted waves of wings in total percentage...

EDIT: It's called "ship-type-destroyed"....

I remember having problems with percent-ships destroyed/departed etc... Some time ago I asked something here and karajorma told me to use this sexp, but it didn't work for me. (the sexp itself didn't work) so I think I won't go further this way, especially when the other version is working (I tested it in a small 3 mission campaign, it does).

Quote from: Axem
Okay, I figured it was something like that then. Then that is probably your best bet then (outside of lua scripting).

Since I have no clue about scripting, I stay with this way :P Though I remember a mission in BP where you had to call reinforcements and had some limited points available. Maybe it's possible (for someone else, not me :P) to connect the BankAccount to the script that has been used there to make a more "smooth" way to buy the ships. Otherwise:

Quote from: karajorma
Just out of interest, how do you plan to handle that?

Well I have to rethink a few things but what is working right now:

M 1 you kill ships and collect money (campaign-persistent-variable)

M 2 (some kind of small mission in-between) you fly around a "mercenary market". Using GTNB Pharos buoys and distance-checks, you get messages about certain ships waiting around the market. Once you have enough money and the distance to the ship/buoy becomes smaller than X, the ship jumps out, triggering an event like "Ship XY bought". Congratulations, you bought the mercenery ship for the next mission to aid you and your BankAccount goes down a certain amount of money.

M 3: Several ships appear (right from the start is working, other conditions have to be tested, but should as well) for example when the event "Ship XY bought" became true in M 2.

It's still just a mindgame, but it could lead to some interesting tactical choices you could make before a mission. A script would make that easier (like in BP and mentioned above), but I think my version would work in a more "physical" way by flying around, reading the messages and deciding what to buy for the next mission (or maybe the whole campaign, you could do this with "allow ship/allow weapon" sexps as well). so you can decide how to increase the flyable ships (need a bomber? Go for it, buy one!)

I'm thinking about a part of a campaign where you have a contract with a group of scavengers. They pay you for every ship you shoot (because they'll jump in later and scavenge the debris) or maybe even the police, when you go bounty hunting.
Title: Re: Kill ship = fill up bank account
Post by: karajorma on June 06, 2017, 05:40:49 am
Oh I see, you're letting the player buy wingmen for the mission rather than upgrading his own ship. As cool as that is, I thought for a bit you were using my team loadout stuff to allow the player to alter his own ship or weapons.
Title: Re: Kill ship = fill up bank account
Post by: bomb3rman on June 06, 2017, 08:11:02 am
I didn't know there was this stuff  :lol:

But it sounds interesting, where can I find it? Maybe I have a closer look, too.
Title: Re: Kill ship = fill up bank account
Post by: karajorma on June 06, 2017, 08:18:57 am
The wiki section (http://www.hard-light.net/wiki/index.php/Improved_Team_Loadout) on the feature is a little old. But it should give you an idea how things work.
Title: Re: Kill ship = fill up bank account
Post by: bomb3rman on June 06, 2017, 08:21:07 am
Thanks  :yes: :yes:
Title: Re: Kill ship = fill up bank account
Post by: HLD_Prophecy on June 06, 2017, 01:53:19 pm

Quote from: karajorma
Just out of interest, how do you plan to handle that?

Well I have to rethink a few things but what is working right now:

M 1 you kill ships and collect money (campaign-persistent-variable)

M 2 (some kind of small mission in-between) you fly around a "mercenary market". Using GTNB Pharos buoys and distance-checks, you get messages about certain ships waiting around the market. Once you have enough money and the distance to the ship/buoy becomes smaller than X, the ship jumps out, triggering an event like "Ship XY bought". Congratulations, you bought the mercenery ship for the next mission to aid you and your BankAccount goes down a certain amount of money.

M 3: Several ships appear (right from the start is working, other conditions have to be tested, but should as well) for example when the event "Ship XY bought" became true in M 2.

It's still just a mindgame, but it could lead to some interesting tactical choices you could make before a mission. A script would make that easier (like in BP and mentioned above), but I think my version would work in a more "physical" way by flying around, reading the messages and deciding what to buy for the next mission (or maybe the whole campaign, you could do this with "allow ship/allow weapon" sexps as well). so you can decide how to increase the flyable ships (need a bomber? Go for it, buy one!)

I'm thinking about a part of a campaign where you have a contract with a group of scavengers. They pay you for every ship you shoot (because they'll jump in later and scavenge the debris) or maybe even the police, when you go bounty hunting.

Hey, just happened to notice this. It sounds pretty darn awesome - nice job!
Title: Re: Kill ship = fill up bank account
Post by: bomb3rman on June 06, 2017, 02:27:28 pm
Thank you  :D Let's see if I can integrate this in a meainingful way in a campaign :)
Title: Re: Kill ship = fill up bank account
Post by: gershom on August 07, 2017, 08:52:26 pm
Couldn't you just use your player score as currency?
Title: Re: Kill ship = fill up bank account
Post by: karajorma on August 07, 2017, 10:44:30 pm
I'd be reluctant to alter a player's score since many of us have pilots we've been using for months or years which we wouldn't want to see dicked about. But as long as you only read the changes in the ship score from the start of mission 1 into a variable, and don't use inflated values for ship kills and goals achieved, it could work quite well as a currency.
Title: Re: Kill ship = fill up bank account
Post by: gershom on August 09, 2017, 05:35:47 am
Can you not make a variable that increases as your score does? That way you can spend credits without altering your score, and you wouldn't have to worry about players starting with a huge bank account due to points previously earned. Changing a ship's score value in the editor would be easier and more efficient than having to make multiple events. I'm just speculating, as I'm still trying to learn how to use events and variables myself, but with my limited knowldege on the subject, it seems like this should be possible.
Title: Re: Kill ship = fill up bank account
Post by: karajorma on August 09, 2017, 06:36:18 am
Oh it's definitely possible. All you'd have to do is read the player's score into a campaign or player persistent variable at the start of mission 1 (Which one you choose would depend on how you wanted money to work in your campaign). Then you can just subtract that value from the current player score to figure out how much cash the player had made so far. If the player actually spent the cash, you could add the amount spent onto the variable so that the money would be subtracted from the balance left.
Title: Re: Kill ship = fill up bank account
Post by: gershom on August 09, 2017, 08:27:31 pm
Does that mean there's no way to update the bank account in real-time based on score?
Title: Re: Kill ship = fill up bank account
Post by: karajorma on August 09, 2017, 10:28:22 pm
Nope. You can definitely do that. I'm just saying that if you have a player who starts with a score of 2300 say, what you would do is this right at the start of mission 1

when
-true
-modify-variable
--PlayerOriginalScore[0]
--get-player-score
---Alpha 1

So the variable would be set to 2300. Then whenever you want to know how much money the player has in the bank you simply do this.

modify-variable
- PlayerCurrentMoney[0]
- -
-- get-player-score
--- Alpha 1
-- PlayerOriginalScore[0]

Basically what you are doing is subtracting the score the player had when the campaign started (2300 in this example) from whatever his score is now. That way you only have the score he earned during your campaign.

Now if the player spends money (say 300) you can simply increase PlayerOriginalScore by 300 to 2600 and whenever you calculate what PlayerCurrentMoney is, it will be 300 less.


There are other ways of working out how you want money to work in your campaign (depending on how complex you want to make things) so if you need help, just tell us what you want to do and we'll be more than happy to help.