REM Project: Kamagata
REM Created: 11/27/2004 5:06:00 PM
REM
REM ***** Main Source File *****
`Make window
Set window on
show window
maximize window
Disable escapekey
`Set tExt Properties
Set Text font "Arial"
`Load Media
Load image "Greenish Rock 2.png",1
Load image "skytext.png",2
Load image "newhud.png",3
Load image "textbox.png",4
Load image "Enter!.png",5
load image "menu.png",6
load image "newmphud.png",7
load image "newxphud.png",8
load image "redtext.png",9
load image "bluetext.png",10
sync on:sync rate 45
color backdrop rgb(50,50,255)
ink rgb(0,0,0),rgb(0,0,0)
RemStart
Change this value to change the chance of the enemy casting
magic. Make it bigger to lower the chance and vice versa.
RemEnd
global ChanceOfCast as integer
ChanceOfCast=90
dim key(256)
type enem
health as integer
startx as integer
startz as integer
endx as integer
endz as integer
move as integer
scale as integer
cast as integer
endtype
dim enemy(100) as enem
`Create the world
make matrix 1,10000,10000,10,10
prepare matrix texture 1,1,1,1
position matrix 1,-50,-2,-50
for a=10 to 100
make object sphere a,3,6,6
position object a,rnd(1000),0,rnd(1000)
color object a,rgb(255,0,0)
enemy(a).health=100
enemy(a).startx=object position x(a)
enemy(a).startz=object position z(a)
enemy(a).endx=object position x(a)+rnd(60)
enemy(a).endz=object position z(a)+rnd(60)
enemy(a).scale=100
make object sphere a+100,3,6,6
color object a+100,rgb(0,100,250)
ghost object on a+100
hide object a+100
next a
`Create the player character
make object cube 1,1
color object 1,RGB(0,10,50)
playerhealth=100
xp = 0
xp_to_gain = 100
level = 1
`Create Sword
make object box 2,.2,.2,4
color object 2,rgb(0,0,0)
hide object 2
offset limb 2,0,0,0,2
`Magic Array
DIM spell_cost(1)
mp=100
max_mp=100
cur_spell=0
spell_cost(0)=5
spell_cost(1)=2
spell_cast=0
`Create Followers
For a=3 to 4
make object cube a,1
move object a,a-2
next a
`Ally 1 Setup
Position object 3,0,0,-2
color object 3,RGB(0,50,10)
ally1health=100
`Create Fists
make object cube 5,.25
hide object 5
make object cube 6,.25
hide object 6
color object 5,RGB(255,255,100)
color object 6,RGB(255,255,100)
`Ally 2 Setup
Position object 4,0,0,-4
color object 4,RGB(50,10,0)
ally2health=100
`Create Arrows
Make object sphere 7,.25
color object 7,RGB(255,40,0)
hide object 7
`End Create Followers
set global collision on
do
`Ally Death
`Ally 1
If ally1health <50 then ghost object on 3
If ally1health = 0 then hide object 3
`Ally 2
If ally2health <50 then ghost object on 4
If ally2health = 0 then hide object 4
`Gosubs
Gosub Meters
Gosub Magic
Gosub Statistics
`End gosubs
if upkey()=1 then move object 1,1 : move object 3,1 : move object 4,1
if downkey()=1 then move object 1,-1 : move object 3,-1 : move object 4,-1
if leftkey()=1 then yrotate object 1,object angle y(1)-5 : yrotate object 3,object angle y(3)-5 :yrotate object 4,object angle y(4)-5
if rightkey()=1 then yrotate object 1,object angle y(1)+5 :yrotate object 3,object angle y(3)+5 :yrotate object 4,object angle y(4)+5
if keyready(57)=1 and attack=0
rotate object 2,object angle x(1),object angle y(1)-70,object angle z(1)
attack=16
show object 2
endif
if attack>0
attack=attack-1
position object 2,object position x(1),0,object position z(1)
yrotate object 2,object angle y(2)+10
for a=10 to 100
if object exist(a)=1
if object collision(2,a)=1
enemy(a).health=enemy(a).health-30
move object a,-20
enemy(a).scale=enemy(a).scale-20
scale object a,enemy(a).scale,enemy(a).scale,enemy(a).scale
enemy(a).cast=0
hide object a+100
endif
if enemy(a).health<10 then delete object a : delete object a+100: xp=xp+2
endif
`if enemy(a).health<10
`delete object a: xp=xp+2
if xp>=xp_to_gain
xp=xp-xp_to_gain
xp_to_gain=xp_to_gain+2
level=level+1
max_hp=max_hp+2: hp=hp+2
endif
`endif
next a
endif
if attack=1 then hide object 2
for a=10 to 100
if object exist(a)=1
if distance(1,a)<50 and attack>0 and attack<8 then move object a,-1
if distance(1,a)>50
enemy(a).cast=0
hide object a+100
scale object a+100,100,100,100
patrol(a)
else
if enemy(a).cast=0
point object a,object position x(1),0,object position z(1)
move object a,.5
if object collision(a,1)=1
playerhealth=playerhealth-5
move object a,-15
endif
if object collision(a,3)=1
ally1health=ally1health-5
move object a,-15
endif
if object collision(a,4)=1
ally2health=ally2health-5
move object a,-15
endif
if object collision(a+100,1)=1
playerhealth=playerhealth-1
endif
if object collision(a+100,3)=1
ally1health=ally1health-1
endif
if object collision(a+100,4)=1
ally2health=ally2health-1
endif
testforcast=0
if distance(1,a)<50
testforcast=rnd(ChanceOfCast)
endif
if testforcast=3
enemy(a).cast=100
show object a+100
endif
endif
if enemy(a).cast>0
enemy(a).cast=enemy(a).cast+3
scale object a+100,enemy(a).cast,enemy(a).cast,enemy(a).cast
if object collision(a+100,1)=1
playerhealth=playerhealth-1
endif
endif
if enemy(a).cast>500
enemy(a).cast=0
hide object a+100
endif
endif
position object a+100,object position x(a),object position y(a)-1.5,object position z(a)
endif
next a
position camera (object position x(1)-sin(object angle y(1))*5),object position y(1)+2,(object position z(1)-cos(object angle y(1))*5)
point camera object position x(1),object position y(1),object position z(1)
sync
loop
Meters:
`Health
paste image 3,415,0,1
` now for your actual health, colour change to red
INK RGB(200,0,0),0
` and then draw a box, 1 pixel smaller than the previous one in each direction (so that the white box will be an outline) and this box is as long as your health bariable
box 419,3,playerhealth*2/2+494,17
`Magic
paste image 7,415,22,1
` green box
INK RGB(0,0,100),0
box 419,25,mp*2/2+494,39
`Xp setup
if xp>=xp_to_gain
xp=xp-xp_to_gain
xp_to_gain = xp_to_gain+2
level=level+1
max_hp=max_hp+2: playerhealth=playerhealth+2
endif
`as for a meter
` blue box
paste image 8,1,455
INK RGB(0,200,0),0
box 4,458,xp*4+3,472
Return
`Magic
Magic:
` code for changing current spell (control key). Cannot change if a spell is currently being cast
if keystate(79)=1 and spell_cast=0
cur_spell=cur_spell+1
if cur_spell>1 then cur_spell=0
endif
` if shift key is pressed and no spell is already being cast AND have enough MP, then we create the particles and stuff
if keystate(82)=1 and spell_cast=0 and mp>=spell_cost(cur_spell)
mp=mp-spell_cost(cur_spell)
make particles 1,cur_spell+8,40,20: rotate particles 1,0,object angle y(1),90
particleangle#=object angle y(1)
particlex#=object position x(1): particley#=object position y(1): particlez#=object position z(1)
position particles 1,particlex#,particley#,particlez#
make object sphere 9,1: hide object 9
position object 9,particlex#,particley#,particlez#
spell_cast=1
endif
` if a spell is in play, it must move and check for collision with enemies
if spell_cast=1
particlex#=newxvalue(particlex#,particleangle#,1.3)
particlez#=newzvalue(particlez#,particleangle#,1.3)
position particles 1,particlex#,particley#,particlez#
position object 9,particlex#,particley#,particlez#
for a=10 to 100
if object exist(a)=1 and spell_cast=1
if object collision(9,a)=1
if cur_spell=0 then enemy(a).health=enemy(a).health-75
if cur_spell=1 then enemy(a).health=enemy(a).health-25
delete object 9
delete particles 1
spell_cast=0
endif
if enemy(a).health<10
delete object a: xp=xp+2
if xp>=xp_to_gain
xp=xp-xp_to_gain
xp_to_gain=xp_to_gain+2
level=level+1
max_hp=max_hp+2: hp=hp+2
endif
endif
endif
next a
endif
if particlex#<object position x(1)-100 or particlex#>object position x(1)+100 or particlez#<object position z(1)-100 or particlez#>object position z(1)+100
if spell_cast=1
delete object 9
delete particles 1
spell_cast=0
endif
endif
Return
`End Magic
Statistics:
Ink RGB(0,0,0),0
text 0,0,"X:"+STR$(object position x(1))
text 0,20,"Y:"+STR$(object position y(1))
text 0,40,"Z:"+STR$(object position z(1))
text 0,60,"FPS:"+STR$(Screen FPS())
text 0,80,"Ally 1 Hp:"+STR$(ally1health)
text 0,100,"Ally 2 Hp:"+STR$(ally2health)
Return
function patrol(object)
if threeD_distance(object position x(object),enemy(object).endx,0,0,object position z(object),enemy(object).endz)<2 then enemy(object).move=1
if threeD_distance(object position x(object),enemy(object).startx,0,0,object position z(object),enemy(object).startz)<2 then enemy(object).move=0
if enemy(object).move=0
point object object,enemy(object).endx,0,enemy(object).endz
move object object,1
endif
if enemy(object).move=1
point object object,enemy(object).startx,0,enemy(object).startz
move object object,1
endif
endfunction
function distance(obj1,obj2)
dist=sqrt(((object position x(obj1)-object position x(obj2))*(object position x(obj1)-object position x(obj2)))+((object position z(obj1)-object position z(obj2))*(object position z(obj1)-object position z(obj2))))
endfunction dist
FUNCTION threeD_distance(x1# AS float, x2# AS float, y1# AS float, y2# AS float, z1# AS float, z2# AS float)
temp = 1
null = make vector3(temp)
set vector3 temp, x1# - x2#, y1# - y2#, z1# - z2#
length_vector = abs(length vector3(temp))
null = delete vector3(temp)
ENDFUNCTION length_vector
function keyready(keyz)
vl=0
if keystate(keyz)=1 and key(keyz) = 0
key(keyz) = 1
vl=1
endif
if keystate(keyz)=0
key(keyz) = 0
vl = 0
endif
endfunction vl
I need to take this code and make it so it can work in DBC, can anyone help? If you need the media so you can test and whatnot, then I'll make a media free version.
Please help me, because I want to have something to do while I wait to buy DBP next year or whenever.
Have a heart and join my message board.