I need Help with scripts for a game!

This is a discussion on I need Help with scripts for a game! within the Game Programming forums, part of the General Programming Boards category; Alright Im making an adventure for a game called The Punic Wars. What im trying to do is, After im ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    3

    I need Help with scripts for a game!

    Alright Im making an adventure for a game called The Punic Wars.

    What im trying to do is, After im done with a conversation between 2 players, I want the person, and his army, to be set as player 1, just like me.

    His name is Barnabas.

    What ive done is:
    Code:
     GetNamedObj("Barnabas").SetPlayer(1);
    - Which works, for 1 unit.. But since the army is made of 50 other people, i wouldnt sit and make that code 51 times.. Well I hope ya understand what i mean.

    So i added them to the group " Barnabas_team"

    Then tried:
    Code:
     GetNamedObj("Barnabas_team").SetPlayer(1);
    - which did compile, but didnt work in test mode/or in game generally.

    Any ideas ? :-)

    Thanks!
    Last edited by LubuKage; 07-12-2010 at 09:19 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    So have an array of names, say

    Code:
    // the names of all the people in your army
    std::vector< std::string > armyDudes;
    Then you can have a loop to do something like
    Code:
    GetNamedObj( armyDudes[loop] ).SetPlayer(1);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    3
    Hmm, yeah i was thinking that too, but couldnt get it to work.

    Besides its an ingame -editor, using c++ tools, etc . So, both vector and loop aint supported in the editor, i think, lol. Atleast it only gave me errors so far, but thanks for the tip!

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,632
    Err... so what is the scripting language in use? If it is a custom one, what does it allow you to do?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    3
    Im not sure actually, theres a documentation for it:

    http://www.haemimontgames.com/files/...s%20Script.chm

    Celtic Kings Script (CKS) is syntactically very simillar to C. You have the same language constructions - for, if, while, goto. There are constructions, which are absent - switch, defining functions, certain operators. There are also features that are somewhat different from their analogues in C. Be sure to read all articles below, to be sure that every aspect of the syntax is clear to you before continuing with reading sample scripts.
    Ive guess if you want to help me, you can read the documentation, its not much
    Ive got no idea about it myself, im pretty new to this

    Oh and : IF your using Vista/WIndows 7, u would have to right click the documentation - properties - remove the blocked thingy, You'll understand


    Thanks!

  6. #6
    Registered User
    Join Date
    Jul 2010
    Posts
    1

    Lightbulb struct

    Couldn't open your documentation so I'm shooting in the dark here.

    If you can alter the struct of the the fifty dudes you may include a property or a simple string lets suposse "Allegiance" and so you could define this property in the moment you spawn these characters on the scenario - like a function parameter.

    GenNamedObj("Infantry").SetAllegiance(1);

    Furthermore, every character will have its own "Allegiance" variable wich you could change anytime you want with a trigger. That way an army could revolt if you don't pay the wagers huh?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-07-2010, 11:08 PM
  2. Replies: 15
    Last Post: 10-20-2009, 09:39 AM
  3. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  4. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 02:46 PM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21