Commit graph

81 commits

Author SHA1 Message Date
Christoph Oelckers
3dd323ac0d - scriptified the Flechette. Not fully tested yet.
- fixed issues with the refactoring of the recent commits. This one starts again.
- added builtins for TextureID.

Note about builtins: Currently they are just hacked into the compiler backend. They really should be made part of the respective types to keep matters clean and allow more widespread use of builtins to create more efficient code.
2016-11-27 16:24:33 +01:00
Christoph Oelckers
b10ffb5133 - exported a few more functions.
- refactored the ModifyDamage interface to be more scripting friendly.

In general it should be avoided having to call directly into chained inventory functions because they are very problematic and prone to errors. So this got wrapped into a single handler (on AActor, not AInventory!) which will later make it easier to refactor the parameters of ModifyDamage to work better for scripting and avoid the chaining.
2016-11-27 16:24:32 +01:00
Christoph Oelckers
096c51d546 - changed AInventory::HandlePickup to work iteratively instead of recursively.
Two reasons for this:

1. if this has to be routed through the VM each recursion will cost 1000 bytes of stack space which simply is not good.
2. having the virtual function only care about the item itself but not the entire inventory chain is a lot less error prone for scripting.

Since the scripting interface needs a separate caller function anyway this seemed like a good time to change it. The same will be done for the other chained inventory handlers as well.
2016-11-27 16:24:31 +01:00
Christoph Oelckers
ab03b016e9 - scriptified the IceGuy. 2016-11-27 00:41:06 +01:00
Christoph Oelckers
69d4d36429 - scriptified ArtiHealingRadius.
- allow switch/case with names.
- fixed break jump target handling for switch/case. This only worked when the break was in the outermost compound statement, those in inner ones were missed.
2016-11-27 00:18:07 +01:00
Christoph Oelckers
796c262285 - scriptified the Quietus. 2016-11-26 23:05:16 +01:00
Christoph Oelckers
80f233cd0b - scriptified the fighter's fist. 2016-11-26 22:25:49 +01:00
Christoph Oelckers
997e4a2ac4 - scriptified the remaining Cleric weapons. 2016-11-26 19:23:22 +01:00
Christoph Oelckers
177aa6ec42 - converted half of ClericHoly. (Making a commit before starting on the more complex stuff.)
- added a 'constructor' for color values.
2016-11-26 13:18:48 +01:00
Christoph Oelckers
4e802652c7 - scriptified ArtiBlastRadius. 2016-11-26 09:51:14 +01:00
Christoph Oelckers
7385cd70c0 - scriptified the Minotaur.
Interesting tidbit: The damage calculation in P_MinotaurSlam had been incorrect for the Heretic version since the friendly Hexen Dark Servant was added, but nobody ever noticed in 14 years...
2016-11-26 01:14:47 +01:00
Christoph Oelckers
6e1c6c4b33 - scriptified ArtiTeleport.
- shortened ArtiEgg and ArtiPork's use state to a single function.
2016-11-25 19:52:35 +01:00
Christoph Oelckers
8dba322775 - scriptified Heretic's Skull Rod.
- Took the opportunity and fixed the logic for the Skull Rod's rain spawner. The old code which was part of the 3D floor submission was unable to work with portals at all. The new approach no longer tries to hide the dead projectile in the ceiling, it leaves it where it is and changes a few flags, so that its z-position can be used as reference to get the actual ceiling. This works for line portals, but for sector portals still requires some changes to sector_t::NextHighestCeilingAt to work, but at least this can be made to work unlike the old code.
- added names for the player-related translations to A_SetTranslation.
- fixed: Failure to resolve a function argument was checked for, too late.
- made the parameter for A_SetTranslation a name instead of a string, because it is more efficient. We do not need full strings here.
2016-11-25 16:05:03 +01:00
Christoph Oelckers
9ae272d753 - scriptified Heretic's blaster.
- scriptified all Effect functions of Fastprojectile's children
- implemented access to class meta data.
- added a VM instruction to retrieve the class metadata, to eliminate the overhead of the function call that would otherwise be needed.
- made GetClass() a builtin so that it can use the new instruction

Important note about this commit: Scriptifying CFlameMissile::Effect revealed a problem with the virtual function interface: In order to work, this needs to be explicitly enabled for each single native class that may be used as a base for a scripted class. Needless to say, this will end up way too much work, as there are over 100 native classes, excluding those which will be scriptified. But in order to fix the problem this partially broken state needs to be committed first.
2016-11-24 20:02:44 +01:00
Christoph Oelckers
3f5bf88d69 - scriptified Heretic's mace.
- fixed: FxAssignSelf did not the correct number of registers for vector operations.
- fixed a few asserts in vector2 instructions.
- turned the virtual AActor::HitFloor method into a flag MF7_SMASHABLE. The only use of this function was to kill Hexen's pottery when they hit the floor, and this looks like something that can be exposed to modders less clumsily.
2016-11-24 13:45:43 +01:00
Christoph Oelckers
3e890d182b - scriptified D'Sparil.
- added retrieval of defaults from an actor pointer.
2016-11-24 01:23:35 +01:00
Christoph Oelckers
5e67cf79d3 - scriptified the Ironlich. 2016-11-23 21:26:59 +01:00
Christoph Oelckers
1a20a5b999 - scriptified A_PainShootSkull which was the last remaining bit in g_doom, so this directory is gone now. 2016-11-23 19:47:09 +01:00
Christoph Oelckers
980c986305 - allow defining native fields through scripts. Internally this only requires exporting the address, but not the entire field.
- added new VARF_Transient flag so that the decision whether to serialize a field does not depend solely on its native status. It may actually make a lot of sense to use the auto-serializer for native fields, too, as this would eliminate a lot of maintenance code.
- defined (u)int8/16 as aliases to the byte and short types (Can't we not just get rid of this naming convention already...?)
- exporting the fields of Actor revealed a few name clashes between them and some global types, so Actor.Sector was renamed to CurSector and Actor.Inventory was renamed to Actor.Inv.
2016-11-22 19:20:31 +01:00
Christoph Oelckers
bbb0778fd4 - scriptified Chicken and Pig - not tested yet, because other things have priority. 2016-11-22 12:21:55 +01:00
Christoph Oelckers
135cfcf016 - implemented State as an actual native struct, so that its fields can be accessed from scripts.
- refactored state bitfield members into a flag word because the address of a bitfield cannot be taken, making such variables inaccessible to scripts.
- actually use PNativeStruct for representing native structs defined in a script.
2016-11-21 21:34:34 +01:00
Christoph Oelckers
360436c201 - scriptified the scripted marines.
- fixed symbol name generation for native functions.
- moved PrintableName to VMFunction so that native functions also have this information.
2016-11-21 19:09:58 +01:00
Christoph Oelckers
97763b5a2b - added scriptable virtual overrides for PostBeginPlay, Tick, BeginPlay, Activate and Deactivate. 2016-11-21 14:59:17 +01:00
Christoph Oelckers
7c122d03e9 - renamed all instances of 'float' parameters to 'double', so that the Float32 type can be made usable for structs. 2016-11-21 13:04:27 +01:00
Christoph Oelckers
159f09105e - used static constant arrays to shorten some code. 2016-11-20 18:34:27 +01:00
Christoph Oelckers
bb25c5faaa - scriptified the remaining Doom weapon code.
- implemented method calls from struct instances.
- optimized disassembly of VM call instructions to print the function's name at the end where it is more visible and does not need to be truncated. Also use the printable name for script functions here.
2016-11-20 12:27:26 +01:00
Christoph Oelckers
fdab994fcb - scriptified the Rocket launcher. 2016-11-20 01:11:01 +01:00
Christoph Oelckers
af34d82888 - scriptified A_Saw.
- implemented multiple-return-value assignment. Due to some grammar conflicts the originally intended Lua-inspired syntax of 'a, b = Function()' could not be done, so it's '[a, b] = Function()'
2016-11-20 00:25:38 +01:00
Christoph Oelckers
d50da34664 - scriptified the pistol to test if struct member functions work.
- made APlayerPawn::PlayAttacking(2) virtual script functions so that mods have better control over player animations. Note that these have no native base so they skip the templated interface for managing virtual functions.
2016-11-19 13:56:29 +01:00
Christoph Oelckers
3ce699bf9b - implemented pass-by-reference arguments - so far only for memory based variables.
- changed Dehacked weapon function lookup to check the symbol table instead of directly referencing the VM functions. Once scriptified these pointers will no longer be available.
- removed all special ATAGs from the VM. While well intentioned any pointer tagged with them is basically unusable because it'd trigger asserts all over the place.
- scriptified A_Punch for testing pass-by-reference parameters and stack variables.
2016-11-19 01:23:56 +01:00
Christoph Oelckers
aa32d8970b - scriptified a_hereticmisc.cpp. 2016-11-18 21:34:06 +01:00
Christoph Oelckers
2cc48ec378 - implemented code generation for stack variables.
- fixed code generation for using local variables as array index. This must use a different register for the array element offset because the original register may not be overwritten.
2016-11-17 16:44:41 +01:00
Christoph Oelckers
21a1d5ffc8 - scriptified Hexen's Wraith and parts of the Spike. 2016-11-17 00:44:43 +01:00
Christoph Oelckers
df43ee96ce - fixed a lost '='.
- scriptified A_TimeBomb.
2016-11-16 21:12:16 +01:00
Major Cooke
60d93008ba Exported TryMove. 2016-11-16 19:47:06 +01:00
Christoph Oelckers
633da6e5d8 - scriptified two of the Acolyte's functions.
- added a DActorIterator class.
- fixed: It was not possible to have functions of the same name in two different classes because the name they were searched for was not qualified by the class. Changed so that the class name is included now, but to avoid renaming several hundreds of functions all at once, if the search fails, it will repeat with 'Actor' as class name.

This commit contains preparations for scriptifying Hexen's Dragon, but that doesn't work yet so it's not included.
2016-11-16 01:36:21 +01:00
Christoph Oelckers
a63c749f04 - moved A_Light to Actor after finding some mods which used it badly. Besides, it should be fine to use this from PlayerPawns as well. 2016-11-15 13:39:41 +01:00
Christoph Oelckers
4f998fa879 - finished the state usage parser.
- added state usage specifiers to Actor and Inventory. The states in these classes must be set to full access so that any existing mod can link to them.
2016-11-14 23:24:10 +01:00
Christoph Oelckers
384f4fe7ce - added a 'DefaultStateUsage' property so that this setting can be properly set up for the classes that can inject states into other actors. 2016-11-14 18:31:12 +01:00
Christoph Oelckers
a8e2f4d539 - added missing 'action' qualifiers to A_Warp and A_Teleport 2016-11-14 18:11:44 +01:00
Christoph Oelckers
ac86a535e7 - fixed: State labels were resolved in the calling function's context instead of the called function one's.
This could cause problems with functions that take states as parameters but use them to set them internally instead of passing them through the A_Jump interface back to the caller, like A_Chase or A_LookEx.
This required some quite significant refactoring because the entire state resolution logic had been baked into the compiler which turned out to be a major maintenance problem.
Fixed this by adding a new builtin type 'statelabel'. This is an opaque identifier representing a state, with the actual data either directly encoded into the number for single label state or an index into a state information table.
The state resolution is now the task of the called function as it should always have remained. Note, that this required giving back the 'action' qualifier to most state jumping functions.

- refactored most A_Jump checkers to a two stage setup with a pure checker that returns a boolean and a scripted A_Jump wrapper, for some simpler checks the checker function was entirely omitted and calculated inline in the A_Jump function. It is strongly recommended to use the boolean checkers unless using an inline function invocation in a state as they lead to vastly clearer code and offer more flexibility.

- let Min() and Max() use the OP_MIN and OP_MAX opcodes. Although these were present, these function were implemented using some grossly inefficient branching tests.
- the DECORATE 'state' cast kludge will now actually call ResolveState because a state label is not a state and needs conversion.
2016-11-14 14:12:27 +01:00
Christoph Oelckers
a2f4cd7cda - fixed: All functions that are callable from weapon states and not members of Actor need to be declared 'action'.
With the stricter type checks of the self pointer that were now implemented these all produced errors.
2016-11-13 14:20:30 +01:00
Christoph Oelckers
49ef541513 - scriptified Hexen's Firedemon. 2016-11-12 19:16:47 +01:00
Christoph Oelckers
213b3f1fe4 - scriptified Hexen's Centaur. 2016-11-12 17:21:11 +01:00
Christoph Oelckers
8f8017836f - scriptified Hexen's Bishop. 2016-11-12 16:32:26 +01:00
Christoph Oelckers
91938cd35b - fixed: The pointer defaulr for GetDistance was incorrect. 2016-11-12 15:26:29 +01:00
Christoph Oelckers
5adb2fe690 - fixed copy/paste error in A_UnsetReflectiveInvulnerable. 2016-11-12 13:11:32 +01:00
Christoph Oelckers
34fc6323a4 - scriptified Hexen's bats.
- removed AMinotaurFriend::IsOkayToAttack. The condition it checks (i.e. friendliness with player) is already covered by the base version of this function so this is quite redundant.
- removed a few 'virtual' qualifiers from functions that never get overridden.
2016-11-12 09:33:43 +01:00
Christoph Oelckers
14a9c13113 - scriptified Heretic's wizard. 2016-11-11 23:32:13 +01:00
Christoph Oelckers
a5f9eb5be1 - Scriptified Heretic's knight. 2016-11-11 22:14:29 +01:00