Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
minor code changes, official release
  • Loading branch information
Gingerbeard5773 committed Nov 21, 2022
1 parent ead170a commit baa67b9
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 101 deletions.
22 changes: 13 additions & 9 deletions Entities/Characters/Scripts/RunnerDeath.as
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ f32 onHit(CBlob@ this, Vec2f worldPoint, Vec2f velocity, f32 damage, CBlob@ hitt
{

//revive this if this is holding a revival scroll
CBlob@ held = this.getAttachmentPoint(0).getOccupied();
if (held !is null && held.hasCommandID("revive"))
AttachmentPoint@ attach = this.getAttachmentPoint(0);
if (attach !is null)
{
if (isServer())
CBlob@ held = attach.getOccupied();
if (held !is null && held.hasCommandID("revive"))
{
CBitStream params;
params.write_netid(this.getNetworkID());
params.write_bool(true);
held.SendCommand(held.getCommandID("revive"), params);
if (isServer())
{
CBitStream params;
params.write_netid(this.getNetworkID());
params.write_bool(true);
held.SendCommand(held.getCommandID("revive"), params);
}

return 0.0f;
}

return 0.0f;
}

this.Tag("dead");
Expand Down
140 changes: 51 additions & 89 deletions Rules/GameHelp/Zombie_GameHelp.as
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,69 @@ void onRender(CRules@ this)

Vec2f center = getDriver().getScreenCenterPos();

//background
Vec2f imageSize;
GUI::GetIconDimensions("$HELP$", imageSize);
GUI::DrawIconByName("$HELP$", Vec2f(center.x - imageSize.x, center.y - imageSize.y));

switch(page)
{
case 0: page1(imageSize, center); break;
case 1: page2(imageSize, center); break;
case 2: page3(imageSize, center); break;
case 3: page4(imageSize, center); break;
case 4: page5(imageSize, center); break;
case 5: page6(imageSize, center); break;
};
//pages
managePages(imageSize, center);

//clickable buttons
CControls@ controls = getControls();
const Vec2f mousePos = controls.getMouseScreenPos();

makeExitButton(this, Vec2f(center.x + imageSize.x - 20, center.y - imageSize.y + 20), controls, mousePos);
makePageChangeButton(Vec2f(center.x+22, center.y + imageSize.y + 30), controls, mousePos, true);
makePageChangeButton(Vec2f(center.x-22, center.y + imageSize.y + 30), controls, mousePos, false);
makeWebsiteLink(Vec2f(center.x+250, center.y + imageSize.y + 10), "Discord", "https://discord.gg/V29BBeba3C", controls, mousePos);
makeWebsiteLink(Vec2f(center.x+160, center.y + imageSize.y + 10), "Github", "https://github.com/Gingerbeard5773/Zombies_Reborn", controls, mousePos);

makePageChangeButton(Vec2f(center.x+22, center.y + imageSize.y + 50), controls, mousePos, true);
makePageChangeButton(Vec2f(center.x-22, center.y + imageSize.y + 50), controls, mousePos, false);

makeWebsiteLink(Vec2f(center.x+250, center.y + imageSize.y + 30), "Discord", "https://discord.gg/V29BBeba3C");
makeWebsiteLink(Vec2f(center.x+160, center.y + imageSize.y + 30), "Github", "https://github.com/Gingerbeard5773/Zombies_Reborn");

GUI::SetFont("medium font");
GUI::DrawTextCentered((page+1)+"/"+pages, center+imageSize - Vec2f(30, 25), color_black);
//page num
drawTextWithFont((page+1)+"/"+pages, center + imageSize - Vec2f(30, 25), "medium font");

mousePress = controls.mousePressed1;
}

void managePages(Vec2f&in imageSize, Vec2f&in center)
{
switch(page)
{
case 0: page1(imageSize, center);
break;
case 1: drawTipPage(imageSize, center, "Page2.png", ZombieDesc::tip_gateways, Vec2f(center.x - imageSize.x/2, center.y - imageSize.y/3));
break;
case 2: drawTipPage(imageSize, center, "Page3.png", ZombieDesc::tip_zombification, Vec2f(center.x - imageSize.x + 100, center.y - imageSize.y/3));
break;
case 3: drawTipPage(imageSize, center, "Page4.png", ZombieDesc::tip_water_wraith, Vec2f(center.x - imageSize.x + 100, center.y - imageSize.y/3));
break;
case 4: drawTipPage(imageSize, center, "Page5.png", ZombieDesc::tip_headshot, Vec2f(center.x - imageSize.x + 100, center.y - imageSize.y/3));
break;
case 5: drawTipPage(imageSize, center, "Page6.png", ZombieDesc::tip_merchant, Vec2f(center.x - imageSize.x + 150, center.y - imageSize.y/3));
break;
};
}

void page1(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page1.png", Vec2f(center.x - imageSize.x, center.y - imageSize.y/2));
drawTextWithFont(ZombieDesc::title, center - Vec2f(0, imageSize.y - 50), "big font");
drawTextWithFont(ZombieDesc::game_mode, center - Vec2f(0, imageSize.y - 140), "medium font");
//drawTextWithFont(ZombieDesc::change_page, center - Vec2f(0, imageSize.y - 180), "medium font");
}

void drawTipPage(Vec2f&in imageSize, Vec2f&in center, const string&in pagefile, const string&in tip, Vec2f&in imagePos)
{
GUI::DrawIcon(pagefile, imagePos);
drawTextWithFont(ZombieDesc::tips, center - Vec2f(0, imageSize.y - 50), "big font");
drawTextWithFont(tip, center - Vec2f(0, imageSize.y - 140), "medium font");
}

void drawTextWithFont(const string&in text, const Vec2f&in pos, const string&in font)
{
GUI::SetFont(font);
GUI::DrawTextCentered(text, pos, color_black);
}

void makeExitButton(CRules@ this, Vec2f&in pos, CControls@ controls, Vec2f&in mousePos)
{
Vec2f tl = pos + Vec2f(-20, -20);
Expand Down Expand Up @@ -120,7 +152,7 @@ void makePageChangeButton(Vec2f&in pos, CControls@ controls, Vec2f&in mousePos,
GUI::DrawIcon("MenuItems", right ? 22 : 23, Vec2f(32,32), Vec2f(pos.x-32, pos.y-32), 1.0f);
}

void makeWebsiteLink(Vec2f pos, const string&in text, const string&in website)
void makeWebsiteLink(Vec2f pos, const string&in text, const string&in website, CControls@ controls, Vec2f&in mousePos)
{
Vec2f dim;
GUI::GetTextDimensions(text, dim);
Expand All @@ -130,9 +162,6 @@ void makeWebsiteLink(Vec2f pos, const string&in text, const string&in website)
const Vec2f tl = Vec2f(getScreenWidth() - width - pos.x, pos.y);
const Vec2f br = Vec2f(getScreenWidth() - pos.x, tl.y + height);

CControls@ controls = getControls();
const Vec2f mousePos = controls.getMouseScreenPos();

const bool hover = (mousePos.x > tl.x && mousePos.x < br.x && mousePos.y > tl.y && mousePos.y < br.y);
if (hover)
{
Expand All @@ -151,70 +180,3 @@ void makeWebsiteLink(Vec2f pos, const string&in text, const string&in website)

GUI::DrawTextCentered(text, Vec2f(tl.x + (width * 0.50f), tl.y + (height * 0.50f)), 0xffffffff);
}

void drawHeader(const string&in text, const Vec2f&in pos)
{
GUI::SetFont("big font");
GUI::DrawTextCentered(text, pos, color_black);
}

void page1(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page1.png", Vec2f(center.x - imageSize.x, center.y - imageSize.y/2));

drawHeader(ZombieDesc::title, center - Vec2f(0, imageSize.y - 50));

GUI::SetFont("medium font");
GUI::DrawTextCentered(ZombieDesc::game_mode, center - Vec2f(0, imageSize.y - 140), color_black);
//GUI::DrawTextCentered(ZombieDesc::change_page, center - Vec2f(0, imageSize.y - 180), color_black);
}

void page2(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page2.png", Vec2f(center.x - imageSize.x/2, center.y - imageSize.y/3));

drawHeader(ZombieDesc::tips, center - Vec2f(0, imageSize.y - 50));

GUI::SetFont("medium font");
GUI::DrawTextCentered(ZombieDesc::tip_gateways, center - Vec2f(0, imageSize.y - 140), color_black);
}

void page3(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page3.png", Vec2f(center.x - imageSize.x + 100, center.y - imageSize.y/3));

drawHeader(ZombieDesc::tips, center - Vec2f(0, imageSize.y - 50));

GUI::SetFont("medium font");
GUI::DrawTextCentered(ZombieDesc::tip_zombification, center - Vec2f(0, imageSize.y - 140), color_black);
}

void page4(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page4.png", Vec2f(center.x - imageSize.x + 100, center.y - imageSize.y/3));

drawHeader(ZombieDesc::tips, center - Vec2f(0, imageSize.y - 50));

GUI::SetFont("medium font");
GUI::DrawTextCentered(ZombieDesc::tip_water_wraith, center - Vec2f(0, imageSize.y - 140), color_black);
}

void page5(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page5.png", Vec2f(center.x - imageSize.x + 100, center.y - imageSize.y/3));

drawHeader(ZombieDesc::tips, center - Vec2f(0, imageSize.y - 50));

GUI::SetFont("medium font");
GUI::DrawTextCentered(ZombieDesc::tip_headshot, center - Vec2f(0, imageSize.y - 140), color_black);
}

void page6(Vec2f&in imageSize, Vec2f&in center)
{
GUI::DrawIcon("Page6.png", Vec2f(center.x - imageSize.x + 150, center.y - imageSize.y/3));

drawHeader(ZombieDesc::tips, center - Vec2f(0, imageSize.y - 50));

GUI::SetFont("medium font");
GUI::DrawTextCentered(ZombieDesc::tip_merchant, center - Vec2f(0, imageSize.y - 140), color_black);
}
2 changes: 1 addition & 1 deletion Rules/Zombie_Scoreboard.as
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const f32 drawScoreboard(CPlayer@[] players, Vec2f topleft, const u8 teamNum)
//draw team info
GUI::DrawText(teams[teamNum], Vec2f(topleft.x, topleft.y), SColor(0xffffffff));
GUI::DrawText(getTranslatedString("Players: {PLAYERCOUNT}").replace("{PLAYERCOUNT}", "" + playersLength), Vec2f(bottomright.x - 470, topleft.y), SColor(0xffffffff));
GUI::DrawText(getTranslatedString("Zombies: {ZOMBIECOUNT}").replace("{ZOMBIECOUNT}", "" + zombies), Vec2f(bottomright.x - 270, topleft.y), SColor(0xffffffff));
GUI::DrawText(ZombieDesc::zombie_count.replace("{ZOMBIECOUNT}", "" + zombies), Vec2f(bottomright.x - 270, topleft.y), SColor(0xffffffff));

topleft.y += stepheight * 2;

Expand Down
4 changes: 2 additions & 2 deletions Rules/Zombie_Settings.as
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

void onInit(CRules@ this)
{
this.set_string("version", "1.1.0");
this.set_string("version", "1.2.0");
sv_contact_info = "github.com/Gingerbeard5773/Zombies_Reborn";

print("\n ---- INITIALIZING ZOMBIE FORTRESS ---- \n"+
Expand Down Expand Up @@ -47,7 +47,7 @@ void AddFonts()
void onBlobCreated(CRules@ this, CBlob@ blob)
{
//keep gold from decaying
if (blob.getName() == "mat_gold")
if (isServer() && blob.getName() == "mat_gold")
{
blob.RemoveScript("DecayQuantity.as");
}
Expand Down
1 change: 1 addition & 0 deletions Rules/Zombie_Translation.as
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace ZombieDesc

//scoreboard
day = Translate("Day"),
zombie_count = Translate("Zombies: {ZOMBIECOUNT}"),
open_manual = Translate("Press {KEY} to toggle the help manual on/off."),

//respawning
Expand Down

0 comments on commit baa67b9

Please sign in to comment.