Author Topic: Smoke's Modding Guide  (Read 9970 times)

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 210
  • T:REP 668
    • View Profile
Re: Smoke's Modding Guide
« Reply #40 on: February 05, 2018, 12:34:16 AM »
Added some info to kCModel and kActor::CanSee(), based on some experiments with raycasting.  The new CModel info is from a post Kaiser made on steam a long time ago, but I tried to rephrase the function descriptions to be a little clearer now that I've finally done some actual testing.

Online Dinomite

  • Chronoscepter
  • ******
  • Posts: 2657
  • T:REP 8197
    • View Profile
Re: Smoke's Modding Guide
« Reply #41 on: September 03, 2018, 05:31:39 PM »
Got anything else to add to the guide?

The most hated person on the internet.

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 210
  • T:REP 668
    • View Profile
Re: Smoke's Modding Guide
« Reply #42 on: September 03, 2018, 06:30:20 PM »
I update stuff occasionally as I refine my understanding: https://github.com/Smoke39/turok/commits/master

Online Dinomite

  • Chronoscepter
  • ******
  • Posts: 2657
  • T:REP 8197
    • View Profile
Re: Smoke's Modding Guide
« Reply #43 on: September 04, 2018, 03:06:35 AM »
Oh, alright. :D

The most hated person on the internet.

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 210
  • T:REP 668
    • View Profile
Re: Smoke's Modding Guide
« Reply #44 on: March 07, 2019, 03:25:56 AM »
After a fair bit of experimentation, I think I've reverse-engineered the details of how kActor::MeleeObject() works.  I also documented kActor::InteractActorsAtPosition(), which can, for example, be used to implement custom alternatives to MeleeObject().

Offline DoomMarine23

  • Raptor
  • ***
  • Posts: 60
  • T:REP 204
    • View Profile
Re: Smoke's Modding Guide
« Reply #45 on: March 07, 2019, 03:56:57 PM »
Glad to see you've continued with this. When I get the time, maybe this weekend or next week, I am gonna look into documenting a few functions as well.

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 210
  • T:REP 668
    • View Profile
Re: Smoke's Modding Guide
« Reply #46 on: March 08, 2019, 03:16:36 AM »
Clearing out a backlog of stuff I accumulated while working on my first map:

Figured out which params are which with kActor::SpawnParams().

The levels section has been massively expanded.  In addition to a bunch of handy reference info, of particular note are a couple of quirks with triggers:
1. enemy Target TID can only trigger other actors on death, not level scripts
2. event sectors can only trigger level scripts if there are no actors with a matching TID

Online BehemothProgrammer

  • Endtrail
  • ****
  • Posts: 221
  • T:REP 782
    • View Profile
Re: Smoke's Modding Guide
« Reply #47 on: March 09, 2019, 01:24:54 AM »
Nice work listing all the attacks for all the enemies. That was something annoying I never wanted to do, but needed to lol. You pretty much got everything listed that's awesome.

Your mentioning InteractActorsAtPosition and I just wanted to show a helper function I used for calling functions from the map module to an actor in the game module, that uses InteractActorsAtPosition. This function will spawn a special actor type at the players position and set it to solid so InteractActorsAtPosition will call it. You only want the function to be called on the actor once instead of for every solid actor in range so you need to do a condition check for that actor type at the start of your function.

Code: [Select]
//------------------------------------------------------------------------------------------------------------------------
// Useful to call custom functions from the map script module to the game script module.
// Otherwise just use the ScriptObject's ScriptObject() function to get a handle to it.
//
// Required:
// Function header: void funcName(kActor @actor, const float arg1, const float arg2, const float arg3, const float arg4)
// Function body condition check: if (actor.Type() != BP_AT_FUNCTIONCALL) return;
//------------------------------------------------------------------------------------------------------------------------
void CallFunc(kActor@ actor, const kStr &in funcName, const float arg1 = 0.0f, const float arg2 = 0.0f, const float arg3 = 0.0f, const float arg4 = 0.0f)
{
kActor@ playerActor = Player.Actor().CastToActor();
kActor@ dummy = Spawn(BP_AT_FUNCTIONCALL, playerActor.Origin(), 0.0f, playerActor.SectorIndex());
dummy.Flags() |= AF_SOLID;
actor.InteractActorsAtPosition(playerActor.Origin(), funcName, arg1, arg2, arg3, arg4);
dummy.Remove();
}

and going the other way from game to map module is easy with the Game.CallDelayedMapScript function.

Here's the last of my random stuff I found out when making my last map that I don't think you have in the guide, hope it helps.
https://pastebin.com/raw/fExJrV1j
« Last Edit: March 09, 2019, 01:26:56 AM by BehemothProgrammer »

Offline Smoke39

  • Endtrail
  • ****
  • Posts: 210
  • T:REP 668
    • View Profile
Re: Smoke's Modding Guide
« Reply #48 on: March 09, 2019, 03:47:09 AM »
Shit, you can actually get an actor's script object from a level script?  I tried doing that while making Cliffside Outpost, and as I recall I was getting cast errors, so I thought the game and level script contexts were just so distinct that they each had their own distinct copies of classes or something.  Just did a quick test with a QuakeSource from a level script, though, and I was able to call SetupShake() and mess with its member variables, so apparently I was doing something wrong before.  Really good to know that's possible after all.

Given that, I'm not sure what the purpose of using InteractActorsAtPosition() is?  Why not just get a handle to the dummy actor's script object and call the function directly?

Thanks for the notes.  I'll parse through them eventually, but just skimming through them I'm noting some nice little nuggets. :)

Online BehemothProgrammer

  • Endtrail
  • ****
  • Posts: 221
  • T:REP 782
    • View Profile
Re: Smoke's Modding Guide
« Reply #49 on: March 09, 2019, 02:02:25 PM »
That works because QuakeSource is a shared class. https://www.angelcode.com/angelscript/sdk/docs/manual/doc_script_shared.html

Quote
Shared entities have a restriction in that they cannot access non-shared entities because the non-shared entities are exclusive to the script module in which they were compiled.

And that's not going to work when trying to get non shared classes from the game default scripts. And also it says there that you can share funcdefs which is wrong, or the angelscript version used in the game is really old. So casting to a non shared class compiled from another module will always return null. The only way to do custom things with non shared scripts is with that helper function that's able to call a function on an actor to the game module with 4 floats that can do whatever.

In this game there are 2 modules for scripting, I'll call them the game module and the map module. https://www.angelcode.com/angelscript/sdk/docs/manual/doc_module.html