• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


  • Content count

  • Joined

  • Last visited

Community Reputation

129 Neutral

About MajinMLF

  • Rank
  1. [quote name='Gambini' timestamp='1339366157' post='4948021'] This is one heck of a question. I am not familliar with luabind, so I will go over the general ideas, and maybe hit some specifics. [/quote] Aye, and thanks alot for taking the time to lay out all that - i checked this post yesterday regularly but there wasnt a reply and in the meantime i got the idea to the solution myself which is basically similar to your pseudo code - however there is a gist - first the basic schedule function was pretty easy - its just a callback which - as you said i check the time in c++ - here it is for completion [CODE] void NPC::AddSE(const luabind::objectluabind::object &fn,int millisec) { if(luabind::type(fn) == LUA_TFUNCTION) { ScheduledEvent sEvent; sEvent.eventFunction = fn; sEvent.time = GetMilliCount() + millisec; printf("AddScheduledEvent\n"); m_scheduledEventFunctions.push_back(sEvent); } } void NPC::CheckForScheduledEvents() { std::vector<ScheduledEvent>::iterator sEvent = m_scheduledEventFunctions.begin(); while (sEvent != m_scheduledEventFunctions.end()) { if(sEvent->time < GetMilliCount()) { if(sEvent->eventFunction.is_valid()) { luabind::call_function<void>(sEvent->eventFunction); } // erase returns the new iterator sEvent = m_scheduledEventFunctions.erase(sEvent); } else { ++sEvent; } } } [/CODE] Now the hard part was having scheduled movie like events with delays in between for scheduled events e.g. NPC:Say("Hello") WaitTime(1000) NPC:Say("Continue after 1sec") That without letting the mainloop sleep! I got around this with the unique function of lua = coroutines - basically if WaitTime calls yield(x) the x will be returned to my lua_resume function - and in my code i will schedule the next call to resume after XX amount of time. [quote name='Gambini' timestamp='1339366157' post='4948021'] To answer your second question: The functions are in the same scope as long as they are loaded (luaL_dofile) with the same lua_State. So you can call those functions any time you want. However, I do suggest that you create tables named after each NPC behavior to hold those functions to avoid name conflicts. [/quote] Yes - thats what i want todo - is there a scope for a lua_state ? i dont like to name my functions unqiuely in each lua script - e.g. there should be no collision - how can i export one lua script to a specific scope only valid for one NPC ? Lets say all NPCs have an ID instead of doing luabind::globals(myLuaState)["npc"] = npc; i somehow have to put this NPC only in the scope of the loaded script - which brings the next problem if i use Lual_doFile or similar luaL_dostring(myLuaState, "code...") how put this in a scope ? I dont want that the scripts need to make namespaces or something similar - this should be safely done in c++ code. To reach the script of another NPC i would just expose an object to lua e.g. npc->GetScript()->CallFunction(luabind::object)... (I gather best practise is to have one lua_state for all NPCs and not multiple) Any idea? And thanks again =)
  2. This is a ida pro dump (CODE XREF: gives it away) - so why not use hexrays to give you pseudo c
  3. Hello, i have a game with a mainloop - on each loop i call for every NPC in the game ->ProcessAI() to execute any actions. This is a server so the call to ProcessAI is not executed on every frame like on a client game! Its also singlethreaded. Now i wanted to extend the C++ codebase with lua using luabind (maybe, even with boost overhead). So i expose some functions of my NPC class to LUA. I wanted to create actor scripts for example - boss battles which have more sophisticated behaviour - whenever in my c++ ProcessAI function an event happens - i would delegate this to the corresponding lua script for the specific NPC. i imagined in my boss.lua script i would have something like this function OnEngageCombat(NPC) NPC:say ("Some taunts...") ScheduleEvent(CastEvilSpell,/*time*/2000,/*numExecutions*/1,) end function CastEvilSpell(NPC) NPC:CastSpell("someSpell") end However - i have no idea how to do this - i gather ScheduleEvent should be some C++ function exported to Lua - but what would be the best approach to keep the object reference of the NPC (boss) with this and call a function in that script about 2 seconds later ? Furthmore along with this delayed execution - i want that NPCs can interact with each other - my current idea is to have an actor behavior script for each special NPC. Now what i imagined is to initiate a conversation between two NPCs e.g. function DoGossip(NPC) // check if NPC1 is close to NPC2 if NPC:DistanceToNpc("SomeGuy") < 10 then StartConversation1() end function StartConversation1(NPC) NPC:Say("Hello ...") // wait a moment now trigger NPC to reply ???? Basically - how do i call a function from lua scriptA which exists in lua scriptB which is the behavior script for NPC2. What would be a good design? Thanks
  4. I have an old game i like to add an FPS limiter while in windowed mode - the game uses direct7x IDDraw7 - i was able to hook into the ID3DXContext_UpdateFrame the game called and added a sleep(x) there and that worked fine, the FPS has been reduced - but i figured there is a better way todo this with the standard APIs - however as far as i gathered the default vsync with ddx7 was very cpu consuming?
  5. I hooked an old game to enable windowed mode which uses DirectDrawCreateEx (by basically hooking CreateWindowExA, the game itself has already code for windowed mode i hooked too, so its enabled) - this works - however for some reason it still receives input while not focused. I hooked into the container windows wndproc function and even made sure that no keypresses are dispatched whatsover when the app is not in forground - it didnt help. My theory is, that through DirectInput the keyboard will still be queried through non WIn32 msg calls - however i debugged this and IDDraw7::SetCooperativeLevel is not using BACKGROUND or EXCLUSIVE bits - its just using DDSCL_NORMAL Its not receiving mouse input only keyboard tho (maybe its a software mouse and only the keyboard is directinput, no idea). - Also weird is that while the game has focus - i can see the window desktop mouse moving - even when using SetCursor null - i worked around this issue and set the cursor rectangle to be at windowed game size - at least its hidden behind the window now - still not optimal. Additionally, i tried to hook the DirectDrawCreateEx call - that works, but for some reason i cant use the object myself [code] HRESULT WINAPI Hook_DirectDrawCreateEx(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter) { debug_print("Hook_DirectDrawCreateEx\n"); HRESULT res = Real_DirectDrawCreateEx(lpGuid,lplpDD,iid,pUnkOuter); //LPDIRECTDRAW7 testlplpDD; //testlplpDD = (LPDIRECTDRAW7)lplpDD; // Crash //testlplpDD->SetCooperativeLevel( 0, DDSCL_NORMAL ); return res; } [/code] when i try to use any function it crashes here with an access violation - however just proxxying this works fine! Any hints? Thanks! EDIT: Alright - i was confused about the IDDraw7::SetCooperativeLevel - thats actually for the display - the game uses IDirectInputDevice7::SetCooperativeLevel(DISCL_BACKGROUND) which is the issue why its receiving input while not focused - switching to FORGROUND fixes that