PDA

View Full Version : Game design warmup



TSO
05-12-2010, 10:22 PM
Starting to design something more personal using steps and example levels provided now.

Want to make use of the troll and 'man' or 'player' animation from treeRPG i think it was.
Troll_up animation I plan to use as one team.
and I got the man or 'player' animation I was gona turn into a 2nd team.
Both NPC's

To start, I'm using the dragon patrol script that I plan to adapt so the teams follow a main road until they meet the other team.
Target each other rather then the player.
Or at least the player secondary once the current target is defeated.

I'm still learning and adjusting to lua.
Using the first tutorial on way points I was going to make a test path with one entity each side of the path meeting approximately center.
So I started by copy&paste patrol script in the .lua in the troll and quickly leave edit mode to see it move along the way points but it's just standing there.

it worked pretty well instantly on dragon eggs so it confused me why it happened.

A copy of my files. any suggestions or patterns to look for in lua will be appreciated.
http://apps.facebook.com/files/shared/ayvcvm8gxc

EDIT: Found my mistake. Forgot entity name. Pretty obvious. Other day my head was really cloudy but making good progress today.

Got waypoints numbered now. odd numbers heading right and even numbers on the left.
Both entities connect at point0. and works perfectly.
Will adjust so they got teams and instead of depending on the 0 point, seek each other out when they crossing paths.

Since this is a first design idea though. I'd like to keep some of my progress on the forum so that a history of what I'm trying to do can be seen and improvements made or suggested.

Thank you for any who took time to read. or help =)

TSO
05-14-2010, 04:58 PM
I scraped the design I was starting with because I understood how to work the path finding and entity name.

I copied everything in topviewRPG because it had the basic code I'm trying to find and all I need is to figure out how top_troll targets the player. and try to change it from targeting just one player to maybe a group of players to achieve the effect I want.

In short:
Switched all 'GetPlayer' all to 'GetMan'.
I even added a data value on the previously 'player' entity saying something along the lines of 'name: type value: Man'

Some physics chaos insued (bumped and started to make each other spin.)
Shadows jumped out of position when they entities were clicked on.
and the troll didn't notice the 'man'

I'd like to skip a whole .lua class as much as I'm sure no one here wants to teach me. but I'm at a loss.
What functions do I look to so I can basically have the troll attack any number of NPC 'players'. Attack the nearest target. and then continue on the given patrol route of even numbered waypoints.

This should be a copy and paste job with just a couple functions switched from default I believe. If no one answers I'll take the hint and began my long crash course in .Lua

Seth
05-15-2010, 09:40 AM
Hmm, well, everything should work without problems, there is nothing in the AI that is player specific really, so it should all be changeable to allow AI vs AI and such.

But about lua - it's probably worth your time to get your hands dirty with it, there is a bit of a learning curve, but everything will seem simpler once you understand how to debug using lua (using the console to print out variables to find problems, etc) things will go a lot faster.

TSO
05-21-2010, 12:02 AM
Alright got a new link to latest setup.
http://apps.facebook.com/files/shared/5adcype1ek

I'm having a little trouble with getting ID of my entities and worried it won't work well when I create more copies of the entities with the current setup.
I'll wait to play test those issues and maybe put together some better targeting systems.

Last error I got was about 'GetEntityDistance' I think which wasn't a problem in the past so either it's ID problems again or the new ID code I slipped into the distance comparison that has the wrong syntax or something else.

I also set "HasLineOfSightToPosition" param 'boolean bIgnoreLivingCreatures' to false since I marked both the troll and man as creatures for the moment and didn't want them ignored. It was part of the code copied off the dragon tutorial and I forgot the the exact benefits were.
Shouldn't make a difference for the moment.

Finally getting the hang of lua. often use the given index to find syntax and param's... Got a lot of trial and error to do still.

EDIT:


Original screensize detected as 1024.00 X 768.00
[debug] Unable to find all symbols in dbghlp.dll. Crash reporter disabled.
Command line parms received:
TSO_Equilibrium.novashell
C:\Novashell\worlds\TSO_Equilibrium.novashell

Initializing GameLogic...
Clanlib Sound System Initialized
Mounting world path C:\Novashell\worlds\TSO_Equilibrium.
Updated binary version of C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll\top_troll.lua
Novashell V0.81 and Lua 5.13 RT Edition Initted.
Initting world
Ignoring UnloadMapByName, Intro isn't loaded yet.
Ignoring UnloadMapByName, Game isn't loaded yet.
Loaded map Intro at tick 0. 3 non-empty chunks, size is 1 by 1.
Editor opened up
Setting retail to false
Loaded map Game Palette at tick 697. 0 non-empty chunks, size is 1 by 1.
Switching world focus to ourself?
Loaded map Game at tick 697. 5 non-empty chunks, size is 2 by 1.
Editor closed
Setting player to Entity 110 (Player)
Setting camera tracking to player Entity 110 (Player)
Brain StandardBase doesn't understand keyword ' '
---------------- Lua Error! Stack Dump ----------------

-1: no overload of 'Entity:GetDistanceFromEntityByID' matched the arguments (Entity, string). Did you forget a parm?
Entity 113, function OnPostInit
Brain StandardBase doesn't understand keyword ' '
Editor opened up
Setting retail to false
Brain StandardBase doesn't understand keyword ' '
Brain StandardBase doesn't understand keyword ' '
---------------- Lua Error! Stack Dump ----------------

-1: no overload of 'Entity:GetDistanceFromEntityByID' matched the arguments (Entity, string). Did you forget a parm?
Entity 133, function OnPostInit
Brain StandardBase doesn't understand keyword ' '
---------------- Lua Error! Stack Dump ----------------

-1: no overload of 'Entity:GetDistanceFromEntityByID' matched the arguments (Entity, string). Did you forget a parm?
Entity 136, function OnPostInit
Window description says X:1024, Y:768
Window description says X:1024, Y:768


My console posted above after a re-initalizeing a few times. That explains repeated errors.

Seth
05-24-2010, 01:24 PM
Hmm, how are you using GetDistanceFromEntityByID? You should be sending it a number, not a string? At least I think is what the error means. Maybe you tried sending it a name instead?

If the # is in a string for some reason ('21' or such) then I guess you can convert it to a number by doing tonumber(numInAStringForSomeReason) and passing that in.

Also, that "Brain StandardBase doesn't understand keyword ' '" error is worrying, might want to figure out what lua line is causing that.

TSO
05-27-2010, 02:23 PM
In the distance compairson. Not home atm so can't copy and paste atm. later today i will.

if (distance from this to target is) =< 400
then
Start chase

distance from this to target Is where I used it in a sort sub comparison I guess.

this:get distance from (get distance from entity by ID)


I changed it because I couldn't get any response to "GetMan" so at the time I tried that new piece of code.
Now I figure i'll just try every ID and Distance combination possible to figure out what works.

The standard base error I've tried to narrow down but I think it's in the stardard base line it self. Just because I got a blank param.
If I don't leave it blank the error gets bigger and I think more problems form.

I'll do a test to check the code again at home. And show the differences in the code I made.
I'll see about showing my steps more so it's more clear what I've done also.

TSO
05-29-2010, 06:32 PM
The code and Entity info as of this morning is pasted below.
I'll give a step by step of my leading up to the error and current state of code.

I think I fixed the standardbase error by removing a space seen in the code below.

this:GetBrainManager():Add("StandardBase", " ");

Objective is to move along odd number waypoints counting down to 0 and Start to attack the "Man" when close enough.

http://sphotos.ak.fbcdn.net/hphotos-ak-snc3/hs596.snc3/31398_10150174736175262_609990261_12536214_2599751 _n.jpghttp://sphotos.ak.fbcdn.net/hphotos-ak-ash1/hs536.ash1/31398_10150174736195262_609990261_12536215_3090360 _n.jpg


Below is top_troll.lua


function OnInit() //run upon initialization

//hint to the path-finding system that it can ignore this while computing paths if it needs to
this:SetVisualProfile("~/top_troll.xml", "top_troll");
this:LoadCollisionInfo("~/top_troll.col");
this:SetIsCreature(true);
end



function OnPostInit() //run after being placed on a map

this:GetBrainManager():Add("StandardBase", " ");
PatrolGoals();
TargetingSystem();
end



function OnKill() //run when removed

end



function PatrolGoals()

//let's make him move to the 3 checkpoints

this:GetGoalManager():AddApproachAndSay("Point3", GetEntityByName("point3"):GetID(),C_DISTANCE_INSIDE);
this:GetGoalManager():AddApproach(GetEntityByName("point1"):GetID(), C_DISTANCE_INSIDE);
this:GetGoalManager():AddApproach(GetEntityByName("point0"):GetID(), C_DISTANCE_INSIDE);

this:GetGoalManager():AddSay("All done", C_FACING_NONE);
return;
end



function TargetingSystem()
//we in battle?
local ManPos
if (this:GetGoalManager():IsGoalActiveByName("battle")) then
if (this:GetDistanceFromPosition(ManPos:GetPosFromNam e("Man")) > 400
and not this:HasLineOfSightToPosition(GetEntityByName("Man"):GetPos(), false) ) then

//he's not visible and more than 400 pixels away. Stop.
GetTextManager:Add("Target Lost.", this);
this:SetDesiredSpeed(2.4); //walk speed again

//cancel the chase, start patrolling
this:GetGoalManager():RemoveAllSubgoals(); //stop whatever we were doing
PatrolGoals();
this:GetGoalManager():PushDelay(2000); //wait two seconds first
GetTextManager:Add("Starting Patrol", this);

else

//the player is still in range. Let's recalcuate our chase path.
FightMen();
GetTextManager:Add("Moveing in!", this);
end

else

//not currently chasing player. But should we?
//is the player close?
if (GetEntityByName("Man") != nil and this:GetDistanceFromEntityByID("Man") <700
and this:HasLineOfSightToPosition(GetEntityByName("Man"):GetPos(), false)) then
//We can see the player!
this:SetDesiredSpeed(5); //start running
FightMen();
GetTextManager:Add("Charge!", this);
end

end

//call this function again, randomly chooses a time to look again
Schedule(random(500,1000), this:GetID(), "TargetingSystem()");

end


function FightMen()

//cancel other goals and start chasing the player.

this:GetGoalManager():RemoveAllSubgoals();
//stop whatever we were doing
local goal = this:GetGoalManager():AddNewGoal("battle");
goal:AddApproachAndSay("War!", GetEntityByName("Man"):GetID(), C_DISTANCE_INSIDE);

end



I copied and pasted the code directly to the post. The preview of my post is showing some extra spaces in my code.
So if you see a extra space out of place (apart of standardbase) I think it's the forum that added it into the code because text in edit box looks fine.

I rather not go through editing the errors because that leads to confusion and may accidentally correct the problem at hand and lead to more confusion.

:excl:Console AFTER I remove space in standard base.
So only 1 Error to fix now.


[debug] Unable to find all symbols in dbghlp.dll. Crash reporter disabled.
Original screensize detected as 1024.00 X 768.00
Command line parms received:
TSO_Equilibrium.novashell
C:\Novashell\worlds\TSO_Equilibrium.novashell

Initializing GameLogic...
Clanlib Sound System Initialized
Mounting world path C:\Novashell\worlds\TSO_Equilibrium.
Updated binary version of C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll\top_troll2.lua
Novashell V0.81 and Lua 5.13 RT Edition Initted.
Initting world
Ignoring UnloadMapByName, Intro isn't loaded yet.
Ignoring UnloadMapByName, Game isn't loaded yet.
Loaded map Intro at tick 0. 3 non-empty chunks, size is 1 by 1.
Editor opened up
Setting retail to false
Editor closed
Editor opened up
Setting retail to false
Loaded map Game at tick 2182. 4 non-empty chunks, size is 1 by 1.
---------------- Lua Error! Stack Dump ----------------

-1: no overload of 'Entity:GetDistanceFromEntityByID' matched the arguments (Entity, string). Did you forget a parm?
Entity 127, function OnPostInit
---------------- Lua Error! Stack Dump ----------------

-1: no overload of 'Entity:GetDistanceFromEntityByID' matched the arguments (Entity, string). Did you forget a parm?
Entity 127, function OnPostInit
Log copied to system text buffer.



The source of error:

function TargetingSystem()
//we in battle?
local ManPos
if (this:GetGoalManager():IsGoalActiveByName("battle" )) then
if (this:GetDistanceFromPosition(ManPos:GetPosFromNam e("Man")) > 400
and not this:HasLineOfSightToPosition(GetEntityByName("Man "):GetPos(), false) ) then


It is copied and modified from the Dragon Eggs tutorial.

function LookAround()

//we already chasing him?
if (this:GetGoalManager():IsGoalActiveByName("ChasingPlayer")) then
//we're already chasing him. Should we stop?

//if we're far away AND can't see him, yes, stop

if (this:GetDistanceFromEntityByID(g_playerID) > 400
and not this:HasLineOfSightToPosition(GetPlayer:GetPos(), true) ) then


I changed

if (this:GetDistanceFromEntityByID(g_playerID) > 400
to

if (this:GetDistanceFromEntityByID(getMan) > 400
to

if (this:GetDistanceFromEntityByID(GetMan) > 400
to

if (this:GetDistanceFromEntityByID(GetEntityByName("Man")) > 400
to

local ManPos
if (this:GetDistanceFromPosition(ManPos:GetPosFromNam e("Man")) > 400
which no doubt looks sloppy. (Once again ignore random spaces)
The rest of the changes made in names of variables and functions all appear to be in working order.
It's getting this 'if' statement to work is causing all the hold up.

I understand the if statement uses the position of 'this' entity in
"this:GetDistance"
vs the target
"FromEntityByID(GetEntityByName("Man")"

for a 'x,y' position combined in one number or w/e... a vPos as these pages on "GetDistanceFromEntityByID" and "GetDistanceFromPosition" say:

http://www.rtsoft.com/novashell/docs/api/files/EntityBindings-cpp.html#Entity.GetDistanceFromEntityByID
http://www.rtsoft.com/novashell/docs/api/files/EntityBindings-cpp.html#Entity.GetDistanceFromPosition

So the if statement gets a number to run against the condition.
"(This entities position vs targets = vPos) < 400"

That's how I ended up trying the "GetDistanceFromPosition" since the problem isn't clear when using "GetMan" or "GetEntityByName("Man").

I went back to using "GetMan" to remember what error it gave me.
I'll paste copy of error using "GetMan" in place of "GetEntityByName("Man")" and "GetDistanceFromPosition".


---------------- Lua Error! Stack Dump ----------------

-1: Variable 'GetMan' is not defined.
Entity 152, function OnPostInit
---------------- Lua Error! Stack Dump ----------------

-1: Variable 'GetMan' is not defined.
Entity 152, function OnPostInit
Window description says X:1024, Y:768
Window description says X:1024, Y:768
Window description says X:1024, Y:768
Window description says X:1024, Y:768


Not sure what else I can say about the problem in front of me.
"g_playerID" or "GetPlayer" isn't a special line of code from what your lua guides say.
It isn't a local variable.
It isn't a entity or at least one any different from what my own appears like.
I'm stumped as to what it is I should be researching to understand the problem so I can fix it as well.

So I'm just waiting for the moment now where seth or who ever drops the bomb shell of "you forgot this" and it allllll makes sense. :eek: :crazy:

I laugh.
Curse the past 2-3 weeks of semi-wasted time.(I learned...the math a lil?) :poop:
Move on to hopefully get a beta going by june 13th. :ninja:

Seth
05-31-2010, 01:05 AM
Well, right away I can see this won't work:


function TargetingSystem()
local ManPos
if (this:GetGoalManager():IsGoalActiveByName("battle" )) then
if (this:GetDistanceFromPosition(ManPos:GetPosFromNam e("Man")) > 400


Because ManPos is not defined, it's going to be nil.

g_playerID from the original is a global variable of the player. In your case, you should probably be scanning nearby entities and when you find one, put it into m_targetEntID or something. Don't specify local, and it will be available to all functions in the entity name space.

Now, if lets assume that you already know the entity name of who you want to attack..

You tried this:


if (this:GetDistanceFromEntityByID(GetEntityByName("Man")) > 400

This won't work. You are sending an entity into something that expects a number (id).

You could do this though:

if (this:GetDistanceFromEntityByID(GetEntityByName("Man"):GetID()) > 400

But actually, you should probably do this for more error checking:


local ent = GetEntityByName("Man");

if (ent == nil) then
LogMsg("***! No entity exists with that name.");
end

if (this:GetDistanceFromEntityByID(ent:GetID()) > 400...(more)

So, for debugging, you get into the habit of using LogMsg() to display stuff like position before you feed it into functions to see if it's correct.

Maybe you saw manPos used an example, it's just an example variable of a position, you need to come up with your own.


if (GetEntityByName("Man") != nil and this:GetDistanceFromEntityByID("Man") <700

The above is wrong - you are sending in "Man" when it expects an ID.

Instead, do this:


if (GetEntityByName("Man") != nil and this:GetDistanceFromEntityByID(GetEntityByName("Man"):GetID()) <700

There might also be a GetDistanceFromEntity that doesn't need the GetID part, can't remember.

TSO
05-31-2010, 05:28 PM
Ah. I was working with the idea the info was one and the same or both provided as needed when I sent in the entity name.

That was the detail that 'g_playerID' and I now realize 'GetPlayer:GetPos()' kind of threw me off on a lot of places.
Novashell Scripting Reference doesn't seem to have an index to LogMsg Syntax. Had to track that line down in the tutorial.

Anyway. With that info I think I got a better understanding of what I missed and need.
This should end up looking something like a ai vs ai RTS game soon.

TSO
06-02-2010, 04:15 PM
**Fixed it. Keep this here as reminder =P**


copied top_troll from RT_TopViewRPG and filling it with extra LogMsg to sorta watch the flow of information and get an idea of how the damage portion works now that I can get AI to charge at each other.

Using the given console errors and some trial and error with re-Initializeing entity to narrow down what line of code causes error.

(basically add a bunch of extra lines increasing what line of code the error is on and then removing the extra spaces. moving down the code and repeating until the error number doesn't change.
I'm not sure I wanna try your tutorial suggested "UltraEdit" or "conTEXT" just yet. Not sure of it's full features and support and rather work then research it more atm.)

First Error:


---------------- Lua Error! Stack Dump ----------------

-1: C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.lua:103: 'end' expected (to close 'function' at line 74) near 'LogMsg'
Ent 196 (troll) error while loading lua script char/top_troll/top_troll2.lua.
Syntax error in script C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.luac
---------------- Lua Error! Stack Dump ----------------

-1: C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.lua:103: 'end' expected (to close 'function' at line 74) near 'LogMsg'
Ent 197 (troll) error while loading lua script char/top_troll/top_troll2.lua.
Syntax error in script C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.luac
---------------- Lua Error! Stack Dump ----------------

-1: C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.lua:103: 'end' expected (to close 'function' at line 74) near 'LogMsg'
Ent 198 (troll) error while loading lua script char/top_troll/top_troll2.lua.
Window description says X:1024, Y:768
Window description says X:1024, Y:768
Log copied to system text buffer.



Function the error was narrowed down to.


function CanAttack()
LogMsg("CanAttack func started. Get distance from player");
if (GetPlayer and this:GetDistanceFromEntityByID(GetPlayer:GetID()) < 50) then

//well, we're close enough to the player, but we better check to see if we're facing
//towards him or not.
//first, let's tell the AI we want to rotate towards him
this:SetVectorFacingTarget(this:GetVectorToEntity( GetPlayer));

//only if we're already looking at him should we swing
LogMsg("if we're facing within tolerance we'll attack");
local toleranceAngleInRadians = 1.3;
if (this:IsFacingTarget(toleranceAngleInRadians)) then
LogMsg("Set attack state and play soundeffect");
this:GetBrainManager():SetStateByName("Attack");
//GetSoundManager:Play("audio/effects/swing.ogg");

//setup where the actual damage will happen
LogMsg("setup where actual damage will happen. creates entity top_damage");



Schedule(200, this:GetID(), 'ent = CreateEntity(this:GetMap(), this:GetPos(), "weapons/top_damage/top_damage.lua"); ent:RunFunction("SetParent", this); ent:RunFunction("SetStrength", 5);');

return true;
end
end

return false;
LogMsg("CanAttack end");
end


Not sure why the error repeats 3 times exactly but I took a guess at most likely cause of error... I guessed the single quotes in this piece of code.


CreateEntity(this:GetMap(), this:GetPos(), "weapons/top_damage/top_damage.lua"); ent:RunFunction("SetParent", this); ent:RunFunction("SetStrength", 5);');


For a quick test removed the single quotes from above piece of code and got new errors below.

---------------- Lua Error! Stack Dump ----------------

-1: C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.lua:97: ')' expected near '='
Ent 190 (troll) error while loading lua script char/top_troll/top_troll2.lua.
Syntax error in script C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.luac
---------------- Lua Error! Stack Dump ----------------

-1: C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.lua:97: ')' expected near '='
Ent 191 (troll) error while loading lua script char/top_troll/top_troll2.lua.
Syntax error in script C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.luac
---------------- Lua Error! Stack Dump ----------------

-1: C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.lua:97: ')' expected near '='
Ent 192 (troll) error while loading lua script char/top_troll/top_troll2.lua.
Window description says X:1024, Y:768
Window description says X:1024, Y:768
Syntax error in script C:\Novashell\worlds\TSO_Equilibrium/script/char/top_troll/top_troll2.luac

Moved piece of code to test error was still in same place. (just remembered old lesson where using comment marks is much faster for this...)

I presume original error just narrowed down problem to the function. and new error is probably just result of my change.

I'm continuing to examine code to find the cause of original error. But if you beat me to answer... well things get sped along and hopefully I gain more insight...

EDIT: Narrowed it down to:
return false;
LogMsg("CanAttack end");
Some reason my mind figured I could still log a message after "return". I think that was problem.
Ha! back to it then!

TSO
07-16-2010, 05:17 AM
Haven't double checked tutorials yet but there a good place to find free 2d character graphics/pictures? Or perhaps a program to throw a lil simple 2d hero together with?

otherwise suppose I could just use paint to make a couple simple poses and put them in a xml file for novashell to make it turn left right and look up when idle?...

Making main 2d character(s) for another project.

EDIT:
Made my own 2d character for now though so answer doesn't have to be restricted to that detail.

Good links for gathering images, sounds, and heck even a copyrights loophole tutorial would be welcome for a reply...

I google a couple things of my own but I feel I got some crappy results out of my search. So maybe some key words to search for would also help. =P