Jump to content
Sign in to follow this  
Andrew Downing

Resolving Unkown Types

Recommended Posts

I'm an experienced programmer, but have no experience with Enforcescript or modding DayZ. This got me started: https://community.bistudio.com/wiki/DayZ:Modding_Basics. I'm expanding on the example they have there and trying to show when a player kills something. Here is what I have.

#include "scripts/3_Game/analytics/analyticsmanagerserver.c"
#include "scripts/4_World/entities/firearms/weapon_base.c"

modded class AnalyticsManagerServer
{
    override void OnEntityKilled( Object killer, EntityAI target )
	{
		super.OnEntityKilled(killer, target);
		Weapon_Base w = Weapon_Base.Cast(killer);
		Print(killer);
		Print(target);
		Print(w);
	}
}

 

This mostly works except for casting to Weapon_Base. The script editor outputs this when I shoot a zombie:

SCRIPT : Object killer = Mp133Shotgun_Base<179c6ec0>

SCRIPT : EntityAI target = ZmbM_HermitSkinny_Base<deea31b0>

 

Here is the problem I have when compiling:

SCRIPT (E): FirstMod/Scripts/3_Game/analytics/AnalyticsmanagerServer.c(9): error: Unknown type 'Weapon_Base

 

If I take out the first #include I also get this error when compiling (everything still works the same though):

SCRIPT (E): FirstMod/Scripts/3_Game/analytics/AnalyticsmanagerServer.c(14): error: Unknown type 'AnalyticsManagerServer'

 

I'm not sure what i need to do to be able to use Weapon_Base here, or any other class I might later decide to use. I also have no idea why in their example linked above there is no unresolved type error for PlayerBase, but I do have one for AnalyticsManagerServer unless I have that first #include.

Share this post


Link to post
Share on other sites
On 10/2/2022 at 10:58 PM, Andrew Downing said:

I'm an experienced programmer, but have no experience with Enforcescript or modding DayZ. This got me started: https://community.bistudio.com/wiki/DayZ:Modding_Basics. I'm expanding on the example they have there and trying to show when a player kills something. Here is what I have.


#include "scripts/3_Game/analytics/analyticsmanagerserver.c"
#include "scripts/4_World/entities/firearms/weapon_base.c"

modded class AnalyticsManagerServer
{
    override void OnEntityKilled( Object killer, EntityAI target )
	{
		super.OnEntityKilled(killer, target);
		Weapon_Base w = Weapon_Base.Cast(killer);
		Print(killer);
		Print(target);
		Print(w);
	}
}

 

This mostly works except for casting to Weapon_Base. The script editor outputs this when I shoot a zombie:

SCRIPT : Object killer = Mp133Shotgun_Base<179c6ec0>

SCRIPT : EntityAI target = ZmbM_HermitSkinny_Base<deea31b0>

 

Here is the problem I have when compiling:

SCRIPT (E): FirstMod/Scripts/3_Game/analytics/AnalyticsmanagerServer.c(9): error: Unknown type 'Weapon_Base

 

If I take out the first #include I also get this error when compiling (everything still works the same though):

SCRIPT (E): FirstMod/Scripts/3_Game/analytics/AnalyticsmanagerServer.c(14): error: Unknown type 'AnalyticsManagerServer'

 

I'm not sure what i need to do to be able to use Weapon_Base here, or any other class I might later decide to use. I also have no idea why in their example linked above there is no unresolved type error for PlayerBase, but I do have one for AnalyticsManagerServer unless I have that first #include.

Interesting situation.
I'm sorry but did you tried to include Weapon_Base?
You may call it through:

#include "scripts\4_World\Entities\Firearms\Weapin_Base.c";

And after casting check is it NULL state like:

EntityAI crazy_killing_stuff = blablabla;
Weapon_Base crazy_wpn = Weapon_Base.Cast(crazy_killing_stuff);
if (crazy_wpn)
{
	Print("Wpn cast is complete");
}
else
{
	print ("you know my shift hacked up...");
}

I know that's not simply way but all classes that you're using shall be included in your script (through #include option like in C-based langs).

Secondary did you included in your mod config file the link on overriding of classes?
You trying to override the Game-module,
So you need to include in your mod

CfgMods -> class FirstMod ->
class defs 
{
	Class gameScriptModule {
		files[] = { "FirstMod/Scripts/3_Game" };
	}
}

Also please make a point on the #include, it's required ";" at the end of the line.

And also if you override some class it contains the base class so you don't need the line:

#include "scripts/3_Game/analytics/analyticsmanagerserver.c"

 

Edited by Sid Debian

Share this post


Link to post
Share on other sites

The issue was that I was trying to use Weapon_Base which is the 3_Game module, inside AnalyticsManager which is in the 4_World module. I didn't realize that classes defined in a module are only available in that module, or higher numbered modules. I haven't seen any documentation stating that, I just happened to find that info in someones personal blog.

The solution was to use a modded override on PlayerBase::EEKIlled() and ZombieBase::EEKilled() which are in 4_World along with MissionBaseWorld. I added a modded override MissionBaseWorld::OnEntityKilled() which the EEKilled() functions call. I could then override OnEntityKilled() in my mission class in the 5_Mission module.

Share this post


Link to post
Share on other sites
On 10/5/2022 at 9:09 PM, Andrew Downing said:

The issue was that I was trying to use Weapon_Base which is the 3_Game module, inside AnalyticsManager which is in the 4_World module. I didn't realize that classes defined in a module are only available in that module, or higher numbered modules. I haven't seen any documentation stating that, I just happened to find that info in someones personal blog.

The solution was to use a modded override on PlayerBase::EEKIlled() and ZombieBase::EEKilled() which are in 4_World along with MissionBaseWorld. I added a modded override MissionBaseWorld::OnEntityKilled() which the EEKilled() functions call. I could then override OnEntityKilled() in my mission class in the 5_Mission module.

That's a kind of logistics!

Problem is dependents. If you allowed in mod config nesesary links you'll able to override nesesary statements in other way - without it everything will be hecked up.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×