Home   Help Search Login Register  

Author Topic: Config editing via scripts ?  (Read 1011 times)

0 Members and 1 Guest are viewing this topic.

Offline Roni

  • Members
  • *
  • Play the Game !
Config editing via scripts ?
« on: 09 Oct 2003, 02:23:25 »
I've been playing around with the scripts a LOT lately  :) :P :) and came up with a neat idea.  More than likely it's been suggested before but just in case it hasn't here goes.   :beat:

One of the neat things that you can do with scripts is continuously record the value of some variable (say - health, ammo, velocity, player position etc) and with the appropriate delay set up a check for any change in that variable.  Then all you have to do is code in a subroutine that only works when a specified change occurs.

For example - how about this (all coding in outline form only) -

#loop

<_CurrentHealth = players health>
~0.3
<if _CurrentHealth >= player's health then goto "loop"

; note - the short delay means that if the player is wounded in the interim then the "event handler", below, kicks in

<force the player prone>
<disable player controls>
<play sound "Splurcch">
<titlecut "BLACK OUT", 0.5 / titlecut "BLACK IN", 10>
<enable players controls>

goto "loop"

What this script will do is that any time a player character takes damage he will be forced prone and blacked out for about 10 seconds.  You can tweak the script so that the damage taken by the player must be above a certain amount (say, _CurrentHealth - dammage player > 0.3) for the effect to kick in so that only "big" hits will incapacitate the player.

Once the player comes to he will be able to continue the fight.  And of course the added sound effect can be anything that you want it to be (cries for help, mother, sickening squishy effects etc).

Or how about this.  Same as above, but at the start of the script set a variable (say) _HasLimp to FALSE

Then , if the player takes a HIGH amount of damage (so that say _CurrentHealth - dammage player > 0.3) then the script will do all of the above PLUS -

_HasLimp = True

; the following will be added to the start of the loop, above

<getDir Player>
< if velocity player > 0 && _HasLimp = TRUE then change player direction (L or R) by a small amount>


What this will do is "pull" the character to one side every time he moves.  To compensate the player will have to move slowly and keep changing direction to the opposite side of the pull.  In other words - "limp"


Other ideas.

Now that the principle has been defined (set script to check for a change to a variable) the possibilities are endless.  Try these -

You could set a script that checks the players ammo so that every time a bullet is fired (change in ammo held) your own sound effect is played on top of the existing sound.  Might get messy or even add lag but if timed right you should be able to beef up the firing sound of any weapon.

You could set a script so that once a vehicle's speed goes above a certain point a warning tone sounds.  Or play a warning sound only if an aircraft's velocity is above a certain limit DOWN, while the vehicle is below a certain height ("Pull up !  BEEP BEEP !  Pull up !  BEEP BEEP !").

You could check a vehicles damage and velocity, and if you try to drive a heavily damaged vehicle then it will either a) periodically fail to start, b) make a terrible noise, c) emit smoke, d) pull to one side (see "Limp", above"), e) stutter in speed, f) blow up (not literally - just make smoke and/or burst into flame and set damage to 1).


That's about it for now.  This idea may be too generic to be of much use but I just thought that I should share it just in case it hadn't been done.

I was working on adding customised respawns and customised graphic damage to a scenario (random factor each tme player is hit - black out, limp, hands go shaky, character goes dizzy etc) and I realised that this concept can be generalised to change the in game effect of just about anything (within reason).

Comments, suggestions . . . ?

 :) ;) :D ;D >:( :( :o 8) ??? ::) :P :-[ :-X :-\ :-*
« Last Edit: 09 Oct 2003, 02:26:55 by Roni »

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Config editing via scripts ?
« Reply #1 on: 21 Nov 2003, 12:13:59 »
Roni,

I made a script similar to your first idea once. Basically, the player would suffer momentary blackouts depending on how hurt he was. If he was badly injured, he would fall down unconcious for a few seconds. It works pretty well, and makes it darn annoying to be injured. The limping idea is something I've never heard of/thought about though, and it sounds pretty interesting...


Quote
You could set a script that checks the players ammo so that every time a bullet is fired (change in ammo held) your own sound effect is played on top of the existing sound.  Might get messy or even add lag but if timed right you should be able to beef up the firing sound of any weapon.

It would work better using an eventhandler.

Quote
Or play a warning sound only if an aircraft's velocity is above a certain limit DOWN, while the vehicle is below a certain height ("Pull up !  BEEP BEEP !  Pull up !  BEEP BEEP !").

Try TakeOffTim's flight supervision systems script. They do that and a lot more.

Quote
You could check a vehicles damage and velocity, and if you try to drive a heavily damaged vehicle then it will either a) periodically fail to start, b) make a terrible noise, c) emit smoke, d) pull to one side (see "Limp", above"), e) stutter in speed, f) blow up (not literally - just make smoke and/or burst into flame and set damage to 1).

I think it is hard enough as is to drive a damaged vehicle; especially cars and the like. I'm not sure you need to make it much harder.

Okay, I've commented on your ideas, and now I have a question:

How is this 'config editing'?!? Maybe I'm missing something here...... :-X
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Config editing via scripts ?
« Reply #2 on: 25 Nov 2003, 03:38:15 »
Hi General

Sorry about the confusion in the header - just showing my own ignorance.

I have read about various modders creating new addons by changing configs and so on and asumed that each addon has a number of associated files all wrapped up in that little pbo - a model (.p3v), a set of sound effects (.ogg) and a set of game characteristics (.cpp) ?  Am I right ?

My understanding is that the way the modder tweaks the cpp affects the way that the addon behaves, such as who it shoots, who it runs from etc.  Again - not being an addon modder I wouldn't know.

My idea was to change the way that various units behave not by changing the cpp but by use of scripts.  To give one last example - you could double the speed of a vehicle by simply doubling its velocity vector whenever it moved (easier with a getVelocity command then with getPos and trigonometry I can tell you !).

I am working on a simple mission based on the movie "The Beast of War" (I think it was recently re-released as just "The Beast").  A bunch of Afghan loonies with a single RPG chase a lost Soviet T-55 through the wilds of Afghanistan.  (BTW - Great movie, see it if you can).

I have written a number of scripts that basically tear the payers and the tank apart as time pases.  The scripts continuously check the positions of each player and vehicle and increase damage and reduce fuel based on how fast they move.  I've also written a time dilation script - sprint for too long in the Afghan sun and you could end up killing yourself !

I am currently writing Repair and Revive scripts so that the tank crew and/or the Afghans can set up camp and gain back their lost damage or health.  Combined with a group respawn script for the Afghans it should be pretty sweet !

If you're interested I could post some of these scripts to the Beta board when I'm finished.

Cheers



RD

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Config editing via scripts ?
« Reply #3 on: 25 Nov 2003, 06:58:57 »
Quote
My understanding is that the way the modder tweaks the cpp affects the way that the addon behaves, such as who it shoots, who it runs from etc.  Again - not being an addon modder I wouldn't know.

I don't know much about addon editing either, but I believe that you can only adjust a few behaviors via the config. Like you said, what a weapon can shoot at, which units are considered higher priority to kill, etc. Speed, turning radius, and some other aspects. But the basic AI remains unchanged, and the only way to "teak" that is via scripts, as you have suggested.

Take a look in the editors depot, and you will see some examples of this, such as Bremmer's AI script. There are quite a few scripts out there that change a unit's behaviour, in one way or another. Check them out to get some ideas, and to see how some things can be done. (Actually, that's a good thing to do with ANY script!) Unfortunately, most of those scripts do seem to be pretty similar; scripts such as your (and mine :P) enhanced damage script (limping, blackouts, etc) seem to be much rarer than the common "AI" script (i.e. call-for-reinforcements script).

And your mission does sound interesting. I'd like to see how all those different effects fit together (if you can in fact pull it off!).
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Roni

  • Members
  • *
  • Play the Game !
Re:Config editing via scripts ?
« Reply #4 on: 25 Nov 2003, 07:30:23 »
Hi General

Actually, I finished the vehicle fuel burn script only to end up deleting it somehow !  I will find it or rebuild it  - it's just kind of annoying at the moment !  >:(  ???  

The big problem is that (there isn't a way || I don't know a way) to check whether a unit is sprinting, walking or running.  I ended up making a script that checked the unit's change in position every 10 seconds and converted this to an absolute change of position number.  I then reduced the unit's fuel level by a very small amount based on the CUBE of this number.

The idea of the cubing is to make going faster burn more fuel.  I initially tried squaring the units movement but this didn't give a big enough incentive to keep your speed down.  Eventually I had it set so that if you poked along to the next fuel depot you would be okay - you just had to remember that there are a dozen Afghanis out there shadowing your very move !

Of course I also had to trial a whole bunch of different values to divide the movement factor by - at one stage I was playing around with a biplane that ran out of fuel in around 10 seconds -  launch off cliff top, climb, run out of fuel, try (and fail) to glide into a landing next to a fuel depot.  Lots of irrelevent and mindless fun !   ;D

The "player entropy" script will be almost exactly the same - the further the player runs the faster his damage will go up.  Of course this shouldn't apply to player's in vehicles (or should be greatly reduced) and will probably be reduced at night.  All reasonably easy to code.    :P :-\


I've written a query in another forum to find out if it's possible to create a "jerrycan" object so that the players can transfer fuel from one vehicle to another.  What I want is for the Soviet players and vehicles to gradually fall apart and run out of fuel / ammo / brake fluid until they're completely stuffed.  Then the question will be - should I try to get ONE tank up and running or bail out of all of them and try to run the remaining 5k on foot ?  See comment above about shadowing Afghanis !   :noo: :gunman: :help:

I will post the various bits (or even the whole shooting match) oince its finished.

See ya round.



Roni