1
Work In Progress / Re: scripting
« on: March 21, 2012, 09:52:37 pm »
I have merged the master branch in swigX and rebuild the windows installer: https://gchevallereau.net/guillaume/openxcom/OpenXcom_python-0.3-win32_2012_03_18.zip
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Must be a fault in the ruleset data, soon you will be able put the sales price as high as you want by editing the ruleset file.It's just a development leftover. When doing manufacturing, I made some tests with selling price and I didn't fix all ruleset settings when finished. For example, just try to manufacture a laser rifle.
In git should exist groff and xml. But, of course end user need only groff file. Just keep it up-to-date after each change made in xml-file.I disagree. There should be only the XML file:
class MyState : public State
{
};
class MyStateInfo : public StateInfo
{
};
REGISTER_CREATOR("MyStateId", MyStateInfo); https:// automatically append it to the StateFactory
State * s = _game->getStateFactory ()->createState("OPENXCOM_RESEARCHSTATE",
args);
This downside, is that when creating a state we usually need to pass some arguments. As we have no base class for thing in Ruleset or Savegame, I have used a little hack. All arguments are void * pointers. If it's not really the cleanest way to do it, it actually work great.- name: STR_PLASMA_RIFLE
cost: 700
prereqItems:
- STR_PLASMA_RIFLE:
- needed: 3
- destroyed: true
prereqResearch:
[]
unlock:
[]
import OpenXcom
game = OpenXcom.getGame
savedGame = game.getSavedGame()
import OpenXcom
savedGame = OpenXcom.getGame().getSavedGame()
savedGame.setFunds(0)
# Or get more money. But this cheating. This is bad
savedGame.setFunds(99999999)
import OpenXcom
# Start a battlescape terror mission
g = OpenXcom.getGame()
sg = g.getSavedGame()
sbg = OpenXcom.SavedBattleGame()
bases = sg.getBases()
base = bases.front()
crafts = base.getCrafts()
craft = crafts.front()
sg.setBattleGame(sbg)
bg = OpenXcom.BattlescapeGenerator(g)
bg.setMissionType(OpenXcom.MISS_TERROR)
bg.setWorldTexture(1)
bg.setWorldShade(0)
bg.setCraft(craft)
bg.run()
battlegame = sg.getBattleGame()
battlegame.resetUnitTiles()
battlescape = OpenXcom.BattlescapeState(g)
g.pushState(battlescape)
But i'm not sure about python. What about lua? It's popular in gamesIt should be doable with lua either. I choosed python because this the one i know. But the way it's done, it's shoud be easy to get lua support.
What was already said here:Did not see that discussion before. Ruleset are fine, but i don't think it's enough. There are case where you need programming language In the referenced discussion, someone suggested a teleporting device. It's not something you can do only with ruleset. I'm sure that you can easily find other thing where it can be useful.
https://openxcom.org/forum/index.php/topic,11
And that discussion did lead to having all hardcoded data in external YAML files. Which imho is already a big step forward.
Also, you will see that modders always come up with things that will not be able to be done with scripting alone. Code changes are always needed. Unless you have a very generic game engine, and really move all logic to scripting. But then I think we can start all over again... but I can be wrong, because honestly I don't have any experience with either python or lua.
You could move game logic from c++ to scrips partially, for example battlescape ai first, then geoscape ai, etc.There are little points in moving already implemented stuff to another language. It's much more interresting for new stuff.
Anyway, that stuff should wait after 1.0. Adding it now to official repo could slow project too much. But IMHO it's good to experimentIt's exactly how i see it. There are a lot's of stuff which are much more important than scripting at the moment(ruleset for instance). But when we will need it, we will already have something to experiment with. It can also be interresting to see what will need to be modified later to help moddability.
if (part < 0)
{
part = 0;
}
You actually load the weapon with an ammo item of a new class "NoAmmoItem"?Yes it seems to be the easiest way.
Also did you try what happens if you want to unload the ammo out of a laser weapon?No, it was just a quick hack to have laser weapons working in the battlescape. But it should be easy to forbid unload if weapons has unlimmited ammo