diff --git a/src/dobjtype.h b/src/dobjtype.h index 0b4235a76..8ccb62aca 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -24,6 +24,11 @@ enum VARF_Private = (1<<5), // field is private to containing class VARF_Protected = (1<<6), // field is only accessible by containing class and children. VARF_Deprecated = (1<<7), // Deprecated fields should output warnings when used. + VARF_Virtual = (1<<8), // function is virtual + VARF_Final = (1<<9), // Function may not be overridden in subclasses + VARF_In = (1<<10), + VARF_Out = (1<<11), + VARF_Implicit = (1<<12), // implicitly created parameters (i.e. do not compare when checking function signatures) }; // Symbol information ------------------------------------------------------- diff --git a/src/namedef.h b/src/namedef.h index f07db2ce9..8d883d566 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -714,6 +714,11 @@ xx(Mant_Dig) xx(Min_10_Exp) xx(Max_10_Exp) +// implicit function parameters +xx(self) +xx(caller) +xx(stateinfo) + xx(__decorate_internal_int__) xx(__decorate_internal_bool__) xx(__decorate_internal_state__) diff --git a/src/thingdef/thingdef.h b/src/thingdef/thingdef.h index 426eddd41..107a496d8 100644 --- a/src/thingdef/thingdef.h +++ b/src/thingdef/thingdef.h @@ -195,7 +195,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray *args, TArray *argflags, PClassActor *cls, DWORD funcflags); +void SetImplicitArgs(TArray *args, TArray *argflags, PClass *cls, DWORD funcflags); PFunction *FindGlobalActionFunction(const char *name); diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 5789038b7..6d1077ffe 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -410,7 +410,7 @@ static void ParseArgListDef(FScanner &sc, PClassActor *cls, // //========================================================================== -void SetImplicitArgs(TArray *args, TArray *argflags, PClassActor *cls, DWORD funcflags) +void SetImplicitArgs(TArray *args, TArray *argflags, PClass *cls, DWORD funcflags) { // Must be called before adding any other arguments. assert(args == NULL || args->Size() == 0); @@ -419,21 +419,21 @@ void SetImplicitArgs(TArray *args, TArray *argflags, PClassActor if (funcflags & VARF_Method) { // implied self pointer - if (args != NULL) args->Push(NewClassPointer(cls)); - if (argflags != NULL) argflags->Push(0); + if (args != NULL) args->Push(NewClassPointer(RUNTIME_CLASS(AActor))); + if (argflags != NULL) argflags->Push(VARF_Implicit); } if (funcflags & VARF_Action) { // implied stateowner and callingstate pointers if (args != NULL) { - args->Push(NewClassPointer(RUNTIME_CLASS(AActor))); + args->Push(NewClassPointer(cls)); args->Push(TypeState); } if (argflags != NULL) { - argflags->Push(0); - argflags->Push(0); + argflags->Push(VARF_Implicit); + argflags->Push(VARF_Implicit); } } } diff --git a/src/zscript/zcc_compile.cpp b/src/zscript/zcc_compile.cpp index 98448069a..7e718b42f 100644 --- a/src/zscript/zcc_compile.cpp +++ b/src/zscript/zcc_compile.cpp @@ -111,7 +111,10 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode) // todo case AST_States: + break; + case AST_FuncDeclarator: + cls->Functions.Push(static_cast(node)); break; case AST_Default: @@ -364,6 +367,7 @@ int ZCCCompiler::Compile() CompileAllConstants(); CompileAllFields(); InitDefaults(); + InitFunctions(); return ErrorCount; } @@ -1179,7 +1183,7 @@ bool ZCCCompiler::CompileFields(PStruct *type, TArray &Fiel { auto field = Fields[0]; - PType *fieldtype = DetermineType(type, field, field->Type, true); + PType *fieldtype = DetermineType(type, field, field->Names->Name, field->Type, true); // For structs only allow 'deprecated', for classes exclude function qualifiers. int notallowed = forstruct? ~ZCC_Deprecated : ZCC_Latent | ZCC_Final | ZCC_Action | ZCC_Static | ZCC_FuncConst | ZCC_Abstract; @@ -1264,11 +1268,11 @@ FString ZCCCompiler::FlagsToString(uint32_t flags) // //========================================================================== -PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_VarDeclarator *field, ZCC_Type *ztype, bool allowarraytypes) +PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName name, ZCC_Type *ztype, bool allowarraytypes) { if (!allowarraytypes && ztype->ArraySize != nullptr) { - Error(field, "%s: Array type not allowed", FName(field->Names->Name).GetChars()); + Error(field, "%s: Array type not allowed", name.GetChars()); return TypeError; } switch (ztype->NodeType) @@ -1322,9 +1326,18 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_VarDeclarator *field, ZC case ZCC_Vector4: // This has almost no use, so we really shouldn't bother. - Error(field, "vector<4> not implemented for %s", FName(field->Names->Name).GetChars()); + Error(field, "vector<4> not implemented for %s", name.GetChars()); return TypeError; + case ZCC_State: + return TypeState; + + case ZCC_Color: + return TypeColor; + + case ZCC_Sound: + return TypeSound; + case ZCC_UserType: return ResolveUserType(btype, &outertype->Symbols); break; @@ -1334,19 +1347,19 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_VarDeclarator *field, ZC case AST_MapType: if (allowarraytypes) { - Error(field, "%s: Map types not implemented yet", FName(field->Names->Name).GetChars()); + Error(field, "%s: Map types not implemented yet", name.GetChars()); // Todo: Decide what we allow here and if it makes sense to allow more complex constructs. auto mtype = static_cast(ztype); - return NewMap(DetermineType(outertype, field, mtype->KeyType, false), DetermineType(outertype, field, mtype->ValueType, false)); + return NewMap(DetermineType(outertype, field, name, mtype->KeyType, false), DetermineType(outertype, field, name, mtype->ValueType, false)); } break; case AST_DynArrayType: if (allowarraytypes) { - Error(field, "%s: Dynamic array types not implemented yet", FName(field->Names->Name).GetChars()); + Error(field, "%s: Dynamic array types not implemented yet", name.GetChars()); auto atype = static_cast(ztype); - return NewDynArray(DetermineType(outertype, field, atype->ElementType, false)); + return NewDynArray(DetermineType(outertype, field, name, atype->ElementType, false)); } break; @@ -1648,6 +1661,7 @@ void ZCCCompiler::DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *proper } } // call the handler + FScriptPosition::ErrorCounter = 0; try { prop->Handler(defaults, bag.Info, bag, ¶ms[0]); @@ -1656,6 +1670,7 @@ void ZCCCompiler::DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *proper { Error(property, "%s", error.GetMessage()); } + ErrorCount += FScriptPosition::ErrorCounter; } //========================================================================== @@ -1824,3 +1839,130 @@ void ZCCCompiler::InitDefaults() } } +//========================================================================== +// +// Parses the functions list +// +//========================================================================== + +void ZCCCompiler::InitFunctions() +{ + TArray rets(1); + TArray args; + TArray argflags; + TArray argnames; + + for (auto c : Classes) + { + for (auto f : c->Functions) + { + Printf("processing function %s\n", FName(f->Name).GetChars()); + rets.Clear(); + args.Clear(); + argflags.Clear(); + // For the time being, let's not allow overloading. This may be reconsidered later but really just adds an unnecessary amount of complexity here. + if (AddTreeNode(f->Name, f, &c->TreeNodes, false)) + { + auto t = f->Type; + if (t != nullptr) + { + do + { + auto type = DetermineType(c->Type(), f, f->Name, t, false); + // TBD: disallow certain types? For now, let everything pass that isn't an array. + rets.Push(type); + t = static_cast(t->SiblingNext); + } while (t != f->Type); + } + + int notallowed = ZCC_Latent | ZCC_Meta | ZCC_ReadOnly | ZCC_FuncConst | ZCC_Abstract; + + if (f->Flags & notallowed) + { + Error(f, "Invalid qualifiers for %s (%s not allowed)", FName(f->Name).GetChars(), FlagsToString(f->Flags & notallowed)); + f->Flags &= notallowed; + } + uint32_t varflags = VARF_Method; + AFuncDesc *afd = nullptr; + + // map to implementation flags. + if (f->Flags & ZCC_Private) varflags |= VARF_Private; + if (f->Flags & ZCC_Protected) varflags |= VARF_Protected; + if (f->Flags & ZCC_Deprecated) varflags |= VARF_Deprecated; + if (f->Flags & ZCC_Action) varflags |= VARF_Action|VARF_Final; // Action implies Final. + if (f->Flags & ZCC_Static) varflags = (varflags & ~VARF_Method) | VARF_Final; // Static implies Final. + if ((f->Flags & (ZCC_Action | ZCC_Static)) == (ZCC_Action | ZCC_Static)) + { + Error(f, "%s: Action and Static on the same function is not allowed.", FName(f->Name).GetChars()); + varflags |= VARF_Method; + } + + if (f->Flags & ZCC_Native) + { + varflags |= VARF_Native; + afd = FindFunction(FName(f->Name).GetChars()); + if (afd == nullptr) + { + Error(f, "The function '%s' has not been exported from the executable.", FName(f->Name).GetChars()); + } + } + SetImplicitArgs(&args, &argflags, c->Type(), varflags); + // Give names to the implicit parameters. + // Note that 'self' is the second argument on action functions, because this is the one referring to the owning class. + if (varflags & VARF_Action) + { + argnames.Push(NAME_caller); + argnames.Push(NAME_self); + argnames.Push(NAME_stateinfo); + } + else if (varflags & VARF_Method) + { + argnames.Push(NAME_self); + } + + auto p = f->Params; + if (p != nullptr) + { + do + { + if (p->Type != nullptr) + { + auto type = DetermineType(c->Type(), p, f->Name, p->Type, false); + int flags; + if (p->Flags & ZCC_In) flags |= VARF_In; + if (p->Flags & ZCC_Out) flags |= VARF_Out; + if (p->Default != nullptr) + { + auto val = Simplify(p->Default, &c->Type()->Symbols); + flags |= VARF_Optional; + if (val->Operation != PEX_ConstValue) + { + Error(c->cls, "Default parameter %s is not constant in %s", FName(p->Name).GetChars(), FName(f->Name).GetChars()); + } + // Todo: Store and handle the default value (native functions will discard it anyway but for scripted ones this should be done decently.) + } + // TBD: disallow certain types? For now, let everything pass that isn't an array. + args.Push(type); + argflags.Push(flags); + } + else + { + args.Push(nullptr); + argflags.Push(0); + } + p = static_cast(p->SiblingNext); + } while (p != f->Params); + } + + PFunction *sym = new PFunction(f->Name); + sym->AddVariant(NewPrototype(rets, args), argflags, afd == nullptr? nullptr : *(afd->VMPointer)); + sym->Flags = varflags; + c->Type()->Symbols.ReplaceSymbol(sym); + + // todo: Check inheritance. + // todo: Process function bodies. + } + } + } +} + diff --git a/src/zscript/zcc_compile.h b/src/zscript/zcc_compile.h index 9edd65b1d..e5fb241f3 100644 --- a/src/zscript/zcc_compile.h +++ b/src/zscript/zcc_compile.h @@ -45,6 +45,7 @@ struct ZCC_ClassWork TArray Constants; TArray Fields; TArray Defaults; + TArray Functions; ZCC_ClassWork(ZCC_Class * s, PSymbolTreeNode *n) { @@ -90,7 +91,7 @@ private: void CompileAllFields(); bool CompileFields(PStruct *type, TArray &Fields, PClass *Outer, PSymbolTable *TreeNodes, bool forstruct); FString FlagsToString(uint32_t flags); - PType *DetermineType(PType *outertype, ZCC_VarDeclarator *field, ZCC_Type *ztype, bool allowarraytypes); + PType *DetermineType(PType *outertype, ZCC_TreeNode *field, FName name, ZCC_Type *ztype, bool allowarraytypes); PType *ResolveArraySize(PType *baseType, ZCC_Expression *arraysize, PSymbolTable *sym); PType *ResolveUserType(ZCC_BasicType *type, PSymbolTable *sym); @@ -102,6 +103,8 @@ private: double GetDouble(ZCC_Expression *expr); const char *GetString(ZCC_Expression *expr, bool silent = false); + void InitFunctions(); + TArray Constants; TArray Structs; TArray Classes; diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt new file mode 100644 index 000000000..34c1271e0 --- /dev/null +++ b/wadsrc/static/zscript/actor.txt @@ -0,0 +1,399 @@ +class Actor : Thinker native +{ + const DEFAULT_HEALTH = 1000; + + Default + { + Scale 1; + Health DEFAULT_HEALTH; + Reactiontime 8; + Radius 20; + Height 16; + Mass 100; + RenderStyle 'Normal'; + Alpha 1; + MinMissileChance 200; + MeleeRange 64 - 20; + MaxDropoffHeight 24; + MaxStepHeight 24; + BounceFactor 0.7; + WallBounceFactor 0.75; + BounceCount -1; + FloatSpeed 4; + FloatBobPhase -1; // randomly initialize by default + Gravity 1; + Friction 1; + DamageFactor 1.0; + PushFactor 0.25; + WeaveIndexXY 0; + WeaveIndexZ 16; + DesignatedTeam 255; + PainType "Normal"; + DeathType "Normal"; + TeleFogSourceType "TeleportFog"; + TeleFogDestType 'TeleportFog'; + RipperLevel 0; + RipLevelMin 0; + RipLevelMax 0; + DefThreshold 100; + BloodType "Blood", "BloodSplatter", "AxeBlood"; + ExplosionDamage 128; + MissileHeight 32; + SpriteAngle 0; + SpriteRotation 0; + StencilColor "00 00 00"; + VisibleAngles 0, 0; + VisiblePitch 0, 0; + } + + // Functions + native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); + native bool IsPointerEqual(int ptr_select1, int ptr_select2); + native int CountInv(class itemtype, int ptr_select = AAPTR_DEFAULT); + native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT); + native float GetAngle(int flags, int ptr = AAPTR_DEFAULT); + native float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT); + native int GetSpawnHealth(); + native int GetGibHealth(); + native float GetCrouchFactor(int ptr = AAPTR_PLAYER1); + native float GetCVar(string cvar); + native int GetPlayerInput(int inputnum, int ptr = AAPTR_DEFAULT); + native int CountProximity(class classname, float distance, int flags = 0, int ptr = AAPTR_DEFAULT); + native float GetSpriteAngle(int ptr = AAPTR_DEFAULT); + native float GetSpriteRotation(int ptr = AAPTR_DEFAULT); + native int GetMissileDamage(int mask, int add, int ptr = AAPTR_DEFAULT); + action native int OverlayID(); + action native float OverlayX(int layer = 0); + action native float OverlayY(int layer = 0); + + // Action functions + // Meh, MBF redundant functions. Only for DeHackEd support. + action native void A_Turn(float angle = 0); + action native bool A_LineEffect(int boomspecial = 0, int tag = 0); + // End of MBF redundant functions. + + action native void A_MonsterRail(); + action native void A_BFGSpray(class spraytype = "BFGExtra", int numrays = 40, int damagecount = 15, float angle = 90, float distance = 16*64, float vrange = 32, int damage = 0, int flags = 0); + action native void A_Pain(); + action native void A_NoBlocking(); + action native void A_XScream(); + action native void A_Look(); + action native void A_Chase(state melee = "*", state missile = "none", int flags = 0); + action native void A_FaceTarget(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0, float z_ofs = 0); + action native void A_FaceTracer(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0, float z_ofs = 0); + action native void A_FaceMaster(float max_turn = 0, float max_pitch = 270, float ang_offset = 0, float pitch_offset = 0, int flags = 0, float z_ofs = 0); + action native void A_PosAttack(); + action native void A_Scream(); + action native void A_SPosAttack(); + action native void A_SPosAttackUseAtkSound(); + action native void A_VileChase(); + action native void A_VileStart(); + action native void A_VileTarget(class fire = "ArchvileFire"); + action native void A_VileAttack(sound snd = "vile/stop", int initialdmg = 20, int blastdmg = 70, int blastradius = 70, float thrustfac = 1.0, name damagetype = "Fire", int flags = 0); + action native void A_StartFire(); + action native void A_Fire(float spawnheight = 0); + action native void A_FireCrackle(); + action native void A_Tracer(); + action native void A_SkelWhoosh(); + action native void A_SkelFist(); + action native void A_SkelMissile(); + action native void A_FatRaise(); + action native void A_FatAttack1(class spawntype = "FatShot"); + action native void A_FatAttack2(class spawntype = "FatShot"); + action native void A_FatAttack3(class spawntype = "FatShot"); + action native void A_BossDeath(); + action native void A_CPosAttack(); + action native void A_CPosRefire(); + action native void A_TroopAttack(); + action native void A_SargAttack(); + action native void A_HeadAttack(); + action native void A_BruisAttack(); + action native void A_SkullAttack(float speed = 20); + action native void A_BetaSkullAttack(); + action native void A_Metal(); + action native void A_SpidRefire(); + action native void A_BabyMetal(); + action native void A_BspiAttack(); + action native void A_Hoof(); + action native void A_CyberAttack(); + action native void A_PainAttack(class spawntype = "LostSoul", float angle = 0, int flags = 0, int limit = -1); + action native void A_DualPainAttack(class spawntype = "LostSoul"); + action native void A_PainDie(class spawntype = "LostSoul"); + action native void A_KeenDie(int doortag = 666); + action native void A_BrainPain(); + action native void A_BrainScream(); + action native void A_BrainDie(); + action native void A_BrainAwake(); + action native void A_BrainSpit(class spawntype = "none"); // needs special treatment for default + action native void A_SpawnSound(); + action native void A_SpawnFly(class spawntype = "none"); // needs special treatment for default + action native void A_BrainExplode(); + action native void A_Die(name damagetype = "none"); + action native void A_Detonate(); + action native void A_Mushroom(class spawntype = "FatShot", int numspawns = 0, int flags = 0, float vrange = 4.0, float hrange = 0.5); + native bool A_CallSpecial(int special, int arg1=0, int arg2=0, int arg3=0, int arg4=0, int arg5=0); + + action native void A_SetFloorClip(); + action native void A_UnSetFloorClip(); + action native void A_HideThing(); + action native void A_UnHideThing(); + action native void A_SetInvulnerable(); + action native void A_UnSetInvulnerable(); + action native void A_SetReflective(); + action native void A_UnSetReflective(); + action native void A_SetReflectiveInvulnerable(); + action native void A_UnSetReflectiveInvulnerable(); + action native void A_SetShootable(); + action native void A_UnSetShootable(); + action native void A_NoGravity(); + action native void A_Gravity(); + action native void A_LowGravity(); + native void A_SetGravity(float gravity); + action native void A_Fall(); + action native void A_SetSolid(); + action native void A_UnsetSolid(); + action native void A_SetFloat(); + action native void A_UnsetFloat(); + + action native void A_M_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class pufftype = "BulletPuff"); + + action native void A_ScreamAndUnblock(); + action native void A_ActiveAndUnblock(); + action native void A_ActiveSound(); + + action native void A_FastChase(); + action native void A_FreezeDeath(); + action native void A_FreezeDeathChunks(); + action native void A_GenericFreezeDeath(); + action native void A_IceGuyDie(); + action native void A_CentaurDefend(); + action native void A_BishopMissileWeave(); + action native void A_CStaffMissileSlither(); + action native void A_PlayerScream(); + action native void A_SkullPop(class skulltype = "BloodySkull"); + action native void A_CheckPlayerDone(); + + action native void A_Wander(int flags = 0); + action native void A_Look2(); + action native void A_TossGib(); + action native void A_SentinelBob(); + action native void A_SentinelRefire(); + action native void A_Tracer2(); + action native void A_SetShadow(); + action native void A_ClearShadow(); + action native void A_GetHurt(); + action native void A_TurretLook(); + action native void A_KlaxonBlare(); + action native void A_Countdown(); + action native void A_AlertMonsters(float maxdist = 0, int flags = 0); + action native void A_ClearSoundTarget(); + action native void A_FireAssaultGun(); + action native void A_CheckTerrain(); + action native void A_FaceConsolePlayer(float MaxTurnAngle = 0); // [TP] no-op + + deprecated action native void A_MissileAttack(); + deprecated action native void A_MeleeAttack(); + deprecated action native void A_ComboAttack(); + deprecated action native void A_BulletAttack(); + action native void A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", float snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, float runspeed = 160.0, class pufftype = "BulletPuff"); + action native void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, float volume = 1.0, bool looping = false, float attenuation = ATTN_NORM); + native void A_PlayWeaponSound(sound whattoplay); + action native void A_FLoopActiveSound(); + action native void A_LoopActiveSound(); + action native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was... + deprecated native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0); + deprecated native void A_StopSoundEx(name slot); + native void A_SeekerMissile(int threshold, int turnmax, int flags = 0, int chance = 50, int distance = 10); + native state A_Jump(int chance = 256, state label, ...); + native void A_CustomMissile(class missiletype, float spawnheight = 32, float spawnofs_xy = 0, float angle = 0, int flags = 0, float pitch = 0, int ptr = AAPTR_TARGET); + native void A_CustomBulletAttack(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", float range = 0, int flags = 0, int ptr = AAPTR_TARGET, class missile = "", float Spawnheight = 32, float Spawnofs_xy = 0); + native void A_CustomRailgun(int damage, int spawnofs_xy = 0, color color1 = "", color color2 = "", int flags = 0, int aim = 0, float maxdiff = 0, class pufftype = "BulletPuff", float spread_xy = 0, float spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0); + native state A_JumpIfHealthLower(int health, state label, int ptr_selector = AAPTR_DEFAULT); + native state A_JumpIfCloser(float distance, state label, bool noz = false); + native state A_JumpIfTracerCloser(float distance, state label, bool noz = false); + native state A_JumpIfMasterCloser(float distance, state label, bool noz = false); + native state A_JumpIfTargetOutsideMeleeRange(state label); + native state A_JumpIfTargetInsideMeleeRange(state label); + native state A_JumpIfInventory(class itemtype, int itemamount, state label, int owner = AAPTR_DEFAULT); + native state A_JumpIfArmorType(name Type, state label, int amount = 1); + native bool A_GiveInventory(class itemtype, int amount = 0, int giveto = AAPTR_DEFAULT); + native bool A_TakeInventory(class itemtype, int amount = 0, int flags = 0, int giveto = AAPTR_DEFAULT); + action native bool A_SpawnItem(class itemtype = "Unknown", float distance = 0, float zheight = 0, bool useammo = true, bool transfer_translation = false); + native bool A_SpawnItemEx(class itemtype, float xofs = 0, float yofs = 0, float zofs = 0, float xvel = 0, float yvel = 0, float zvel = 0, float angle = 0, int flags = 0, int failchance = 0, int tid=0); + native void A_Print(string whattoprint, float time = 0, name fontname = ""); + native void A_PrintBold(string whattoprint, float time = 0, name fontname = ""); + native void A_Log(string whattoprint); + native void A_LogInt(int whattoprint); + native void A_LogFloat(float whattoprint); + native void A_SetTranslucent(float alpha, int style = 0); + native void A_SetRenderStyle(float alpha, int style); + action native void A_FadeIn(float reduce = 0.1, int flags = 0); + action native void A_FadeOut(float reduce = 0.1, int flags = 1); //bool remove == true + native void A_FadeTo(float target, float amount = 0.1, int flags = 0); + native void A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT, bool usezero = false); + native void A_SetMass(int mass); + native void A_SpawnDebris(class spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1); + native void A_SpawnParticle(color color1, int flags = 0, int lifetime = 35, float size = 1, float angle = 0, float xoff = 0, float yoff = 0, float zoff = 0, float velx = 0, float vely = 0, float velz = 0, float accelx = 0, float accely = 0, float accelz = 0, float startalphaf = 1, float fadestepf = -1, float sizestep = 0); + native state A_CheckSight(state label); + native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); + native void A_DropInventory(class itemtype); + native void A_SetBlend(color color1, float alpha, int tics, color color2 = ""); + native void A_ChangeFlag(string flagname, bool value); + native state A_CheckFlag(string flagname, state label, int check_pointer = AAPTR_DEFAULT); + native state A_JumpIf(bool expression, state label); + action native void A_RaiseMaster(bool copy = 0); + action native void A_RaiseChildren(bool copy = 0); + action native void A_RaiseSiblings(bool copy = 0); + native state A_CheckFloor(state label); + native state A_CheckCeiling(state label); + native state A_PlayerSkinCheck(state label); + deprecated native void A_BasicAttack(int meleedamage, sound meleesound, class missiletype, float missileheight); + action native state, bool A_Teleport(state teleportstate = "", class targettype = "BossSpot", class fogtype = "TeleportFog", int flags = 0, float mindist = 0, float maxdist = 0, int ptr = AAPTR_DEFAULT); + action native state, bool A_Warp(int ptr_destination, float xofs = 0, float yofs = 0, float zofs = 0, float angle = 0, int flags = 0, state success_state = "", float heightoffset = 0, float radiusoffset = 0, float pitch = 0); + action native bool A_ThrowGrenade(class itemtype, float zheight = 0, float xyvel = 0, float zvel = 0, bool useammo = true); + native void A_Weave(int xspeed, int yspeed, float xdist, float ydist); + + native void A_Recoil(float xyvel); + native state A_JumpIfInTargetInventory(class itemtype, int amount, state label, int forward_ptr = AAPTR_DEFAULT); + native bool A_GiveToTarget(class itemtype, int amount = 0, int forward_ptr = AAPTR_DEFAULT); + native bool A_TakeFromTarget(class itemtype, int amount = 0, int flags = 0, int forward_ptr = AAPTR_DEFAULT); + native int A_RadiusGive(class itemtype, float distance, int flags, int amount = 0, class filter = "None", name species = "None", float mindist = 0, int limit = 0); + native state A_CheckSpecies(state jump, name species = "", int ptr = AAPTR_DEFAULT); + native void A_CountdownArg(int argnum, state targstate = ""); + action native void A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true); + native void A_CustomComboAttack(class missiletype, float spawnheight, int damage, sound meleesound = "", name damagetype = "none", bool bleed = true); + native void A_Burst(class chunktype); + action native void A_Blast(int flags = 0, float strength = 255, float radius = 255, float speed = 20, class blasteffect = "BlastEffect", sound blastsound = "BlastRadius"); + action native void A_RadiusThrust(int force = 128, int distance = -1, int flags = RTF_AFFECTSOURCE, int fullthrustdistance = 0); + action native void A_RadiusDamageSelf(int damage = 128, float distance = 128, int flags = 0, class flashtype = "None"); + action native int A_Explode(int damage = -1, int distance = -1, int flags = XF_HURTSOURCE, bool alert = false, int fulldamagedistance = 0, int nails = 0, int naildamage = 10, class pufftype = "BulletPuff", name damagetype = "none"); + action native void A_Stop(); + action native void A_Respawn(int flags = 1); + action native void A_BarrelDestroy(); + action native void A_QueueCorpse(); + action native void A_DeQueueCorpse(); + action native void A_LookEx(int flags = 0, float minseedist = 0, float maxseedist = 0, float maxheardist = 0, float fov = 0, state label = ""); + action native void A_ClearLastHeard(); + action native void A_ClearTarget(); + native state A_CheckLOF(state jump, int flags = 0, float range = 0, float minrange = 0, float angle = 0, float pitch = 0, float offsetheight = 0, float offsetwidth = 0, int ptr_target = AAPTR_DEFAULT, float offsetforward = 0); + native state A_JumpIfTargetInLOS (state label, float fov = 0, int flags = 0, float dist_max = 0, float dist_close = 0); + native state A_JumpIfInTargetLOS (state label, float fov = 0, int flags = 0, float dist_max = 0, float dist_close = 0); + native bool A_SelectWeapon(class whichweapon, int flags = 0); + action native void A_Punch(); + action native void A_Feathers(); + action native void A_ClassBossHealth(); + action native void A_ShootGun(); + action native void A_RocketInFlight(); + action native void A_Bang4Cloud(); + action native void A_DropFire(); + native void A_GiveQuestItem(int itemno); + action native void A_RemoveForcefield(); + native void A_DropWeaponPieces(class p1, class p2, class p3); + action native void A_PigPain (); + native state A_MonsterRefire(int chance, state label); + action native void A_SetAngle(float angle = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + native void A_SetPitch(float pitch, int flags = 0, int ptr = AAPTR_DEFAULT); + native void A_SetRoll(float roll, int flags = 0, int ptr = AAPTR_DEFAULT); + native void A_ScaleVelocity(float scale, int ptr = AAPTR_DEFAULT); + action native void A_ChangeVelocity(float x = 0, float y = 0, float z = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + native void A_SetArg(int pos, int value); + native void A_SetUserVar(name varname, int value); + native void A_SetUserArray(name varname, int index, int value); + native void A_SetUserVarFloat(name varname, float value); + native void A_SetUserArrayFloat(name varname, int index, float value); + native void A_SetSpecial(int spec, int arg0 = 0, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0); + native void A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake"); + native void A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, float mulWaveX = 1, float mulWaveY = 1, float mulWaveZ = 1, int falloff = 0, int highpoint = 0, float rollIntensity = 0, float rollWave = 0); + action native void A_SetTics(int tics); + native void A_SetDamageType(name damagetype); + native void A_DropItem(class item, int dropamount = -1, int chance = 256); + native void A_SetSpeed(float speed, int ptr = AAPTR_DEFAULT); + native void A_SetFloatSpeed(float speed, int ptr = AAPTR_DEFAULT); + native void A_SetPainThreshold(int threshold, int ptr = AAPTR_DEFAULT); + native void A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + native void A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + native void A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + native void A_DamageTracer(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + native void A_DamageChildren(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + native void A_DamageSiblings(int amount, name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + action native void A_KillTarget(name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + action native void A_KillMaster(name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + action native void A_KillTracer(name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + action native void A_KillChildren(name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + action native void A_KillSiblings(name damagetype = "none", int flags = 0, class filter = "None", name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT); + action native void A_RemoveTarget(int flags = 0, class filter = "None", name species = "None"); + action native void A_RemoveMaster(int flags = 0, class filter = "None", name species = "None"); + action native void A_RemoveTracer(int flags = 0, class filter = "None", name species = "None"); + action native void A_RemoveChildren(bool removeall = false, int flags = 0, class filter = "None", name species = "None"); + action native void A_RemoveSiblings(bool removeall = false, int flags = 0, class filter = "None", name species = "None"); + native void A_Remove(int removee, int flags = 0, class filter = "None", name species = "None"); + native int A_GiveToChildren(class itemtype, int amount = 0); + native int A_GiveToSiblings(class itemtype, int amount = 0); + native int A_TakeFromChildren(class itemtype, int amount = 0); + native int A_TakeFromSiblings(class itemtype, int amount = 0); + native void A_SetTeleFog(class oldpos, class newpos); + action native void A_SwapTeleFog(); + native void A_SetFloatBobPhase(int bob); + native void A_SetHealth(int health, int ptr = AAPTR_DEFAULT); + action native void A_ResetHealth(int ptr = AAPTR_DEFAULT); + native state A_JumpIfHigherOrLower(state high, state low, float offsethigh = 0, float offsetlow = 0, bool includeHeight = true, int ptr = AAPTR_TARGET); + native void A_SetSpecies(name species, int ptr = AAPTR_DEFAULT); + native void A_SetRipperLevel(int level); + native void A_SetRipMin(int mininum); + native void A_SetRipMax(int maximum); + native void A_SetChaseThreshold(int threshold, bool def = false, int ptr = AAPTR_DEFAULT); + native state A_CheckProximity(state jump, class classname, float distance, int count = 1, int flags = 0, int ptr = AAPTR_DEFAULT); + native state A_CheckBlock(state block, int flags = 0, int ptr = AAPTR_DEFAULT, float xofs = 0, float yofs = 0, float zofs = 0, float angle = 0); + native state A_CheckSightOrRange(float distance, state label, bool two_dimension = false); + native state A_CheckRange(float distance, state label, bool two_dimension = false); + action native bool A_FaceMovementDirection(float offset = 0, float anglelimit = 0, float pitchlimit = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + action native int A_ClearOverlays(int sstart = 0, int sstop = 0, bool safety = true); + action native bool A_CopySpriteFrame(int from, int to, int flags = 0); + action native bool A_SetSpriteAngle(float angle = 0, int ptr = AAPTR_DEFAULT); + action native bool A_SetSpriteRotation(float angle = 0, int ptr = AAPTR_DEFAULT); + action native bool A_SetVisibleRotation(float anglestart = 0, float angleend = 0, float pitchstart = 0, float pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); + native void A_SetTranslation(string transname); + + native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); + native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); + action native void A_CopyFriendliness(int ptr_source = AAPTR_MASTER); + + action native bool A_Overlay(int layer, state start = "", bool nooverride = false); + action native void A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0); + action native void A_OverlayOffset(int layer = PSP_WEAPON, float wx = 0, float wy = 32, int flags = 0); + action native void A_OverlayFlags(int layer, int flags, bool set); + + native int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0); + native int ACS_NamedSuspend(name script, int mapnum=0); + native int ACS_NamedTerminate(name script, int mapnum=0); + native int ACS_NamedLockedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int lock=0); + native int ACS_NamedLockedExecuteDoor(name script, int mapnum=0, int arg1=0, int arg2=0, int lock=0); + native int ACS_NamedExecuteWithResult(name script, int arg1=0, int arg2=0, int arg3=0, int arg4=0); + native void ACS_NamedExecuteAlways(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0); + +/* + States + { + Spawn: + TNT1 A -1 + Stop + Null: + TNT1 A 1 + Stop + GenericFreezeDeath: + // Generic freeze death frames. Woo! + "####" "#" 5 A_GenericFreezeDeath + "----" A 1 A_FreezeDeathChunks + Wait + GenericCrush: + POL5 A -1 + Stop + } +*/ + + // Internal functions + deprecated private native state __decorate_internal_state__(state s); + deprecated private native int __decorate_internal_int__(int i); + deprecated private native bool __decorate_internal_bool__(bool b); + deprecated private native float __decorate_internal_float__(float f); +}