Commit graph

41 commits

Author SHA1 Message Date
Christoph Oelckers
287974968a - renamed A_FireCustomMissile and added a deprecated compatibility wrapper to deal with the inverted pitch this function used. 2016-12-24 16:34:45 +01:00
Christoph Oelckers
8a50004f55 - cleanup of the virtual function definitions for inventory items. Let's better use 'virtual' and 'override' everywhere to make sure that nothing gets overlooked.
- added call wrappers and script hooks for all relevant virtuals in AInventory.
- made GetSpeedFactor and GetNoTeleportFreeze entirely scripted because they are too trivial - also do them iteratively, just like HandlePickup, because it's just a better way to do this stuff.
2016-11-30 15:54:01 +01:00
Christoph Oelckers
b0f3121bec - split up zscript/shared/inventory.txt.
- moved health items to their own file.
- scriptified ScoreItem and MapRevealer whose entire functionality was a small TryPickup method.
- fixed: bit fields in global variables were not correctly written.

This should conclude the inventory cleanup. It is now possible again to find things in there.
2016-11-30 13:36:13 +01:00
Christoph Oelckers
5beebb83b7 - scriptified Strife's assault gun and missile launcher. 2016-11-29 13:28:43 +01:00
Christoph Oelckers
3af9232fca - scriptified a_strifeitems.cpp and a_debris.cpp.
- Changed the glass shards so that they do not have to override FloorBounceMissile. It was the only place where this was virtually overridden and provided little usefulness.
- made 'out' variables work.
- fixed virtual call handling for HandlePickup.
2016-11-29 12:17:05 +01:00
Christoph Oelckers
9064a5b0ac - scriptified Strife's coins.
- added a String class to allow attaching methods to the builtin string type. This works by checking if the left side of the member accessor is a string and just replacing the tyoe in this one place, all the rest is automatic.
2016-11-28 18:15:18 +01:00
Christoph Oelckers
d2ce78fae7 - changed the return value of PickupMessage to an FString so that it can interface with scripts.
- use standard convention of prefacing localizable strings with "$" for C_MidPrint.
2016-11-28 16:19:01 +01:00
Christoph Oelckers
8551a4f6e1 - scriptified the Sigil. This isn't fully tested yet. 2016-11-28 14:39:25 +01:00
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
178db4bb09 - scriptified the fighter's hammer. 2016-11-26 21:39:20 +01:00
Christoph Oelckers
e541c27622 - scriptified the weapon's state getter methods - as preparation for the fighter axe. 2016-11-26 19:48:30 +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
0d6f37835f - completed Heretic scriptification with the two remaining artifacts. 2016-11-25 18:41:00 +01:00
Christoph Oelckers
4f370ba181 - scriptified the Phoenix Rod, completing the Heretic weapons. 2016-11-25 18:13:08 +01:00
Christoph Oelckers
8a7671ad8b - exported all member fields from the morph items.
- renamed APowerMorph::Player to avoid accidental confusion with AActor::player, which in scripting is the same due to case insensitvity.
- renamed save key for above variable.
2016-11-23 23:28:03 +01:00
Christoph Oelckers
7325e3f0f8 - exported all member fields that make sense. Entirely private ones or classes that are not supposed to be extended were left out. 2016-11-23 17:34:36 +01:00
Christoph Oelckers
0c95568d98 - exported native fields of several more classes. 2016-11-23 01:31:48 +01:00
Christoph Oelckers
099b9970ef - added proper definitions for all exported native fields.
- synthesize native fields for all declared flags, not just for AActor.
2016-11-22 23:43:32 +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
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
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
3c726aa570 - scriptified A_FirePlasma. 2016-11-20 01:18:21 +01:00
Christoph Oelckers
fdab994fcb - scriptified the Rocket launcher. 2016-11-20 01:11:01 +01:00
Christoph Oelckers
814493b68d - scriptified the Super Shotgun. 2016-11-20 00:45:06 +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
0b70df88d8 - scriptified A_FireShotgun and A_FireChaingun. 2016-11-19 16:39:45 +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
4cc7d95ba5 - fixed: A_ZoomFactor and A_SetCrosshair need to be declared 'action'. 2016-11-15 16:05:42 +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
c797319314 - fixed parser for state block options.
- fixed incorrect flags for weapons.
2016-11-14 20:00:01 +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
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
66b1f36e56 - actually evaluate the default parameters and store them in the VMFunction.
- disabled the assert in PType::GetRegType. This assert blocks any use to check for types that are incompatible with function parameters.
- pass the default parameter constants to the native functions. At the moment this is not used yet.
- use the function defaults to complete argument lists to script functions.
- fixed all default values that got flagged by the expression evaluator as non-constant. Most were state labels and colors which were defaulted to "". The proper value is null for states and 0 for colors.
- also replaced all "" defaults for names with "none".
2016-10-27 01:30:34 +02:00
Christoph Oelckers
371712c53a - turned everything I could into non-action functions.
- fixed emission of the self pointer in FxVMFunctionCall. I did not realize that the self expression only sets up a register for the value, not pushing it onto the stack.
2016-10-22 17:49:08 +02:00
Christoph Oelckers
32ac1a8ad7 - moved the special weapon functions from Inventory to StateProvider.
This will restrict them to the only classes that may use them: Weapon and CustomInventory.
Note: Should a mod surface which uses them improperly the better solution would be a warning message and NULLing the bogus code pointer instead of leaving them in Inventory.
2016-10-22 16:46:47 +02:00
Christoph Oelckers
091da92819 - Added AStateProvider class which is used to define the special action function behavior of weapons and custom inventorys. The class itself does not do anything, but the compiler will use it to set up the action function prototypes differently which in turn will be used to do type checking during code generation. 2016-10-15 15:10:48 +02:00
Christoph Oelckers
433bf46010 - removed token 'mode' because it isn't used anywhere and clashed with some actor properties.
- fixed uninitialized counter variable in DECORATE parser.
- allow dottable_id of xxx.color so that the property parser can parse 'powerup.color'.
- fixed crash with actor replacement in script compiler.
- add the lump number to tree nodes because parts of the property parser need that to make decisions.
- removed test stuff.
- converted inventory.txt, player.txt and specialspot.txt to ZSCRIPT. These were the minimal files required to allow actor.txt to parse successfully.
- removed the converted files from the DECORATE include list so that these are entirely handled by ZSCRIPT now.
2016-10-13 20:45:52 +02:00