A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

User projects written in or related to FreeBASIC.
mrminecrafttnt
Posts: 69
Joined: Feb 11, 2013 12:23

A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby mrminecrafttnt » Oct 11, 2018 11:29

Code: Select all

type Item
    Itemname as string
    ItemType as string
    ItemID as Integer
    Amount as Integer
    Cost as Integer
    Damage as Integer
end type

type charakter
    Username as String
    Inventory(any) as Item
    HP as integer
    Damage as integer
end type

'find an item in an itemtable
function find_item(ItemName as string,ItemTable() as Item) as integer
    for i as integer = lbound(ItemTable) to ubound(ItemTable)
        If ItemTable(i).Itemname = ItemName then
            return i
        end if
    next
    return -1
end function


'add an item to the itemtable
sub add_item_to_table (ItemName as String,ItemTable() as Item)
    if find_item(ItemName,ItemTable()) = -1 then
        redim preserve ItemTable(ubound(ItemTable)+1)
        with ItemTable(ubound(ItemTable))
            .ItemName = ItemName
            .Amount = 0
            .ItemId = ubound(ItemTable)
            .ItemType = "None"
        end with
        print "Item '";ItemName;"' Registered to ID :";Ubound(ItemTable)
    else
        print "Registration failed"
    end if
end sub

'add an item to the charactere inventory like a player or a seller
sub add_item_to_character (ItemName as String,ItemTable() as Item,character as charakter)
    dim as integer item_id = find_item(ItemName,ItemTable())
    dim as integer id = find_item(ItemName,character.inventory())
    if id > -1 then print "Item already added" : EXIT SUB
    if item_id = -1 then print "E Item not found" : exit sub
    redim preserve character.inventory(ubound(character.inventory)+1)
    id = ubound(character.inventory)
    character.inventory(id)=ItemTable(item_id)
end sub

'set the amount of the item to a charactere
sub set_amount (ItemName as String,amount as integer,char as charakter)
    dim as integer id = find_item(ItemName,char.inventory())
    if id = -1 then print "A Item not found" : exit sub
    char.inventory(id).amount = amount
end sub

'get the amount of the item from a charactere
function get_amount (ItemName as String,char as charakter) as uinteger
    dim as integer id = find_item(ItemName,char.inventory())
    if id = -1 then print "B Item not found" : exit function
    return char.inventory(id).amount
end function

'set the cost of an item to the itemtable
sub set_cost (ItemName as String,cost as uinteger,ItemTable() as Item)
   
    dim as integer id = find_item(ItemName,ItemTable())
    if id =-1 then print "C Item not found" : exit sub
    ItemTable(id).cost = cost
    Print "Item ";Itemname;" has now Cost :";cost
end sub

'get the cost of an item from the itemtable
function get_cost (ItemName as String,ItemTable() as Item) as integer
    dim as integer id = find_Item(ItemName,ItemTable())
    if id = -1 then print "F Item not found" : exit function
    Return ItemTable(id).cost
end function

'lists all inventorys from charactere
sub list_inventory(char as charakter)
    Print "Charakter '";char.username;"' has this items:"
    print "Amount","ItemName","ItemType","Damage"
    for i as integer = lbound(char.inventory) to ubound(char.inventory)
        with char.inventory(i)
            Print .amount,.Itemname,.ItemType,.Damage
        end with
       
    next
end sub

sub set_damage(Itemname as string,damage as integer,ItemTable() as Item)
    dim as integer id = find_Item(ItemName,ItemTable())
    if id = -1 then print "G Item not found"
    ItemTable(id).damage = damage
    Print "Item ";Itemname;" has now Damage :";damage
end sub

function get_damage (ItemName as String,ItemTable() as Item) as integer
    dim as integer id = find_item(ItemName,ItemTable())
    if id = -1 then print "H Item not found"
    return ItemTable(id).damage
end function

sub set_itemtype(ItemName as String,Itemtype as string,ItemTable() as Item)
    dim as integer id = find_item(ItemName,ItemTable())
    if id = -1 then print "I Item not found"
    ItemTable(id).ItemType = ItemType
end sub

sub list_player_stats(p as charakter)
    with p
        print "Username : ";.Username
        list_inventory(p)
        PRINT "HP :";.hp
        Print "Damage :";.damage
    end with
end sub

sub set_waepon_damage_from_charakter (char as charakter)
    with char
        for i as integer = lbound(char.inventory) to ubound(char.inventory)
            .damage += char.inventory(i).damage * char.inventory(i).amount
        next
    end with
end sub

   

sub buy_item(buy_from as charakter,buy_to as charakter, buywith as string,buywhat as string,buy_amount as integer,ItemTable() as Item)
    dim as integer buy_from_object = find_item(buywhat, buy_from.inventory())
    dim as integer buy_to_object   = find_item(buywhat, buy_to.inventory())
    dim as integer from_money_id  = find_item(buywith, buy_from.inventory())
    dim as integer to_money_id  = find_item(buywith, buy_to.inventory())
    dim as integer ItemID          = find_item(buywhat, ItemTable())
    if buy_from_object = -1 then print "D Item not found"
    If ItemTable(ItemID).Cost * buy_amount <= buy_to.inventory(to_money_id).amount then
        if buy_to_object = -1 then
            add_item_to_character(buywhat,ItemTable(),buy_to)
            buy_to_object = ubound(buy_to.inventory)           
        end if
        if get_amount(buywhat,buy_from) >= buy_amount then
           
            buy_to.inventory(to_money_id).amount -= get_cost(BuyWith,ItemTable()) * ItemTable(ItemID).Cost * buy_amount
            buy_from.inventory(from_money_id).amount += get_cost(BuyWith,ItemTable()) *ItemTable(ItemID).Cost*buy_amount
            buy_to.inventory(buy_to_object).amount += buy_amount
            buy_from.inventory(buy_from_object).amount -= buy_amount
            Select case ItemTable(ItemId).ItemType
            case "Waepon"
                set_waepon_damage_from_charakter buy_to
            end select
           
               
        else
            print "Buy Failed - ";buywhat; " sold out."
        end if
    else
        print "Buy Failed - Not engouh money"
       
    end if
   
end sub

sub fight (byref Player as charakter,byref Enemy1 as charakter,Items() as Item)
cls
locate ,,0
do
   
   locate 1
   Print "Lets fight!"
   
   color 15
   PRINT "**PLAYER STATS**"
   color 11
   list_player_stats(Player)
   color 12
   list_player_stats(Enemy1)
   color 7

    select case inkey
    case " "
        beep
        cls
        Enemy1.HP - = Player.Damage
       
        Player.HP - = Enemy1.Damage
        if Enemy1.HP <= 0 then Enemy1.HP = 0
        If Player.HP <= 0 then Player.HP = 0 : Print "You lose! :O" : Exit do
        If Enemy1.HP <= 0 then
            locate 1
            Print "Let's Fight"
            color 15
            PRINT "**PLAYER STATS**"
            color 11
            list_player_stats(Player)
            color 12
            list_player_stats(Enemy1)
            color 15
            print "You won this fight!"
            for i as integer = lbound(Enemy1.Inventory) to ubound(Enemy1.Inventory)
                Print "You became " & Enemy1.Inventory(i).amount ;" ";Enemy1.Inventory(i).Itemname ;
                if Enemy1.Inventory(i).ItemType = "Waepon" then
                    print " with Damage ";Enemy1.Inventory(i).Damage & "."
                else
                    print ""
                end if
               
                add_item_to_character(Enemy1.Inventory(i).Itemname,Items(),Player)
                set_amount(Enemy1.Inventory(i).Itemname,Enemy1.Inventory(i).amount,Player)
                set_amount(Enemy1.Inventory(i).Itemname,0,Enemy1)
                if Enemy1.Inventory(i).ItemType = "Waepon" then
                    Player.Damage + = Enemy1.Inventory(i).Damage * Enemy1.Inventory(i).Amount : print Enemy1.Inventory(i).Damage * Enemy1.Inventory(i).Amount
                    Enemy1.Damage - = Enemy1.Inventory(i).Damage
                    Print "Congratulations your damage is now :";Player.Damage
                end if
               
            next
            exit do
        end if
               
    case chr(27)
        exit do
    end select
loop
end sub


'example

'configuration
dim Items(any) as Item
dim as charakter Player,Seller,Enemy1
add_item_to_table "Gold",Items()
add_item_to_table "Sword",Items()
add_item_to_table "Sting",Items()
add_item_to_character ("Gold",Items(),Seller)
add_item_to_character ("Gold",Items(),Player)
add_item_to_character ("Sword",Items(),Seller)
set_amount("Gold",10000,Seller)
set_amount("Gold",5000,Player)
set_itemtype("Sword","Waepon",Items())
set_amount("Sword",15,Seller)

set_cost("Sword",2500,Items()) ' here - a sword cost 2500
set_cost("Gold",1,Items())
set_damage("Sting",4,Items())
set_damage("Sword",7,Items())

set_itemtype("Sting","Waepon",Items())
add_item_to_character ("Sting",Items(),Enemy1)
set_amount("Sting",1,Enemy1)
set_waepon_damage_from_charakter Enemy1
Player.Username ="Player"
Player.HP = 25
Seller.Username ="Seller"
Enemy1.Username ="MrBee"
Enemy1.HP = 80
list_inventory(Player)
list_inventory(Seller)
color 15 : PRINT "NOW WE BUY TWO SWORDS FOR " & get_cost ("Sword",Items()) * 2: color 7


buy_item (Seller,Player,"Gold","Sword",2,Items())
print "New Player stats:"
list_inventory(Player)
list_inventory(Seller)
PRINT "DONE."
color 15

'example fight
Print "An Enemy is standing in the top of you hit him with [SPACE] :)"
Print "Enemy stats: "
list_player_stats(Enemy1)
print "Press a key to do this!"
sleep
fight (Player,Enemy1,Items())
print "Your Stats:"
list_player_stats(Player)


Code: Select all

dim Items(any) as Item

-some other issues fixed.
-dummy not more needed
-Itemtype and Damage added to list_inventory
Last edited by mrminecrafttnt on Oct 12, 2018 16:10, edited 9 times in total.
sancho3
Posts: 300
Joined: Sep 30, 2017 3:22

Re: A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby sancho3 » Oct 12, 2018 3:00

This should not work. In fact it doesn't on my system Linux.
The first problem encountered is that you use the line

Code: Select all

dim Items(0) as Item

This creates a fixed length array. A fixed length array cannot be resized.
You then send that array to:

Code: Select all

sub add_item_to_table (ItemName as String,ItemTable() as Item)
    if find_item(ItemName,ItemTable()) = -1 then
        redim preserve ItemTable(ubound(ItemTable)+1)
        with ItemTable(ubound(ItemTable))
            .ItemName = ItemName
            .Amount = 0
            .ItemId = ubound(ItemTable)
        end with
        print "Item '";ItemName;"' Registered to ID :";Ubound(ItemTable)
    else
        print "Registration failed"
    end if
end sub

And that sub tries to ReDim a fixed length array. This should be failing on your system as well.
grindstone
Posts: 582
Joined: May 05, 2015 5:35
Location: Germany

Re: A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby grindstone » Oct 12, 2018 10:06

At a first glance it works here (WinXP).
paul doe
Posts: 802
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby paul doe » Oct 12, 2018 10:15

In works here (Win10) in 32-bit mode (shouldn't even work, as sancho3 stated). In 64-bit, it fails miserably.
mrminecrafttnt
Posts: 69
Joined: Feb 11, 2013 12:23

Re: A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby mrminecrafttnt » Oct 12, 2018 15:00

Yay! The crash i now removed but it does not that waht it should..^^
With:

Code: Select all

dim Items(any) as Item

Update:
OK! Engine errors are complete fixed. And the code is updated.
Let me know when you have more issuses..
Lachie Dazdarian
Posts: 2259
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Re: A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby Lachie Dazdarian » Oct 14, 2018 21:13

Can I do anything here besides pressing SPACE?
mrminecrafttnt
Posts: 69
Joined: Feb 11, 2013 12:23

Re: A simple RPG Engine with Charakters, buyable Items, Inventory and a simple Fightsystem, written by me

Postby mrminecrafttnt » Oct 14, 2018 22:33

Lachie Dazdarian wrote:Can I do anything here besides pressing SPACE?

Here is a little version with Healing and Hero Leveling and a little Quest
Press [Space] to fight, [H] to get heal you self.. Actually i have so much to rewrite to get more Dynamic.. :)

Code: Select all

type Experience
    XP as Uinteger
    XP_Next as Uinteger
    Level as Uinteger
    LP as Uinteger
    declare constructor
end type

constructor Experience
    Level = 1
    XP_Next = 10
end constructor

sub list_experience (XP as Experience)
    PRINT "XP :";XP.LP;"/" & XP.XP_Next;"   "
    PRINT "Level :";XP.Level
end sub


sub add_xp_handler (XP as Experience,ADD_XP as Uinteger)
        XP.XP+=ADD_XP
        IF XP.XP > XP.XP_NEXT THEN
                DO
                    XP.XP_NEXT+=1
                    XP.XP_NEXT+=XP.LEVEL*10.75
                    XP.LEVEL+=1
                   
                LOOP UNTIL XP.XP_NEXT >= XP.LP
                XP.LP += XP.LEVEL*1.25
            END IF
end sub


type Item
    Itemname as string
    ItemType as string
    ItemID as Integer
    Amount as Integer
    Cost as Integer
    Damage as Integer
    Heal as Integer
end type 

type charakter
    Username as String
    Inventory(any) as Item
    XP as Experience
    HP as integer
    Damage as integer
end type

'find an item in an itemtable
function find_item(ItemName as string,ItemTable() as Item) as integer
    for i as integer = lbound(ItemTable) to ubound(ItemTable)
        If ItemTable(i).Itemname = ItemName then
            return i
        end if
    next
    return -1
end function


'add an item to the itemtable
sub add_item_to_table (ItemName as String,ItemTable() as Item)
    if find_item(ItemName,ItemTable()) = -1 then
        redim preserve ItemTable(ubound(ItemTable)+1)
        with ItemTable(ubound(ItemTable))
            .ItemName = ItemName
            .Amount = 0
            .ItemId = ubound(ItemTable)
            .ItemType = "None"
        end with
        print "Item '";ItemName;"' Registered to ID :";Ubound(ItemTable)
    else
        print "Registration failed"
    end if
end sub

'add an item to the charactere inventory like a player or a seller
sub add_item_to_character (ItemName as String,ItemTable() as Item,character as charakter)
    dim as integer item_id = find_item(ItemName,ItemTable())
    dim as integer id = find_item(ItemName,character.inventory())
    if id > -1 then print "Item already added" : EXIT SUB
    if item_id = -1 then print "E Item not found" : exit sub
    redim preserve character.inventory(ubound(character.inventory)+1)
    id = ubound(character.inventory)
    character.inventory(id)=ItemTable(item_id)
end sub

'set the amount of the item to a charactere
sub set_amount (ItemName as String,amount as integer,char as charakter)
    dim as integer id = find_item(ItemName,char.inventory())
    if id = -1 then print "A Item not found" : exit sub
    char.inventory(id).amount = amount
end sub

'get the amount of the item from a charactere
function get_amount (ItemName as String,char as charakter) as uinteger
    dim as integer id = find_item(ItemName,char.inventory())
    if id = -1 then print "B Item not found" : exit function
    return char.inventory(id).amount
end function

'set the cost of an item to the itemtable
sub set_cost (ItemName as String,cost as uinteger,ItemTable() as Item)
   
    dim as integer id = find_item(ItemName,ItemTable())
    if id =-1 then print "C Item not found" : exit sub
    ItemTable(id).cost = cost
    Print "Item ";Itemname;" has now Cost :";cost
end sub

'get the cost of an item from the itemtable
function get_cost (ItemName as String,ItemTable() as Item) as integer
    dim as integer id = find_Item(ItemName,ItemTable())
    if id = -1 then print "F Item not found" : exit function
    Return ItemTable(id).cost
end function

'lists all inventorys from charactere
sub list_inventory(char as charakter)
    Print "Charakter '";char.username;"' has this items:"
    print "Amount","ItemName","ItemType","Damage"
    for i as integer = lbound(char.inventory) to ubound(char.inventory)
        with char.inventory(i)
            Print .amount,.Itemname,.ItemType,.Damage
        end with
    next
end sub

function find_item_id_by_type_and_aviable(ItemType as String,ItemTable() as Item) as uinteger
    for i as integer = lbound(ItemTable) to ubound(ItemTable)
        if ItemTable(i).ItemType = ItemType and ItemTable(i).Amount > 0 then
            return i
        end if
    next
    return -1
end function

       
       

sub set_damage(Itemname as string,damage as integer,ItemTable() as Item)
    dim as integer id = find_Item(ItemName,ItemTable())
    if id = -1 then print "G Item not found"
    ItemTable(id).damage = damage
    Print "Item ";Itemname;" has now Damage :";damage
end sub

function get_damage (ItemName as String,ItemTable() as Item) as integer
    dim as integer id = find_item(ItemName,ItemTable())
    if id = -1 then print "H Item not found"
    return ItemTable(id).damage
end function

sub set_itemtype(ItemName as String,Itemtype as string,ItemTable() as Item)
    dim as integer id = find_item(ItemName,ItemTable())
    if id = -1 then print "I Item not found"
    ItemTable(id).ItemType = ItemType
end sub

sub list_player_stats(p as charakter)
    with p
        print "Username : ";.Username
        list_inventory(p)
        PRINT "HP :";.hp
        Print "Damage :";.damage
        Print "Experience :"
        list_experience(p.Xp)
    end with
end sub

sub set_waepon_damage_from_charakter (char as charakter)
    with char
        for i as integer = lbound(char.inventory) to ubound(char.inventory)
            .damage += char.inventory(i).damage * char.inventory(i).amount
        next
    end with
end sub

sub set_hp_heal(Itemname as string,healvalue as integer,ItemTable() as Item)
    dim as integer id = find_Item(ItemName,ItemTable())
    if id = -1 then print "G Item not found"
    ItemTable(id).heal = healvalue
    Print "Item ";Itemname;" has now Heal :";healvalue
end sub

   

sub buy_item(buy_from as charakter,buy_to as charakter, buywith as string,buywhat as string,buy_amount as integer,ItemTable() as Item)
    dim as integer buy_from_object = find_item(buywhat, buy_from.inventory())
    dim as integer buy_to_object   = find_item(buywhat, buy_to.inventory())
    dim as integer from_money_id  = find_item(buywith, buy_from.inventory())
    dim as integer to_money_id  = find_item(buywith, buy_to.inventory())
    dim as integer ItemID          = find_item(buywhat, ItemTable())
    if buy_from_object = -1 then print "D Item not found"
    If ItemTable(ItemID).Cost * buy_amount <= buy_to.inventory(to_money_id).amount then
        if buy_to_object = -1 then
            add_item_to_character(buywhat,ItemTable(),buy_to)
            buy_to_object = ubound(buy_to.inventory)           
        end if
        if get_amount(buywhat,buy_from) >= buy_amount then
           
            buy_to.inventory(to_money_id).amount -= get_cost(BuyWith,ItemTable()) * ItemTable(ItemID).Cost * buy_amount
            buy_from.inventory(from_money_id).amount += get_cost(BuyWith,ItemTable()) *ItemTable(ItemID).Cost*buy_amount
            buy_to.inventory(buy_to_object).amount += buy_amount
            buy_from.inventory(buy_from_object).amount -= buy_amount
            Select case ItemTable(ItemId).ItemType
            case "Waepon"
                set_waepon_damage_from_charakter buy_to
            end select
           
               
        else
            print "Buy Failed - ";buywhat; " sold out."
        end if
    else
        print "Buy Failed - Not engouh money"
       
    end if
   
end sub

function search_item_type (ItemTypeName as string,ItemTable() as Item) as uinteger
    For i as integer = lbound(ItemTable) to ubound(ItemTable)
        If ItemTypeName = ItemTable(i).ItemType then
            return i
        end if
    next
end function

sub use_item (ItemName as String,From_Player as charakter,To_player as charakter,ItemTable() as Item)
    dim as integer user_item_id = find_item(ItemName,From_Player.Inventory())
    if user_item_id = -1 then print "ZZ Item not found"
   
    with from_player.inventory(user_item_id)
        if .Amount > 0 then
            select case .ItemType
            case "Waepon"
                To_Player.HP -= .Damage
            case "Heal"
                From_Player.HP +=.Heal
                Print "You have now : ";From_Player.HP ;"HP"
            end select
            .Amount -=1
        else
            Print "You don't have this item Anymore."
        end if
    end with
end sub


sub fight (byref Player as charakter,byref Enemy1 as charakter,XP_IF_Won as Uinteger = 0,Items() as Item)
cls
locate ,,0
do
   
   locate 1
   Print "Lets fight! [SPACE] to fight, [H] to HEAL"
   
   color 15
   PRINT "**PLAYER STATS**"
   color 11
   list_player_stats(Player)
   color 12
   list_player_stats(Enemy1)
   color 7

    select case inkey
    case "H"
        dim as integer ItemID = find_item_id_by_type_and_aviable("Heal",Player.Inventory())
        if ItemID =-1 then Print "Healing not aviable!" : exit select
        with PLayer.Inventory(ItemID)
            Use_Item(.ItemName,Player,Enemy1,Items())
        end with
       
    case " "
        beep
        cls
        Enemy1.HP - = Player.Damage
       
        Player.HP - = Enemy1.Damage
        if Enemy1.HP <= 0 then Enemy1.HP = 0
        If Player.HP <= 0 then Player.HP = 0 : Print "You lose! :O" : Exit do
        If Enemy1.HP <= 0 then
            locate 2
            Print "Let's Fight"
            color 15
            PRINT "**PLAYER STATS**"
            color 11
            list_player_stats(Player)
            color 12
            list_player_stats(Enemy1)
            color 15
            print "You won this fight!"
            for i as integer = lbound(Enemy1.Inventory) to ubound(Enemy1.Inventory)
                Print "You became " & Enemy1.Inventory(i).amount ;" ";Enemy1.Inventory(i).Itemname ;
                if Enemy1.Inventory(i).ItemType = "Waepon" then
                    print " with Damage ";Enemy1.Inventory(i).Damage & "."
                else
                    print ""
                end if
               
               
                add_item_to_character(Enemy1.Inventory(i).Itemname,Items(),Player)
                Dim as integer PlayerItemID = Find_Item(Enemy1.Inventory(i).ItemName,Player.Inventory())
                IF PlayerItemID = -1 then print "ZZZ Item not found"
                set_amount(Enemy1.Inventory(i).Itemname,Player.Inventory(PlayerItemId).amount + Enemy1.Inventory(i).amount,Player)
                Select case Enemy1.Inventory(i).ItemType
                case "Waepon"
                    Player.Damage + = Enemy1.Inventory(i).Damage * Enemy1.Inventory(i).Amount : print Enemy1.Inventory(i).Damage * Enemy1.Inventory(i).Amount
                   
                    set_amount(Enemy1.Inventory(i).Itemname,0,Enemy1)
                    Print "Congratulations your damage is now :";Player.Damage
                case "Heal"
                    Player.HP + = Enemy1.Inventory(i).Heal
                    set_amount(Enemy1.Inventory(i).ItemName,0,Enemy1)
                end select
                Enemy1.Damage - = Enemy1.Inventory(i).Damage
               
                dim as integer oldlevel = Player.XP.Level
                add_xp_handler(Player.XP,XP_If_won)
                dim as integer newlevel = Player.XP.Level
                If newlevel > oldlevel then
                    print "Congratualtions your Level is now  : ";Player.XP.Level
                    print "You became ";INT(Player.HP*1.05-Player.HP);"HP"
                    Player.HP*=1.05
                end if
                   
            next
            exit do
        end if
       
               
    case chr(27)
        exit do
    end select
loop
end sub


'example

'configuration
dim Items(any) as Item
dim as charakter Player,Seller,Enemy1
add_item_to_table "Gold",Items()
add_item_to_table "Sword",Items()
add_item_to_table "Sting",Items()
add_item_to_table "HP_Healer",Items()
set_itemtype("HP_Healer","Heal",Items())
set_hp_heal("HP_Healer",80,Items())
add_item_to_character ("Gold",Items(),Seller)
add_item_to_character ("Gold",Items(),Player)
add_item_to_character ("Sword",Items(),Seller)
add_item_to_character ("HP_Healer",Items(),Player)
set_amount("HP_Healer",1,Player)
set_amount("Gold",10000,Seller)
set_amount("Gold",5000,Player)
set_itemtype("Sword","Waepon",Items())

set_amount("Sword",15,Seller)
sleep
set_cost("Sword",2500,Items()) ' here - a sword cost 2500
set_cost("Gold",1,Items())
set_damage("Sting",4,Items())
set_damage("Sword",7,Items())

set_itemtype("Sting","Waepon",Items())
add_item_to_character ("Sting",Items(),Enemy1)
set_amount("Sting",1,Enemy1)
set_waepon_damage_from_charakter Enemy1
Player.Username ="Player"
Player.HP = 25
Seller.Username ="Seller"
Enemy1.Username ="MrBee"
Enemy1.HP = 80
list_inventory(Player)
list_inventory(Seller)
color 15 : PRINT "NOW WE BUY TWO SWORDS FOR " & get_cost ("Sword",Items()) * 2: color 7


buy_item (Seller,Player,"Gold","Sword",2,Items())
print "New Player stats:"
list_inventory(Player)
list_inventory(Seller)
PRINT "DONE."
color 15

'example fight
Print "An Enemy is standing in the top of you hit him with [SPACE],[H] to Heal :)"
Print "Your stats: "
list_player_stats(Player)
Print "Enemy stats: "
list_player_stats(Enemy1)
print "Press a key to do this!"
sleep

sleep
dim as charakter BackupEnemy = Enemy1
fight (Player,Enemy1,100,Items())

color 15
PRINT "ANOTHER ENEMY IS THERE CAN YOU WIN THIS? :P"
color 7
sleep
PRINT "PRESS [ENTER] TO TO THIS"
do
    sleep 1
loop until inkey = chr(13)
cls

for i as integer = 1 to 10
   
    Enemy1 = BackupEnemy
   locate 1
    Print "Quest: Kill all Enemys [";i;"/10]"
    sleep
    fight (Player,Enemy1,int(rnd*30)+10,Items())
    SLEEP
    If Player.HP = 0 then exit for
   
next

print "Your Stats:"
list_player_stats(Player)
sleep
sleep

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests