Heya all, I've been working on a RPG with diablo & elder scrolls stylish attitude but now I've encountered a show stopper for me at least. The problem is that I'm not able to do for an example wolfs to the game with HP, collisions and such. I know it should be done with types somehow but I haven't yet realised how, could someone please help me?
tl/dr: How can I make multiple moobs with loot table/hp/exp with minium on code?
Thanks in advance
A problem with real-time thingy
-
- Newcomer
- Posts: 17
- Joined: Mon Feb 09, 2009 8:07 am
- Location: Ikaalinen, Finland
-
- Advanced Member
- Posts: 349
- Joined: Mon Aug 27, 2007 9:00 pm
- Location: Lapinjärvi, Finland
- Contact:
Re: A problem with real-time thingy
Yeah, types should do it. You could make a type for all monsters. Something like this.WinKIller0 wrote:tl/dr: How can I make multiple moobs with loot table/hp/exp with minium on code?
Code: Select all
Type Monster
field obj
field monstertype$
field hp
End Type
Code: Select all
a.monster = new(monster) // note that colon . is used on creation and for - each loop, but backslash \ is used with variables (fields)
a\obj = loadobject("wolf.bmp") // a is the address of this instance
a\hp = 100
a\monstertype = "wolf"
Code: Select all
for i=1 to 5
a.monster = new(monster)
a\obj = loadobject("wolf.bmp")
a\hp = 100
a\monstertype = "wolf"
next i
If you add fields, you'll get more variables to each type instance (monster). Inventory table can be done with memoryblocks. Two dimensional integer array consisting id-number and quantity of item or more, whatever pleases you.
Going through all monsters is easy.
Code: Select all
for a.monster = each monster
//we could check if hp=0 then delete monster
if a\hp <= 0 then
//remember to remove object before type instance
deleteobject a\obj
delete a
endif
//after deletion or possible deletion you shouldn't use instance's variables.
//eg. moveobject a\obj,1 will cause Memory access violation if some
//monster runs out of hitpoints.
next a //a, address, changes to address to next monster
Wolf.cgf could look like this:
Code: Select all
name=Wolf
hp=100
object=media/monsters/wolf.bmp
I'm sorry there isn't much official English help available.
Last edited by otto90x on Mon Feb 16, 2009 12:31 pm, edited 1 time in total.
Otto Martikainen a.k.a. MetalRain, otto90x, kAATOSade.
Runoblogi, vuodatusta ja sekoiluja.
Runoblogi, vuodatusta ja sekoiluja.
-
- Newcomer
- Posts: 17
- Joined: Mon Feb 09, 2009 8:07 am
- Location: Ikaalinen, Finland
Re: A problem with real-time thingy
Thanks for your reply I've made a good progress with this.I'll see if I get everything working as they should and then I could release it perhaps
thanks again and best wishes:
-WinKIller0
Edit: Lack of help files don't really bother me as long as there's some place I can ask for help
thanks again and best wishes:
-WinKIller0
Edit: Lack of help files don't really bother me as long as there's some place I can ask for help
-
- Advanced Member
- Posts: 485
- Joined: Tue Aug 28, 2007 3:53 pm
- Location: Suomi, Finland
- Contact:
Re: A problem with real-time thingy
Here is English manual! It's not as good as the finnish one, but it has some references about the language and the commands. *Click* replace folder "X:\program files\Coolbasic\help" with that (rename it to help).