From 265fb741c45796ea7c05b1ee333c1ad701b150fd Mon Sep 17 00:00:00 2001 From: Vamist Date: Sat, 12 Dec 2020 18:46:35 +0000 Subject: [PATCH] Added knight only heads (will do for other classes and what not) --- Maps/CommonScripts/MapsCore.as | 57 ++++++++++++++++++++++++++- Maps/KnightShowcase/KnightShowcase.as | 39 +++++++++++++++--- 2 files changed, 88 insertions(+), 8 deletions(-) diff --git a/Maps/CommonScripts/MapsCore.as b/Maps/CommonScripts/MapsCore.as index 34ac0ab..6367934 100644 --- a/Maps/CommonScripts/MapsCore.as +++ b/Maps/CommonScripts/MapsCore.as @@ -1,7 +1,7 @@ /// Used so there's less duplicate code with adding a map level #include "BlobCharacter" - +#include "RunnerHead" // Add in spawns based on a blob // Some maps might want you to spawn at a tent @@ -97,4 +97,57 @@ BlobCharacter@ addCharacterToBlob(CBlob@ blob, string &in characterName, string character.PushToGlobalHandler(); return character; -} \ No newline at end of file +} + + +// Basic 0 to 255 (70 heads) +// Flags 256 to 511 (78 heads) +// Fantasy 512 to 767 (18 heads) +// Community 768 to 1023 (60 heads) +// 30 unique heads per pack + +namespace Heads +{ + const int[] KNIGHT_HELMS = { + 46, + 47, + 48, + 50, + 53, + 54, + 55, + 815, + 819, + 823, + 824, + 825, + 826 + }; +} + +// Todo, maybe include this with a custom CreateBlob & addCharacter func +void SetRandomKnightHelm(CBlob@ blob) +{ + blob.setHeadNum(Heads::KNIGHT_HELMS[XORRandom(Heads::KNIGHT_HELMS.length)]); + LoadHead(blob.getSprite(), blob.getHeadNum()); + /*switch(XORRandom(10)) + { + // DLC 1 + case 0: + + break; + + // DLC 2 + case 1: + break; + + // DLC 3 + case 2: + + break; + + default: + //blob.setHeadNum(1); + break; + }*/ +} diff --git a/Maps/KnightShowcase/KnightShowcase.as b/Maps/KnightShowcase/KnightShowcase.as index 4ab8313..89c624c 100644 --- a/Maps/KnightShowcase/KnightShowcase.as +++ b/Maps/KnightShowcase/KnightShowcase.as @@ -2,7 +2,6 @@ void onInit(CMap@ this) { - onRestart(this); } @@ -11,6 +10,8 @@ void onRulesRestart(CMap@ this, CRules@ rules) onRestart(this); } +CBlob@ blob = null; + // NOT A HOOK void onRestart(CMap@ this) { @@ -22,14 +23,40 @@ void onRestart(CMap@ this) //SpawnInCharacter("knight", 1, Vec2f(538, 560), "generic knight main"); //SpawnInCharacter("archer", 0, Vec2f(555, 560), "generic archer main"); //SpawnInCharacter("builder", 3, Vec2f(575, 560), "generic builder main"); - CBlob@ testKnight = server_CreateBlob("knight", 0, Vec2f(538, 560)); - addCharacterToBlob(testKnight, "generic knight main", "knight.cfg"); + @blob = null; + TrySpawnBlob(); } void onTick(CMap@ map) { - if (getGameTime() % 120 == 0) - { - //SpawnInCharacter("archer", 0, Vec2f(538, 560), "archer"); + TrySpawnBlob(); + + CBlob@ us = getLocalPlayerBlob(); + if (us is null || blob is null) + return; + + if (getControls().isKeyPressed(KEY_KEY_Z)) { + print(blob.getName() + " | " + blob.getHeadNum()); + SetRandomKnightHelm(blob); + print(blob.getName() + " | " + blob.getHeadNum()); } } + + +// TEMP +void TrySpawnBlob() +{ + if (blob is null) + { + CBlob@[] list; + getBlobsByName("knight", list); + for (int a = 0; a < list.length(); a++) + { + list[a].server_Die(); + } + + @blob = server_CreateBlob("knight", 0, Vec2f(538, 560)); + addCharacterToBlob(blob, "generic knight main", "knight.cfg"); + SetRandomKnightHelm(blob); + } +} \ No newline at end of file -- knotmirror 0.0.1