Nighthawk RPG template for lite-C

Posted By: i_program_games

Nighthawk RPG template for lite-C - 08/05/08 23:19

I have converted the Nighthawk Arts RPG templates to lite-C.

Enjoy:

http://74.220.207.173/~gametown/NHA_RPG_Template_lite-C.zip
Posted By: Blade280891

Re: Nighthawk RPG template for lite-C - 08/05/08 23:21

Nice contribution wink
Posted By: Nowherebrain

Re: Nighthawk RPG template for lite-C - 08/06/08 12:13

I will check this out for certain!
Posted By: i_program_games

Re: Nighthawk RPG template for lite-C - 08/06/08 16:53

Thanks, do note that this is a straight conversion for the most part which means there is room for improvement. Of course this is the entire point of a template though smile
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 06/30/09 11:57

Nice work smile

It would no doubt be easier to write RPG games in Lite-C than in C-script (especially due to things such as being able to use structs), however it's nice to see that my work haven't been in vain due to people start using Lite-C instead of the good ol' C-script wink

Gonna buy A7 and try out Lite-C myself sometime soon, I just have to finish an old A6 project first off smile (have been away from 3DGS for 2 years now)
Posted By: 3run

Re: Nighthawk RPG template for lite-C - 06/30/09 13:48

I have this error =(
"error in 'nhasc_animation.c' line 21: machine code generator: can not translate P_ANDAND:POINTER:LONG:LONG.
while(my && (my.anim_state != anim_stop))"
HELP ME!!!!
Posted By: ventilator

Re: Nighthawk RPG template for lite-C - 06/30/09 13:49

what version are you using? as far as i know this doesn't happen anymore since a while but you can fix it like that:

while((my != NULL) && (my.anim_state != anim_stop))

or

while((long)my && (my.anim_state != anim_stop))

Posted By: 3run

Re: Nighthawk RPG template for lite-C - 06/30/09 14:58

I'm using ver. 7.77 I'd changed all like that in code. Now works fine))) Thanks
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/15/09 18:13

I was testing this and found that none of the items bmaps show up in the inventory anymore. I was thinking maybe there was a set(show) missing somewhere. I looked at the wdl's and compared them to the .C's and I dont know. Anyone else?
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/15/09 23:16

The item system is great for C-script (in my opinion at least :p), but it could be done a thousand times better in Lite-C, especially due to the use of structs smile

I had a quick look at the Lite-C version of the code, but I'm afraid that I didn't figure out what's wrong (it's been a few years since I wrote the C-script version, so I don't recall exactly how the code works anyway).

I'd like to know whether the rest of the code works though? smile
I got quite a few projects running at the moment, so I won't be the one to write a new inventory system right now however, it shouldn't be that hard to do in Lite-C, compared to C-Script.
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/15/09 23:33

Hello Claus,
Yes the rest of the code works great. Probably one of the best iso templates around. If I can get it to work it would save me many many hours.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/16/09 00:04

I'm glad to hear that the rest of the code works! smile

I guess I could fix the inventory if I could test the code meanwhile, but I haven't got A7 yet frown

@i_program_games
I have uploaded the Lite-C version to my website, and it can now as well be found at http://rpg.nighthawk.dk. Thanks for the contribution! smile
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/16/09 00:24

Btw. paracharlie, have you read this? smile
http://www.nighthawk.dk/v5/?PageID=ShowArticle&ID=13

Just thought that it could be possible that you forgot something/did something wrong, as the item system is not as easy to use as I wanted it to be... frown
(C-script got its limitations, and I had to do a few workarounds while making the item system, to make up for the lack of structs/classes etc.)

Still don't see anything wrong in the script, but I'm too tired now anyways grin
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/16/09 02:11

Yes I have gone over that a few times although this was the first time checking for alpha channels and they do in fact have alpha channels. I have been working with your template for about a month now because I am adding structs for such things as Character statistics, skills, combat tables etc... I am doing 3 things at once and I keep coming back to this trying to find the answer but I guess I just dont see the problem for whatever reason.
I had originally started in cscript but recently converted everything to c just because of the depth of information that I need to plug in.
What is strange to me is that you can pick an item from inventory and it appears as a mouse map but then it disappears again when you drop it into the inventory so that would tell me that the bmap is working correctly.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/16/09 12:06

Hmm, maybe the 'bmap_draw' function just doesn't work anymore for some reason?
It's the function which is responsible for drawing the item bmaps onto the inventory buttons.

Try making a panel with a bmap of an empty inventory cell, and use the bmap_draw function to draw the bmap of an item onto the panel's bmap, just to test the function smile
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/16/09 18:31

Looks to me like bmap_draw() doesnt work.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/16/09 22:38

Ok smile
I just can't see what's wrong with that function. I checked the bmap operations used in that function in both the A6 and then the A7 manual, but nothing seems to have changed, so I don't know why it's not working. I'm checking the 'beta features' page right now to see if something has changed for the pixel_for_bmap and pixel_to_bmap functions.

Anyways, try using the bmap_draw function on two pictures without an alpha channel - maybe it just doesn't draw the other alpha channel onto the picture (just a thought, but might be worth a try).

I'll let you know if I find anything on the beta-page smile
Edit: Didn't find anything there frown

Edit 2: Try initializing the variables in bmap_draw (replace "var i;var k;var t;" by "var i = 0;var k = 0;var t = 0;"),
and remove these lines: "if(t - (max_loops-1) >= 0) {wait(1);t = 0;}"

Just to see if it makes any difference.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/17/09 12:05

Got A7 now, and I tested the bmap_draw function - it works fine for me. So the mistake has to be elsewhere in the code.

Edit: I ran the sample level from the converted version, the bmaps did show up in the inventory, however it was a bit buggy. I tried casting a fireball spell, but that was a bit buggy as well frown

Anyways, it was using A7.77 Trial.
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/17/09 17:47

Ok I'm going to run the sample level directly from the converted sample level. I have 7.77 com.
Ok Claus I redownloaded and over wrote the sample level from this post. The cracked sword bmap does not show up unless i pick it up and its attached to the mouse. Same thing for you? bmap_draw() is not in my intellisense and it doesnt appear anywhere in my manual. So I'm really not even sure how to use it without info on it. I'm assuming it copies var2 to var1?
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/17/09 19:53

The bmap_draw function is in 'NHASC_bitmap.c', and is a part of the template code I wrote smile

For me the items does appear in the inventory when I put them there, so I don't really know why it doesn't work for you frown
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/17/09 21:45

Thats very strange. I didnt make any changes and its the exact copy of the link above. The description shows up but not the item bmap itself when I mouse over. If I pick it up it is attached to the mouse and you can see it but not otherwise. That would be horrible to find out that it works on some customers machines and not others.
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/17/09 21:53

Ok I was curious to see what would happen if I published it.
The item icons show up in the inventory but they do not refresh to the blank icon. So basically if you pick up the cracked short sword and put it in the weapon slot a copy of the sword icon is still in the inventory even though its empty. If you pick up a helm from the ground it will draw over the sword icon in the inventory and then it will itself leave a copy of the icon in the inventory as many times as you move the item around. So I guess this might be the real problem.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/18/09 14:51

It sounds like last time I ran the level, however today it worked fine (except for a part of the weapon-bmap not being drawn properly in the inventory somehow).

It's like it's making less sense everytime I run the level :s
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/18/09 23:42

Sounds like we may need help with one of the other Lite-C programmers here who has more experience. Hopefully one of these other guys here can take a look at it. I'm sure we can make your system the best out there Claus. Thats what I'm hoping.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/19/09 00:19

I think that I'll simply just rewrite it sometime. I've just started writing a Diablo-style inventory in Lite-C, and it just seems so damn easy smile

An inventory like the one in these RPG Templates should be even way easier to write, so it shouldn't take long smile I'll finish this diablo-style inventory first though.
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/19/09 01:03

Sounds great Claus! I'm good at actual mechanics but when it comes to inventories it just all looks greek to me. So I look forward to it. I guess I should learn to write my own inventory some day but I have higher priorities that I have to accomplish.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/25/09 00:33

Okay, I finally got the time for re-writing the inventory system smile it's not done & uploaded yet though.

The function names are the same, and their functionality is still the same - I just either rewrote the functions or simply just changed them to support the structs.

The item-files (ILF) can still be used, and the items in this file, can be used as a "item template" for creating new items using this new function:
Code:
RPGItem* RPGItem_Create(var _number)
{
	RPGItem* _item = malloc(sizeof(RPGItem));
	memset(_item,0,sizeof(_item));
	
	if(_number >= 0 && _number < NHAC_max_items && CITEM_handlesInit_n == true)
	{
		_item.name = ptr_for_handle(NHAC_CITEM_NAME[_number]);
		_item.bmap = ptr_for_handle(NHAC_CITEM_BMAP[_number]);
		_item.model = ptr_for_handle(NHAC_CITEM_MODEL[_number]);
		_item.skin = NHAC_CITEM_SKIN[_number];
		_item.type = NHAC_CITEM_TYPE[_number];
		_item.damage = NHAC_CITEM_DAMAGE[_number];
		_item.defense = NHAC_CITEM_DEFENSE[_number];
		_item.addhealth = NHAC_CITEM_ADDHEALTH[_number];
		_item.addmana = NHAC_CITEM_ADDMANA[_number];
		_item.addspeed = NHAC_CITEM_ADDSPEED[_number];
		_item.reqlevel = NHAC_CITEM_REQLEVEL[_number];
		_item.value = NHAC_CITEM_VALUE[_number];
	}
	
	return _item;
}



And there's a function for removing items as well:

Code:
void RPGItem_Delete(RPGItem* _item)
{
	free(_item);
}



There are no syntax errors, but I'm getting some crashes, however I'll get some sleep before figuring that out smile

P.s. The item struct looks like this:
Code:
typedef struct RPGItem
{
	BMAP* bmap;
	STRING* name;
	STRING* model;
	var skin;
	var type;
	var damage;
	var defense;
	var addhealth;
	var addmana;
	var addspeed;
	var reqlevel;
	var value;
} RPGItem;


Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/25/09 00:39

Quote:
I guess I should learn to write my own inventory some day

It's actually just an array of items wink Then you need a panel to show the items, with a click-event to swap the clicked item with the item held by the mouse.

Of course it way more complicated if you e.g. want to create a "tetris-inventory" (diablo-style inventory). It's as well a bit more complex to re-write an inventory system for a system like this (RPG Template), as it has to fit into the other code, and due to that fact the original item system worked in a different way.
Posted By: Claus_N

New Inventory System - Nighthawk RPG template for lite-C - 07/26/09 23:14

Finally the inventory system is done!

You can get it here:
http://rpg.nighthawk.dk/center/?PageID=downloads

Writing the code didn't take that long, but then fixing crashes, empty pointers, and lots of wierd errors really took some time, so I just hope it's working for you as well wink

It's fully compatible with the previous item system, so the item-list-files (.ilf) can still be used, even though this item system works in a very different way.

My hair almost turned grey whilst making this code work - and I'd say that it's a bit too early as I'm only 18 yet blush
Posted By: paracharlie

Re: New Inventory System - Nighthawk RPG template for lite-C - 07/27/09 04:02

Looks really nice Claus! I'll download and give it a shot. I'll let you know how it goes when I get a chance.

Sorry Claus I can't find the link to download it or it does not show for me on your site.
Posted By: Claus_N

Re: New Inventory System - Nighthawk RPG template for lite-C - 07/27/09 19:38

It's the link "New Inventory System for NHA RPG Templates 2.0 (Lite-C/A7)" at the top of the page I posted smile

A more direct link:
http://www.nighthawk.dk/v5/index.asp?PageID=ShowOther&OID=18
Posted By: paracharlie

Re: New Inventory System - Nighthawk RPG template for lite-C - 07/28/09 01:46

Thanks! I ran through a full test on it, items, character panel, stats, leveling up, save and load. Everything appears to be working great. Nice work, I'm going to study what you did. I like what you did with the structs.
Posted By: Claus_N

Re: New Inventory System - Nighthawk RPG template for lite-C - 07/28/09 21:04

I'm glad to hear that it worked for you as well - especially the save/load, as I didn't try that myself smile
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/29/09 00:09

There is a empty pointer bug when loading the game and loading a level. It appears we have to do something special in lite-c when referencing a pointer. sv_all doesnt save that it appears.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/29/09 08:47

I tried saving/loading and it worked fine for me - no empty pointer errors.
What did you do to make the error appear and where exactly does it say the empty pointer is? smile
Posted By: GorNaKosh

Re: Nighthawk RPG template for lite-C - 07/29/09 12:22

If I try to load a game, I get an empty pointer error, too. I'm interested to know how the code for saving and specially for loading the new Item-Structs look like!? I didn't found it in your script-files.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/29/09 13:24

I didn't change anything in the save/load system to make it work with the structs, it seems the engine handles that. The save/load system is located in NHAC_mainMenu.c.

I still don't get any empty pointer errors, so I don't know why and when they appear frown
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/29/09 18:33

In order to save structs according to the manual it looks like we have to add:
add_struct(void* data, long size) before the first game save and then SV_STRUCT? There is not a whole lot of information on how to use it.

If you setup your character stats and put an item in your equipment slot then save game, exit game, start game, load last save you'll see what I mean.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/29/09 21:02

Ahh, I got an enemy dropping an item, then save -> exit -> load and got the error as well.

Yeah, it seems that we need to use add_struct, though I don't know how that works - it seems like it's necessary to use it on every instance of the struct?
Well, I don't know a fast/good way of solving that right now, so I'll get back to that problem another time.
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/30/09 00:21

Yes it appears that it has to be every instance of the struct. I'm not sure if it can be put in at the end of every function or if it needs to be in the main loop.
Posted By: GorNaKosh

Re: Nighthawk RPG template for lite-C - 07/30/09 04:35

Now it's gonna be interessting ^^ I was wondering why I couldn't find any code using add_struct in your new itemsystem. That's why I asked the saving-question.

Saving structs seems not to be a problem. You have some itemcreate-function where you malloc the struct: This could be a place for add_struct. A disadvantage is if those added items doesn't exists anymore when saving the game. To solve this you could implement an array or a motherstruct which manages the items an saves all pointers to existing ones. When the user saves the game you have to use add_struct for all these struct-pointers.
But loading structs is mystery for my as well. Don't get where the data could be after loading or meet some errors like "Couldn't load xyz.sav".
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/30/09 15:53

After doing these add_structs I still have a showdescription error in inventory and equipment. Not sure where to place those or what to use as the void* data that the add_struct calls for. Here is what I have done so far and not sure if these are even correct.

add_struct(NHAC_CINVENT_CELLS[NHAC_CINVCELLS], sizeof(RPGItem));
add_struct(NHAC_CINVENT_EQUIP[NHAC_CINVCELLS], sizeof(RPGItem));
add_struct(NHAC_MOUSEITEM, sizeof(RPGItem));
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/30/09 18:32

Originally Posted By: paracharlie
After doing these add_structs I still have a showdescription error in inventory and equipment. Not sure where to place those or what to use as the void* data that the add_struct calls for. Here is what I have done so far and not sure if these are even correct.

add_struct(NHAC_CINVENT_CELLS[NHAC_CINVCELLS], sizeof(RPGItem));
add_struct(NHAC_CINVENT_EQUIP[NHAC_CINVCELLS], sizeof(RPGItem));
add_struct(NHAC_MOUSEITEM, sizeof(RPGItem));


Try this instead to get the correct memory areas smile

Code:
add_struct(NHAC_CINVENT_CELLS, sizeof(RPGItem)*NHAC_CINVCELLS);
add_struct(NHAC_CINVENT_EQUIP, sizeof(RPGItem)*3);
add_struct(NHAC_MOUSEITEM, sizeof(RPGItem));



However this won't do, as it will not save items dropped on the ground frown
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 07/31/09 01:03

Yeah I dont know. This is little bit beyond my ability and kinda frustrating. I was planning on doing structs for character stats, monster stats and combat tables but now I might rethink it all unless I can figure it out.
Posted By: GorNaKosh

Re: Nighthawk RPG template for lite-C - 07/31/09 04:18

Items on the ground exists as ENTITY in the level - Entities could save by the normal game_save() function. You need only a code in the action which cretae a new struct for this item after loading the game and maybe register this struct to your item-management-system if necessary.
Have your get the save and load of the item-structs in the inventory worked?
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 07/31/09 10:26

I think that the best way would be to put all struct instances into a linked list, to easily iterate through them and make sure that all items are saved.

About the items on the ground - those entities got the address of an RPGItem instance, and that address might not be valid after a game_load. Another option is to remove the RPGItem-instance when an item is dropped on the ground, and then store the item stats in the skills of the entity (and then re-create the RPGItem instance when the item is picked up).

However, it would be very nice if struct-instances in Lite-C was saved automatically - I'll suggest that in the "The Future" forum smile
Posted By: paracharlie

Re: Nighthawk RPG template for lite-C - 08/04/09 18:09

@Claus,
I was thinking since the members of the data structure only exist during runtime that maybe they should be saved to a file. I found similar in aum 83 and aum 69. If they were saved to like a *.ini file then they could be read anytime and none of the information would be lost. The thing is that your template is alot of code and every instance would have to be found and then read from a file.

I'm still at the artwork stage of my game and unfortunately I dont have the time to help.
Posted By: Claus_N

Re: Nighthawk RPG template for lite-C - 08/04/09 21:54

Saving it in a separate file would no doubt be the best, but such things as items lying on the ground does complicate it a bit.

I'm currently trying to get a project done in time for the shader contest (and I'm quite a noob at shaders, so it really takes some time :P), and my summer holidays are over when I'm done with that, so I don't know when I'll have time to see to this frown
Posted By: not_me

Re: Nighthawk RPG template for lite-C - 07/29/10 04:52

can someone post a new link for this? it seems that its inaccessible on the nighthawk website frown

thanks in advanced
Posted By: 3run

Re: Nighthawk RPG template for lite-C - 08/13/14 12:41

Is there anyone who still has this OLD template on it's HDD? I would be grateful.
Posted By: FEL

Re: Nighthawk RPG template for lite-C - 08/13/14 12:54

Yea that would be nice laugh
Posted By: AceX

Re: Nighthawk RPG template for lite-C - 08/13/14 14:57

Í'm using the C-Script version ,but I'm working on a new HUD,like in World Of Warcraft grin

It have a simple quest...simple things.
Posted By: FEL

Re: Nighthawk RPG template for lite-C - 08/13/14 17:01

but we need the c-lite version ^^ Legacy or so
Posted By: FEL

Re: Nighthawk RPG template for lite-C - 09/13/14 13:29

So AceX grin can u upload your modified version? Or the old one?
Posted By: AceX

Re: Nighthawk RPG template for lite-C - 09/14/14 12:50

Originally Posted By: FEL
So AceX grin can u upload your modified version? Or the old one?


Sure ,but you need to wait for the next week-end because i'm not at my home :| .Sorry Also When I will come home I will update it a bit wink
© 2024 lite-C Forums