Username:    Password:    Remember Me?         

map editor - Page 4 - Reverie World Studios Forums

Go Back   Reverie World Studios Forums > Kingdom Wars > Main Square
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #31  
Old 08-13-2007, 08:18 AM
jap88 jap88 is offline
Human Sect:
Knight
 
Join Date: Feb 2007
Posts: 228
jap88 has a default reputation
Default

Thank you Darvin, i wasn't exactly sure how to explain it.
Reply With Quote
  #32  
Old 08-13-2007, 08:30 AM
kingtom256 kingtom256 is offline
Member
 
Join Date: Jul 2007
Posts: 39
kingtom256 has a default reputation
Default

I would imagine it being limited, but the scripts would probably be catagorized into certain aspects. Nothing too difficult

By the way, scripting will be easier as soon as the new mini-keyboard is released for xbox 360
Reply With Quote
  #33  
Old 08-13-2007, 11:00 AM
The Witch King of Angmar's Avatar
The Witch King of Angmar The Witch King of Angmar is offline
Reverie Super Moderator
 
Join Date: Jun 2007
Location: Minas Morgul, Middle-Earth
Posts: 1,809
The Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputation
Default

Quote:
Originally Posted by kingtom256 View Post
I would imagine it being limited, but the scripts would probably be catagorized into certain aspects. Nothing too difficult

By the way, scripting will be easier as soon as the new mini-keyboard is released for xbox 360
I hope so. I would figure if gameplay was easy to learn scripting must be easier to do.
__________________
"Do not come between a Nazgul and his prey..."

Feel free to check out my soundcloud:
http://soundcloud.com/dylan-lang
Reply With Quote
  #34  
Old 08-13-2007, 06:23 PM
Darvin's Avatar
Darvin Darvin is offline
Reverie Super Moderator - RTSCommunity.com Ambassador
 
Join Date: Mar 2007
Posts: 666
Darvin is just really niceDarvin is just really niceDarvin is just really nice
Default

Quote:
I would imagine it being limited, but the scripts would probably be catagorized into certain aspects. Nothing too difficult
That's what warcraft III did, and it ended up with over a thousand of these "categories" (or rather, functions). Moreover, they could be combined in countless ways. For instance, "create a unit" function (sounds simple, eh?) requires certain parameters; it needs to know where you want to create the unit, what type of unit, and who the unit should belong to. These are called "parameters", and parameters themselves could be functions (for instance, if I'm creating a "boss" enemy that spawns units around itself, the position of the unit isn't static; it must be based on the position of the boss). These parameter functions themselves take parameters, which may be functions. What you end up with could be rather complex at the end of the day.

To give you an idea, this is some Jass code I wrote in the warcraft III editor. It might be difficult for you to follow, but what I will tell you is that the effect of this trigger is that any time any paladin casts a spell, he gains 15 hit points per level he has invested in devotion aura.

Code:
//===========================================================================
function InitTrig_Devotion takes nothing returns nothing
    set gg_trg_Devotion = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Devotion, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Devotion, Condition( function Trig_devotion_Conditions ) )
    call TriggerAddAction( gg_trg_Devotion, function Trig_devotion_Actions )
endfunction

function Trig_devotion_Conditions takes nothing returns boolean
    if ( not ( 'H000' == GetUnitTypeId(GetSpellAbilityUnit()) ) ) then
        return false
    endif
    return true
endfunction

function Trig_devotion_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local real healed = ( I2R(GetUnitAbilityLevelSwapped('A00L', caster)) * 15.00 )
    call SetUnitLifeBJ( caster, ( GetUnitStateSwap(UNIT_STATE_LIFE, caster) + healed ) )
    set caster = null
endfunction
__________________
----------------------------------------------
www.RTSCommunity.com
----------------------------------------------
Reply With Quote
  #35  
Old 08-14-2007, 01:35 PM
The Witch King of Angmar's Avatar
The Witch King of Angmar The Witch King of Angmar is offline
Reverie Super Moderator
 
Join Date: Jun 2007
Location: Minas Morgul, Middle-Earth
Posts: 1,809
The Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputation
Default

Well Darvin I kind of understand what that looks like as I have in school done a little bit of scripting in creating a website.
__________________
"Do not come between a Nazgul and his prey..."

Feel free to check out my soundcloud:
http://soundcloud.com/dylan-lang
Reply With Quote
  #36  
Old 08-14-2007, 04:47 PM
Darvin's Avatar
Darvin Darvin is offline
Reverie Super Moderator - RTSCommunity.com Ambassador
 
Join Date: Mar 2007
Posts: 666
Darvin is just really niceDarvin is just really niceDarvin is just really nice
Default

Programming languages are logical, which is why if you know one, others start to look somewhat familiar.
__________________
----------------------------------------------
www.RTSCommunity.com
----------------------------------------------
Reply With Quote
  #37  
Old 08-14-2007, 05:04 PM
kingtom256 kingtom256 is offline
Member
 
Join Date: Jul 2007
Posts: 39
kingtom256 has a default reputation
Default

I understand some of it, i use to do a little messing with CAH on bfme 2
Reply With Quote
  #38  
Old 08-14-2007, 09:23 PM
The Witch King of Angmar's Avatar
The Witch King of Angmar The Witch King of Angmar is offline
Reverie Super Moderator
 
Join Date: Jun 2007
Location: Minas Morgul, Middle-Earth
Posts: 1,809
The Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputation
Default

Quote:
Originally Posted by Darvin View Post
Programming languages are logical, which is why if you know one, others start to look somewhat familiar.
I mean I understand what it means and how it's set up but I don't understand some of the codes and what those do.
__________________
"Do not come between a Nazgul and his prey..."

Feel free to check out my soundcloud:
http://soundcloud.com/dylan-lang
Reply With Quote
  #39  
Old 08-15-2007, 01:17 AM
Darvin's Avatar
Darvin Darvin is offline
Reverie Super Moderator - RTSCommunity.com Ambassador
 
Join Date: Mar 2007
Posts: 666
Darvin is just really niceDarvin is just really niceDarvin is just really nice
Default

Code:
//===========================================================================
function InitTrig_Devotion takes nothing returns nothing
    set gg_trg_Devotion = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Devotion, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Devotion, Condition( function Trig_devotion_Conditions ) )
    call TriggerAddAction( gg_trg_Devotion, function Trig_devotion_Actions )
endfunction
This is the trigger definition. It runs when the map is initialized and sets up the trigger. gg_trg_Devotion is a global variable which extends handle (it's closest to a "reference" for you guys with Java experience, or a "pointer" for you guys with C++ experience), and it is instantiated as a new trigger.

The second line is a function that adds a "register event" to the trigger. It takes as parameter the trigger variable and the type of event. In this case, it causes the trigger to execute whenever any unit casts a spell.

The next line adds a condition to the trigger. The condition is itself a function which returns a boolean. If it returns true, the trigger goes ahead, if it returns false, the trigger does not go ahead. The condition is checked every time the "event" happens.

The final line adds an "action" to the trigger, something that happens when the event happens and the condition is satisfied. The majority of the code (naturally) ends up in the action.


Code:
function Trig_devotion_Conditions takes nothing returns boolean
    if ( not ( 'H000' == GetUnitTypeId(GetSpellAbilityUnit()) ) ) then
        return false
    endif
    return true
endfunction
This is a function which returns a boolean (true or false). It is the function that was defined as the condition for the trigger. 'H000' is the unit-type ID of the custom "paladin" type hero I created for my map. GetSpellAbilityUnit() is a useful trigger that returns a reference to the unit which casted the spell which caused the trigger to execute. If it's unit-type ID is equal to 'H000' (that is, it's a paladin), then the condition is satisfied. This function was created through an automatic generation process, and as a result it uses negative logic (that is, if the unit is NOT a paladin, return false; rather than if the unit IS a paladin, return true). I usually have the editor generate a skeletal trigger for me, and then I work around it; in this case, the condition was so trivial I didn't need to touch the code it generated.

Code:
function Trig_devotion_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local real healed = ( I2R(GetUnitAbilityLevelSwapped('A00L', caster)) * 15.00 )
    call SetUnitLifeBJ( caster, ( GetUnitStateSwap(UNIT_STATE_LIFE, caster) + healed ) )
    set caster = null
endfunction
This is the actual trigger itself; what happens when the conditions are satisfied. The first two lines declare local variables. They aren't actually needed, they just exist to make the code more readable (in actuality, the only reason why I used Jass here rather than GUI was to make modifying the trigger easier, since changing the amount of health it healed would be an important balance consideration).

"Caster" is literally the unit that casted the spell that triggered the script. The real (that is, a decimal value) healed is the amount that unit can expect to be healed. "GetUnitAbilityLevelSwapped" is a weird function name. It takes as parameters an ability type and a unit reference. In this case, the ability type is 'A00L', which is the code for my custom devotion aura. I2R is an explicit conversion of an integer to a real (Jass does not permit implicit conversions). The result is that the amount the caster can expect to be healed is 15 times the number of levels he has invested in the devotion aura skill. A paladin with level 3 devotion aura gains 45 hit points every time he casts a spell; a nifty bonus.

Unfortunately, there is no "add health to unit" function, so I have to use "SetUnitLifeBJ" instead. I set the caster's health to his current health plus the value of "healed". GetUnitStateSwap(UNIT_STATE_LIFE, caster) returns the caster's current health, which then has the value of "healed" added to it, and his health is set to this new value (overflow over his maximum health isn't an issue with the "SetUnitLifeBJ" function).

The final line is necessary due to an oversight in the map editor's scripting system. It unfortunately has an issue any time we create local variables extending "handle" (which is anything that's not a real, integer, boolean, or string...). By explicitly setting the variable to "null", it is flagged to be dereferenced when it goes out of scope. If I didn't set it to "null", it would never be dereferenced; a memory leak.

That should be understandable to anyone with half a brain ^_^
__________________
----------------------------------------------
www.RTSCommunity.com
----------------------------------------------
Reply With Quote
  #40  
Old 08-15-2007, 12:53 PM
The Witch King of Angmar's Avatar
The Witch King of Angmar The Witch King of Angmar is offline
Reverie Super Moderator
 
Join Date: Jun 2007
Location: Minas Morgul, Middle-Earth
Posts: 1,809
The Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputationThe Witch King of Angmar has extremely good reputation
Default

So basically one code is setup based off a trigger for a certain action to be done.
__________________
"Do not come between a Nazgul and his prey..."

Feel free to check out my soundcloud:
http://soundcloud.com/dylan-lang
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -6. The time now is 04:20 AM.

ESRB Rated T
US/CANADA
PEGI 16
EUROPE
USK 16
GERMANY

privacy policy   |   Copyright © Reverie World Studios INC.

Kingdom Wars and Reverie World Studios are trademarks of Reverie World Studios, Inc. Developed by Reverie World Studios, inc. All Rights Reserved. All other trademarks are property of their respective owners.
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.