FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Can a unit fire multiple weapons each turn?  (Read 4300 times)

wild_qwerty

  • Newbie
  • Posts: 6
    • View Profile
Can a unit fire multiple weapons each turn?
« on: September 03, 2008, 06:05:52 pm »

Is it possible to make a game where:

1) Each unit has multiple weapons that each get to fire each turn (or can be turned on or off to save ammo and reduce heat)
2) Weapons can be destroyed
3) Limbs can be crippled
4) Provide a 'heat scale', that goes up with each fired weapon but drops for wokring heat sink.

I've had a long term goal/pipe dream of making a battletech game much like the very first battletech computer game (Crescent Hawks Inception) which contained rpg elements, the player could walk around outside of mech etc...

To be honest this wouldnt have to a turned based game either it could be real time quite easily, is it possible for FIFE to do both or either  real time and/or turn based?
Logged

mvBarracuda

  • Administrator
  • Sr. Member
  • *
  • Posts: 411
    • View Profile
Re: Can a unit fire multiple weapons each turn?
« Reply #1 on: September 03, 2008, 06:54:18 pm »

You would write the game specific code in Python and I think all of these features can be implemented by a programmer. FIFE is not restricted to one specific game type but that also means you'll end up writing a lot of code on your own.
Logged

wild_qwerty

  • Newbie
  • Posts: 6
    • View Profile
Re: Can a unit fire multiple weapons each turn?
« Reply #2 on: September 03, 2008, 08:26:36 pm »

So I wouldn't need to edit the main C code? (I have more chance of winning lotto that than that happening).

Do the scripts have to be compiled like in fallout or can I just leave them as text based and edit them with notepad for example?
Logged

chewie

  • Developer
  • Full Member
  • *
  • Posts: 123
    • View Profile
    • zero-projekt.net
Re: Can a unit fire multiple weapons each turn?
« Reply #3 on: September 04, 2008, 08:54:24 am »

Moin wild_qwerty :)

No, you don't have to touch any c++ code to make this working.

You just need

 - to provide the necessary animation files (pngs, organized via an xml file)
 - a python class to manage your "character" / mech (like agent.py and hero.py in rio de hola client)

For a basic prototype I'd suggest a random function to let the mech decide which weapon should be fired (= which animation should be played), later the AI or the player should be able to control this.

A small example:

Random says "fire right rail gun". Adopting the current python code form rio de hola, you can make this happen with this line:


Code: [Select]
"""
    syntax: self.agent.act(<animation name>, <facing location>, <looping>)

    <animation name>: defined via xml files
    <facing location>: provided by the engine, just call getFacingLocation() method
    <looping>: loop the animation or not
"""

self.agent.act("animation_right_railgun_shoot", self.agent.getFacingLocation, False)


After the animation ends, the agent uses the ActionListener to call OnActionFinished to get further instructions.

If you implement a state machine (like the rio de hola demo does) you can ask which state the agent has. If you set STATE = Shoot when firing the railgun, you also can make a fancy recharge ani for the railgun which is seperated from the shot itself:

Code: [Select]

def onInstanceActionFinished(self, instance, action):
    if self.STATE == "Shoot":
        self.reload()
        return

    if self.STATE == "Reload":
        self.idle()
        return

def shoot(self):
    self.STATE = "Shoot"
    self.agent.act("animation_right_railgun_shoot", self.agent.getFacingLocation, False)

def reload(self):
    self.STATE = "Reload"
    self.agent.act("animation_right_railgun_reload", self.agent.getFacingLocation, False)

def idle(self):
    self.STATE = "Idle"
    self.agent.act("idle", self.agent.getFacingLocation, False)


Of course, this is a very simple example - there should be some logic to handle the different weapons, ammo consumption etc...

The python scripts are compiled (by python itself) before execution, but you always can edit the sources. Python takes care to compile the newest version of the script.

btw. Notepad is kind of a no-go if you seriously want to work with scripts. I personally prefer geany (a light weight IDE for both linux and windows)

Quote
2) Weapons can be destroyed
3) Limbs can be crippled
4) Provide a 'heat scale', that goes up with each fired weapon but drops for wokring heat sink.

These are things which have "nothing" to do with FIFE - so to say. Your weapons statistics / mech health life within your python code. The engine don't want to know them.  ;D
FIFE "only" loads your maps, plays your sounds and changes the appearance of your map objects. So if a locker door opens, you only tell FIFE to play the "open animation", if your mech moves, you tell FIFE to play "move mech" for the current degree.

An example how you can implement the stuff you mentioned:
- Weapon fired 10 times -> weapon durabilty - 1 %
- If weapon durability = 0 %, weapon is destroyed

Same goes to crippled legs etc. You just give a feedback to the player by telling FIFE to play e. g. an animation which shows the weapon exploding, or let the mech limping from now on because of the damaged leg.

The heat status of the weapon is basically the same - you only read out the current status and visualize it via the GUI of FIFE. (either with numbers or an image)
« Last Edit: September 04, 2008, 09:20:35 am by chewie »
Logged

mvBarracuda

  • Administrator
  • Sr. Member
  • *
  • Posts: 411
    • View Profile
Re: Can a unit fire multiple weapons each turn?
« Reply #4 on: September 10, 2008, 07:46:19 am »

So I wouldn't need to edit the main C code? (I have more chance of winning lotto that than that happening).

Do the scripts have to be compiled like in fallout or can I just leave them as text based and edit them with notepad for example?
The engine core is written in C++ and I don't think that you'll need to modify it for such a game. If there ever the need arises and you can't find a way to implement the feature in Python, get in contact with the our programmers and we'll consider to put the functionality into the FIFE core in case it would be useful for other users of the engine as well.

One word of warning though: the term "script" is a bit misleading in this case. Python is a full-featured programming though its learning curve is not as high compared to other languages that rely on manual memory management. Furthermore Python is a rather sane language design-wise and doesn't feature many dark corners (undefined behaviour) that you might hit in C++.

You can let scripters tweak your game later but at first you'll need a Python programmer on your team who comes up with solid framework code for you game. FIFE offers basically Python bindings to the FIFE C++ core but the disadvantage of the flexibility of the engine is that you'll end up writing a lot of game-specific code in Python as FIFE doesn't come with that code to be not limited to a certain type of game.

Last but not least: good luck to your project.
Logged

shevegen

  • Newbie
  • Posts: 16
    • View Profile
Re: Can a unit fire multiple weapons each turn?
« Reply #5 on: September 12, 2008, 04:06:27 pm »

I actually think Python is quite easy. I am using Ruby since 5 years, but I am still fine with well written python code (I didnt write a lot of python so I will have to learn more in order to create something FIFE related + Python), but if I compare it to C++ or C, I really think both ruby and python are SUPER EASY. :-)

If I managed to learn,
everyone can!
Logged