Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Armor for Ply's Mod - A concept

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 8th Apr 2008 05:50 Edited at: 12th Apr 2008 00:46
Final Script is posted further down

Original Post:
-----------------------------
Okay, so here's my idea.

We already know that the player's health is adjustable, but in some games we want to have an "Armor" that will diminish BEFORE the health does.

Now, in my Mod you can set up variables, we'll call them "PlrArmor" and "PlrHealth" and (for calculations) "Temp", in the setuplevel.fpi, which will keep you from having to declare the variable inside a level and it will remain there throughout your game. Now, we can also set up a HUD and a numeric HUD for this variable in that same file. This is covered elsewhere so I won't go into detail here.

Now, FPSC is hard-coded to take away the player's health first... so we'll need to think of a way to get around that.

Here's my idea for this part:

- Create an "Always Active" entity in your level(s) that will be in control of the "Armor Script". (I like to use invisible entities that are not effected by physics, because that makes things easier on me)

- For the actual script, we will need to CAPTURE the player's health on every loop and store it into a variable, so we'll need this line of code:


This will set the "PlrHealth" variable to the amount of health that the player currently has on every loop.

- Now, if our player still has armor, we'll need to "restore" any health that the player lost while the armor was still active:


Okay, that was a bunch of calculating, and I know a bunch of people around here aren't used to that, so here's the gist of what's going on:
- If the PlrHealth variable is GREATER THAN the player's CURRENT health (meaning they got hit at some point in time) AND the player still has some Armor (Armor variable is greater than 0), then...
- Set the Temp variable to the player's OLD health
- Subtract the player's CURRENT health from the Temp variable (This will find out how much damage the player took)
- Give the player that much health back!


Awesome... in theory, this would prevent the player from taking ANY damage while their armor was still active.


Now... since our Temp variable holds a value telling us how much damage the player just took, then we can use THIS to distribute the damage to our player's "Armor":


More variable stuff, so here's the low down:
- If our Temp variable has a value greater than 0, then we know that the player just took damage, so...
- subtract that amount of damage the player SHOULD have taken from the player's armor.
- Reset the Temp variable to 0.


Okay, so if all goes well, our player will ONLY take health damage if their Armor is diminished, and if it isn't then their ARMOR will take the damage for them.

One more line will make this complete:


This will keep our player's armor from going into the negatives.


Throw it all in My Magic Script Cooking Pot and we get:



Hey, look at that, my Cooking Pot even corrected the placement of our first line of code and put it at the end.


Perhaps with a little tweaking, you could even code in some armor regeneration code and have it display an animated HUD while the armor regenerates.


*** FINAL NOTE ***

This is untested, but it makes sense in my head. (And hopefully in your head, too)

If someone is willing to test it, it will need Ply's Mod V1.05 (No earlier, because that is the only one which has the $PH function for grabbing the player's health)



Enjoy!


The one and only,
~PlystirE~

Slayer222
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: Wherever I feel like
Posted: 8th Apr 2008 05:56
Ummm... you lost me Which mod would that be? The dual wielding one?

[img]
[/img] Check out the Elite OPS Terrorstike thread in the showcase.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 8th Apr 2008 05:58
Lol, using variables lets me script more like a programmer, so that's what this script does. It's actually more programming than scripting.

Yes, V1.05 of my Mod is the one that uses Dual-Wielding.

If you're lost, then I suggest waiting for someone else to get it worked out first. (Although, I do believe that the way I described above will work as described)


The one and only,
~PlystirE~

Slayer222
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: Wherever I feel like
Posted: 8th Apr 2008 06:18
Well, I'd be content if my PC stopped acting like a ***** and let me use your mod properly

[img]
[/img] Check out the Elite OPS Terrorstike thread in the showcase.
Zeldar
16
Years of Service
User Offline
Joined: 16th Mar 2008
Location:
Posted: 8th Apr 2008 06:38
[clueless]So this is armor for the player?[/clueless]Oh, it is. I wish I could test it, but I have to download some DirectX 9(I think) update so FPS Creator can work.
Keo C
17
Years of Service
User Offline
Joined: 3rd Aug 2007
Location: Somewhere between here and there.
Posted: 8th Apr 2008 07:05
Quote: "I wish I could test it, but I have to download some DirectX 9(I think) update so FPS Creator can work."

I'll fetch that link.


Image made by the overworked Biggadd.
Orrion Carn
17
Years of Service
User Offline
Joined: 23rd Jul 2007
Location: Sandpoint, Idaho
Posted: 8th Apr 2008 07:36
AWESOME!!! This sounds perfect Ply.



My first animated Gif. Made in GIMP 2.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 8th Apr 2008 07:41
@Slayer222:

Lol, well I still can't say for sure if it's a PC specific problem with my Mod or if it's an actual issue.


@Orrion:

Thanks!

You know, sometimes I am even surprised by the stuff I can do with my own Mod. LOL


The one and only,
~PlystirE~

Slayer222
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: Wherever I feel like
Posted: 8th Apr 2008 08:43
Not bragging, but my PC is pretty damn good. Not a uber gaming rig, but most likely above the average here. Whatever it is, it's very annoying

[img]
[/img] Check out the Elite OPS Terrorstike thread in the showcase.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 9th Apr 2008 10:33
Just got the chance to test out this theory... and sure enough, it works!

It needed a little tweaking with some of the conditions, but other than that, it worked just like I thought it would.


I even put in a regeneration section for it, so that if you can keep from getting hit for 5 seconds, your Armor will start to regenerate.


Here's the "Armor.fpi" script (finished):





And here are the additional lines needed to put into the "setuplevel.fpi":




Remember, you'll need the image "armor.bmp" in your "gamecore/huds" folder. It's the same one that the "health.dds" file is located.

For everyone's convenience, I've attached that image to this post.



Please enjoy, and if someone tries it out, let me know what you think.


The one and only,
~PlystirE~

Attachments

Login to view attachments
Marc Steene
FPSC Master
18
Years of Service
User Offline
Joined: 27th Mar 2006
Location: Bahrain
Posted: 9th Apr 2008 20:48
Shouldn't it be the health healing, not the armor (at least that's what it's like in most games)

Free Segment Packs: V1-http://forum.thegamecreators.com/?m=forum_view&t=124552&b=24
V2 - http://forum.thegamecreators.com/?m=forum_view&t=124709&b=24
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 9th Apr 2008 22:06
So change it to health, I'm not forcing you to use the script "as-is"


The one and only,
~PlystirE~

Avid
17
Years of Service
User Offline
Joined: 24th Jun 2007
Location:
Posted: 10th Apr 2008 01:32
Halo 1 has the shield, which regenerates whilst health does not. If it's possible to implement the armour in lieu of the shield - I made some halo style graphics people can use.
Airslide
20
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 10th Apr 2008 01:55
I assume it's easy enough, but would it be possible for the armor to absorb only a percentage of the health lost? If you've ever played Doom or Return to Castle Wolfenstien you'd see that armor merely absorbs the bulk of the punishment, but you'll still loose health. I'm not entirely sure what functions your mod has, so I'm curious. I think it would be awesome if the more armor you have the more of the damage it absorbs. Lemme try to explain:

If you have 100% armor, it absorbs 100% of the damage delt. If you only have 79% armor left now, it will only absorb 79% of the damage you take, dealing the rest on your health. Meaning as you loose armor, you loose less at a time but begin to loose more health. That's somewhat how I programmed it for my old Wolfenstien 3D mod.

Slayer222
17
Years of Service
User Offline
Joined: 19th Mar 2007
Location: Wherever I feel like
Posted: 10th Apr 2008 02:03
Cool idea, I loved Q2's way of doing it.
Slayer_2
P.S. It's "lose", not "loose" [/grammar nerd moment]

[img]
[/img] Check out the Elite OPS Terrorstike thread in the showcase.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 10th Apr 2008 02:29
Interesting Airslide... but you'd be able to use any mathematical function (Below Trig) in my mod, so you could set up a way for a percentage to be taken.

I'm sure since you've already programmed this before that you have the algorithm, but for everyone else:

T = Damage dealt * PlrArmor/500 (Replace 500 with the maximum armor you will allow)

T2 = Damage dealth * (1 - PlrArmor/500)

PlrArmor = PlrArmor - T

PlrHealth = PlrHealth - T2


You'll need to do some playing around with the variables to get the calculations done right, but it's possible in the current system.


The one and only,
~PlystirE~

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 12th Apr 2008 00:26
Nice work mate, I'll get cracking on my V2 shop script, once I get my PC back...


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 12th Apr 2008 00:49
Hold off on that for a little bit, CG. I just got a weapon shop working.

Best thing about this shop is you can use the cursor and not have to allocate keys to choices.

More info to come.


The one and only,
~PlystirE~

Airslide
20
Years of Service
User Offline
Joined: 18th Oct 2004
Location: California
Posted: 12th Apr 2008 02:20 Edited at: 12th Apr 2008 02:20
Ya, that's almost exactly the same:


I never bothered adding in another variable, however. Mainly because I'd rather copy and paste than bother to scroll up and add int tempdamage; Might have been good too with the whole DOS compiler setup thing not liking too much extra stuff thrown in...I actually spent an hour or two when I first starting working on my last wolf mod just going through and removing/simplifying things so I had more databytes to work with at the start.

Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 12th Apr 2008 03:11
Well, you do have 100 variables in my Mod.

Plus, Temp variables are made to be reused specifically for calculations. So for the Armor script above, Temp should actually be given a name since it isn't reusable.

And, yeah, your algorithm IS the same thing as what I wrote, it's just that you multiplied the damage through, so:

damage * (1 - (PlrArmor/500))

would become

damage - (damage*PlrArmor/500)

Just some simple algebra for you.


The one and only,
~PlystirE~

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 12th Apr 2008 11:13
Is the cursor through scripting?

If so, how did you do it? And do you want my Stamina script instead or should I scrap that too?

I've also got a system where the player can carry healthpacks around instead of using them instantly...

But that's easy to do....


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 12th Apr 2008 12:31 Edited at: 12th Apr 2008 13:11
Yes, the cursor is through scripting.

Technically you SHOULD be able to do this with V107 (No mods), however the way to allow the cursor on screen is only by using the "pausegame" command... and unfortunately, that command will DISABLE all active scripts except for the one and only "setuplevel.fpi" script.

If you're clever enough I'm sure you could make your menu in that script, but it'd be unwise to overload with so much stuff.


The way I did it is by modifying the source some more and created... dum dum DUUUUM:

"startmenu"

and

"stopmenu"

scripting actions.

When you "startmenu", it will disable all player input for the game, but the game will not be paused (Meaning you could be getting shot while the menu is open). While the menu is started you will be allowed to move the cursor around on screen. To be able to see the cursor, though, you'll need to "hudshow=pointer". Pointer is a HUD created in the "setuplevel.fpi" and contains the image of the cursor used on all menus. (Pause Menu, Main Menu, etc.)

If you look in the "setuplevel.fpi", at the very bottom, you'll see how they created the Pause Menu, and with these two new commands I made, you'll be able to make your own menus just like that! Except instead of "pausegame" and "resumegame", you'll be using "startmenu" and "stopmenu" respectively.


When I release the next version of my Mod, I'll be sure to include a Demo Game that includes most of the capabilities that come with it.


The one and only,
~PlystirE~

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 12th Apr 2008 17:13
Hmm, so is this in V1.05? of your mod?

If so could you show me some example code, I'm on my PSP at the moment...


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 13th Apr 2008 02:52
Nope, I did this after I released V105.

Here's the code I used for my weapon shop, though:



Basically, I set up three entities in front of the shop (where the player will be standing), and called them "ShopAssaultRifle", "ShopAutoSlug", and "ShopVickers". Then I set them all to spawn when activated.

The only draw-backs that I'm having is the engine keeps moving the weapons around because of them being too close to each other. I found a work-around for this, though. Just make a "PickupWeapon.fpi" script that will pickup your weapon no matter how far away it is, then use that script for your shop weapons.

And attached is a picture of the resulting Shop.

It's a little bland, but I'm no artist.


The one and only,
~PlystirE~

Attachments

Login to view attachments
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 13th Apr 2008 10:02
Can't see screenie, I'm on my PSP and I have to turn images off or it takes an hour to load each page...


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 13th Apr 2008 12:06
Well... basically, it's all green and says "Weapon Shop" at the top, lol. Yup, that's the entire picture in a nutshell.


The one and only,
~PlystirE~

Fuzz
18
Years of Service
User Offline
Joined: 14th Nov 2006
Location: Tasmania, Australia
Posted: 13th Apr 2008 12:33
awesome

Victory Is Imminent
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 13th Apr 2008 20:05
Where'd you get that cool ice-blue numeric by the way?


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 13th Apr 2008 23:35
I made it myself in PSP 7, you like it?

I felt it fit the Armor nicely.

Here's the numeric if anyone would like to use it.


The one and only,
~PlystirE~

Attachments

Login to view attachments
CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 14th Apr 2008 00:19
...sweet, I could use this...

BTW, has anyone tested the armour script, I think I may have found a flaw with it...


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 14th Apr 2008 00:49
Flaw?


The one and only,
~PlystirE~

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 14th Apr 2008 01:03
I think...

It's the plrhealth variable, you have a line that constantly sets it to be equal to the player's health, but are also using it to calculate armour damage if it goes above the player's health, which it can't because it gets reset to be equal to the player`s health...

So perhaps FPSC would interpret it wrong at some points....


Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 14th Apr 2008 01:49
Here is the code as I have it, and have tested:



What's happening here is:

- The PlrHealth variable MUST be assigned to $PH at the end of the script, this is because we want FPSC to handle the player taking damage imediately after we set the PlrHealth variable.

- By the time FPSC gets back to the beginning of the script, the player COULD have taken damage, so we can freely assume that if the FIRST condition of the script is true, then the player has taken damage equal to "$PH-PlrHealth", because PlrHealth is holding the value of the player's health BEFORE the player got hurt and $PH is holding the player's true health value after getting hurt.

- Once we recognise this, we can correctly give the player their health back and take the correct amount away from the player's armor.





The one and only,
~PlystirE~

CoffeeGrunt
17
Years of Service
User Offline
Joined: 5th Oct 2007
Location: England
Posted: 14th Apr 2008 17:37
Ohhhh....ok.....


Login to post a reply

Server time is: 2024-11-24 08:03:51
Your offset time is: 2024-11-24 08:03:51