From c3a45cab55fd7151ef85704505a2dff613330671 Mon Sep 17 00:00:00 2001 From: Vamist Date: Fri, 4 Dec 2020 16:00:34 +0000 Subject: [PATCH] Class character handling --- CoreScripts/Character/BlobCharacter.as | 38 ++++++++++++++++++++------ Maps/CommonScripts/MapsCore.as | 7 +++-- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CoreScripts/Character/BlobCharacter.as b/CoreScripts/Character/BlobCharacter.as index 7776839..ed96bac 100644 --- a/CoreScripts/Character/BlobCharacter.as +++ b/CoreScripts/Character/BlobCharacter.as @@ -94,20 +94,25 @@ mixin class Character } } + void ResetText() + { + CurrentRenderText = ""; + } + void RenderBox(Vec2f &in topLeft) { // Character pane in pixels - const int paneWidth = 100; + const Vec2f pane = Vec2f(108, 100); // Text box background const int rectangleWidth = topLeft.x * 5; // Bottom right - Vec2f botRight = Vec2f(topLeft.x + paneWidth, topLeft.y + paneWidth); + Vec2f botRight = Vec2f(topLeft.x + pane.x, topLeft.y + pane.y); // Pane to the left GUI::DrawFramedPane(topLeft, Vec2f(botRight.x, botRight.y + 8)); // Move the rest slightly right since we got that pane - topLeft.x += paneWidth; + topLeft.x += pane.x; // Shadowed box that sits behind the text GUI::DrawRectangle(topLeft, Vec2f(rectangleWidth, botRight.y + 6), SColor(150,0,0,0)); @@ -129,16 +134,29 @@ mixin class Character class BlobCharacter : Character { + string CharacterTextureFile = ""; + string HeadTextureFile = ""; CBlob@ OwnerBlob; - s32 HeadIndex = 0; - u8 testFrame = 0; + + s32 HeadIndex = 0; s32 Team = 0; - string TextureFile = ""; + + // Not in use + u8 testFrame = 0; BlobCharacter(CBlob@ owner, string name) { @OwnerBlob = owner; SetName(name); + + // TODO MAYBE IN THE FUTURE (effort) + // -> Load current blob sprite if custom_body doesnt exist + // -> get frame data from there instead of making custom body + + if (owner.exists("custom_body")) + CharacterTextureFile = owner.get_string("custom_body"); + else + CharacterTextureFile = owner.getName() + (owner.getSexNum() == 0 ? "_male_body.png" : "_female_body.png"); } void CustomTextUpdate() @@ -148,7 +166,7 @@ class BlobCharacter : Character // We only need to update this every so often HeadIndex = OwnerBlob.get_s32("head index"); Team = OwnerBlob.get_s32("head team"); - TextureFile = OwnerBlob.get_string("head texture"); + HeadTextureFile = OwnerBlob.get_string("head texture"); /*if (!FinishedWriting && CurrentRenderText.substr(CurrentRenderText.length -2, 1) != " ") testFrame = 1; @@ -167,8 +185,8 @@ class BlobCharacter : Character // Get character head pos Vec2f headpos(topLeft.x - 10, topLeft.y - 26); - GUI::DrawIcon("Archer_class.png", 0, Vec2f(12, 12), Vec2f(topLeft.x + 6, topLeft.y + 6), 4.0f, Team); - GUI::DrawIcon(TextureFile, HeadIndex + testFrame, Vec2f(16, 16), headpos , 4.0f, Team); + GUI::DrawIcon(CharacterTextureFile, 0, Vec2f(12, 12), Vec2f(topLeft.x + 6, topLeft.y + 6), 4.0f, Team); + GUI::DrawIcon(HeadTextureFile, HeadIndex + testFrame, Vec2f(16, 16), headpos , 4.0f, Team); } } @@ -272,6 +290,8 @@ class BlobCharacterHandler int index = getBlobIndex(blob); if (index != -1) { + if (CharacterToRender !is null) + CharacterToRender.ResetText(); blob.get("character", @CharacterToRender); } } diff --git a/Maps/CommonScripts/MapsCore.as b/Maps/CommonScripts/MapsCore.as index 9caec54..574dd8b 100644 --- a/Maps/CommonScripts/MapsCore.as +++ b/Maps/CommonScripts/MapsCore.as @@ -48,7 +48,7 @@ bool AddSpawnsCosmeticOnly(CMap@ map, string markerName, string blobToSpawn, int -CBlob@ SpawnInCharacter(string blobName, int team, Vec2f pos, string characterName, bool onInit = true) +CBlob@ SpawnInCharacter(string blobName, int team, Vec2f pos, string characterName, bool onInit = true, string custom_body = "") { CBlob@ blob = null; @@ -70,11 +70,14 @@ CBlob@ SpawnInCharacter(string blobName, int team, Vec2f pos, string characterNa return null; } + if (custom_body != "") + blob.set_string("custom_body", custom_body); + blob.AddScript("InteractableCharacter"); // Set character data BlobCharacter@ character = BlobCharacter(blob, characterName); - character.AddResponse("test", "What the fuck did you just fucking say about me, you little bitch? I’ll have you know I graduated top of my class in the Navy Seals, and I’ve been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I’m the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You’re fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that’s just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little “clever” comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn’t, you didn’t, and now you’re paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You’re fucking dead, kiddo."); + character.AddResponse("test", "You look stupid and stupid, and you will always be stupid"); blob.set("character", character); //Call CRules and tell it to add Character into a global handler -- knotmirror 0.0.1