Topic:   The iPhone Project   (Read 395184 times)


0 Members and 1 Guest are viewing this topic.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #525 on: April 23, 2010, 07:52:07 AM »
No worries, take a break, cool off, have some fun, go to a BBQ.
Meanwhile...
*Rubs Hands Together*
Time to start building the battle engine.


-Gan

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #526 on: April 23, 2010, 08:42:21 AM »
Hey guys, remember that extremely long targeting and battle system I showed before? Here's the new one:
Code: [Select]
- (void)thinkNpc:(int)npcNum {
    //Think on what to do
     //Then call moveNpc
    WorldNpc* npc = [npcs objectAtIndex:npcNum];
    NpcData* npcsData = [npcData objectAtIndex:npc.npcNum];
    if (npcsData.canMove) {
        if (npcsData.movementStyles == MoveRand) {
            [self moveNpc:npcNum direction:rand() % 5];
        } else if (npcsData.movementStyles == MoveToPlayer) {
             /** Directions
             1 = Left
             2 = Right
             3 = Up
             4 = Down
             **/
            int HorzVert = rand() % 3;
            if (playerData.playerTilePos.x == npc.currentTile.x) {HorzVert = 2;}
            if (playerData.playerTilePos.y == npc.currentTile.y) {HorzVert = 1;}
            if (playerData.playerTilePos.x < npc.currentTile.x && HorzVert == 1) {
                [self moveNpc:npcNum direction:1];
            } else if (playerData.playerTilePos.x > npc.currentTile.x && HorzVert == 1) {
                [self moveNpc:npcNum direction:2];
            } else if (playerData.playerTilePos.y < npc.currentTile.y && HorzVert == 2) {
                [self moveNpc:npcNum direction:3];
            } else if (playerData.playerTilePos.y > npc.currentTile.y && HorzVert == 2) {
                [self moveNpc:npcNum direction:4];
            }
         }
    }
}


-Gan

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: The iPhone Project
« Reply #527 on: April 23, 2010, 08:47:29 AM »
What's WorldNpc*?
I survived the spammage of 2007

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #528 on: April 23, 2010, 09:15:36 AM »
WorldNpc is the npc class that holds the npc's position in the world. It also holds the npc's NpcData which holds attack, defense, ect... data.
In the game I have a list of all npcs in the world which it goes through.

Anyways, battle system is working. Targeting system is working. Use potion button is working. Independent Programming class ends in 30 seconds. Adios.


-Gan

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: The iPhone Project
« Reply #529 on: April 23, 2010, 09:44:37 AM »
Awesome, the engine is so big now. Well done Gan!
I survived the spammage of 2007

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #530 on: April 24, 2010, 02:50:11 PM »
"Smart" NPCs are now like 200x smarter. They can maneuver around barriers and even go through a maze to get you. Though, at times it could take a while.


-Gan

Mystor


  • GMG-er

  • **


  • Posts: 696

  • I am the myst that consumes us all.
Re: The iPhone Project
« Reply #531 on: April 24, 2010, 03:49:49 PM »
A*?
"I'll lie to him."
"And if that doesn't work?"
"Then I'll tell the truth. We're allowed to do that, in emergencies. We can't plan for everything, you know."
   -Colonel Graff, Ender&

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: The iPhone Project
« Reply #532 on: April 24, 2010, 03:51:04 PM »
So you got the A* working. Cool.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: The iPhone Project
« Reply #533 on: April 24, 2010, 04:08:37 PM »
Ah, no. A* is lots of code, very complex, and very CPU intensive.
My code is very little, very simple, and very easy on the CPU.
I have it so that the npc tries to move directly towards the player. Though if there's something in the way, it'll pick a random direction to get around. Very effective, makes it look like the NPC is actually deciding on how to get around instead of following a set path to get to the player.


-Gan

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: The iPhone Project
« Reply #534 on: April 24, 2010, 05:09:04 PM »
I thought you already had that.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Mystor


  • GMG-er

  • **


  • Posts: 696

  • I am the myst that consumes us all.
Re: The iPhone Project
« Reply #535 on: April 24, 2010, 10:56:17 PM »
Quote
Ah, no. A* is lots of code, very complex, and very CPU intensive.
My code is very little, very simple, and very easy on the CPU.
I have it so that the npc tries to move directly towards the player. Though if there's something in the way, it'll pick a random direction to get around. Very effective, makes it look like the NPC is actually deciding on how to get around instead of following a set path to get to the player.


-Gan
A* is not that complex. I find it quite simple actually, it just makes sense.
There is a cost, and a heuristic, you just move towards the goal. and acquire the fastest route.
"I'll lie to him."
"And if that doesn't work?"
"Then I'll tell the truth. We're allowed to do that, in emergencies. We can't plan for everything, you know."
   -Colonel Graff, Ender&

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: The iPhone Project
« Reply #536 on: April 25, 2010, 02:35:29 AM »
I understand the logic but couldn't keep track of the order to calculate things in when I sat down to do it. Could you make a version Mist?
I survived the spammage of 2007

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: The iPhone Project
« Reply #537 on: April 25, 2010, 09:56:29 AM »
I made Gandolfs version of super smart AI if your interested Silverwind.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Mystor


  • GMG-er

  • **


  • Posts: 696

  • I am the myst that consumes us all.
Re: The iPhone Project
« Reply #538 on: April 25, 2010, 10:02:04 AM »
Quote
I understand the logic but couldn't keep track of the order to calculate things in when I sat down to do it. Could you make a version Mist?
What language? It would be next to impossible for me to do in GameMaker (I would be just writing the code in a text file, as I don't have easy access to a Mac anymore)

I could try in flash, C# or a similar language.
"I'll lie to him."
"And if that doesn't work?"
"Then I'll tell the truth. We're allowed to do that, in emergencies. We can't plan for everything, you know."
   -Colonel Graff, Ender&

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: The iPhone Project
« Reply #539 on: April 25, 2010, 12:57:33 PM »
Oh I don't mind, I'd just love to see it in action. :)

Yeah, way too LoC heavy for GM. ;D
I survived the spammage of 2007