• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Calling all Coders!

Status
Not open for further replies.
Level 11
Joined
Jun 30, 2008
Messages
580
:p

Hello,

I'm going to making a very large system, and was wondering if anyone would like to help out with it.

I am going to make a Easy Quest Making System, I know how but will be faster with more people, plus people can point out flaws or bugs or help with ideas or what I should add into it.

I will post more info after I see there are a bit of people who want to help.

This system is going to be very large and complicated because I'm going to try to create every kind possible..

Thank you,

Forsakener
 
Level 11
Joined
Jun 30, 2008
Messages
580
vJass

A quest making system where users can easier make quests, all in a good framework to easily detect things in a save/load system.

Complicated in the way of being to peice everything together, all the differen't types of quests their are, mixtures of them, etc.
 
Level 11
Joined
Jun 30, 2008
Messages
580
JASS:
library QuestLib initializer Init
  globals
    constant integer MAX_UNITTYPE_CAP = 5
    constant string COMPLETE_COLOR = "|cff808080"
    constant string UPDATE_STRING = " - "
    constant string Ln = "|n"
    constant integer TALK_ID = 'a000'
    hashtable q
  endglobals
  
  struct heros
    unit hero
    
  endstruct
  /* Quest Types:
  Kill Quest    - 1
  Item Quest    - 2
  Travel Quest  - 3
  Event Quest   - 4
  */
  struct Quest
    unit giver = null
    integer quests = 0
        method InitGiver takes unit u returns nothing
            set this.giver = u
            set this.quests = this.quests+1
            call SaveInteger(q, GetHandleId(u), this.quests, this)
        endmethod
    integer level = 0    
    string name = ""
        method IntQuest takes integer i, string s returns nothing
            set this.level = i
            set this.name = s
        endmethod
    boolean array Qtypes[4]
    integer killunits
        method IntKillQuest takes nothing returns nothing
            set this.Qtypes[1] = true
            set this.killunits = 0
        endmethod
    integer array killunit[MAX_UNITTYPE_CAP]
    integer array howmany[MAX_UNITTYPE_CAP]
        method IntKillUnit takes integer u, integer i returns nothing
            set this.killunits = this.killunits+1
            set this.killunit[this.killunits] = u
            set this.howmany[this.killunits] = i
        endmethod
    integer array rewarditem[12]
    integer ritems=0
        method AddRItem takes integer i returns nothing
            set this.ritems = this.ritems+1
            set this.rewarditem[this.ritems] = i
        endmethod
    integer exp
    integer gold
    integer lumber
        method AddReward takes integer e, integer g, integer l returns nothing
            set this.exp = e
            set this.gold = g
            set this.lumber = l
        endmethod
    string intro
    string info
    string complete
    string reinfo
        method IntStrings takes string a, string b, string c, string d returns nothing
            set this.intro = a
            set this.info = b
            set this.complete = c
            set this.reinfo = d
        endmethod
  endstruct
  function check takes nothing returns nothing
    //local unit u = whatunit
    //local Quest dat = LoadInteger(q, GetHandleId(u), 1)
    call BJDebugMsg("2")
    //call DisplayTextToPlayer(Player(0), 0, 0, I2S(GetUnitTypeId(dat.giver)))
    call BJDebugMsg("1")
    //set u = null
  endfunction
  
  function GetGiverID takes nothing returns nothing
    call BJDebugMsg("1")
  endfunction
  private function talk takes nothing returns nothing
    local real angle = GetUnitFacing(GetTriggerUnit())-180
  endfunction
  private function cond takes nothing returns boolean
     if ( not ( GetSpellAbilityId() == TALK_ID ) ) then
        return false
    endif
    return true
  endfunction
  
  private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function talk)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function cond))
  endfunction





endlibrary

This is what I started with, but ran into a problem, I am trying to see if all values are being saved correctly, so I tried to call a function retrieving the Unit Id of the giver, but for some reason the function doesn't run, i tried several different methods, and it isn't being ran at all.

Anyone see the reason why?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you're using vJass this is really simple. I made one of these (for no particular reason) a little while ago in like 3 hours of testing/coding. At the time I knew very little about quests so I thought it would be a good opportunity to learn.

Why don't you just have the "giver" as a unit variable within the quest struct.

JASS:
library Quests
globals
    public constant integer     QUEST_ITEM_MAX          = 10
endglobals


struct s_questitem
    s_quest     main        
    questitem   mainItem            = null

    static method create takes s_quest forQuest returns thistype
        local thistype dat = thistype.allocate()
        
        set dat.main = forQuest
        set dat.mainItem = QuestCreateItem(dat.main.mainQuest)
        
        return dat
    endmethod
endstruct


struct s_quest
    quest       mainQuest           = CreateQuest()
    unit        mainQuestUnit       = null
    
    static method create takes unit fromUnit returns thistype
        local thistype dat = thistype.allocate()
        // if you don't need to have a unit for the quest (in some cases, you won't) you should be able
        // to successfully input 'null' instead of a unit handle.
    
        set dat.mainQuestUnit = fromUnit
        
        return dat
    endmethod
endstruct
endlibrary

I would start it off like this, and build functionality onto it after you've laid the foundation.
 
Level 11
Joined
Jun 30, 2008
Messages
580
Okay, I have built most of the start of this system,

Now I need to figure out the BEST way to show Quest Updates:

Quest Update:
- 1 / 4 Bandits Killed
- 2 / 6 Bandit Badges Collected
- 4 / 4 Bandit Wolves Killed (Completed)

But what I am trying to do is allow users to mix quest types within a quest, Like a Kill Quest along with a Gather Quest or of that sort.

But trying to think of a way to most efficiently code this.

This is my System So far:
(Please Ignore the talk function and all other functions going along with it.

JASS:
library QuestLib initializer Init
  globals
    constant integer MAX_UNITTYPE_CAP = 5
    constant string COMPLETE_COLOR = "|cff808080"
    constant string UPDATE_STRING = " - "
    constant string Ln = "|n"
    constant integer TALK_ID = 'A000'
    hashtable q
  endglobals
  
  struct heros
    unit hero
    
  endstruct
  /* Quest Types:
  Kill Quest    - 1
  Item Quest    - 2
  Travel Quest  - 3
  Event Quest   - 4
  */
  struct Quest
    unit giver = null
    integer quests = 0
    integer level = 0    
    string name = ""
    boolean array Qtypes[4]
    integer killunits
    integer array killunit[MAX_UNITTYPE_CAP]
    integer array howmany[MAX_UNITTYPE_CAP]
    integer array rewarditem[12]
    integer ritems=0
    integer exp
    integer gold
    integer lumber
    string intro
    string info
    string complete
    string reinfo
        method InitGiver takes unit u returns nothing
            set this.giver = u
        endmethod
        
        method IntQuest takes integer i, string s returns nothing
            set this.level = i
            set this.name = s
            set this.quests = this.quests+1
            call SaveInteger(q, GetHandleId(this.giver), this.quests, this)
        endmethod

        method IntKillQuest takes nothing returns nothing
            set this.Qtypes[1] = true
            set this.killunits = 0
        endmethod

        method IntKillUnit takes integer u, integer i returns nothing
            set this.killunits = this.killunits+1
            set this.killunit[this.killunits] = u
            set this.howmany[this.killunits] = i
            call SaveInteger(q, u, this.killunits, this)
        endmethod

        method AddRItem takes integer i returns nothing
            set this.ritems = this.ritems+1
            set this.rewarditem[this.ritems] = i
        endmethod

        method AddReward takes integer e, integer g, integer l returns nothing
            set this.exp = e
            set this.gold = g
            set this.lumber = l
        endmethod

        method IntStrings takes string a, string b, string c, string d returns nothing
            set this.intro = a
            set this.info = b
            set this.complete = c
            set this.reinfo = d
        endmethod
        
  endstruct

  private function talk takes nothing returns nothing
    local real angle = GetUnitFacing(GetSpellTargetUnit())+180
    call SetCameraTargetControllerNoZForPlayer( GetOwningPlayer(GetTriggerUnit()), GetSpellTargetUnit(), 0, 0, false )
    //call RotateCameraAroundLocBJ( 360.00, GetUnitLoc(GetTriggerUnit()), GetOwningPlayer(GetSpellTargetUnit()), 100000000.00 )
    call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_ROTATION, angle, 3 )
    call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_TARGET_DISTANCE, 250, 3 )
    call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_ANGLE_OF_ATTACK, 0, 3 )
    call SetCameraFieldForPlayer( GetOwningPlayer(GetTriggerUnit()), CAMERA_FIELD_ZOFFSET, 100, 3 )    
  endfunction
  
  private function KillDeath takes nothing returns nothing
    local Quest dat
    local integer i
    set dat = LoadInteger(q, GetUnitTypeId(GetTriggerUnit()), i)
    
  endfunction
  
  private function cond takes nothing returns boolean
     if ( not ( GetSpellAbilityId() == TALK_ID ) ) then
        return false
    endif
    return true
  endfunction
  
  private function KillCond takes nothing returns boolean
      if ( not ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
        return false
    endif
    return true
  endfunction
  
  private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function talk)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function cond))
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( t, Condition( function KillCond ) )
    call TriggerAddAction( t, function KillDeath )
  endfunction





endlibrary

This is the initialization of the quests: Not complete yet because not all functions are in place yet:

JASS:
library QuestInit initializer InitQuests
    function InitQuests takes nothing returns nothing
        local Quest KillBoar = Quest.create()
        call KillBoar.InitGiver(gg_unit_Hpal_0001)
        call KillBoar.IntQuest(1, "Killer Boars")
        call KillBoar.IntKillQuest()
        call KillBoar.IntKillUnit('hfoo', 5)
        call KillBoar.IntKillUnit('hrif', 2)
        call KillBoar.AddRItem('i000')
        call KillBoar.AddReward(150, 15, 0)
        call KillBoar.IntStrings(/*
        */"This is the intro!",/* 
        */"This is the Info!",/* 
        */"This is the Complete msg!",/*
        */"This is the reinfo!"/*
        */)

    
    
    
    
    
    
    
    
    
    endfunction

    endlibrary
 
Status
Not open for further replies.
Top