🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Part 4: Portals and UI changes

posted in trill41 for project ABx
Published September 15, 2018
Advertisement

Portals

In games you find something that take you to other maps, sometimes this is called a Portal. On the server side Portals are just scriptable objects like NPCs. The game script adds Portals like it would add an NPC:


-- Game start up
function onStart()
  local portal = self:AddNpc("/scripts/creatures/logic/portal.lua")
  if (portal ~= nil) then
    -- Map ID where this portal leads to
    portal:SetVarString("destination", "75e3dfcf-479a-11e8-ad09-02100700d6f0")
    -- Will call onTrigger() when it collides
    portal:SetTrigger(true)
    -- Set position of portal
    local x = -20.059
    local z = -0.00870347
    local y = 26.7
    portal:SetPosition(x, y, z)
  end
  
  -- ...
end

The script for the portal is similar to a script for an NPC:


name = "Temple of Athene"
level = 20
modelIndex = 11
sex = 0
creatureState = 1
prof1Index = 0
prof2Index = 0

function onInit()
  -- Player collides with BB. Make it a bit larger than the default BB.
  self:SetBoundingBox(-1, -1, -1, 1, 1, 1)
  return true
end

function onTrigger(creature)
  local player = creature:AsPlayer()
  if (player ~= nil) then
    player:ChangeGame(self:GetVarString("destination"))
  end
end

The process for changing a game instance is a bit complicated. The player is only connected to the game server when he/she is in a game instance. When you click on a map in the map window the client disconnects from the game server and connects to it again, telling the game server which map it would like to access. The game server creates an instance of this map, and adds the player to this instance.

A Portal is a bit different, because the server initiates the switch to a different map. Also we must distinguish whether the client enters an existing instance—which is always the case when using the map window and the instance is not full, because these are outposts where people can meet—or the server creates a new instance. This is the case when entering a battle field, which is exclusive for a party or two, e.g. a PvP combat. But when it comes to gameplay and game mechanics, nothing has been implemented yet.

Video

UI changes

Several small changes to the UI were made. The people from Urho3D have updated the UI texture and styles, which I really like, it is so friendly and ... green xD. A big Thank You to the Urho3D developers for this great library!

Additionally the position of the health bar above the characters looks now more natural and speech bubbles have been added.

fw2018-09-15-09-18-33.thumb.png.c90c2498d0104bb56d5d92a542d4e7ba.png

 

Previous Entry Part 3: UI and Network
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement