Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,426 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
First person RPG example #414010
12/21/12 08:14
12/21/12 08:14
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
I have been working on my next project for a bit and was wondering if anyone could help me understand how to code this main part in the game. I know there are several ways to do it and I can probably work with any way but I need to figure out a good way to get multiple weapons to swing from the player's hand including weapons like a sword, axe, mace, and even a staff. Are there any example tutorials? Any help will do and Merry Christmas!!! Here is an example of what I am trying to do:



boolean my.awesomeness = so true;
Re: First person RPG example [Re: Dega] #414025
12/21/12 11:58
12/21/12 11:58
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
Hey Dega, ich you are able to read German you can take a look at my book. There I explain how to write a first person RPG and even hand out the finished code.

http://www.amazon.de/Spiele-entwickeln-m...1048&sr=8-1

Here is a video of my RPG:

http://www.youtube.com/watch?v=amdZIno89gY

Re: First person RPG example [Re: PadMalcom] #414031
12/21/12 12:34
12/21/12 12:34
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Offtopic: which game is that actually?

Ontopic: there are multiple ways, mostly depending on how complex you want the weapons to be. Do you have an abundant of weapons in the game? Or is it like most shooter games where you will have ~10 or less weapons?

Re: First person RPG example [Re: Reconnoiter] #414039
12/21/12 15:09
12/21/12 15:09
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Offtopic: That game is called Eternal Ring for the playstation 2. I play that game still with my friends. It is hard at first but then it gets soooooo fun. You start out with a sword and then create rings to use magic while in search of the Eternal ring. It's really fun!

Ontopic: I am thinking of using as many weapons as I can think up but so far I am going to start with a basic sword and go from there.

To PadMalcom: Hey thanks! I can't read German but I can use Google Translate! If it is a big piece then I can just work with it page by page. Thanks very much!<------okay never mind that lol. I was thinking you were showing me a pdf file for some reason. Sorry! The movie is perfect for what I am doing though. Thanks anyways! I just reposted.

Do you think you could show me a simple example on how to code an entity picking up three different weapons and using them? Weapon examples: sword, mace, and an axe. That's all I really need.

Last edited by Dega; 12/21/12 15:36.

boolean my.awesomeness = so true;
Re: First person RPG example [Re: Dega] #414041
12/21/12 15:49
12/21/12 15:49
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Well if you only have a few weapons you can add an action for each weapon. So when you pick up the item you can can create the item with its action:

Code:
ent_create("ShortSword.mdl",vector_myrightarm,ShortSword);



The action of the item can than have things like
*when is the model visible (e.g. through a variable: var_weaponslot == 1)
*when it deals damage to an enemy (e.g. through c_trace or c_scan to check whether the weapon touches an enemy)
*its x, y and z coordinates (just use vec_for_bone to transfer the x/y/z coordinates of e.g. the 'right hand bone' to 'vector_myrightarm')
*the animations the sword uses etc.

If you have alot weapons, you can use an action for your 'right weapon' (or 'left weapon'). Through variables like e.g. var_weaponslot you can check which weapon the player has equiped.

There are ofcourse more possible ways and I dont know if this is the best one, but for me it works.

Re: First person RPG example [Re: Reconnoiter] #414042
12/21/12 16:03
12/21/12 16:03
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Okay thanks. I will do that. However, I am wondering on how I get the sword to animate with the player. Do I use c_rotate() with the code and if yes how to code that or how do I animate with MED somehow???


boolean my.awesomeness = so true;
Re: First person RPG example [Re: Dega] #414043
12/21/12 16:14
12/21/12 16:14
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Code:
void _apply_sword(){
   VECTOR _ang, _pos;
   while (you){ // do as long player != NULL
      // move with players animation
      vec_for_bone(_pos, you, "Right Hand"); // get xyz pos of hand bone
      ang_for_bone(_ang, you, "Right Hand"); // get rotation of hand bone
      vec_set(my.x, _pos.x); // set xyz
      vec_set(my.pan, _ang); // set rotation

      // optional animation
      //my.skill1 += time_step;
      //ent_animate(me, "idle", my.skill1, ANM_CYCLE);
      wait(1);
      }
      ptr_remove(me); // no more player ? remove weapon
}
..
action myPlayer()
{
  player = me;
  // create the sword and apply to players hand
  ent_create("sword.mdl", vector(player.x, player.y, player.z), _apply_sword);
}


Last edited by rayp; 12/21/12 16:19.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: First person RPG example [Re: rayp] #414044
12/21/12 16:21
12/21/12 16:21
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Instead of "idle" can I code that the same way as "swinging"? Do I make the model animate "swinging" in MED?


boolean my.awesomeness = so true;
Re: First person RPG example [Re: Dega] #414045
12/21/12 16:23
12/21/12 16:23
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Maybe you should do some tuts before.

The trick is, weapon is moved and animated with the ( in this case ) "Right Hand" bone of the YOU (player) entity. So you only need to animate the weapon, if the weapon itself should do something. After using this code, your player should hold a weapon ( animated with him [and the weapon itself has no animation] ).

Note: You need to change "Right Hand" to the name of your right hand bone ^^
Edit: I would use this code for 3rd person. For a FPS, i would not give weapons to the players hand (this way).

Last edited by rayp; 12/21/12 16:31.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: First person RPG example [Re: rayp] #414048
12/21/12 16:30
12/21/12 16:30
Joined: Dec 2010
Posts: 100
D
Dega Offline OP
Member
Dega  Offline OP
Member
D

Joined: Dec 2010
Posts: 100
Sorry I couldn't find any tutorials for GStudio A8 for something like this and are you saying for "swinging" I animate it in MED and code it to move at the same time? I am trying to use a different model for the player and the weapons.

Last edited by Dega; 12/21/12 16:39.

boolean my.awesomeness = so true;
Page 1 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1