-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZScript.zsc
137 lines (125 loc) · 7.57 KB
/
ZScript.zsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*=============================================================================================================================
___ ___ ___ ___ ___ ___ ___ ___
/\__\ /\ \ ___ /\__\ ___ /\ \ /\ \ /\ \ /\ \ |\__\
/:/ / /::\ \ /\ \ /:/ / /\ \ /::\ \ /::\ \ /::\ \ /::\ \ |:| |
/:/__/ /:/\:\ \ \:\ \ /:/ / \:\ \ /:/\:\ \ /:/\:\ \ /:/\:\ \ /:/\:\ \ |:| |
/::\__\____ /::\~\:\ \ /::\__\ /:/ / /::\__\ /::\~\:\__\ /::\~\:\ \ /::\~\:\ \ /::\~\:\ \ |:|__|__
/:/\:::::\__\/:/\:\ \:\__\ __/:/\/__/ /:/__/ __/:/\/__//:/\:\ \:|__|/:/\:\ \:\__\/:/\:\ \:\__\/:/\:\ \:\__\ /::::\__\
\/_|:|~~|~ \/__\:\/:/ //\/:/ / \:\ \ /\/:/ / \:\~\:\/:/ /\/_|::\/:/ /\/__\:\/:/ /\/_|::\/:/ //:/~~/~
|:| | \::/ / \::/__/ \:\ \\::/__/ \:\ \::/ / |:|::/ / \::/ / |:|::/ //:/ /
|:| | /:/ / \:\__\ \:\ \\:\__\ \:\/:/ / |:|\/__/ /:/ / |:|\/__/ \/__/
|:| | /:/ / \/__/ \:\__\\/__/ \::/__/ |:| | /:/ / |:| |
\|__| \/__/ \/__/ ~~ \|__| \/__/ \|__|
===============================================================================================================================*/
Version "4.12.0"
//CUSTOM CODE TAGS: (Temporary list !)
//DOCUMENT: This bit of code needs documentation.
//PLAYTEST: The code has been written, but not tested, so it might be buggy.
//URGENT: This is something urgent, likely a bugfix, some really visible debug code I don't want to appear in-game etcetera.
//CREDIT: This is to credit some bit of code or function to someone else. Usually when someone else helps me with writing some code.
//DEBUG: Unlike the defintion on Wikipedia, here this signifies some bit of debugging code, probably something that should be removed or commented out before a full release.
//MAYDO: Unlike TODO, this means that it's something I may or may not do. Hence the name.
//IDEA: This is just an idea for the project. Likely some far away goal that would take a lot of time to implement.
//IDEA:
/*Today (1/7/2023) I made a suggestion to PBs' developers on how to implement the hitbox system to monsters. Move the hitbox handling to a HandleLocalDamage
virtual, change the hitbox factors (e.g if an attack hit 0.8 of the monsters' height or above ,it hit the head) into properties instead of hardcoded values etc.
Maybe I should add locational damage to the library as well based on this suggestion ? Might be out of scope though, since this is an AI library.
The body part types for normal NPCs should be PART_HEAD, PART_TORSO, PART_LEG, and PART_ARM.
For vehicles it should be PART_ENGINE, PART_WHEEL (With an alternate PART_TRACK name too), PART_SENSOR (?).
These parts should be interchangeable between NPC types, especially for vehicles. Since a vehicle like a mech can have legs, arms, and an engine.
Also add generic hit locations for what part of the hitbox was hit relative to the victims' angle. HIT_FRONT, HIT_BACK, HIT_LEFT, HIT_RIGHT, HIT_TOP, HIT BOTTOM.
This one will be especially useful for vehicles, allowing me to for example, make the top and back of the MBT more vulnerable compared to the sides and front.
Since these part types will just be ints, it should also be able to define custom parts similar to thread levels. Like PART_DICK, PART_FOOT, PART_HAND etc.
Add a GetBodyPart virtual to NPCs, to define positions for parts, and return the right part based on position. Callable from other actors like projectiles,
allowing for projectiles to do special effects like double damage on headshots.
Maybe also add an OnBodyPartHit callback for projectiles to use. Such as to make the victim itself react to a headshot. Or the back of the tank being hit.
*/
/*Cacodemon345 exposed the native FScanner class to ZScript a few months ago, maybe I could retry my idea for
NPC voice packs using ScriptScanner ? Hopefully it'll be a lot easier to use than manually reading and parsing files !*/
/*Make some kind of target priority queue system, or something ? Like, for having NPCs optionally target multiple enemies.*/
//DEBUG DEBUG DEBUG
class TestPinky : KAI_Actor// Replaces Demon
{
Default
{
Health 150;
PainChance 180;
Speed 10;
Radius 30;
Height 56;
Mass 400;
Monster;
+FLOORCLIP+missileevenmore;+MISSILEMORE;
SeeSound "demon/sight";
AttackSound "demon/melee";
PainSound "demon/pain";
DeathSound "demon/death";
ActiveSound "demon/active";
Obituary "$OB_DEMONHIT";
Tag "$FN_DEMON";
}
States
{
Spawn:
SARG AB 10 A_Look;
Loop;
See:
SARG AABBCCDD 2 Fast// A_Chase;
{
//If (!done && Target) {done = true;IsPosReachable(Target.Pos,(Target.Radius*2)+(Radius*2)+8);}
/*KAI_Chase_PreChecks(0);
KAI_Chase_Retarget(0);if (goal && target != goal) target = goal;
if (goal)KAI_MoveTowards(goal.Pos,detourfactor:0.5);
KAI_Chase_HandleActiveSound(0);
KAI_Chase_PatrolHandling();*/
//if (target) KAI_MoveTowards(target.Pos,detourfactor:0.5,flags:KMT_ZIGZAG);
//KAI_Wander(32,1024,256);
KAIMoveParams data;
data.cornerdist = 384;
data.cornerdiv = 16;
data.obstacledist = 256;
data.obstacleslices = 16;
if (target) KAI_MoveAway(target,runrad:256,maxsteps:64,detourfactor:0.5,flags:0,kmaflags:KMA_STRAIGHT,extraparams:data);
//A_Chase ("Melee",Null);
}
Loop;
//Shit out plasma balls to test VelInterceptEx().
Missile:
TNT1 A 0 A_FaceTarget(0,0);
SARG EF 4 Fast;// A_FaceTarget;
SARG G 1 Fast
{A_FaceTarget(0,0);//A_StartSound ("Vehicle/APC/SmallMGFire",CHAN_WEAPON,CHANF_OVERLAP,1.0,0.4);
Actor Misl = A_SpawnProjectile ("PlasmaBall",angle:Angle,CMF_AIMDIRECTION,Pitch);
//Speed it up for science purposes.
Misl.Speed = 50;
Misl.Vel3DFromAngle (Misl.Speed,Angle,Pitch);
//VelIntercept ();
VelInterceptEx (Misl,(0.4,-0.4),(0.55,-0.55),1024);
if (!target || isdead(target))a_look();
}
Wait;//Goto See;
}
}
//=====|Library structure|=====\\
/*The most basic NPC class, all types are based on this, land/water/air vehicles, humanoids, flying creatures, you name it.
So, the code that is meant to be shared by all NPCs also goes here.*/
#Include "ZScript/Bases/Base.zsc"
#Include "ZScript/Bases/Projectile.zsc"
#Include "ZScript/Bases/AIFunctions.zsc"
#Include "ZScript/Bases/OtherFunctions.zsc"
#Include "ZScript/Bases/OtherCode.zsc"
#Include "ZScript/Bases/Hazard.zsc" //Universal code for hazards, hazard zones, etc
#Include "ZScript/Bases/Groups.zsc" //NPC group/squad handling.
#Include "ZScript/Bases/SharedCode.zsc" //Mixins and shit.
//The base *land* vehicle class. As of 8/4/2023, this basically a direct rip from a dev build of MVP 0.5.0.
//Any future vehicle types like air and water vehicles will be based on this.
#Include "ZScript/Bases/Vehicle/Base.zsc"
#Include "ZScript/Bases/Vehicle/BaseProp.zsc"
#Include "ZScript/Bases/Vehicle/CommonFunctions.zsc"
#Include "ZScript/Bases/Vehicle/TurretFunctions.zsc"
//Air, sea, etc vehicles.
//The base creature class, for living NPCs like demons and animals.
#Include "ZScript/Bases/Creature/Base.zsc"
//The base class for more intelligent creatures, based on KAI_Creature.
#Include "ZScript/Bases/Humanoid/Base.zsc"
#Include "ZScript/Bases/Humanoid/Emplacement.zsc" //Player and KAI_Humanoid-usable emplacements, like turrets.