Author Topic: [OLD] Old OXCE discussion thread  (Read 663745 times)

Offline Vesparco

  • Sergeant
  • **
  • Posts: 49
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #810 on: June 30, 2016, 01:30:35 am »
After some thoughts I come to conclusion that this property should prevent building other buildings.
If you list some base functionality on forbid list then when this building is build you can't build any building that provide that functionality.
In case if you already have that functionality in base, you can't place building with it on forbid list.

One point to avoid "exploits" is that this should be considered even with the facility "being build", otherwise you could potentially chain the constructions and surpass the limitation. I imagine this complicates things  ???

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #811 on: June 30, 2016, 06:59:17 pm »
One point to avoid "exploits" is that this should be considered even with the facility "being build", otherwise you could potentially chain the constructions and surpass the limitation. I imagine this complicates things  ???
In case of OXC "harder" is test for finished buildings :> From game engine you create new thing when you place it on grid. Its simply deactivated until construction is finished.

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #812 on: July 01, 2016, 09:29:23 pm »
I prepare short tutorial for OXCE scripts. Before expanding it more I would like hear some feedback.
Is it easy to understand? What you would want be more elaborate? Anything is missing?



Tutorial of using scripts

List of available function and vales in script is available in log file with debug mode enabled.

Assume you want add reaction to melee attacks.
Then you can do it in two ways:
Code: [Select]
#script defined per item
items:
  - type: STR_WEAPON_WITH_MELEE
    scripts:
      reactionWeaponAction: |
        if eq action action_hit; #when you hit with this weapon enemy can react to it.
          return 100;
        else;
          return reaction_chance;
        end;
#script defined for all items
extended:
  scripts:
    offset: 1.0
    reactionWeaponAction: |
      if eq action action_hit; #all items used as melee will case enemies to react.
        return 100;
      else;
        return reaction_chance; #return old reaction chance
      end;

every thing after `#` is comments, exactly same as in yaml.
each operation need end with `;`.
`if` is condition operation. It will control what code will be executed.
Code: [Select]
someScriptCode: |
  if OPERATION A B; #OPERATION can be: `lt` - less, `le` - less equal, `gt` - greater, `ge` - greater equal, `eq` - equal, `neq` - not equal
    #some code 1
  else OPERATION A B; #`else` can have same condition as first `if`.
    #some code 2
  else OPERATION A B; #you can repeat `else` with test multiple times.
    #some code 3
  else;
    #final case, can be skipped.
  end;


`reaction_chance` in `reactionWeaponAction` is current percent chance of enemy to react. You can modifi it and return it:
Code: [Select]
reactionWeaponAction: |
  var int shade; #definition of new variable that can be used by script.
  BattleUnit.getTileShade action_unit shade; #getting shade of tile that unit is standing on.
  if gt shade 10; #shade of tile is greater than 10.
    div reaction_chance 2; #now is two time less chance to react.
  end;
  div distance 16; #distance between units is in vexels, dividing by 16 give us distance in tiles.
  if gt distance 10; #distance is greater than 10 tiles.
    sub reaction_chance 30; #subtracting
  end;
  return reaction_chance;
Now if acting unit is in dark place (unit lighting count!) and 10 tiles away, then enemy units will have only 20% chance to
react (20 = 100/2 - 30).

We can define variables, each variable have fixed type and can't store anything else:
Code: [Select]
someScriptCode: |
  var int var_name;
`var` mean that we create new variable. `int` is type of it, in this case this is number.
`var_name` is name of variable. New variable start with empty value, in case of `int` this is 0.
You can set different value when you define it:
Code: [Select]
someScriptCode: |
  var int answer_to_every_thing 42; #42 is starting value of this variable.
  set answer_to_every_thing 13; #it was 42 but now is 13.
We have other types than `int`. They are pointers to object from OpenXcom engine.
Code: [Select]
someScriptCode: |
  var int unit_size;
  var ptr BattleUnit unit; #read only pointer to battle unit, this mean unit that you can see in battlescape.
  var ptr RuleArmor unit_armor; #read only pointer to armor that unit can use and what is defined in `armors` node.
  set unit action_unit; #now `unit` and `action_unit` represents same unit.
  BattleUnit.getRuleArmor unit unit_armor; #we get pointer to armor of that unit.
  unit.getRuleArmor unit_armor; #shortcut of previous operation.
  unit_armor.getSize unit_size; #now we have size of unit armor in variable `unit_size`.

Offline ivandogovich

  • Commander
  • *****
  • Posts: 2381
  • X-Com Afficionado
    • View Profile
    • Ivan Dogovich Youtube
Re: [EXE] OpenXcom Extended
« Reply #813 on: July 02, 2016, 04:45:27 am »
Thanks for the tutorials on scripting, Yankes!  I do have a question about the ability to do alternate graphics for corpses....

Let me try to think how this would be handled....

Say we want to know from looking at them which were alive (stunned), which were wounded (bleeding), and which were dead. 

Could we do this on mouse over?  say hover over a corpse floorOb and if its bleeding, it Pops text "wounded" (from a defined STR_WOUNDED definition) or "Stunned" etc,?   Or maybe by placing another graphic over it?   "ZZzz" for stunned "++++" for wounded, and nothing for dead, etc.

At a minimum could a system of multiple different graphic versions for each item would similar to the altBigsprite that I'm currently using in the Alt_Corpses mod for Piratez?   If so, how would that work, could you use the file name convention to define it, ...

Here corpses (bigObs) are dead (b), stunned (bs), and wounded (bw).
Code: [Select]
Resources/Corpses/PIR_1_b.png
Resources/Corpses/PIR_1_bs.png
Resources/Corpses/PIR_1_bw.png

Alternately could we do some of that weird glowy stuff for the floor objects, ie, flash them blue glow for stunned, red glow for wounded, or even pulse an outline around them? :)

I hope this isn't too much of a ramble, and thanks for the amazing work externalizing these functions.

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #814 on: July 02, 2016, 05:19:48 pm »
I think in future I could add option for that script could react to if current tile is selected by mouse.
Adding text is impossible and for long time will be. You can only change sprites.

I'm now working on implementing example scripts that will change corpse ground image based on unit state (stunned/wounded/dead).
Whiled doing that I find couple small bugs and missing features needed to do it. In beginning of next week I will release new version that fix that problems and allow crating fully functioning corpse replacer. With that I will post example script that will implements this functionality.

Offline ivandogovich

  • Commander
  • *****
  • Posts: 2381
  • X-Com Afficionado
    • View Profile
    • Ivan Dogovich Youtube
Re: [EXE] OpenXcom Extended
« Reply #815 on: July 03, 2016, 02:37:01 am »
Hey Yankes,  I was curious if the capability from the nightlies to set the number of waypoints for a guided missiles made it into your latest version of 3.0?

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #816 on: July 03, 2016, 12:26:39 pm »
Not yet. I will merge recent changes from master at end of this month or beginning of next.

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 8598
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #817 on: July 03, 2016, 07:19:37 pm »
I am getting following errors when trying to compile oxce 3.0 in visual studiio 2015... any idea what's wrong?

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #818 on: July 03, 2016, 09:16:49 pm »
I am getting following errors when trying to compile oxce 3.0 in visual studiio 2015... any idea what's wrong?
sh**, probably bug in VS. I will think how I could avoid it.

[ps]
Ok I manage reproduce it on web compiler and fix it: https://rextester.com/DQH12645
Problem is that VS can't handle static functions (and nested types too) when template pack is expanded.
One way to work around is access it indirectly (`helper` function from that link).
Tomorrow I will prepare special commit that will fix it.
« Last Edit: July 04, 2016, 02:25:46 am by Yankes »

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 8598
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #819 on: July 04, 2016, 01:49:02 pm »
I have upgraded my piratez campaign to OXCE 3.0 (without +) and there are some glitches:
1. Clicking on "New project" takes about 30 seconds...
2. When I go into craft and inventory screen to equip my soldiers... after clicking OK to return back... I get crash to desktop

This was just 5 minutes of testing, I'll do more tests in the evening and report them in this post...

EDIT1:
3. when I transfer a soldier from one base to another, after arrival the game seems to get in an endless loop and stops responding
4. actually just letting the time pass on 1hour or 1day results in application hanging quite soon (with 100% CPU usage)
« Last Edit: July 04, 2016, 04:21:10 pm by Meridian »

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #820 on: July 04, 2016, 06:16:02 pm »
1: confirmed.
2 - 4: at leas on my exe and some old piratez version I can't get it. Did you do it on exe compiled by my or yourself?

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 8598
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #821 on: July 04, 2016, 06:50:38 pm »
1: confirmed.
2 - 4: at leas on my exe and some old piratez version I can't get it. Did you do it on exe compiled by my or yourself?

On your EXE from the first post, mediafire link.

2/ happens only during equiping in the base, not during the mission... happens also with no mods at all, just go to skyranger, click inventory and click OK... see attached screenshot

Code: [Select]
[04-07-2016 17:46:52] [INFO] OpenXcom started successfully!
[04-07-2016 17:47:07] [ERROR] Surface MAN_0M50.SPK not found
[04-07-2016 17:47:07] [ERROR] Surface MAN_0M18.SPK not found
[04-07-2016 17:47:09] [FATAL] A fatal error has occurred: code 0xc0000005
[04-07-2016 17:47:09] [FATAL] SymFromAddr failed: 487
[04-07-2016 17:47:09] [FATAL] StackWalk64 failed: 299
[04-07-2016 17:47:09] [FATAL] Crash dump generated at c:\!private\OpenXcom_XPiratez 0.99\user\04-07-2016_17-47-09.dmp
[04-07-2016 17:47:16] [FATAL] OpenXcom has crashed: code 0xc0000005
Extra information has been saved to openxcom.log.
Please report this to the developers.

3/ and 4/ are probably the same issue... game just stops responding after some time... this may be related to my game, also attached... I will try to narrow it down, but it's hard without being able to run it from VS
« Last Edit: July 04, 2016, 06:52:54 pm by Meridian »

Online Meridian

  • Global Moderator
  • Commander
  • ***
  • Posts: 8598
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #822 on: July 04, 2016, 07:09:29 pm »
5/ Also, I don't see any games I save in piratez using this new exe.
They are on the harddisk... but not in the Load window :(

Looks like the save is missing the "- piratez" in the "mods:" section... all other mods are there, just the main mod not.

Offline Yankes

  • Moderator
  • Commander
  • ***
  • Posts: 3194
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #823 on: July 04, 2016, 09:01:55 pm »
https://github.com/Yankes/OpenXcom/commit/dcd84b09cd25a3090e361d8240c9e8251e5c5f29
This commit should fix VS bug. Meantime I'm working on rest of bugs.

Offline clownagent

  • Colonel
  • ****
  • Posts: 380
    • View Profile
Re: [EXE] OpenXcom Extended
« Reply #824 on: July 04, 2016, 09:17:05 pm »
5/ Also, I don't see any games I save in piratez using this new exe.
They are on the harddisk... but not in the Load window :(

Looks like the save is missing the "- piratez" in the "mods:" section... all other mods are there, just the main mod not.


Some time ago a similar bug was fixed in the main openxcom branch.
https://github.com/SupSuper/OpenXcom/commit/ab552fb0aa7b16ef29f3c178bddcbb0b9546903b