Jump to content

  • Log In with Google      Sign In   
  • Create Account

Ashaman73

Member Since 10 Nov 2006
Offline Last Active Today, 03:12 AM

#5254539 How to manage multiple enemies/mobs in open world RPG

Posted by on 28 September 2015 - 10:24 PM


The problem is, imagine i have +3000 enemies in my map, how can i manage to execute their IA Behavior, and test who the player attacked, etc.

Here are some tips with pseudo code:

1. Have a next update/next ai time like this:

obj::updateAi() 
{
   // do something with obj

   
   if(is_player_around==true) {
     // hi-frequent update time
     obj.next_ai_updattime = current_time + 100;
   } else {
     // low-frequent update time
     obj.next_ai_updattime = current_time + 3000;
   }
}


main_loop:
for each obj in my_game_objects do
{
   if(obj.next_ai_updatetime<current_time) {
     obj.updateAI();
   }
}


2. use timed events, e.g. like this

addEvent(event) 
{
   obj.event_list.add(event);
   obj.next_event_time = min(event.execute_at,obj.next_event_time);
}
process_all_events_up_to_time(obj,time)
{
  min_event_time = MAX;
  for each event in obj.event_list do
  {
     if(event.execute_at<current_time) {
       event.execute(obj);
       obj.event_list.remove(event);
     } else {
        min_event_time = min(min_event_time,event.execute_at);
     }
  }
  obj.next_event_time = min_event_time;

}

main loop:
for each obj in my_game_objs do
{
   if(obj.next_event_time<current_time) {

      process_all_events_up_to_time(obj,current_time);
   }
}

3. for objects, which needs to be updated really seldomly, e.g. a pusling shrine which is active for only a few seconds after being triggered, use the event system instead of the update system like this:

pulsing_shrine_triggered_update(obj) = 
{

   // do something, e.g. heal nearby creatures

   // done ?
   if(!done) {
     // trigger again in 1 second
      obj.addEvent(pulsing_shrine_triggered_update,current_time+1000);
   }
}




4. if you use the tips from above, replicate the times in an array for faster memory access,because you really need to test only the timestamps most of the time. No need to access large objects all the time. Thought the performance benefit might be small to tiny ;-)




#5253946 Is there a market for 2d/ low end 3d games?

Posted by on 24 September 2015 - 10:40 PM

Yes, there is. Many successful indie  games were made within a "week" (aka short duration). When you are able to sell a few hundred copies of a game you made within a week you could make a profit. Sure, good looking, top game will sell more, but they cost millions of $. 

 

Thought low-end is != ugly art, remember this. The 100th clone of a platformer with not appealing art will have a much harder time than a clever idea with low/abstract art.




#5253761 Voxel terrain smoothing

Posted by on 23 September 2015 - 10:19 PM

It is unclear if you want to smooth the terrain or the voxel presentation of the terrain.

For smoothing terrain look up gaussian blur. For smoothing voxels look up marching cubes.

 

 

 


I've looked a lot at this article:

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html

The terrain is too rough though,

If this is too rought, then you have some really demanding goals. Voxel worlds are notoriously memory hungry. For more memory efficient implementation look up sparse voxel/octtrees.




#5253401 Game Development Laptop

Posted by on 22 September 2015 - 12:49 AM

I've a custom 11'' laptop for development with a dedicated GPU (really hard to find !) and it works great when not home, but it is not comparable to a desktop setup. It isn't really the power, but the missing screenspace. Using several tools concurrently on a single screen limits the usage of my laptop to some scripting or modelling. But the heavy works need to be done at my desktop PC wub.png .




#5253392 Loading multiple LUA tables as data

Posted by on 21 September 2015 - 11:03 PM


Edit: Small question, If I follow that last suggestion, how do I access the tables contained within "my_data_container"

If you just declare a variable in a file using dofile, it is automatically global. Therefor you can handle it like any other global variable

local item = my_data_container.ID1
local item2 = my_data_container["ID1"]



#5253386 Loading multiple LUA tables as data

Posted by on 21 September 2015 - 10:16 PM

Create a read function, then enclose your data  with the read which handles the data.

Example main.lua

my_data_container = {}

read = function( _chunk)
  -- get id
  local id = _chunk.id
  -- assign table to container
  my_data_container[id] = _chunk

.. do some processing..
end


do_file("my_data_file.lua")


You data should look like this

read({
    id = "ID1",
    name = "Description 1",
    mod = 20
})



read({
    id = "ID2",
    name = "Description 2",
    mod = -15
})

When calling a function with just a table you can leave the parentheses away:

read{
    id = "ID1",
    name = "Description 1",
    mod = 20
}



read{
    id = "ID2",
    name = "Description 2",
    mod = -15
}

Alternative for full-data table without the need of any processing just setup your data like this:

my_data_container = 
{
  ID1 =
  {
    name = "Description 1",
    mod = 20
  },
  ID2 = 
  {
    name = "Description 2",
    mod = -15
  },
}




#5252624 A General copy constructor question

Posted by on 17 September 2015 - 03:16 AM


QuadNode(int id, long t)
: TimeAStarNode(this->ancestor, this->m_quadNode, this->path_cost, this->estimated_cost, this->t, this->depth)
{
// overwrites current id
this->id = id;
this->parent = NULL; ;
this->transition = 0;
}

No, this will pass the un-initialized/unknown attributes to the parent class. This will not really work.

 

Something like this would do

    QuadNode(const QuadNode& node,int id, long t)
        : TimeAStarNode(node.ancestor, node.m_quadNode, node.path_cost, node.estimated_cost, node.t, node.depth)
    {
// optional standard copy constructor code from above...


        // overwrites current id
        this->id = id;
        this->parent = NULL; ;
        this->transition = 0;
    }

Or, if you just want to reassign a new id and t, then add an simple reassign method:

void reassign(int id, long t)
    {
        // overwrites current id
        this->id = id;
        this->parent = NULL; ;
        this->transition = 0;
    }



#5252607 PID steering controller flips from 0° to 178°

Posted by on 16 September 2015 - 11:51 PM


it spin back around it's self and then enter some flipping loop.

The radius to check if it reached the waypoint is too tight or the speed too high. The problem occurs, when your object shoots beyond the waypoint, then turns around and shoots on the other side all the time, never really coming within the radius of the waypoint.

 

To ease it:

1. For intermediate waypoints relax the radius.

2. For the final waypoint use the arrival steering behavior (you get slower when approaching your target to avoid this loop).

 

An other tip:

When checking the radius, it could be useful to ignore the y-component. If you have eg. an high object (center at 1m) and a waypoint at the ground level (0m), then the distance  would be minimal 1m,even when the object sits right on top of the waypoint. When ignoring the y-axis the distance would be 0.




#5252603 Reducing Post-Processing Aliasing ?

Posted by on 16 September 2015 - 11:13 PM


I'm not using any post AA shaders so maybe that's the route I should go ? Perhaps I can use supersampling, I can probably render to 2x and downsample but will that destroy the effect I'm shooting for ? I don't know what to do or even if I should be working with image-space effects.

Supersampling is 4x the screen resolution, besides memory issues you will have performance issues. Check your video card, I think that nvidia at least provides some hardware AA based on image data alone (FXAA), this could be a quick way to test it out.




#5252601 File format for 3D Meshes and Animations

Posted by on 16 September 2015 - 11:09 PM


I read a bit about that, but it doesn't really seem to have a lot of support (there's a few unofficial exporters I suppose). I also read a lot of criticism on the way it stores stuff. (For example animations are part of a mesh)

You should consider, that most intermediate formats are really only a temporary step between your modelling tool and your game. FBX and collada are really bloated and are not suited for any serious game project. A common way is, to export to one of the intermediate formats and then convert these formats to a custom format which will be used by your game.

 

I've used collada for several years, but the (blender) support was really bad and the format is quite complex. Afterwards I have written a custom FBX reader I use up to now. The FBX format is structured in a more clearly way, but it is not a open format.

 

I would have wished, that I know about OpenGEX before I wrote my FBX converter. Collada and FBX are not designed to be used in a game engine and have lot of stuff which is not really useful in game development, OpenGEX has been designed to be used by games and I would try it out first nowadays.




#5252597 Zombie AI

Posted by on 16 September 2015 - 10:18 PM


I have absolutely no programming skills because I am an artist, not a programmer.

Here are a lot of programmers who can't do art and looking for someone to help out. Maybe you can exchange some custom models/pixel art whatever you do with some custom script/code smile.png




#5252287 Planet Centauri - 2D Rpg/Sandbox - private beta available on Steam!

Posted by on 14 September 2015 - 10:58 PM

Awesome art and great work. Gratz !smile.png




#5252125 Alternatives to tiered gear

Posted by on 13 September 2015 - 11:14 PM


i'm not using vectors or able to swap colors except on shaders

When you use shaders, changing the color is quite easy. An old trick in 2d art is to use an else unused color (e.g. pink XX00XX)  to recolor parts of the image.

E.g. you have the bodyarmor part colored in pink-scale, a shader could look like this

const float THRESHOLD = 3.0/256.0;
vec4 texel = ...get texel of sprite
if(texel.g==0 && abs(texel.r-texel.b)<THRESHOLD) {
  // recolor texel
  texel.rgb = armor_color.rgb * texel.r; // r=b holding value
}



#5251675 Whats True -1?

Posted by on 11 September 2015 - 12:36 AM


(i'm using Android Java on eclipse).

 

You are talking about java, not C or C++. So, you need a boolean in an if-statement, no int or float. Therefor this will not compile in java:

 if(  (q == hh) - 1.0f ){ ... }

First, you can't substract a float from a boolean, second, you can't have a non-boolean statement in an if-statement.

This

 if(  q == hh - 1.0f ){ ... }

will compile and it will first substract 1.0f from hh and then compare the result to q.




#5251465 Next Step: Proper NPC Design

Posted by on 09 September 2015 - 10:34 PM

The old ultima games (hmm.. part IV or V ?) have some nice behavior. In general, I would recommend (thought somewhat technically) to move behavior to single objects. That is, instead of a NPC who knows that he needs to eat at a tavern table, the tavern table provides the interaction to eat. This makes it a lot easier to let your NPCs interact with the world (the NPCs in Sims interact like this).

 

Simple example:

 

tavern: lot of table objects, which provides "eat" interaction

home: bed, which provides "sleep" interaciton for NPC Harry

field: corn objects which provides "farmer_work" interaction

 

NPC Harry, simple behavior tree (behavior trees, in short BHT, are a technically AI implementation) :

priority_node
- check_if_hungry
--> scan for eat interaction objects
--> find path to eat object
--> move to target
--> start interaction "eat" with target object (play animation,remove food items, update hungry state )
- is_morning
--> scan for farmer_work interaction objects
--> find path to farmer_work object
--> move to target
--> start interaction "farmer_work" with target object (play animation, produce new items, put them in inventory etc.)
- is_evening
--> scan for sleep interaction objects
--> find path to sleep object
--> move to target
--> start interaction "sleep" with target object (play animation,start snoring sound etc. )

Behavior can be reused and combined. New behavior can be added with ease (monster near->panic/combat, guards who seek objects with the interaction "catch_criminal", the player can get marked as "catch_criminal" after stealing something etc.)






PARTNERS