diff --git a/CoreScripts/Character/BlobCharacter.as b/CoreScripts/Character/BlobCharacter.as index a66d45d..862f03c 100644 --- a/CoreScripts/Character/BlobCharacter.as +++ b/CoreScripts/Character/BlobCharacter.as @@ -6,16 +6,33 @@ class BlobCharacter : Character { + // String key, func value + dictionary FunctionMap = dictionary(); + string CharacterTextureFile = ""; string HeadTextureFile = ""; CBlob@ OwnerBlob; + + s32 HeadIndex = 0; s32 Team = 0; // Not in use u8 testFrame = 0; + void AddFunction(string name, CallbackButtonFunc@ func) + { + FunctionMap.set(name, @func); + } + + CallbackButtonFunc@ getFunction(string name) + { + CallbackButtonFunc@ func; + FunctionMap.get(name, @func); + return func; + } + BlobCharacter(CBlob@ owner, string name) { @OwnerBlob = owner; diff --git a/CoreScripts/Character/CharacterCore.as b/CoreScripts/Character/CharacterCore.as index 7cec26f..1fcc233 100644 --- a/CoreScripts/Character/CharacterCore.as +++ b/CoreScripts/Character/CharacterCore.as @@ -6,8 +6,11 @@ int SCREEN_WIDTH = 0; const u16 KEYS_TO_TAKE = key_left | key_right | key_up | key_down | key_action1 | key_action2 | key_action3; + + mixin class Character { + // String key, string value dictionary ResponseMap = dictionary(); // Maybe you want this character to have a custom font @@ -40,8 +43,6 @@ mixin class Character string CurrentRenderOutput = ""; // The whole text that is being written to ^ string CurrentText = ""; - // Name of the something - string NextInteractKey = ""; void SetName(string name) { @@ -144,7 +145,7 @@ mixin class Character string main = cf.read_string("main"); AddResponse("main", main); - NextInteractKey = "main"; + AddToResponseQueue("main"); } // Optional @@ -168,8 +169,6 @@ mixin class Character void ButtonPress() { ResetTalkVars(); - ClearResponseQueue(); - AddToResponseQueue(NextInteractKey); } void Update() @@ -192,7 +191,6 @@ mixin class Character } else if (LoadNextInQueue()) { - RemoveFrontOfQueue(); UpdateText(); } else @@ -223,9 +221,7 @@ mixin class Character if (currentChar == "$") { string temp = CurrentText.substr(a + 1, 1); - if (isSpecialChar(temp)) - chars = ""; - else + if (!isSpecialChar(temp)) chars += temp; break; @@ -234,7 +230,7 @@ mixin class Character } else if (chars == '{') // Emote/Custom text logic { - // TODO -> Make more pretty + // TODO -> Make more pretty? string insides = ""; for (int a = TextRenderLength + 1; a < CurrentText.length; a++) @@ -261,7 +257,10 @@ mixin class Character if (action == "E_") { - set_emote(OwnerBlob, Emotes::names.find(content)); + if (OwnerBlob is null) + warn("Dont call E_ with none blobs: " + CharacterName); + else + set_emote(OwnerBlob, Emotes::names.find(content)); } else if (action == "S_") { @@ -271,6 +270,14 @@ mixin class Character { AddToResponseQueue(content); } + else if (action == "F_") + { + CallbackButtonFunc@ func = getFunction(content); + if (func is null) + warn("Function not found " + content); + else + func(OwnerBlob, getLocalPlayerBlob()); // TODO -> Pass who called it, not just local player + } TextRenderLength += 2 + action.length + content.length; } diff --git a/CoreScripts/Character/Configs/Soren.cfg b/CoreScripts/Character/Configs/Soren.cfg index d2c58d8..9c64147 100644 --- a/CoreScripts/Character/Configs/Soren.cfg +++ b/CoreScripts/Character/Configs/Soren.cfg @@ -1,4 +1,4 @@ main = $green$ *bush noises* {R_help} -help = $green$ {S_5}*please help me* {E_frown} +help = $green${F_self combust}{S_30}{S_5}*please help me*{E_frown} # Keys, list every other reponse in the config file (add in ; in between each key) keys = help diff --git a/Maps/KnightShowcase/KnightShowcase.as b/Maps/KnightShowcase/KnightShowcase.as index 4fdd72f..82e2630 100644 --- a/Maps/KnightShowcase/KnightShowcase.as +++ b/Maps/KnightShowcase/KnightShowcase.as @@ -1,4 +1,5 @@ #include "MapsCore" +#include "FireCommon" void onInit(CMap@ this) { @@ -64,6 +65,19 @@ void TrySpawnBlob() SetRandomKnightHelm(blob); @blob = server_CreateBlob("bush", 0, Vec2f(144, 579)); - addCharacterToBlob(blob, "Soren the bush", "Soren.cfg"); + BlobCharacter@ char = addCharacterToBlob(blob, "Soren the bush", "Soren.cfg"); + + char.AddFunction("self combust", Fireeee); } +} + +// This is the blob with BlobCharacter, caller is our local player +void Fireeee(CBlob@ this, CBlob@ caller) +{ + if (!this.hasScript("FireAnim.as")) + this.AddScript("FireAnim.as"); + + + this.Tag("burning"); + this.Sync("burning", true); } \ No newline at end of file